ソースを参照

fix: 委外发货单计划默认仓仅在校验过的可选仓内预选,并丢弃切换订单时的过期响应

lihaiting 4 日 前
親
コミット
6b83cdf126

+ 15 - 6
src/views/purchasingManage/purchaseOrder/outSourceSend/components/addOrEditDialog.vue

@@ -218,7 +218,9 @@
         businessId: '',
         // 采购订单关联的采购计划 id / 计划回写的默认仓库映射(按产品匹配)
         purchasePlanId: '',
-        planWarehouse: null
+        planWarehouse: null,
+        // 订单详情请求序号:切换订单时丢弃过期响应
+        orderDetailSeq: 0
       };
     },
 
@@ -230,6 +232,8 @@
         this.row = row;
         this.purchasePlanId = purchasePlanId || '';
         this.planWarehouse = null;
+        // 使上一次打开时未返回的订单详情请求失效,避免把旧数据写进本次弹窗
+        this.orderDetailSeq = this.orderDetailSeq + 1;
         if (orderId) {
           await this.getPurchaseOrderDetail(orderId);
         }
@@ -304,15 +308,18 @@
       },
       //获取订单详情
       async getPurchaseOrderDetail(id) {
+        const seq = (this.orderDetailSeq = this.orderDetailSeq + 1);
         this.loading = true;
         const data = await getByIdCondition(id, 1);
-        this.loading = false;
+        if (seq !== this.orderDetailSeq) return;
         if (data) {
           // 订单未直接带出仓库时,按关联采购计划回写的默认仓库预选明细行仓库
-          this.planWarehouse =
-            (await this.getPlanWarehouse(
-              this.purchasePlanId || data.purchasePlanId
-            )) || null;
+          const planWarehouse = await this.getPlanWarehouse(
+            this.purchasePlanId || data.purchasePlanId
+          );
+          if (seq !== this.orderDetailSeq) return;
+          this.loading = false;
+          this.planWarehouse = planWarehouse || null;
           this.$nextTick(() => {
             let {
               partbId,
@@ -344,6 +351,8 @@
             this.$refs.inventoryTableref &&
               this.$refs.inventoryTableref.putTableValue(productList);
           });
+        } else {
+          this.loading = false;
         }
       },
 

+ 3 - 11
src/views/purchasingManage/purchaseOrder/outSourceSend/components/inventoryTable.vue

@@ -975,9 +975,8 @@
             }
             const warehouseList =
               (await getIdWarehouseList({ categoryId: item.productId })) || [];
-            // 采购计划回写的仓库(warehouseId/warehouseName/warehouseCode)优先回显,
-            // 不在该行可选仓库内时补到选项里,保证仓库名称按计划数据显示
-            // 按产品精确命中的计划仓库优先;整单默认仓库只在明细行自身没有仓库时使用
+            // 采购计划回写的仓库在校验过的可选仓库内才预选:按产品精确命中的优先,
+            // 整单默认仓库只在明细行自身没有仓库时使用;不在可选范围(权限)内不预选
             const specificWarehouse =
               this.planWarehouse?.[String(item.productId)] ||
               this.planWarehouse?.[String(item.categoryId)] ||
@@ -999,14 +998,7 @@
                     planWarehouse.warehouseCode &&
                     String(w.warehouseCode) ===
                       String(planWarehouse.warehouseCode)
-                ) || {
-                  warehouseId: planWarehouse.warehouseId,
-                  warehouseName: planWarehouse.warehouseName,
-                  warehouseCode: planWarehouse.warehouseCode
-                };
-              if (!warehouseList.includes(planMatched)) {
-                warehouseList.unshift(planMatched);
-              }
+                );
             }
             this.$set(
               this.form.datasource[index],