Browse Source

refactor(MaterialInOutConfirm): 移除未使用的operationId并优化离开处理逻辑

- 删除未使用的operationId变量及相关赋值操作
- 合并还料和领料的离开处理逻辑,优化代码结构
- 修复物料有效性初始化位置问题
- 调整离开成功后的路由跳转路径
yangzhijie 5 months ago
parent
commit
742a6e40e1
1 changed files with 22 additions and 32 deletions
  1. 22 32
      src/stock-out/MaterialInOutConfirm.vue

+ 22 - 32
src/stock-out/MaterialInOutConfirm.vue

@@ -192,8 +192,6 @@ import bgImg from '../assets/images/bj.png';
 // 路由
 const router = useRouter();
 
-// 操作的id
-const operationId = ref(null);
 
 // 返回主页
 const goHome = () => {
@@ -268,7 +266,6 @@ const isCanLeave = computed(() => {
 
 // 开始领料
 const handleStart = record => {
-    operationId.value = record.inventoryId;
     generateCFStockOut(record.stockOutPrepareLineId);
 };
 
@@ -280,7 +277,6 @@ const handleApply = async record => {
 
         if (res.errorCode === 0) {
             showNotify({ type: 'success', message: '申请领料成功' });
-            operationId.value = record.inventoryId;
             getStockOutList();
         } else {
             showNotify({ type: 'danger', message: res.errorMessage });
@@ -295,7 +291,7 @@ const handleApply = async record => {
 
 // 领料完成后离开
 const handleLeave = async () => {
-
+    //----------------------------------- 还料数据处理 -----------------------------------//
     await getCFStockInByUser();
 
     let invalidCount = 0;
@@ -310,10 +306,16 @@ const handleLeave = async () => {
             message: '请检查有' + invalidCount + '条物料已经入库,但是被闸机扫描到了。请自己检查以后,点击【重新校验】按钮' });
         return;
     }
+    // 还料离开,回填入库单中的离开时间
+    const stockInIds = needConfirmStockInMaterialList.value.map(item => {
+        return item.stockInId;
+    });
 
+    if(stockInIds.length > 0){
+        await generateCFStockIn(stockInIds);
+    }
 
-    await handleComplete();
-
+    //----------------------------------- 领料数据处理 -----------------------------------//
     const params = [];
     materialList.value.map(item => {
         if(item.isValid === true && item.inventoryId != null){
@@ -331,21 +333,15 @@ const handleLeave = async () => {
         return;
     }
 
-    materialList.value.map(item => {
-        return {
-            stockOutPrepareLineId: item.stockOutPrepareLineId,
-            stockOutId: item.stockOutId,
-            inventoryId: item.inventoryId,
-        };
-    });
     loading.value = true;
+
     try {
         const res = await cfStockOutLeave(params);
 
         if (res.errorCode === 0) {
             gateController('SHOTOPEN');
             showNotify({ type: 'success', message: '领料离开成功' });
-            router.push('/home');
+            router.push('/');
         } else {
             showNotify({ type: 'danger', message: res.errorMessage });
         }
@@ -393,8 +389,8 @@ const getStockOutList = async () => {
                             j.stockOutNo = i.stockOutNo;
                             j.inventoryId = i.inventoryId;
                             j.stockOutPrepareLineId = i.stockOutPrepareLineId;
-                            j.status = 1;
                             j.queryStatus = 2;
+                            j.status = i.status;
                         }
                     });
                 });
@@ -528,17 +524,7 @@ const getCFStockInByUser = async () => {
 };
 
 
-// 还料离开,回填入库单中的离开时间
-const handleComplete = async () => {
-    const params = needConfirmStockInMaterialList.value.map(item => {
-        return item.stockInId;
-    });
 
-    console.log('提交参数:', params);
-    if(params.length > 0){
-        await generateCFStockIn(params);
-    }
-};
 
 
 // 还料离开(回填归还入库单入库时间)
@@ -566,18 +552,22 @@ const generateCFStockIn = async params => {
 
 // 待入库确认的数据,与扫描到的数据进行比对,待入库确认的数据不能被扫描到
 const computerErrorData = data => {
+    if(needConfirmStockInMaterialList.value != null){
+        needConfirmStockInMaterialList.value.forEach(item => {
+            item.isValid = true;
+        });
+    }
+    if(materialList.value != null){
+        materialList.value.forEach(i => {
+            i.isValid = true;
+        });
+    }
     if (!needConfirmStockInMaterialList.value || needConfirmStockInMaterialList.value.length === 0) {
         return;
     }
     if (!materialList.value || materialList.value.length === 0) {
         return;
     }
-    needConfirmStockInMaterialList.value.forEach(item => {
-        item.isValid = true;
-    });
-    materialList.value.forEach(i => {
-        i.isValid = true;
-    });
 
     needConfirmStockInMaterialList.value.forEach(item => {
         materialList.value.forEach(i => {