Browse Source

1.出库完善。

jiaxiaoqiang 1 năm trước cách đây
mục cha
commit
ef069fbfb6
3 tập tin đã thay đổi với 34 bổ sung21 xóa
  1. 1 0
      .gitignore
  2. 6 2
      src/store/modules/common.ts
  3. 27 19
      src/views/storage-out/index.vue

+ 1 - 0
.gitignore

@@ -1,4 +1,5 @@
 node_modules
+dist
 .DS_Store
 docker/dist
 dist-ssr

+ 6 - 2
src/store/modules/common.ts

@@ -7,8 +7,9 @@ export const useCommonStore = defineStore("commonStore", {
     isShowTable: false,
     tableType: 1,
     tableTitle: "",
-    loadingMap: new Map(),
-    orderId: 68, // 出库后在检料位使用,派发后重置。
+    loadingMap: new Map<string, boolean>(),
+    storageInOrderId: -1, // 入库界面的出库使用
+    orderId: -1, // 出库后在检料位使用,派发后重置。
   }),
   actions: {
     // 获取当前时间格式的函数
@@ -25,6 +26,9 @@ export const useCommonStore = defineStore("commonStore", {
       return now.toLocaleDateString(undefined, options);
     },
   },
+  // persist: { 有map类型的时候不能使用持久化, 因为storage只支持存储字符串键值对,会转为object
+  //   paths: ["orderId", "storageInOrderId"],
+  // },
 });
 
 export function useCommonStoreHook() {

+ 27 - 19
src/views/storage-out/index.vue

@@ -176,27 +176,35 @@ const checkHasOuting = () => {
   // 如果没有数据则停止轮询。数据返回的state是1处理中2启用3处理异常4已完成, 当为3或者4的时候停止轮询,并且在派发后清空oderid。
   if (commonS.orderId != -1) {
     outInterval = setInterval(() => {
-      getStorageOrderInfo({ id: commonS.orderId }).then((res: any) => {
-        if (res.data) {
-          if (res.data.state === 3 || res.data.state === 4) {
-            clearInterval(outInterval);
-            outingBox.value = { ...res.data };
-            console.log(outingBox.value);
-            if (res.data.detailsList.length > 0) {
-              outingMaterials.value = outingBox.value.detailsList;
-              outingRawBoxList = JSON.parse(
-                JSON.stringify(outingBox.value.detailsList)
-              );
-            } else {
-              outingRawBoxList = [];
-              outingMaterials.value = [];
+      getStorageOrderInfo({ id: commonS.orderId })
+        .then((res: any) => {
+          if (res.data) {
+            if (res.data.state === 3 || res.data.state === 4) {
+              clearInterval(outInterval);
+              outingBox.value = { ...res.data };
+              // 同时也刷新左侧列表数据
+              getStorageBoxesList({}).then((res: any) => {
+                boxesList.value = res.data;
+              });
+              if (res.data.detailsList.length > 0) {
+                outingMaterials.value = outingBox.value.detailsList;
+                outingRawBoxList = JSON.parse(
+                  JSON.stringify(outingBox.value.detailsList)
+                );
+              } else {
+                outingRawBoxList = [];
+                outingMaterials.value = [];
+              }
             }
+          } else {
+            clearInterval(outInterval);
           }
-        } else {
+        })
+        .catch(() => {
           clearInterval(outInterval);
-        }
-      });
-    }, 1000);
+          commonS.orderId = -1;
+        });
+    }, 5000);
   }
 };
 const backToStorage = async () => {
@@ -278,7 +286,7 @@ onMounted(() => {
   getDestinationList(0).then((res: any) => {
     destinationList.value = res.data;
   });
-  getStorageBoxesList({}).then((res) => {
+  getStorageBoxesList({}).then((res: any) => {
     boxesList.value = res.data;
   });
   checkHasOuting();