maintenance.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  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.maintenance.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. <!-- 工单类型状态统计 -->
  71. <uni-card>
  72. <uni-section :title="$t('statistic.maintenance.orderType.title')" />
  73. <view class="flex-row align-center">
  74. <view class="charts-box">
  75. <qiun-data-charts
  76. type="ring"
  77. :opts="opts1"
  78. :chartData="data.typeChart"
  79. />
  80. </view>
  81. </view>
  82. </uni-card>
  83. </view>
  84. </template>
  85. <script setup>
  86. import { getCurrentInstance, reactive, ref } from "vue";
  87. import {
  88. getMaintenanceStatusStatistic,
  89. getMaintenanceTodayStatusStatistic,
  90. getMaintenanceTypeStatistic,
  91. getMonthlyMaintenanceStatistic,
  92. getTotalMaintenanceStatistic,
  93. getWeeklyMaintenanceStatistic,
  94. getYesterdayMaintenanceStatistic
  95. } from "@/api/statistic";
  96. const { appContext } = getCurrentInstance()
  97. const t = appContext.config.globalProperties.$t
  98. // 初始化环形图
  99. const opts = {
  100. color: ['#0055BB', '#FF5D00'],
  101. padding: [0, 10, 0, 10],
  102. title: { name: '' },
  103. subtitle: { name: '' },
  104. legend: {
  105. position: 'bottom',
  106. },
  107. extra: {
  108. ring: {
  109. ringWidth: 30, // 圆环的宽度
  110. activeOpacity: 0.5, // 启用Tooltip点击时,突出部分的透明度
  111. activeRadius: 10, // 启用Tooltip点击时,突出部分的宽度(最大值不得超过labelWidth)
  112. offsetAngle: -90, // 起始角度偏移度数
  113. labelWidth: 10, // 数据标签到饼图外圆连线的长度
  114. customRadius: 80, // 自定义半径
  115. borderWidth: 3, // 分割线的宽度
  116. borderColor: "#FFFFFF" // 分割线的颜色
  117. }
  118. }
  119. }
  120. const opts1 = { ...opts, color: ['#5470C6', '#9CDC7E'] }
  121. const data = reactive({
  122. yesterday: {},
  123. week: {},
  124. month: {},
  125. total: {},
  126. statusChart: { series: [] },
  127. todayStatusChart: { series: [] },
  128. typeChart: { series: [] },
  129. })
  130. const isLoadData = ref(false)
  131. // 加载维修相关统计数据
  132. const loadData = async () => {
  133. if (isLoadData.value) return // 已加载数据后不再加载数据
  134. isLoadData.value = true
  135. const getYesterdayMaintenanceStatisticAsync = getYesterdayMaintenanceStatistic()
  136. const getWeeklyMaintenanceStatisticAsync = getWeeklyMaintenanceStatistic()
  137. const getMonthlyMaintenanceStatisticAsync = getMonthlyMaintenanceStatistic()
  138. const getTotalMaintenanceStatisticAsync = getTotalMaintenanceStatistic()
  139. const getMaintenanceStatusStatisticAsync = getMaintenanceStatusStatistic()
  140. const getMaintenanceTodayStatusStatisticAsync = getMaintenanceTodayStatusStatistic()
  141. const getMaintenanceTypeStatisticAsync = getMaintenanceTypeStatistic()
  142. data.yesterday = (await getYesterdayMaintenanceStatisticAsync).data
  143. data.week = (await getWeeklyMaintenanceStatisticAsync).data
  144. data.month = (await getMonthlyMaintenanceStatisticAsync).data
  145. data.total = (await getTotalMaintenanceStatisticAsync).data
  146. const status = (await getMaintenanceStatusStatisticAsync).data
  147. const todayStatus = (await getMaintenanceTodayStatusStatisticAsync).data
  148. const type = (await getMaintenanceTypeStatisticAsync).data
  149. // 工单状态数据填充
  150. data.statusChart.series = [{
  151. data: [
  152. {
  153. name: t('statistic.maintenance.workOrder.status1'),
  154. value: status.todo || 0,
  155. labelText: t('statistic.maintenance.workOrder.status1') + ': ' + (status.todo || 0)
  156. },
  157. { name: t('statistic.maintenance.workOrder.status2'),
  158. value: status.finished || 0,
  159. labelText: t('statistic.maintenance.workOrder.status2') + ': ' + (status.finished || 0)
  160. },
  161. ],
  162. }]
  163. // 今日工单状态相关数据填充
  164. data.todayStatusChart.series = [{
  165. data: [
  166. {
  167. name: t('statistic.maintenance.workOrder.status1'),
  168. value: todayStatus.todo || 0,
  169. labelText: t('statistic.maintenance.workOrder.status1') + ': ' + (todayStatus.todo || 0)
  170. },
  171. { name: t('statistic.maintenance.workOrder.status2'),
  172. value: todayStatus.finished || 0,
  173. labelText: t('statistic.maintenance.workOrder.status2') + ': ' + (todayStatus.finished || 0)
  174. },
  175. ],
  176. }]
  177. // 工单类型数据填充
  178. data.typeChart.series = [{
  179. data: [
  180. {
  181. name: t('statistic.maintenance.orderType.status1'),
  182. value: type['临时新建'] ?? 0,
  183. labelText: t('statistic.maintenance.orderType.status1') + ': ' + (type['临时新建'] ?? 0)
  184. },
  185. { name: t('statistic.maintenance.orderType.status2'),
  186. value: type['计划生成'] ?? 0,
  187. labelText: t('statistic.maintenance.orderType.status2') + ': ' + (type['计划生成'] ?? 0)
  188. },
  189. ],
  190. }]
  191. }
  192. defineExpose({ loadData })
  193. </script>
  194. <style scoped lang="scss">
  195. .charts-box {
  196. width: 100%;
  197. height: 300px;
  198. }
  199. :deep(.uni-card) {
  200. padding: 0 !important;
  201. .uni-card__content {
  202. padding: 0 !important;
  203. }
  204. .uni-section {
  205. margin-top: 8px;
  206. padding: 0 15px 0 20px;
  207. .uni-section-header {
  208. padding: 10px 0;
  209. }
  210. .uni-section__content-title {
  211. font-size: 16px !important;
  212. font-weight: 600;
  213. }
  214. }
  215. }
  216. :deep(.uni-section) {
  217. background-color: transparent;
  218. .uni-section-header {
  219. padding: 5px 10px;
  220. }
  221. .line {
  222. width: 3px;
  223. height: 14px;
  224. background-color: #004098;
  225. }
  226. }
  227. .divider {
  228. width: 1px;
  229. height: 114px;
  230. background-color: #CACCCF;
  231. margin: 0 24px;
  232. }
  233. .divider-v {
  234. width: auto;
  235. height: 1.5px;
  236. border-bottom: 1.5px #CACCCF dashed;
  237. margin: 0 20px;
  238. }
  239. .divider-h {
  240. width: 1.5px;
  241. height: 50px;
  242. border-left: 1.5px #CACCCF dashed;
  243. margin: 0 4px;
  244. }
  245. .count-label {
  246. color: #666666;
  247. font-size: 14px;
  248. }
  249. .count-value {
  250. color: #333333;
  251. font-size: 18px;
  252. font-weight: 500;
  253. }
  254. .mt-5 {
  255. margin-top: 5px;
  256. }
  257. .mt-8 {
  258. margin-top: 8px;
  259. }
  260. .pl-10 {
  261. padding-left: 10px;
  262. }
  263. </style>