list.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  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. <view class="list">
  6. <view class="item" v-for="(item, index) in dataList" :key="index">
  7. <view
  8. class="item-module flex-row align-center justify-between"
  9. :class="{
  10. tobeFilled: item.orderStatus == 0,
  11. ignore: item.orderStatus == 3,
  12. }">
  13. <!-- 创建时间 -->
  14. <view class="module-name">
  15. {{ item.createTime ? formatDate(item.createTime) : "" }}
  16. </view>
  17. <!-- 工单状态 -->
  18. <view
  19. class="module-status"
  20. :class="{
  21. pending: item.orderStatus == 0,
  22. ignore: item.orderStatus == 3,
  23. }">
  24. {{ fillStatusDict[item.orderStatus] }}
  25. </view>
  26. </view>
  27. <view class="item-content">
  28. <!-- 负责人 -->
  29. <view class="item-title flex-row">
  30. <span class="item-title-width"
  31. >{{ $t("operationRecordFilling.responsiblePerson") }}:</span
  32. >
  33. <span>{{ item.userName }}</span>
  34. </view>
  35. <!-- 工单名称 -->
  36. <view class="item-title flex-row">
  37. <span class="item-title-width"
  38. >{{ $t("operationRecordFilling.workOrderName") }}:</span
  39. >
  40. <span>{{ item.orderName }}</span>
  41. </view>
  42. <!-- 工单设备 -->
  43. <view class="item-title flex-row">
  44. <span class="item-title-width"
  45. >{{ $t("operationRecordFilling.workOrderDevice") }}:</span
  46. >
  47. <span>{{ item.fillList }}</span>
  48. </view>
  49. <!-- 应填设备数 -->
  50. <view class="item-title flex-row">
  51. <span class="item-title-width"
  52. >{{ $t("operationRecordFilling.totalDeviceCount") }}:</span
  53. >
  54. <span>{{ item.allDev }}</span>
  55. </view>
  56. <!-- 已填设备数 -->
  57. <view class="item-title flex-row">
  58. <span class="item-title-width"
  59. >{{ $t("operationRecordFilling.filledDeviceCount") }}:</span
  60. >
  61. <span class="color-green">{{ item.fillDev }}</span>
  62. </view>
  63. <!-- 未填设备数 -->
  64. <view class="item-title flex-row">
  65. <span class="item-title-width"
  66. >{{ $t("operationRecordFilling.unfilledDeviceCount") }}:</span
  67. >
  68. <span class="color-red">{{ item.unFillDev }}</span>
  69. </view>
  70. <!-- 创建时间 -->
  71. <view class="item-title flex-row">
  72. <span class="item-title-width"
  73. >{{ $t("operation.createTime") }}:</span
  74. >
  75. <span>{{
  76. item.createTime ? formatTime(item.createTime) : ""
  77. }}</span>
  78. </view>
  79. <!-- 填写时间 -->
  80. <view class="item-title flex-row">
  81. <span class="item-title-width"
  82. >{{ $t("operation.fillTime") }}:</span
  83. >
  84. <span>{{
  85. item.updateTime ? formatTime(item.updateTime) : ""
  86. }}</span>
  87. </view>
  88. <!-- 忽略理由 (仅忽略状态下显示)-->
  89. <view class="item-title flex-row" v-if="item.orderStatus == 3">
  90. <span class="item-title-width"
  91. >{{ $t("operation.ignoreReason") }}:</span
  92. >
  93. <span>{{ item.reason }}</span>
  94. </view>
  95. </view>
  96. <view class="item-btn flex-row align-center justify-end">
  97. <!-- 状态:0(待填写),1(已完成),2(填写中),3(忽略) -->
  98. <!-- 忽略 -->
  99. <button
  100. type="default"
  101. class="btn-ignore"
  102. v-if="item.orderStatus == 0 || item.orderStatus == 2"
  103. @click="ignoreOrder(item)">
  104. {{ $t("operation.ignore") }}
  105. </button>
  106. <!-- 查看 -->
  107. <button
  108. type="primary"
  109. plain="true"
  110. v-if="item.orderStatus == 1 || item.orderStatus == 3"
  111. @click="navigatorDetail(item, 0)">
  112. {{ $t("operation.view") }}
  113. </button>
  114. <!-- 填写 -->
  115. <button
  116. type="primary"
  117. v-if="item.orderStatus == 0 || item.orderStatus == 2"
  118. @click="navigatorDetail(item, 1)">
  119. {{ $t("operation.fill") }}
  120. </button>
  121. </view>
  122. </view>
  123. </view>
  124. </z-paging>
  125. <UniFab
  126. :pattern="fabPattern"
  127. horizontal="right"
  128. vertical="bottom"
  129. direction="horizontal"
  130. :popMenu="false"
  131. @fabClick="openFilterPopup" />
  132. <uni-popup
  133. ref="filterPopup"
  134. type="bottom"
  135. background-color="#fff"
  136. border-radius="10px 10px 0 0">
  137. <view class="filter-popup">
  138. <view class="filter-header">
  139. <text class="filter-action" @click="closeFilterPopup">{{
  140. $t("operation.cancel")
  141. }}</text>
  142. <text class="filter-title">筛选条件</text>
  143. <text class="filter-action primary" @click="searchList">{{
  144. $t("operation.confirm")
  145. }}</text>
  146. </view>
  147. <view class="filter-body">
  148. <view class="filter-item">
  149. <view class="filter-label">工单名称</view>
  150. <uni-easyinput
  151. v-model="orderName"
  152. :input-border="false"
  153. :styles="inputStyles"
  154. :placeholderStyle="placeholderStyle"
  155. :placeholder="$t('operation.searchText')"
  156. @confirm="searchList" />
  157. </view>
  158. <view class="filter-item">
  159. <view class="filter-label">创建时间</view>
  160. <uni-datetime-picker
  161. v-model="createTime"
  162. type="datetimerange"
  163. return-type="string"
  164. :border="false"
  165. :placeholder="$t('operation.PleaseSelect')" />
  166. </view>
  167. </view>
  168. <view class="filter-footer">
  169. <button class="filter-button reset" @click="resetFilter">
  170. {{ $t("inventory.search.reset") }}
  171. </button>
  172. <button class="filter-button" type="primary" @click="searchList">
  173. {{ $t("operation.search") }}
  174. </button>
  175. </view>
  176. </view>
  177. </uni-popup>
  178. <ignore-reason ref="ignorePopupRef" @ignore-submit="ignoreSubmit" />
  179. </template>
  180. <script setup>
  181. import { ref, reactive, nextTick } from "vue";
  182. import { onShow } from "@dcloudio/uni-app";
  183. import dayjs from "dayjs";
  184. import {
  185. getRecordFillingList,
  186. recordFillingIgnore,
  187. } from "@/api/recordFilling.js";
  188. import { getDeptId } from "@/utils/auth.js";
  189. import { useDataDictStore } from "@/store/modules/dataDict";
  190. import ignoreReason from "@/components/ignore/reason.vue";
  191. import UniFab from "@/uni_modules/uni-fab/components/uni-fab/uni-fab.vue";
  192. // 获取字典项
  193. const { getStrDictOptions } = useDataDictStore();
  194. // 填写状态
  195. const fillStatusDict = reactive({});
  196. getStrDictOptions("operation_fill_order_status").map((item) => {
  197. fillStatusDict[item.value] = item.label;
  198. });
  199. console.log("🚀 ~ getDataDictList ~ fillStatusDict:", fillStatusDict);
  200. const orderName = ref("");
  201. const getRecentWeekRange = () => [
  202. dayjs().subtract(6, "day").startOf("day").format("YYYY-MM-DD HH:mm:ss"),
  203. dayjs().endOf("day").format("YYYY-MM-DD HH:mm:ss"),
  204. ];
  205. const createTime = ref(getRecentWeekRange());
  206. const filterPopup = ref(null);
  207. const fabPattern = reactive({
  208. color: "#fff",
  209. backgroundColor: "#fff",
  210. selectedColor: "#fff",
  211. buttonColor: "#004098",
  212. iconColor: "#fff",
  213. icon: "search",
  214. });
  215. const placeholderStyle = ref("color:#797979;font-weight:500;font-size:16px");
  216. const inputStyles = reactive({
  217. backgroundColor: "#FFFFFF",
  218. color: "#797979",
  219. });
  220. const paging = ref(null);
  221. // v-model绑定的这个变量不要在分页请求结束中自己赋值,直接使用即可
  222. const dataList = ref([]);
  223. // @query所绑定的方法不要自己调用!!需要刷新列表数据时,只需要调用paging.value.reload()即可
  224. const queryList = (pageNo, pageSize) => {
  225. // 此处请求仅为演示,请替换为自己项目中的请求
  226. getRecordFillingList({
  227. pageNo,
  228. pageSize,
  229. deptId: getDeptId(),
  230. orderName: orderName.value,
  231. createTime: createTime.value,
  232. })
  233. .then((res) => {
  234. // 将请求结果通过complete传给z-paging处理,同时也代表请求结束,这一行必须调用
  235. paging.value.complete(res.data.list);
  236. })
  237. .catch((res) => {
  238. // 如果请求失败写paging.value.complete(false);
  239. // 注意,每次都需要在catch中写这句话很麻烦,z-paging提供了方案可以全局统一处理
  240. // 在底层的网络请求抛出异常时,写uni.$emit('z-paging-error-emit');即可
  241. paging.value.complete(false);
  242. });
  243. };
  244. const searchList = () => {
  245. closeFilterPopup();
  246. paging.value.reload();
  247. };
  248. const openFilterPopup = () => {
  249. filterPopup.value?.open();
  250. };
  251. const closeFilterPopup = () => {
  252. filterPopup.value?.close();
  253. };
  254. const resetFilter = () => {
  255. orderName.value = "";
  256. createTime.value = getRecentWeekRange();
  257. };
  258. const navigatorDetail = (item, type) => {
  259. console.log("item", item);
  260. const param = {
  261. ...item,
  262. orderId: item.id,
  263. };
  264. uni.navigateTo({
  265. url:
  266. "/pages/recordFilling/detail?view=" +
  267. type +
  268. "&param=" +
  269. JSON.stringify(param),
  270. });
  271. };
  272. const formatDate = (time) => {
  273. return dayjs(time).format("YYYY-MM-DD");
  274. };
  275. const formatTime = (time) => {
  276. return dayjs(time).format("YYYY-MM-DD HH:mm:ss");
  277. };
  278. const ignoreItem = ref(null);
  279. const ignorePopupRef = ref(null);
  280. const ignoreOrder = (item) => {
  281. console.log("🚀 ~ ignoreOrder ~ item:", item);
  282. ignoreItem.value = item;
  283. ignorePopupRef.value.openIgnore();
  284. };
  285. const ignoreSubmit = (reason) => {
  286. console.log("🚀 ~ ignoreSubmit ~ reason:", reason);
  287. recordFillingIgnore({
  288. id: ignoreItem.value.id,
  289. reason,
  290. })
  291. .then((res) => {
  292. console.log("🚀 ~ ignoreSubmit ~ res:", res);
  293. if (res.code !== 0) {
  294. uni.showToast({
  295. title: res.msg,
  296. icon: "error",
  297. });
  298. return;
  299. }
  300. uni.showToast({
  301. title: t("operation.success"),
  302. icon: "success",
  303. });
  304. ignorePopupRef.value.close();
  305. searchList();
  306. })
  307. .catch((err) => {
  308. console.log("🚀 ~ ignoreSubmit ~ err:", err);
  309. uni.showToast({
  310. title: err.msg,
  311. icon: "error",
  312. });
  313. });
  314. };
  315. onShow(() => {
  316. nextTick(() => {
  317. searchList();
  318. });
  319. });
  320. </script>
  321. <style lang="scss" scoped>
  322. @import "@/style/work-order.scss";
  323. .item {
  324. width: 100%;
  325. // height: 245px;
  326. min-height: 245px;
  327. // max-height: fit-content;
  328. background: #ffffff;
  329. border-radius: 6px;
  330. margin-top: 10px;
  331. }
  332. .filter-popup {
  333. display: flex;
  334. flex-direction: column;
  335. padding-bottom: env(safe-area-inset-bottom);
  336. background: #fff;
  337. }
  338. .filter-header {
  339. height: 48px;
  340. padding: 0 16px;
  341. display: flex;
  342. align-items: center;
  343. justify-content: space-between;
  344. border-bottom: 1px solid #f0f0f0;
  345. box-sizing: border-box;
  346. }
  347. .filter-title {
  348. color: #333;
  349. font-size: 16px;
  350. font-weight: 600;
  351. }
  352. .filter-action {
  353. min-width: 48px;
  354. color: #666;
  355. font-size: 14px;
  356. }
  357. .filter-action.primary {
  358. color: #004098;
  359. text-align: right;
  360. }
  361. .filter-body {
  362. padding: 16px;
  363. box-sizing: border-box;
  364. }
  365. .filter-item + .filter-item {
  366. margin-top: 16px;
  367. }
  368. .filter-label {
  369. margin-bottom: 8px;
  370. color: #333;
  371. font-size: 14px;
  372. font-weight: 500;
  373. }
  374. .filter-footer {
  375. display: flex;
  376. padding: 10px 16px 14px;
  377. border-top: 1px solid #f0f0f0;
  378. box-sizing: border-box;
  379. }
  380. .filter-button {
  381. flex: 1;
  382. height: 38px;
  383. margin: 0;
  384. font-size: 14px;
  385. line-height: 38px;
  386. }
  387. .filter-button + .filter-button {
  388. margin-left: 10px;
  389. }
  390. .filter-button.reset {
  391. border: 1px solid #004098;
  392. background: #fff;
  393. color: #004098;
  394. }
  395. </style>