Browse Source

修改来料登记录入

chensibo 1 week ago
parent
commit
d67318b28e
1 changed files with 44 additions and 12 deletions
  1. 44 12
      src/views/wms/incoming/register/materialRegistration.vue

+ 44 - 12
src/views/wms/incoming/register/materialRegistration.vue

@@ -80,6 +80,7 @@
           <el-form-item label="物料编码" prop="materialNo">
             <MaterialSelect
               ref="materialOrder"
+              :key="materialKey"
               v-model="form.wmsPurchaseOrderDetailId"
               clearable
               :disabled="materialDisabled || !!materialLots"
@@ -435,6 +436,7 @@ export default {
         createTime: [],
         materialName: null,
       },
+      materialKey: 0, // 控制 MaterialSelect 强制重建
       // 显示客户
       receiptShow: true,
       // 物料编码
@@ -469,6 +471,7 @@ export default {
         HicoreReportName: "",
         reportType: "0",
         deliverBatch: null,
+        wmsPurchaseOrderDetailId: null,
         materialNo: null,
         produceDate: null,
         purchaseOrderNo: null,
@@ -839,21 +842,50 @@ export default {
       // 重新计算所有行的到货总数
       this.calculateTotalReceiptQty();
     },
-    // 单单号change事件
+    // 单单号change事件
     OrderNoChange(item) {
-      if (item && typeof item === "object") {
-        const { erpOrderNo, id, supplierCode } = item;
-        this.form.purchaseOrderNo = erpOrderNo;
-        if (supplierCode) {
-          this.form.supplierCode = supplierCode;
-        }
-        if (this.form.receiptType == "3") {
-          this.$refs.materialOrder.outSourceId = id;
+      // 无论选中还是清空,先清空物料编码及后续所有字段
+      this.form.wmsPurchaseOrderDetailId = null;
+      this.form.materialNo = null;
+      this.form.materialName = null;
+      this.form.checkIncoming = null;
+      this.form.storageEnvironment = null;
+      this.form.unitCode = null;
+      this.form.unitName = null;
+      this.form.size = null;
+      this.form.receiptQty = null;
+      this.form.deliverBatch = null;
+      this.form.produceDate = null;
+      this.form.validTill = null;
+      this.form.remark = null;
+      this.list = [];
+
+      // 强制重建 MaterialSelect 组件,彻底重置其内部选中状态
+      this.materialKey++;
+
+      this.$nextTick(() => {
+        if (item && typeof item === "object") {
+          const { erpOrderNo, id, supplierCode } = item;
+          this.form.purchaseOrderNo = erpOrderNo;
+          if (supplierCode) {
+            this.form.supplierCode = supplierCode;
+          }
+          if (this.form.receiptType == "3") {
+            this.$refs.materialOrder.outSourceId = id;
+          } else {
+            this.$refs.materialOrder.inStockId = id;
+          }
+          this.materialDisabled = false;
         } else {
-          this.$refs.materialOrder.inStockId = id;
+          // 清空源单编号时的处理
+          this.form.purchaseOrderNo = null;
+          if (this.$refs.materialOrder) {
+            this.$refs.materialOrder.inStockId = null;
+            this.$refs.materialOrder.outSourceId = null;
+          }
+          this.materialDisabled = true;
         }
-        this.materialDisabled = false;
-      }
+      });
     },
     // 物料编码change事件
     materialNoChange(item) {