hmttr.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <script lang="ts" setup>
  2. import CountTo from '@/components/count-to1.vue'
  3. import { IotStatApi } from '@/api/pms/stat'
  4. const mttr = ref(0)
  5. const loading = ref(false)
  6. function toNumber(value: unknown) {
  7. const num = Number(value)
  8. return Number.isFinite(num) ? num : 0
  9. }
  10. async function loadMttr() {
  11. loading.value = true
  12. try {
  13. const res = await IotStatApi.getMttr()
  14. mttr.value = toNumber(res)
  15. } catch (error) {
  16. console.error('获取 MTTR 失败:', error)
  17. mttr.value = 0
  18. } finally {
  19. loading.value = false
  20. }
  21. }
  22. onMounted(() => {
  23. loadMttr()
  24. })
  25. </script>
  26. <template>
  27. <div class="panel flex flex-col">
  28. <div class="panel-title panel-title--md">
  29. <div class="icon-decorator">
  30. <span></span>
  31. <span></span>
  32. </div>
  33. MTTR(平均解决时间)
  34. </div>
  35. <div
  36. class="metric-panel flex-1 min-h-0"
  37. style="
  38. /* stylelint-disable-next-line custom-property-empty-line-before */
  39. --metric-accent: #21b7b1;
  40. --metric-glow: rgb(33 183 177 / 16%);
  41. --metric-border: rgb(33 183 177 / 14%);
  42. --metric-tag-bg: rgb(33 183 177 / 10%);
  43. "
  44. >
  45. <div class="metric-panel__orbit metric-panel__orbit--outer"></div>
  46. <div class="metric-panel__top">
  47. <span class="metric-panel__tag">REPAIR</span>
  48. </div>
  49. <div class="metric-panel__center">
  50. <div class="metric-panel__headline">平均处理时长</div>
  51. <div class="metric-panel__value-row translate-x-1">
  52. <CountTo
  53. class="metric-panel__value"
  54. :start-val="0"
  55. :end-val="mttr"
  56. :duration="1200"
  57. :decimals="1"
  58. />
  59. <span class="metric-panel__unit">h</span>
  60. </div>
  61. </div>
  62. </div>
  63. </div>
  64. </template>
  65. <style lang="scss" scoped>
  66. @import url('@/styles/kb.scss');
  67. .metric-panel {
  68. position: relative;
  69. display: flex;
  70. padding: calc(12px * var(--kb-scale, 1)) calc(12px * var(--kb-scale, 1))
  71. calc(9px * var(--kb-scale, 1));
  72. overflow: hidden;
  73. flex-direction: column;
  74. }
  75. .metric-panel__orbit {
  76. position: absolute;
  77. left: 50%;
  78. border: 1px solid var(--metric-border);
  79. border-radius: 999px;
  80. transform: translateX(-50%);
  81. }
  82. .metric-panel__orbit--outer {
  83. top: calc(20px * var(--kb-scale, 1));
  84. width: calc(180px * var(--kb-scale, 1));
  85. height: calc(180px * var(--kb-scale, 1));
  86. }
  87. .metric-panel__top,
  88. .metric-panel__center {
  89. position: relative;
  90. z-index: 1;
  91. }
  92. .metric-panel__tag {
  93. display: inline-flex;
  94. padding: calc(4px * var(--kb-scale, 1)) calc(10px * var(--kb-scale, 1));
  95. font-family: YouSheBiaoTiHei, sans-serif;
  96. font-size: calc(14px * var(--kb-scale, 1));
  97. line-height: 1;
  98. letter-spacing: 1px;
  99. color: var(--metric-accent);
  100. background: var(--metric-tag-bg);
  101. border: 1px solid rgb(255 255 255 / 72%);
  102. border-radius: 999px;
  103. box-shadow: inset 0 1px 0 rgb(255 255 255 / 78%);
  104. }
  105. .metric-panel__center {
  106. display: flex;
  107. margin: auto 0;
  108. flex-direction: column;
  109. align-items: center;
  110. justify-content: center;
  111. text-align: center;
  112. }
  113. .metric-panel__headline {
  114. font-size: calc(16px * var(--kb-scale, 1));
  115. font-weight: 600;
  116. letter-spacing: 1px;
  117. color: #4f678a;
  118. }
  119. .metric-panel__value-row {
  120. display: flex;
  121. margin-top: calc(10px * var(--kb-scale, 1));
  122. align-items: flex-end;
  123. justify-content: center;
  124. }
  125. .metric-panel__value {
  126. font-family: YouSheBiaoTiHei, sans-serif;
  127. font-size: calc(54px * var(--kb-scale, 1));
  128. line-height: 0.92;
  129. letter-spacing: 1px;
  130. color: var(--metric-accent);
  131. text-shadow: 0 10px 18px var(--metric-glow);
  132. }
  133. .metric-panel__unit {
  134. padding-bottom: calc(7px * var(--kb-scale, 1));
  135. margin-left: calc(4px * var(--kb-scale, 1));
  136. font-family: YouSheBiaoTiHei, sans-serif;
  137. font-size: calc(22px * var(--kb-scale, 1));
  138. line-height: 1;
  139. color: #5b789e;
  140. }
  141. </style>