فهرست منبع

fix(发货单): 修复库存验证逻辑和仓库变更处理

liujt 7 ماه پیش
والد
کامیت
85351b4d19
1فایلهای تغییر یافته به همراه20 افزوده شده و 18 حذف شده
  1. 20 18
      src/views/saleManage/saleOrder/invoice/components/inventoryTable.vue

+ 20 - 18
src/views/saleManage/saleOrder/invoice/components/inventoryTable.vue

@@ -1025,12 +1025,22 @@
       pendingReplaceTableConfirm(list) {
         console.log('confirm', list)
         list.forEach((item) => {
-          item.warehouseList =[{
+          // item.warehouseList = item.warehouseList.map( i => {
+          //   return {
+          //     warehouseName: i.warehouse_name,
+          //     warehouseId: i.warehouse_id,
+          //   }
+          // })
+          item.warehouseList = [{
             warehouseName: item.warehouseName,
             warehouseId: item.warehouseId,
           }]
         });
-        
+
+        // if(list[0].warehouseList.length == 1) {
+        //   this.$set(this.current, 'warehouseId', list[0].warehouseId)
+        // }
+    
         this.$set(this.current, 'warehouseList', list[0].warehouseList)
         this.$set(this.current, 'warehouseId', list[0].warehouseId)
         this.$set(this.current, 'warehouseNum', list[0].measureQuantity)
@@ -1126,6 +1136,7 @@
       },
 
       async warehouseChange(index, row, isReset = false) {
+        console.log('warehouseChange', index, row.isSuspend, isReset);
         const data = row.warehouseList.find(
           (item) => item.warehouseId == row.warehouseId
         );
@@ -1140,17 +1151,8 @@
           'warehouseCode',
           data.warehouseCode
         );
-        const warehouseOutStock = await getWarehouseOutStock({
-          warehouseId: data.warehouseId,
-          code: row.productCode
-        });
-        this.$set(
-          this.form.datasource[index],
-          'warehouseNum',
-          warehouseOutStock || 0
-        );
-
-        if(isReset) {
+        
+        if(isReset && row.isSuspend != 1) {
           this.$set(this.form.datasource[index], 'batchStockId', '');
           this.$set(this.form.datasource[index], 'batchNo', '');
         }
@@ -2012,11 +2014,11 @@
               });
             }
 
-            // 检查挂起产品库存
-            if (this.isSuspendedProductOverstock(item)) {
+            // 检查产品库存
+            if (this.isProductOverstock(item)) {
               errors.push({ 
                 type: 'suspend', 
-                message: `挂起产品[${productInfo.name}]的发货数量${item.totalCount}不能大于库存${item.warehouseNum}`, 
+                message: `产品[${productInfo.name}]的发货数量${item.totalCount}不能大于库存${item.warehouseNum}`, 
                 stopValidation: true,
                 item: item
               });
@@ -2067,8 +2069,8 @@
        * @param {Object} item 数据项
        * @returns {boolean} 是否超过
        */
-      isSuspendedProductOverstock(item) {
-        return item.isSuspend == 1 && Number(item.totalCount) > item.warehouseNum;
+      isProductOverstock(item) {
+        return Number(item.totalCount) > item.warehouseNum;
       },
 
       /**