Ver Fonte

入库物料明细反向修改重量

huang_an há 2 anos atrás
pai
commit
9658481f1b
1 ficheiros alterados com 93 adições e 8 exclusões
  1. 93 8
      src/views/warehouseManagement/stockManagement/add.vue

+ 93 - 8
src/views/warehouseManagement/stockManagement/add.vue

@@ -798,6 +798,7 @@
           </header-title>
 
           <el-table
+            v-if="showMaterialTable"
             ref="materialCodeReqListTable"
             :data="materialCodeReqList"
             tooltip-effect="dark"
@@ -1033,24 +1034,34 @@
             ></el-table-column>
             <el-table-column label="物料代号" prop="materielCode">
               <template slot-scope="{ row }">
-                <el-input v-model="row.materielCode"></el-input>
+                <el-input
+                  v-if="!row.isPack"
+                  v-model="row.materielCode"
+                ></el-input>
+                <span v-else>{{ row.materielCode }}</span>
               </template>
             </el-table-column>
             <el-table-column label="客户代号" prop="clientCode">
               <template slot-scope="{ row }">
-                <el-input v-model="row.clientCode"></el-input>
+                <el-input
+                  v-if="!row.isPack"
+                  v-model="row.clientCode"
+                ></el-input>
+                <span v-else>{{ row.clientCode }}</span>
               </template>
             </el-table-column>
             <el-table-column label="刻码" prop="engrave">
               <template slot-scope="{ row }">
-                <el-input v-model="row.engrave"></el-input>
+                <el-input v-if="!row.isPack" v-model="row.engrave"></el-input>
+                <span v-else>{{ row.engrave }}</span>
+              </template>
+            </el-table-column>
+            <el-table-column label="重量" prop="weight" width="100">
+              <template slot-scope="{ row }">
+                <el-input v-if="!row.isPack" v-model="row.weight"></el-input>
+                <span v-else>{{ row.weight }}</span>
               </template>
             </el-table-column>
-            <el-table-column
-              label="重量"
-              prop="weight"
-              width="100"
-            ></el-table-column>
             <el-table-column
               label="重量单位"
               prop="weightUnit"
@@ -1173,6 +1184,7 @@
     },
     data() {
       return {
+        showMaterialTable: true, // 缓存包装明细列表
         isSplit: false, // 是否拆分到物料明细
         qualityStatus: ['未检', '已检'], // 质检状态 0未检 1已检
         qualityResults: ['合格', '不合格', '让步接收'], // 质检结果 0合格 1不合格 2让步接收
@@ -1325,7 +1337,14 @@
               });
             }
           });
+
           this.resultArray = resultArray;
+          // 批量修改包装明细
+          this.isWeight = false;
+          this.bulkEditingWrap();
+          this.$nextTick(() => {
+            this.isWeight = true;
+          });
         } else {
           // 包装维度改成编辑状态
           list.forEach((item) => {
@@ -1377,13 +1396,79 @@
 
         // }, 100);
       },
+      // 批量修改包装明细
+      bulkEditingWrap() {
+        // 批量修改包装明细列表状态(已保存)
+        this.materialCodeReqList.forEach((item) => {
+          item.isPack = true;
+        });
+        // 改变产品明细重量
+        this.warehousingMaterialList.forEach((outItem) => {
+          let arr = [];
+          this.materialCodeReqList.forEach((inneritem) => {
+            if (
+              inneritem.assetCode == outItem.assetCode &&
+              inneritem.batchNo == outItem.batchNo
+            ) {
+              arr.push(inneritem);
+            }
+          });
+          const count = arr.reduce((acc, curr) => acc + +curr.weight, 0);
+          this.$set(outItem, 'weight', count);
+        });
+      },
+      // 批量修改物料明细
+      bulkEditingMaterial() {
+        // 批量修改物料明细列表状态(已保存)
+        this.resultArray.forEach((item) => {
+          item.isPack = true;
+        });
+        // 改变包装明细重量
+        this.materialCodeReqList.forEach((outItem) => {
+          let arr = [];
+          this.resultArray.forEach((inneritem) => {
+            if (
+              inneritem.assetCode == outItem.assetCode &&
+              inneritem.batchNo == outItem.batchNo
+            ) {
+              arr.push(inneritem);
+            }
+          });
+          const count = arr.reduce((acc, curr) => acc + +curr.weight, 0);
+          this.$set(outItem, 'weight', count);
+        });
+      },
       // 物料明细保存
       materialBtn(row) {
         console.log(row);
+        console.log(this.resultArray);
         // true保存 false编辑
         if (!row.isPack) {
           row.isPack = true;
           // 物料维度修改质检改变包装维度质检(结果和状态)
+          // 物料维度修改重量改变包装维度重量
+          let onlyCode = row.onlyCode;
+          this.materialCodeReqList.forEach((item) => {
+            if (item.onlyCode === onlyCode) {
+              let arr = [];
+              for (const key in this.resultArray) {
+                if (this.resultArray[key].onlyCode == item.onlyCode) {
+                  arr.push({ ...this.resultArray[key] });
+                }
+              }
+              const count = arr.reduce((acc, curr) => acc + +curr.weight, 0);
+              this.$set(item, 'weight', count);
+            }
+          });
+          // 包装维度修改重量改变产品信息
+          console.log(this.warehousingMaterialList);
+          console.log(this.materialCodeReqList);
+          this.isWeight = false;
+          // 批量修改包装明细
+          this.bulkEditingWrap();
+          this.$nextTick(() => {
+            this.isWeight = true;
+          });
         } else {
           row.isPack = false;
         }