Kaynağa Gözat

fix:5619
【出库管理】手动出库,点击出库提示无法扣减库存,此批次号物品是我刚新增入库的

mlchen 3 hafta önce
ebeveyn
işleme
1286091305

+ 5 - 5
src/views/purchasingManage/purchaseOrder/components/addDialogNew.vue

@@ -1948,10 +1948,12 @@
         });
       },
       //获取订单详情
-      async getpurchaseorderDetail(id) {
+      async getpurchaseorderDetail(id, isEdit = false) {
         this.businessId = id;
         this.loading = true;
-        const data = await getpurchaseorderDetail(id);
+        const data = isEdit
+          ? await getByIdForEdit(id)
+          : await getpurchaseorderDetail(id);
         this.loading = false;
         data.settlementDate = data.startSettlementDate ? [data.startSettlementDate, data.endSettlementDate] : [];
         this.form = data;
@@ -2273,7 +2275,7 @@
           this.form.isGeneratePaymentPlan = +this.isGenReceiptPlan;
         } else {
           this.isUpdate = true;
-          await this.getpurchaseorderDetail(row.id);
+          await this.getpurchaseorderDetail(row.id, true);
         }
       },
       getEnterprisePage() {
@@ -2523,8 +2525,6 @@
 
           if (this.isUpdate) {
             try {
-              // 更新前先拉取最新编辑数据,确保基于最新版本提交
-              await getByIdForEdit(this.form.id || this.businessId);
               const res = await UpdateInformation(commitData);
               this.loading = false;
               this.$message.success('修改成功');

+ 50 - 27
src/views/saleManage/saleOrder/components/printTemplateHt.vue

@@ -179,7 +179,7 @@
 
 <script>
   import { getSaleOrderDetails } from '@/api/saleManage/saleorder';
-  import { getInfoBySourceBizNoAll } from '@/api/wms';
+  import { getBatchList } from '@/api/wms';
   import { mapGetters } from 'vuex';
   import { saveAs } from 'file-saver';
   export default {
@@ -212,32 +212,37 @@
         const list = await getSaleOrderDetails(id);
         this.formData = await Promise.all(
           list.map(async (wrapperItem) => {
-            let outInDetailList = [];
-            try {
-              const outboundList = await getInfoBySourceBizNoAll(wrapperItem.orderNo);
-              outInDetailList = outboundList?.[0]?.outInDetailList || [];
-            } catch (e) {
-              outInDetailList = [];
-            }
-            const productList = (wrapperItem.productList || []).map((item) => {
-              const candidates = outInDetailList.filter(
-                (detail) =>
-                  detail.categoryCode === item.productCode ||
-                  String(detail.categoryId) === String(item.productId)
-              );
-              const outDetail =
-                candidates.find(
-                  (detail) =>
-                    (item.batchNo && detail.batchNo === item.batchNo) ||
-                    (item.systemBatchNo && detail.systemBatchNo === item.systemBatchNo)
-                ) || (candidates.length === 1 ? candidates[0] : {});
-              return {
-                ...item,
-                batchNo: item.batchNo || outDetail.batchNo || '',
-                cuttingLength: item.cuttingLength || outDetail.cuttingLength || '',
-                reelSpecification: item.reelSpecification || outDetail.reelSpecification || ''
-              };
-            });
+            const batchRowsCache = new Map();
+            // 同一批次只查一次 WMS 批次台账,避免明细多时重复请求
+            const getBatchRowsByItem = (item) => {
+              const key = item.batchNo || item.systemBatchNo;
+              if (!key) {
+                return Promise.resolve([]);
+              }
+              if (!batchRowsCache.has(key)) {
+                batchRowsCache.set(key, this.getBatchRows(item));
+              }
+              return batchRowsCache.get(key);
+            };
+            const productList = await Promise.all(
+              (wrapperItem.productList || []).map(async (item) => {
+                const batchRows = await getBatchRowsByItem(item);
+                const candidates = batchRows.filter(
+                  (row) =>
+                    row.categoryCode === item.productCode ||
+                    String(row.categoryId) === String(item.productId)
+                );
+                const batchDetail =
+                  candidates.find((row) => item.batchNo && row.batchNo === item.batchNo) ||
+                  (candidates.length === 1 ? candidates[0] : {});
+                return {
+                  ...item,
+                  batchNo: item.batchNo || batchDetail.batchNo || '',
+                  cuttingLength: item.cuttingLength || '',
+                  reelSpecification: item.reelSpecification || batchDetail.reelSpecification || ''
+                };
+              })
+            );
             return { ...wrapperItem, productList };
           })
         );
@@ -246,6 +251,24 @@
 
         //包装维度
       },
+
+      // 按物品批次查询 WMS 批次库存台账,返回可匹配的候选行
+      async getBatchRows(item) {
+        if (!item.batchNo && !item.systemBatchNo) {
+          return [];
+        }
+        try {
+          const page = await getBatchList({
+            batchNo: item.batchNo || undefined,
+            systemBatchNo: item.systemBatchNo || undefined,
+            pageNum: 1,
+            size: 100
+          });
+          return page?.list || [];
+        } catch (e) {
+          return [];
+        }
+      },
       close() {
         this.QRvisible = false;
       },

+ 50 - 31
src/views/saleManage/saleOrder/components/printTemplateHtBatch.vue

@@ -173,7 +173,7 @@
 
 <script>
   import { getSaleOrderDetails } from '@/api/saleManage/saleorder';
-  import { getInfoBySourceBizNoAll } from '@/api/wms';
+  import { getBatchList } from '@/api/wms';
   import { mapGetters } from 'vuex';
   import { saveAs } from 'file-saver';
   export default {
@@ -203,43 +203,62 @@
     methods: {
       async open(id) {
         const list = await getSaleOrderDetails(id);
-        // 逐单查询出库单信息,补充裁剪米段/盘具字段(销售订单明细缺省时)
         this.formData = await Promise.all(
           list.map(async (wrapperItem) => {
-            let outInDetailList = [];
-            try {
-              const outboundList = await getInfoBySourceBizNoAll(
-                wrapperItem.orderNo
-              );
-              outInDetailList = outboundList?.[0]?.outInDetailList || [];
-            } catch (e) {
-              outInDetailList = [];
-            }
-            const productList = (wrapperItem.productList || []).map((item) => {
-              const candidates = outInDetailList.filter(
-                (detail) =>
-                  detail.categoryCode === item.productCode ||
-                  String(detail.categoryId) === String(item.productId)
-              );
-              const outDetail =
-                candidates.find(
-                  (detail) =>
-                    (item.batchNo && detail.batchNo === item.batchNo) ||
-                    (item.systemBatchNo && detail.systemBatchNo === item.systemBatchNo)
-                ) || (candidates.length === 1 ? candidates[0] : {});
-              return {
-                ...item,
-                batchNo: item.batchNo || outDetail.batchNo || '',
-                cuttingLength: item.cuttingLength || outDetail.cuttingLength || '',
-                reelSpecification:
-                  item.reelSpecification || outDetail.reelSpecification || ''
-              };
-            });
+            const batchRowsCache = new Map();
+            // 同一批次只查一次 WMS 批次台账,避免明细多时重复请求
+            const getBatchRowsByItem = (item) => {
+              const key = item.batchNo || item.systemBatchNo;
+              if (!key) {
+                return Promise.resolve([]);
+              }
+              if (!batchRowsCache.has(key)) {
+                batchRowsCache.set(key, this.getBatchRows(item));
+              }
+              return batchRowsCache.get(key);
+            };
+            const productList = await Promise.all(
+              (wrapperItem.productList || []).map(async (item) => {
+                const batchRows = await getBatchRowsByItem(item);
+                const candidates = batchRows.filter(
+                  (row) =>
+                    row.categoryCode === item.productCode ||
+                    String(row.categoryId) === String(item.productId)
+                );
+                const batchDetail =
+                  candidates.find((row) => item.batchNo && row.batchNo === item.batchNo) ||
+                  (candidates.length === 1 ? candidates[0] : {});
+                return {
+                  ...item,
+                  batchNo: item.batchNo || batchDetail.batchNo || '',
+                  cuttingLength: item.cuttingLength || '',
+                  reelSpecification: item.reelSpecification || batchDetail.reelSpecification || ''
+                };
+              })
+            );
             return { ...wrapperItem, productList };
           })
         );
         this.QRvisible = true;
       },
+
+      // 按物品批次查询 WMS 批次库存台账,返回可匹配的候选行
+      async getBatchRows(item) {
+        if (!item.batchNo && !item.systemBatchNo) {
+          return [];
+        }
+        try {
+          const page = await getBatchList({
+            batchNo: item.batchNo || undefined,
+            systemBatchNo: item.systemBatchNo || undefined,
+            pageNum: 1,
+            size: 100
+          });
+          return page?.list || [];
+        } catch (e) {
+          return [];
+        }
+      },
       close() {
         this.QRvisible = false;
       },