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 |   85 ++++++++++++++++++++++++++++++++++--------
 1 files changed, 68 insertions(+), 17 deletions(-)

diff --git a/zy-asrs-admin/src/components/orderOut/orderOutMergePreview/stockOut.vue b/zy-asrs-admin/src/components/orderOut/orderOutMergePreview/stockOut.vue
index bf83378..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,
@@ -21,9 +21,11 @@
 let searchInput = ref(null);
 let tableData = ref([]);
 const operationPortList = ref([])
+const globalOperationPort = ref(null)
 const open = ref(false);
 const showWidth = ref("60%")
 const records = ref([])
+const waveId = ref(null)
 const loading = ref(false)
 let tableDataValue = []
 let tableDataColSpan = []
@@ -158,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);
         }
@@ -186,6 +194,7 @@
     let defaultOperationPort = "";
     if (operationPortList.value.length > 0) {
         defaultOperationPort = operationPortList.value[0].value;
+        globalOperationPort.value = defaultOperationPort;
     }
 
     post('/api/out/orderOut/merge/loc/preview', data).then((resp) => {
@@ -198,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;
@@ -222,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;
             })
 
@@ -238,10 +275,19 @@
     })
 }
 
+const handleGlobalOperationPortChange = () => {
+    if (tableData.value.length > 0) {
+        tableData.value.forEach((item) => {
+            item.operationPort = globalOperationPort.value;
+        })
+    }
+}
+
 defineExpose({
     open,
     showWidth,
     records,
+    waveId,
 })
 </script>
 
@@ -255,11 +301,16 @@
     <div>
         <a-modal v-model:open="open" :width="showWidth"
             :title="formatMessage('page.orderOutPreview.preview', '棰勮鍚堝苟璁㈠崟鍑哄簱')" @ok="handleOk">
+            <div>
+                <span>浣滀笟鍙o細</span>
+                <a-select v-model:value="globalOperationPort" :options="operationPortList"
+                    @change="handleGlobalOperationPortChange"></a-select>
+            </div>
             <a-table :data-source="tableData" :loading="loading" :defaultExpandAllRows="false" :key="TABLE_KEY"
                 rowKey="index" :scroll="{ y: 768, scrollToFirstRowOnChange: true }" :columns="columns">
                 <template #bodyCell="{ column, text, record, index }">
                     <template v-if="column.dataIndex === 'locNo'">
-                        <div v-if="record.locId != null">
+                        <div v-if="record.locId != null && record.anfme > 0">
                             <a-tag color="green">{{ record.locNo }}</a-tag>
                         </div>
                         <div v-else>

--
Gitblit v1.9.1