ソースを参照

fix(unqualifiedProduct): 添加明细改为追加,修改台账不再清空已有明细

confirmChoose(选择产品弹窗回调,即「+ 添加明细」)第一行就执行 form.poList = [],
修改台账时把已加载的、带 id 的明细行清掉,提交后后端按「未携带即删除」把库里明细物理删除。

- 去掉清空,只 concat 追加(与同目录 edit.vue 的写法一致)
- 主表信息(产品/批次号/规格/单位/重量)仅在创建时用所选产品赋值,
  修改时保留台账原有主信息,避免追加行把主表产品覆盖掉
- 数量改为 form.poList.length,连续添加时不再只统计本次所选行数
wuzh 1 日 前
親
コミット
6baef884ee

+ 18 - 14
src/views/unqualifiedProduct/unqualifiedList/components/create.vue

@@ -601,9 +601,10 @@
       },
 
       // 确定选择
+      // 注意:这里只做"追加",不能清空 form.poList。修改台账时 poList 里是已保存的明细(带 id),
+      // 清空后提交会让后端认为这些明细被删除,把它们物理删掉。
       confirmChoose(data) {
         console.log(data);
-        this.form.poList = [];
 
         let list = [];
         list = data.map((item, index) => {
@@ -661,21 +662,24 @@
             };
           }
         });
-        this.form.categoryCode = data[0].code;
-        this.form.categoryName = data[0].name;
-        this.form.categoryId = data[0].id;
-        this.form.brandNum = data[0].brandNum;
-        this.form.batchNo = data[0].batchNo;
-        this.form.specification = data[0].specification;
-        this.form.modelType = data[0].modelType;
-        this.form.measureQuantity = '';
-        this.form.measureUnit = data[0].measuringUnit;
-        this.form.weight = data[0].netWeight;
-        this.form.weightUnit = data[0].weightUnit;
-        this.form.quantity = data.length;
-
         this.form.poList = this.form.poList.concat(list);
 
+        // 修改台账时保留原有主表信息(产品、批次号、规格等),只追加明细行,避免被新增行的产品覆盖
+        if (this.title !== '修改') {
+          this.form.categoryCode = data[0].code;
+          this.form.categoryName = data[0].name;
+          this.form.categoryId = data[0].id;
+          this.form.brandNum = data[0].brandNum;
+          this.form.batchNo = data[0].batchNo;
+          this.form.specification = data[0].specification;
+          this.form.modelType = data[0].modelType;
+          this.form.measureQuantity = '';
+          this.form.measureUnit = data[0].measuringUnit;
+          this.form.weight = data[0].netWeight;
+          this.form.weightUnit = data[0].weightUnit;
+          this.form.quantity = this.form.poList.length;
+        }
+
         this.produceTaskChange();
         // this.inputNumber();
       },