rapair.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. <template>
  2. <view>
  3. <uni-card>
  4. <uni-row class="flex-row flex-wrap" >
  5. <!-- 平均解决时间 -->
  6. <uni-row class="flex-row flex-wrap align-center" style="flex: 1; padding: 10px">
  7. <uni-col class="count-label" :span="24">MTTR</uni-col>
  8. <uni-col class="count-label" :span="24">{{ $t('statistic.repair.resolutionTime') }}</uni-col>
  9. <uni-col class="count-value" :span="24" style="margin-top: 6px">{{ 0 }}</uni-col>
  10. </uni-row>
  11. <view class="divider-h" style="align-self: end" />
  12. <!-- 近一周工单数量 -->
  13. <uni-row class="flex-row flex-wrap" style="flex: 1; padding: 10px">
  14. <uni-col class="count-label" :span="24">{{ $t('statistic.repair.weeklyCount') }}</uni-col>
  15. <uni-col class="count-label" :span="12">{{ $t('statistic.repair.report') }}</uni-col>
  16. <uni-col class="count-label" :span="12">{{ $t('statistic.repair.workOrder') }}</uni-col>
  17. <uni-col class="count-value" :span="12" style="margin-top: 6px">{{ repairData.week.failureWeek }}</uni-col>
  18. <uni-col class="count-value" :span="12" style="margin-top: 6px">{{ repairData.week.maintainWeek }}</uni-col>
  19. </uni-row>
  20. <uni-col :span="24">
  21. <view class="divider-v" />
  22. </uni-col>
  23. <!-- 近一月工单数量 -->
  24. <uni-row class="flex-row flex-wrap" style="flex: 1; padding: 10px">
  25. <uni-col class="count-label" :span="24">{{ $t('statistic.repair.monthlyCount') }}</uni-col>
  26. <uni-col class="count-label" :span="12">{{ $t('statistic.repair.report') }}</uni-col>
  27. <uni-col class="count-label" :span="12">{{ $t('statistic.repair.workOrder') }}</uni-col>
  28. <uni-col class="count-value" :span="12" style="margin-top: 6px">{{ repairData.month.failureMonth }}</uni-col>
  29. <uni-col class="count-value" :span="12" style="margin-top: 6px">{{ repairData.month.maintainMonth }}</uni-col>
  30. </uni-row>
  31. <view class="divider-h" style="align-self: start" />
  32. <!-- 总工单数量 -->
  33. <uni-row class="flex-row flex-wrap" style="flex: 1; padding: 10px">
  34. <uni-col class="count-label" :span="24">{{ $t('statistic.repair.totalCount') }}</uni-col>
  35. <uni-col class="count-label" :span="12">{{ $t('statistic.repair.report') }}</uni-col>
  36. <uni-col class="count-label" :span="12">{{ $t('statistic.repair.workOrder') }}</uni-col>
  37. <uni-col class="count-value" :span="12" style="margin-top: 6px">{{ repairData.total.failureTotal }}</uni-col>
  38. <uni-col class="count-value" :span="12" style="margin-top: 6px">{{ repairData.total.maintainTotal }}</uni-col>
  39. </uni-row>
  40. </uni-row>
  41. </uni-card>
  42. <!-- 故障上报状态统计 -->
  43. <uni-card>
  44. <uni-section :title="$t('statistic.repair.failure.title')" />
  45. <view class="flex-row align-center">
  46. <view class="charts-box">
  47. <qiun-data-charts
  48. type="ring"
  49. :opts="opts"
  50. :chartData="repairData.chart"
  51. />
  52. </view>
  53. </view>
  54. </uni-card>
  55. <!-- 维修工单状态统计 -->
  56. <uni-card>
  57. <uni-section :title="$t('statistic.repair.workOrder.title')" />
  58. <view class="flex-row align-center">
  59. <view class="charts-box">
  60. <qiun-data-charts
  61. type="ring"
  62. :opts="opts"
  63. :chartData="repairData.orderChart"
  64. />
  65. </view>
  66. </view>
  67. </uni-card>
  68. </view>
  69. </template>
  70. <script setup>
  71. import { getCurrentInstance, reactive, ref } from "vue";
  72. import {
  73. getMonthlyRepairStatistic,
  74. getOtherRepairStatistic,
  75. getTotalRepairStatistic,
  76. getWeeklyRepairStatistic
  77. } from "@/api/statistic";
  78. const { appContext } = getCurrentInstance()
  79. const t = appContext.config.globalProperties.$t
  80. // 初始化环形图
  81. const opts = {
  82. color: ['#00DD99', '#FF5500', '#0056BF', '#FAC858'],
  83. padding: [0, 10, 0, 10],
  84. title: { name: '' },
  85. subtitle: { name: '' },
  86. legend: {
  87. position: 'bottom',
  88. },
  89. extra: {
  90. ring: {
  91. ringWidth: 30, // 圆环的宽度
  92. activeOpacity: 0.5, // 启用Tooltip点击时,突出部分的透明度
  93. activeRadius: 10, // 启用Tooltip点击时,突出部分的宽度(最大值不得超过labelWidth)
  94. offsetAngle: -90, // 起始角度偏移度数
  95. labelWidth: 10, // 数据标签到饼图外圆连线的长度
  96. customRadius: 80, // 自定义半径
  97. borderWidth: 3, // 分割线的宽度
  98. borderColor: "#FFFFFF" // 分割线的颜色
  99. }
  100. }
  101. }
  102. const repairData = reactive({
  103. week: {},
  104. month: {},
  105. total: {},
  106. chart: { series: [] },
  107. orderChart: { series: [] },
  108. })
  109. const isLoadData = ref(false)
  110. // 加载维修相关统计数据
  111. const loadData = async () => {
  112. if (isLoadData.value) return // 已加载数据后不再加载数据
  113. isLoadData.value = true
  114. const getWeeklyRepairStatisticAsync = getWeeklyRepairStatistic()
  115. const getMonthlyRepairStatisticAsync = getMonthlyRepairStatistic()
  116. const getTotalRepairStatisticAsync = getTotalRepairStatistic()
  117. const getOtherRepairStatisticAsync = getOtherRepairStatistic()
  118. repairData.week = (await getWeeklyRepairStatisticAsync).data
  119. repairData.month = (await getMonthlyRepairStatisticAsync).data
  120. repairData.total = (await getTotalRepairStatisticAsync).data
  121. const data = (await getOtherRepairStatisticAsync).data
  122. // 故障相关数据填充
  123. repairData.chart.series = [{
  124. data: [
  125. {
  126. name: t('statistic.repair.failure.reporting'),
  127. value: data.failureStatus.reporting || 0,
  128. labelText: t('statistic.repair.failure.reporting') + ': ' + (data.failureStatus.reporting || 0)
  129. },
  130. { name: t('statistic.repair.failure.finished'),
  131. value: data.failureStatus.finished || 0,
  132. labelText: t('statistic.repair.failure.finished') + ': ' + (data.failureStatus.finished || 0)
  133. },
  134. {
  135. name: t('statistic.repair.failure.trans'),
  136. value: data.failureStatus.trans || 0,
  137. labelText: t('statistic.repair.failure.trans') + ': ' + (data.failureStatus.trans || 0)
  138. },
  139. {
  140. name: t('statistic.repair.failure.over'),
  141. value: 0,
  142. labelText: t('statistic.repair.failure.over') + ': ' + 0
  143. },
  144. ],
  145. }]
  146. // 工单相关数据填充
  147. repairData.orderChart.series = [{
  148. data: [
  149. {
  150. name: t('statistic.repair.workOrder.tx'),
  151. value: data.maintainStatus.tx || 0,
  152. labelText: t('statistic.repair.workOrder.tx') + ': ' + (data.maintainStatus.tx || 0)
  153. },
  154. { name: t('statistic.repair.workOrder.finished'),
  155. value: data.maintainStatus.finished || 0,
  156. labelText: t('statistic.repair.workOrder.finished') + ': ' + (data.maintainStatus.finished || 0)
  157. },
  158. ],
  159. }]
  160. }
  161. defineExpose({ loadData })
  162. </script>
  163. <style scoped lang="scss">
  164. .charts-box {
  165. width: 100%;
  166. height: 300px;
  167. }
  168. :deep(.uni-card) {
  169. padding: 0 !important;
  170. .uni-card__content {
  171. padding: 0 !important;
  172. }
  173. .uni-section {
  174. margin-top: 8px;
  175. padding: 0 15px 0 20px;
  176. .uni-section-header {
  177. padding: 10px 0;
  178. }
  179. .uni-section__content-title {
  180. font-size: 16px !important;
  181. font-weight: 600;
  182. }
  183. }
  184. }
  185. :deep(.uni-section) {
  186. background-color: transparent;
  187. .uni-section-header {
  188. padding: 5px 10px;
  189. }
  190. .line {
  191. width: 3px;
  192. height: 14px;
  193. background-color: #004098;
  194. }
  195. }
  196. .divider {
  197. width: 1px;
  198. height: 114px;
  199. background-color: #CACCCF;
  200. margin: 0 24px;
  201. }
  202. .divider-v {
  203. width: auto;
  204. height: 1.5px;
  205. border-bottom: 1.5px #CACCCF dashed;
  206. margin: 0 20px;
  207. }
  208. .divider-h {
  209. width: 1.5px;
  210. height: 50px;
  211. border-left: 1.5px #CACCCF dashed;
  212. margin: 0 4px;
  213. }
  214. .count-label {
  215. color: #666666;
  216. font-size: 14px;
  217. }
  218. .count-value {
  219. color: #333333;
  220. font-size: 18px;
  221. font-weight: 500;
  222. }
  223. .mt-5 {
  224. margin-top: 5px;
  225. }
  226. .mt-8 {
  227. margin-top: 8px;
  228. }
  229. .pl-10 {
  230. padding-left: 10px;
  231. }
  232. </style>