From ac4341ea6b66ae02427d39d35f41d42d78b2eb2e Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期五, 14 二月 2025 10:08:32 +0800
Subject: [PATCH] #

---
 zy-asrs-admin/src/components/orderOut/orderOutMergePreview/stockOut.vue |   68 ++++++++++++++++++++++++++--------
 1 files changed, 52 insertions(+), 16 deletions(-)

diff --git a/zy-asrs-admin/src/components/orderOut/orderOutMergePreview/stockOut.vue b/zy-asrs-admin/src/components/orderOut/orderOutMergePreview/stockOut.vue
index 6f777c4..480d07f 100644
--- a/zy-asrs-admin/src/components/orderOut/orderOutMergePreview/stockOut.vue
+++ b/zy-asrs-admin/src/components/orderOut/orderOutMergePreview/stockOut.vue
@@ -11,7 +11,7 @@
 
 const TABLE_KEY = 'table-order-out-preview';
 
-const emit = defineEmits(['closeParent'])
+const emit = defineEmits(['closeParent', 'reload'])
 
 const {
     getColumnSearchProps,
@@ -25,6 +25,7 @@
 const open = ref(false);
 const showWidth = ref("60%")
 const records = ref([])
+const waveId = ref(null)
 const loading = ref(false)
 let tableDataValue = []
 let tableDataColSpan = []
@@ -159,12 +160,18 @@
 })
 
 const handleOk = () => {
-    post('/api/out/orderOut/merge', tableData.value).then((resp) => {
+    let requestParam = {
+        waveId: waveId.value,
+        list: tableData.value
+    };
+
+    post('/api/out/orderOut/merge/wave', requestParam).then((resp) => {
         let result = resp.data;
         if (result.code == 200) {
             message.success(formatMessage('page.add.success', '鍑哄簱鎴愬姛'));
             open.value = false;
             emit('closeParent', true)
+            emit('reload', true)
         } else {
             message.error(result.msg);
         }
@@ -200,21 +207,11 @@
             let idx = 0;
             let colSpan = []
             tmp.forEach((item) => {
-                item.locs.forEach((val) => {
-                    let dataTmp = JSON.parse(JSON.stringify(item));
-                    dataTmp.locId = val.locId;
-                    dataTmp.locNo = val.locNo;
-                    dataTmp.locDetlId = val.locDetlId;
-                    dataTmp.anfme = val.anfme;
-                    dataTmp.key = idx;
-                    dataTmp.operationPort = defaultOperationPort;
-
-                    tableDataTmp.push(dataTmp);
-                })
-
                 let count = item.locs.length;
-                if (item.anfme > 0) {
+
+                if (item.locs.length == 0) {
                     let dataTmp = JSON.parse(JSON.stringify(item));
+
                     dataTmp.locId = null;
                     dataTmp.locNo = null;
                     dataTmp.locDetlId = null;
@@ -224,9 +221,47 @@
 
                     tableDataTmp.push(dataTmp);
                     count++;
+                } else {
+                    let isused = item.anfme;
+                    console.log(isused);
+
+                    for (let i = 0; i < item.locs.length; i++) {
+                        if (isused == 0) {
+                            break;
+                        }
+                        const val = item.locs[i];
+                        let dataTmp = JSON.parse(JSON.stringify(item));
+                        let anfme = isused - val.anfme > 0 ? val.anfme : isused;
+                        isused -= anfme;
+
+                        dataTmp.locId = val.locId;
+                        dataTmp.locNo = val.locNo;
+                        dataTmp.locDetlId = val.locDetlId;
+                        dataTmp.anfme = anfme;
+                        dataTmp.key = idx;
+                        dataTmp.operationPort = defaultOperationPort;
+
+                        tableDataTmp.push(dataTmp);
+                    }
+
+                    console.log(tableDataTmp);
+                    
+
+                    if (isused > 0) {
+                        let dataTmp = JSON.parse(JSON.stringify(item));
+                        dataTmp.locId = null;
+                        dataTmp.locNo = null;
+                        dataTmp.locDetlId = null;
+                        dataTmp.anfme = isused;
+                        dataTmp.key = idx;
+                        dataTmp.operationPort = defaultOperationPort;
+
+                        tableDataTmp.push(dataTmp);
+                        count++;
+                    }
                 }
 
-                colSpan[idx] = count
+                colSpan[idx] = count;
                 idx += count;
             })
 
@@ -252,6 +287,7 @@
     open,
     showWidth,
     records,
+    waveId,
 })
 </script>
 

--
Gitblit v1.9.1