list.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. <template>
  2. <z-paging class="page" ref="paging" v-model="dataList" @query="queryList">
  3. <!-- z-paging默认铺满全屏,此时页面所有view都应放在z-paging标签内,否则会被盖住 -->
  4. <!-- 需要固定在页面顶部的view请通过slot="top"插入,包括自定义的导航栏 -->
  5. <template #top>
  6. <uni-row class="search-row flex-row align-center justify-between">
  7. <uni-col :span="19">
  8. <uni-easyinput
  9. v-model="orderName"
  10. :styles="inputStyles"
  11. :placeholderStyle="placeholderStyle"
  12. :placeholder="$t('operation.searchText')"
  13. >
  14. </uni-easyinput>
  15. </uni-col>
  16. <uni-col :span="5" class="flex-row justify-end">
  17. <button
  18. class="mini-btn"
  19. type="primary"
  20. size="mini"
  21. @click="searchList"
  22. >
  23. {{ $t("operation.search") }}
  24. </button>
  25. </uni-col>
  26. </uni-row>
  27. </template>
  28. <view class="list">
  29. <view class="item" v-for="(item, index) in dataList" :key="index">
  30. <view
  31. class="item-module flex-row align-center justify-between"
  32. :class="{
  33. tobeFilled: item.orderStatus == 0,
  34. ignore: item.orderStatus == 3,
  35. }"
  36. >
  37. <!-- 创建时间 -->
  38. <view class="module-name">
  39. {{ item.createTime ? formatDate(item.createTime) : "" }}
  40. </view>
  41. <!-- 工单状态 -->
  42. <view
  43. class="module-status"
  44. :class="{
  45. pending: item.orderStatus == 0,
  46. ignore: item.orderStatus == 3,
  47. }"
  48. >
  49. {{ fillStatusDict[item.orderStatus] }}
  50. </view>
  51. </view>
  52. <view class="item-content">
  53. <!-- 负责人 -->
  54. <view class="item-title flex-row">
  55. <span class="item-title-width"
  56. >{{ $t("operationRecordFilling.responsiblePerson") }}:</span
  57. >
  58. <span>{{ item.userName }}</span>
  59. </view>
  60. <!-- 工单名称 -->
  61. <view class="item-title flex-row">
  62. <span class="item-title-width"
  63. >{{ $t("operationRecordFilling.workOrderName") }}:</span
  64. >
  65. <span>{{ item.orderName }}</span>
  66. </view>
  67. <!-- 工单设备 -->
  68. <view class="item-title flex-row">
  69. <span class="item-title-width"
  70. >{{ $t("operationRecordFilling.workOrderDevice") }}:</span
  71. >
  72. <span>{{ item.fillList }}</span>
  73. </view>
  74. <!-- 应填设备数 -->
  75. <view class="item-title flex-row">
  76. <span class="item-title-width"
  77. >{{ $t("operationRecordFilling.totalDeviceCount") }}:</span
  78. >
  79. <span>{{ item.allDev }}</span>
  80. </view>
  81. <!-- 已填设备数 -->
  82. <view class="item-title flex-row">
  83. <span class="item-title-width"
  84. >{{ $t("operationRecordFilling.filledDeviceCount") }}:</span
  85. >
  86. <span class="color-green">{{ item.fillDev }}</span>
  87. </view>
  88. <!-- 未填设备数 -->
  89. <view class="item-title flex-row">
  90. <span class="item-title-width"
  91. >{{ $t("operationRecordFilling.unfilledDeviceCount") }}:</span
  92. >
  93. <span class="color-red">{{ item.unFillDev }}</span>
  94. </view>
  95. <!-- 创建时间 -->
  96. <view class="item-title flex-row">
  97. <span class="item-title-width"
  98. >{{ $t("operation.createTime") }}:</span
  99. >
  100. <span>{{
  101. item.createTime ? formatTime(item.createTime) : ""
  102. }}</span>
  103. </view>
  104. <!-- 填写时间 -->
  105. <view class="item-title flex-row">
  106. <span class="item-title-width"
  107. >{{ $t("operation.fillTime") }}:</span
  108. >
  109. <span>{{
  110. item.updateTime ? formatTime(item.updateTime) : ""
  111. }}</span>
  112. </view>
  113. <!-- 忽略理由 (仅忽略状态下显示)-->
  114. <view class="item-title flex-row" v-if="item.orderStatus == 3">
  115. <span class="item-title-width"
  116. >{{ $t("operation.ignoreReason") }}:</span
  117. >
  118. <span>{{ item.reason }}</span>
  119. </view>
  120. </view>
  121. <view class="item-btn flex-row align-center justify-end">
  122. <!-- 状态:0(待填写),1(已完成),2(填写中),3(忽略) -->
  123. <!-- 忽略 -->
  124. <button
  125. type="default"
  126. class="btn-ignore"
  127. v-if="item.orderStatus == 0 || item.orderStatus == 2"
  128. @click="ignoreOrder(item)"
  129. >
  130. {{ $t("operation.ignore") }}
  131. </button>
  132. <!-- 查看 -->
  133. <button
  134. type="primary"
  135. plain="true"
  136. v-if="item.orderStatus == 1 || item.orderStatus == 3"
  137. @click="navigatorDetail(item, 0)"
  138. >
  139. {{ $t("operation.view") }}
  140. </button>
  141. <!-- 填写 -->
  142. <button
  143. type="primary"
  144. v-if="item.orderStatus == 0 || item.orderStatus == 2"
  145. @click="navigatorDetail(item, 1)"
  146. >
  147. {{ $t("operation.fill") }}
  148. </button>
  149. </view>
  150. </view>
  151. </view>
  152. </z-paging>
  153. <ignore-reason ref="ignorePopupRef" @ignore-submit="ignoreSubmit" />
  154. </template>
  155. <script setup>
  156. import { ref, reactive, nextTick } from "vue";
  157. import { onShow } from "@dcloudio/uni-app";
  158. import dayjs from "dayjs";
  159. import {
  160. getRecordFillingList,
  161. recordFillingIgnore,
  162. } from "@/api/recordFilling.js";
  163. import { getUserId, getDeptId } from "@/utils/auth.js";
  164. import { useDataDictStore } from "@/store/modules/dataDict";
  165. import ignoreReason from "@/components/ignore/reason.vue";
  166. // 获取字典项
  167. const { getStrDictOptions } = useDataDictStore();
  168. // 填写状态
  169. const fillStatusDict = reactive({});
  170. getStrDictOptions("operation_fill_order_status").map((item) => {
  171. fillStatusDict[item.value] = item.label;
  172. });
  173. console.log("🚀 ~ getDataDictList ~ fillStatusDict:", fillStatusDict);
  174. const orderName = ref("");
  175. const placeholderStyle = ref("color:#797979;font-weight:500;font-size:16px");
  176. const inputStyles = reactive({
  177. backgroundColor: "#FFFFFF",
  178. color: "#797979",
  179. });
  180. const paging = ref(null);
  181. // v-model绑定的这个变量不要在分页请求结束中自己赋值,直接使用即可
  182. const dataList = ref([]);
  183. // @query所绑定的方法不要自己调用!!需要刷新列表数据时,只需要调用paging.value.reload()即可
  184. const queryList = (pageNo, pageSize) => {
  185. // 此处请求仅为演示,请替换为自己项目中的请求
  186. getRecordFillingList({
  187. pageNo,
  188. pageSize,
  189. deptId: getDeptId(),
  190. orderName: orderName.value,
  191. })
  192. .then((res) => {
  193. // 将请求结果通过complete传给z-paging处理,同时也代表请求结束,这一行必须调用
  194. paging.value.complete(res.data.list);
  195. })
  196. .catch((res) => {
  197. // 如果请求失败写paging.value.complete(false);
  198. // 注意,每次都需要在catch中写这句话很麻烦,z-paging提供了方案可以全局统一处理
  199. // 在底层的网络请求抛出异常时,写uni.$emit('z-paging-error-emit');即可
  200. paging.value.complete(false);
  201. });
  202. };
  203. const searchList = () => {
  204. paging.value.reload();
  205. };
  206. const navigatorDetail = (item, type) => {
  207. console.log("item", item);
  208. const param = {
  209. ...item,
  210. orderId: item.id,
  211. };
  212. uni.navigateTo({
  213. url:
  214. "/pages/recordFilling/detail?view=" +
  215. type +
  216. "&param=" +
  217. JSON.stringify(param),
  218. });
  219. };
  220. const formatDate = (time) => {
  221. return dayjs(time).format("YYYY-MM-DD");
  222. };
  223. const formatTime = (time) => {
  224. return dayjs(time).format("YYYY-MM-DD HH:mm:ss");
  225. };
  226. const ignoreItem = ref(null);
  227. const ignorePopupRef = ref(null);
  228. const ignoreOrder = (item) => {
  229. console.log("🚀 ~ ignoreOrder ~ item:", item);
  230. ignoreItem.value = item;
  231. ignorePopupRef.value.openIgnore();
  232. };
  233. const ignoreSubmit = (reason) => {
  234. console.log("🚀 ~ ignoreSubmit ~ reason:", reason);
  235. recordFillingIgnore({
  236. id: ignoreItem.value.id,
  237. reason,
  238. })
  239. .then((res) => {
  240. console.log("🚀 ~ ignoreSubmit ~ res:", res);
  241. if (res.code !== 0) {
  242. uni.showToast({
  243. title: res.msg,
  244. icon: "error",
  245. });
  246. return;
  247. }
  248. uni.showToast({
  249. title: t("operation.success"),
  250. icon: "success",
  251. });
  252. ignorePopupRef.value.close();
  253. searchList();
  254. })
  255. .catch((err) => {
  256. console.log("🚀 ~ ignoreSubmit ~ err:", err);
  257. uni.showToast({
  258. title: err.msg,
  259. icon: "error",
  260. });
  261. });
  262. };
  263. onShow(() => {
  264. nextTick(() => {
  265. searchList();
  266. });
  267. });
  268. </script>
  269. <style lang="scss" scoped>
  270. @import "@/style/work-order.scss";
  271. .search-row {
  272. height: 35px;
  273. background: #f3f5f9;
  274. .mini-btn {
  275. height: 35px;
  276. line-height: 35px;
  277. width: 100%;
  278. margin-left: 8px;
  279. }
  280. }
  281. .item {
  282. width: 100%;
  283. // height: 245px;
  284. min-height: 245px;
  285. // max-height: fit-content;
  286. background: #ffffff;
  287. border-radius: 6px;
  288. margin-top: 10px;
  289. }
  290. </style>