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