yusheng před 10 měsíci
rodič
revize
f5196b0524

+ 72 - 43
src/views/saleManage/saleOrder/invoice/components/inventoryTable.vue

@@ -100,21 +100,19 @@
       </template>
 
       <template v-slot:packagingStrength="scope">
-        <el-form-item
-          :prop="'datasource.' + scope.$index + '.packagingStrength'"
-        >
+        <el-form-item>
           <DictSelection
             dict-name="包装强度"
+            @change="keyChange(scope.$index, scope.row, 'packagingStrength')"
             v-model="scope.row.extField.packagingStrength"
           ></DictSelection>
         </el-form-item>
       </template>
       <template v-slot:packagingDensity="scope">
-        <el-form-item
-          :prop="'datasource.' + scope.$index + '.packagingDensity'"
-        >
+        <el-form-item>
           <DictSelection
             dict-name="包装密度"
+            @change="keyChange(scope.$index, scope.row, 'packagingDensity')"
             v-model="scope.row.extField.packagingDensity"
           ></DictSelection>
         </el-form-item>
@@ -1028,7 +1026,14 @@
         this.curIndex = index;
         this.setIcreaseTotalWeight(row);
       },
-
+      keyChange(index, row, key) {
+        this.$set(
+          this.form.datasource[index],
+          'extField.' + key,
+          row.extField[key]
+        );
+        this.$forceUpdate();
+      },
       //设置增重总重
       setIcreaseTotalWeight(row) {
         let receiveTotalWeight = Number(
@@ -1037,11 +1042,14 @@
         let sendTotalWeight = Number(
           this.form.datasource[this.curIndex]?.sendTotalWeight
         );
-        this.$set(
-          this.form.datasource[this.curIndex],
-          'increaseTotalWeight',
-          (sendTotalWeight - receiveTotalWeight).toFixed(2)
-        );
+        if (sendTotalWeight && receiveTotalWeight) {
+          this.$set(
+            this.form.datasource[this.curIndex],
+            'increaseTotalWeight',
+            (sendTotalWeight - receiveTotalWeight).toFixed(2)
+          );
+        }
+
         this.$refs.table.reload();
         this.$forceUpdate();
       },
@@ -1237,7 +1245,14 @@
         console.log(data, 'data 1+1');
         if (data) {
           this.form.datasource = data;
-          data.forEach(async (item, index) => {
+          this.form.datasource.forEach(async (item, index) => {
+            // if (!item.extField) {
+            //   this.$set(
+            //     this.form.datasource[index],
+            //     'extField',
+            //     item.extField || {}
+            //   );
+            // }
             this.$set(
               this.form.datasource[index],
               'warehouseList',
@@ -1255,40 +1270,54 @@
                 })
               );
             } else if (this.form.datasource[index]?.warehouseList?.length) {
-              
-            }
-
-            //保存初始收货总重
-            this.oldReceiveTotalWeight = this.form.datasource.map((item) => {
-              return {
-                productCode: item.productCode,
-                oldReceiveTotalWeight: item.receiveTotalWeight
-              };
-            });
-            this.form.datasource.forEach((item, index) => {
               this.$set(
                 this.form.datasource[index],
-                'receiveTotalWeight',
-                item.receiveTotalWeight || 0
+                'warehouseId',
+                this.form.datasource[index]?.warehouseList[0].warehouseId
               );
-              if (item.weightUnit == item.measuringUnit) {
-                item.sendTotalWeight = item.sendTotalWeight || item.totalCount;
-              } else {
-                item.sendTotalWeight =
-                  item.sendTotalWeight ||
-                  Number(item.totalCount) * Number(item.singleWeight) ||
-                  0;
-              }
+              await this.warehouseChange(index, this.form.datasource[index]);
+            }
 
-              if (this.outsourceSendCode) {
-                item.increaseTotalWeight =
-                  Number(item.receiveTotalWeight) -
-                  Number(item.sendTotalWeight);
-              } else {
-                item.increaseTotalWeight =
-                  item.increaseTotalWeight || item.receiveTotalWeight || 0;
-              }
-            });
+            this.$set(
+              this.form.datasource[index],
+              'receiveTotalWeight',
+              item.receiveTotalWeight || 0
+            );
+            if (item.weightUnit == item.measuringUnit) {
+              item.sendTotalWeight = item.sendTotalWeight || item.totalCount;
+            } else {
+              item.sendTotalWeight =
+                item.sendTotalWeight ||
+                Number(item.totalCount) * Number(item.singleWeight) ||
+                0;
+            }
+
+            if (this.outsourceSendCode) {
+              item.increaseTotalWeight =
+                Number(item.receiveTotalWeight) - Number(item.sendTotalWeight);
+              item.increaseTotalWeight;
+            } else {
+              item.increaseTotalWeight =
+                item.increaseTotalWeight || item.receiveTotalWeight || 0;
+            }
+            this.$set(
+              this.form.datasource[index],
+              'sendTotalWeight',
+              item.sendTotalWeigh
+            );
+            this.$set(
+              this.form.datasource[index],
+              'increaseTotalWeight',
+              item.increaseTotalWeight
+            );
+            console.log(item.increaseTotalWeight);
+          });
+          //保存初始收货总重
+          this.oldReceiveTotalWeight = this.form.datasource.map((item) => {
+            return {
+              productCode: item.productCode,
+              oldReceiveTotalWeight: item.receiveTotalWeight
+            };
           });
         }
       },