index.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. <template>
  2. <z-paging
  3. class="page repair"
  4. ref="paging"
  5. v-model="dataList"
  6. @query="queryList"
  7. >
  8. <!-- z-paging默认铺满全屏,此时页面所有view都应放在z-paging标签内,否则会被盖住 -->
  9. <!-- 需要固定在页面顶部的view请通过slot="top"插入,包括自定义的导航栏 -->
  10. <template #top>
  11. <view class="page-top">
  12. <view class="page-back"></view>
  13. <view class="uni-page-head navgator justify-center align-center">
  14. <view class="nav-back" @click="navigatorBack()">
  15. <uni-icons type="left"></uni-icons>
  16. </view>
  17. <view class="nav-title">
  18. {{ $t("equipmentMaintenance.title") }}
  19. </view>
  20. </view>
  21. <view class="page-content">
  22. <view class="content-search">
  23. <uni-easyinput
  24. prefixIcon="search"
  25. confirmType="search"
  26. v-model="search"
  27. :placeholder="$t('common.searchHint')"
  28. @confirm="onSearch"
  29. >
  30. </uni-easyinput>
  31. </view>
  32. <uni-row
  33. class="content-statistics flex-row align-center justify-around"
  34. >
  35. <!-- 已完成 -->
  36. <uni-col class="statistics-item flex-col align-center">
  37. <view class="statistics-count font-BiaoTiHei">
  38. {{ statistics.total }}
  39. </view>
  40. <view class="statistics-title">
  41. {{ $t("status.finished") }}
  42. </view>
  43. </uni-col>
  44. <!-- 待填写 -->
  45. <uni-col class="statistics-item flex-col align-center">
  46. <view class="statistics-count font-BiaoTiHei">
  47. {{ statistics.todo }}
  48. </view>
  49. <view class="statistics-title">
  50. {{ $t("status.tobeFilled") }}
  51. </view>
  52. </uni-col>
  53. <!-- 平均解决时间 -->
  54. <uni-col class="statistics-item flex-col align-center">
  55. <view class="statistics-count font-BiaoTiHei">
  56. {{ statistics.average }}
  57. </view>
  58. <view class="statistics-title">
  59. {{ $t("equipmentMaintenance.averageResolutionTime") }}
  60. </view>
  61. </uni-col>
  62. </uni-row>
  63. <button class="full-btn" type="primary" @click="onCreate">
  64. <uni-icons type="plusempty"></uni-icons>
  65. {{ $t("equipmentMaintenance.createButton") }}
  66. </button>
  67. </view>
  68. </view>
  69. </template>
  70. <view class="paging-list">
  71. <view class="item" v-for="(item, index) in dataList" :key="index">
  72. <view
  73. class="item-module flex-row align-center justify-between"
  74. :class="{ tobeFilled: item.status == 'tx' }"
  75. >
  76. <view class="module-name">
  77. {{ $t("equipmentMaintenance.repairCode") }}: {{ item.failureCode }}
  78. </view>
  79. <view class="module-status" :class="{ pending: item.status == 'tx' }" v-if="statusDict[item.status]">
  80. <!-- 状态 -->
  81. <span>{{ statusDict[item.status] }}</span>
  82. </view>
  83. </view>
  84. <view class="item-content">
  85. <!-- 设备编号 -->
  86. <view class="item-title flex-row">
  87. <span class="item-title-width">{{ $t("device.deviceCode") }}:</span>
  88. <span>{{ item.deviceCode }}</span>
  89. </view>
  90. <!-- 设备名称 -->
  91. <view class="item-title flex-row">
  92. <span class="item-title-width">{{ $t("device.deviceName") }}:</span>
  93. <span>{{ item.deviceName }}</span>
  94. </view>
  95. <!-- 故障名称 -->
  96. <view class="item-title flex-row">
  97. <span class="item-title-width">{{ $t("fault.faultName") }}:</span>
  98. <span>{{ item.failureName }}</span>
  99. </view>
  100. <!-- 故障时间 -->
  101. <view class="item-title flex-row">
  102. <span class="item-title-width">{{ $t("fault.faultTime") }}:</span>
  103. <span>
  104. {{ item.failureTime ? formatDate(item.failureTime) : "" }}
  105. </span>
  106. </view>
  107. <!-- 维修开始时间 -->
  108. <view class="item-title flex-row">
  109. <span class="item-title-width">
  110. {{ $t("equipmentMaintenance.maintenanceStartTime") }}:
  111. </span>
  112. <span>
  113. {{
  114. item.maintainStartTime ? formatDate(item.maintainStartTime) : ""
  115. }}
  116. </span>
  117. </view>
  118. <!-- 执行时间 -->
  119. <view class="item-title flex-row">
  120. <span class="item-title-width">
  121. {{ $t("workOrder.executionTime") }}:
  122. </span>
  123. <span>
  124. {{ item.executeDate ? formatDate(item.executeDate) : "" }}
  125. </span>
  126. </view>
  127. <!-- 审核状态 -->
  128. <view class="item-title flex-row">
  129. <span class="item-title-width">
  130. {{ $t("workOrder.auditStatus") }}:
  131. </span>
  132. <span>{{ auditStatusDict[item.auditStatus] }}</span>
  133. </view>
  134. <!-- 是否停机 -->
  135. <view class="item-title flex-row">
  136. <span class="item-title-width">
  137. {{ $t("equipmentMaintenance.isStop") }}:
  138. </span>
  139. <span :class="{ 'color-red': item.ifStop }">
  140. {{ item.ifStop ? $t("operation.yes") : $t("operation.no") }}
  141. </span>
  142. </view>
  143. <!-- 工单来源 -->
  144. <view class="item-title flex-row">
  145. <span class="item-title-width">
  146. {{ $t("workOrder.workOrderSource") }}:
  147. </span>
  148. <span>{{ item.maintainType }}</span>
  149. </view>
  150. </view>
  151. <view class="item-btn flex-row align-center justify-end">
  152. <button
  153. type="primary"
  154. :plain="false"
  155. v-if="item.status !== 'tx'"
  156. @click="onView(item)"
  157. >
  158. {{ $t("workOrder.viewDetails") }}
  159. </button>
  160. <button type="primary" v-else @click="onEdit(item)">
  161. {{ $t("operation.fill") }}
  162. </button>
  163. </view>
  164. </view>
  165. </view>
  166. </z-paging>
  167. </template>
  168. <script setup>
  169. import { ref, reactive, onMounted, nextTick } from "vue";
  170. import { onShow } from "@dcloudio/uni-app";
  171. import { getRepairCount, getRepairList } from "@/api/repair";
  172. import dayjs from "dayjs";
  173. import { useDataDictStore } from "@/store/modules/dataDict";
  174. // 字典项
  175. const { getDataDictList } = useDataDictStore();
  176. // 状态
  177. const statusDict = reactive({});
  178. getDataDictList("pms_maintain_status").map((item) => {
  179. statusDict[item.value] = item.label;
  180. });
  181. console.log("statusDict", statusDict);
  182. // 审核状态
  183. const auditStatusDict = reactive({});
  184. getDataDictList("crm_audit_status").map((item) => {
  185. auditStatusDict[item.value] = item.label;
  186. });
  187. console.log("auditStatusDict", auditStatusDict);
  188. // --- 列表 ---start---
  189. const search = ref("");
  190. const paging = ref(null);
  191. // v-model绑定的这个变量不要在分页请求结束中自己赋值,直接使用即可
  192. const dataList = ref([]);
  193. // @query所绑定的方法不要自己调用!!需要刷新列表数据时,只需要调用paging.value.reload()即可
  194. const queryList = (pageNo, pageSize) => {
  195. // 此处请求仅为演示,请替换为自己项目中的请求
  196. getRepairList({
  197. pageNo,
  198. pageSize,
  199. commonParam: search.value,
  200. })
  201. .then((res) => {
  202. // 将请求结果通过complete传给z-paging处理,同时也代表请求结束,这一行必须调用
  203. paging.value.complete(res.data.list);
  204. })
  205. .catch((res) => {
  206. // 如果请求失败写paging.value.complete(false);
  207. // 注意,每次都需要在catch中写这句话很麻烦,z-paging提供了方案可以全局统一处理
  208. // 在底层的网络请求抛出异常时,写uni.$emit('z-paging-error-emit');即可
  209. paging.value.complete(false);
  210. });
  211. };
  212. const onSearch = () => {
  213. paging.value.reload();
  214. };
  215. const formatDate = (time) => {
  216. return dayjs(time).format("YYYY-MM-DD HH:mm:ss");
  217. };
  218. // -- end --
  219. // 获取顶部统计数量
  220. const statistics = reactive({});
  221. const getCount = () => {
  222. getRepairCount().then((res) => {
  223. statistics.total = res.data.maintainStatus?.finished || 0;
  224. statistics.todo = res.data.maintainStatus?.tx || 0;
  225. statistics.average = 4.8;
  226. });
  227. };
  228. onShow(() => {
  229. getCount();
  230. nextTick(() => {
  231. onSearch();
  232. });
  233. });
  234. const onCreate = () => {
  235. uni.navigateTo({
  236. url: "/pages/repair/create",
  237. });
  238. };
  239. const onEdit = (item) => {
  240. uni.navigateTo({
  241. url: "/pages/repair/edit?id=" + item.id,
  242. });
  243. };
  244. const onView = (item) => {
  245. uni.navigateTo({
  246. url: "/pages/repair/detail?id=" + item.id,
  247. });
  248. };
  249. const navigatorBack = () => {
  250. uni.navigateBack();
  251. };
  252. </script>
  253. <style lang="scss" scoped>
  254. @import "@/style/work-order.scss";
  255. </style>