Sfoglia il codice sorgente

包装曾添加供应商名称和代号

yijing 1 anno fa
parent
commit
9daf632b24

+ 272 - 252
src/views/warehouseManagement/stockManagement/add.vue

@@ -80,8 +80,8 @@
           <el-form ref="productListRef" :model="{ productList: productList }" :show-message="false">
             <!-- <el-button v-if="productList.length != 0" type="success" plain
               style="margin-bottom: 20px; float: right; margin-right: 20px" size="mini"
-              @click="listSaveArrs">批量保存</el-button> -->
-            <el-button v-if="productList.length != 0 && this.packingList.length == 0" type="success" plain
+              @click="batchSave">批量保存</el-button> -->
+            <el-button v-if="productList.length != 0" type="success" plain
               style="margin-bottom: 20px; float: right; margin-right: 20px" size="mini"
               @click="handleWareHouse(productList, '', 'batch')">批量选择仓库</el-button>
             <el-table :header-cell-style="rowClass" :max-height="300" border ref="productListTable" :data="productList"
@@ -855,11 +855,16 @@ export default {
           total = Number(row.packingQuantity) * row.netWeight;
           console.log(total, '22')
         } else {
+          let conversionApplied = false;
           for (; startIndex < endIndex; endIndex--) {
-            total = this.$math.format(
-              row.packingSpecificationOption[endIndex].packageCell * total,
-              14
-            );
+            if (!conversionApplied) {
+              total = this.$math.format(
+                row.packingSpecificationOption[endIndex].packageCell * total,
+                14
+              );
+              conversionApplied = true;
+            }
+
           }
           console.log(total, '333')
         }
@@ -1519,7 +1524,7 @@ export default {
       // obj.isSkip = 1;
       this.saveLoading = true;
       console.log(obj, 'objobjobjobjobjobj');
-   
+
       storageApi
         .storage(obj)
         .then(async (res) => {
@@ -1963,139 +1968,139 @@ export default {
       });
     },
     // 产品批量保存
-    async listSaveArrs() {
-      this.validateForm()
-        .then(async () => {
-          // 批量获取包装编码并处理
-          let packingCodePrams = this.productList.map((row) => {
-            // 判断单位和计量单位是否为不拆物料层规格
-            let packingBoolen = !!this.getDict(
-              '不拆物料层规格',
-              row.packingUnit
-            ).dictValue;
-            let measureBoolen = !!this.getDict(
-              '不拆物料层规格',
-              row.measureUnit
-            ).dictValue;
-            let num = 0;
-            if (packingBoolen) {
-              let filterArr = row.packingSpecificationOption.filter(
-                (item) => {
-                  return (
-                    item.packageUnit == row.packingUnit &&
-                    item.packageUnit != item.conversionUnit
-                  );
-                }
-              );
-              num = Math.ceil(row.packingQuantity / filterArr[0].packageCell);
-            }
-            if (row.isSave) {
-              return {};
-            } else {
-              console.log(packingBoolen, 'packingBoolen怕怕怕怕怕怕怕')
-              // 处理单位为KG类的情况
-              if (packingBoolen) {
-                return {
-                  assetCode: row.categoryCode + row.index,
-                  batchNum: row.batchNo,
-                  num
-                };
-              } else {
-                if (row.isUnpack) {
-                  if (measureBoolen) {
-                    // 处理单位不为KG类,计量单位为KG类的情况
-                    let num = row.packingQuantity;
-                    let splitIndex = row.packingSpecificationOption.findIndex(
-                      (item) =>
-                        item.conversionUnit == row.packingUnit &&
-                        item.packageUnit != item.conversionUnit
-                    );
-                    for (; splitIndex > 1; splitIndex--) {
-                      num = this.$math.format(
-                        num *
-                        row.packingSpecificationOption[splitIndex]
-                          .packageCell,
-                        14
-                      );
-                    }
-                    return {
-                      assetCode: row.categoryCode + row.index,
-                      batchNum: row.batchNo,
-                      num
-                    };
-                  } else {
-                    console.log('拆包情况------:', row.measureQuantity, row.packingSpecificationOption[1]?.packageCell);
-
-                    // 处理拆包到最小包装单元数量的情况
-                    let num = Math.ceil(
-                      row.measureQuantity / row.packingSpecificationOption[1]?.packageCell
-                    );
-                    return {
-                      assetCode: row.categoryCode + row.index,
-                      batchNum: row.batchNo,
-                      num: num
-                    };
-                  }
-                } else {
-                  return {
-                    assetCode: row.categoryCode + row.index,
-                    batchNum: row.batchNo,
-                    num: row.packingQuantity
-                  };
-                }
-              }
-            }
-          });
-          let filterPackingCodePrams = packingCodePrams.filter(
-            (item) => item.assetCode
-          );
-          let { data } = await storageApi.getAssetNum(filterPackingCodePrams);
-          console.log('data-----11111111111111111---', data);
-          let packingCodeList = [];
-          packingCodePrams.forEach((item, index) => {
-            packingCodeList[index] = data.filter(
-              (ite) => ite.assetCode == item.assetCode
-            );
-          });
-          // 批量生成包装
-          this.productList.map((row, index) => {
-            if (!row.isSave) {
-              this.generateWrappers(row, index, packingCodeList[index]);
-              this.$set(this.productList[index], 'isSave', true);
-              console.log('this.productList[index]----', this.productList[index]);
-              console.log('row----', row);
-
-              this.$set(
-                this.productList[index],
-                'warehouseId',
-                row.warehouseId
-              );
-              this.$set(
-                this.productList[index],
-                'warehouseName',
-                row.warehouseName
-              );
-
-              this.$set(
-                this.productList[index],
-                'warehouseIds',
-                [row.warehouseId]
-              );
-              this.$set(
-                this.productList[index],
-                'warehouseNames',
-                [row.warehouseName]
-              );
-            }
-          });
-          // 加载虚拟列表数据(分页)
-          // this.pickingFetchData();
-          // this.materielFetchData();
-        })
-        .catch((err) => {
-          console.log(err);
-        });
-    },
+    // async listSaveArrs() {
+    //   this.validateForm()
+    //     .then(async () => {
+    //       // 批量获取包装编码并处理
+    //       let packingCodePrams = this.productList.map((row) => {
+    //         // 判断单位和计量单位是否为不拆物料层规格
+    //         let packingBoolen = !!this.getDict(
+    //           '不拆物料层规格',
+    //           row.packingUnit
+    //         ).dictValue;
+    //         let measureBoolen = !!this.getDict(
+    //           '不拆物料层规格',
+    //           row.measureUnit
+    //         ).dictValue;
+    //         let num = 0;
+    //         if (packingBoolen) {
+    //           let filterArr = row.packingSpecificationOption.filter(
+    //             (item) => {
+    //               return (
+    //                 item.packageUnit == row.packingUnit &&
+    //                 item.packageUnit != item.conversionUnit
+    //               );
+    //             }
+    //           );
+    //           num = Math.ceil(row.packingQuantity / filterArr[0].packageCell);
+    //         }
+    //         if (row.isSave) {
+    //           return {};
+    //         } else {
+    //           console.log(packingBoolen, 'packingBoolen怕怕怕怕怕怕怕')
+    //           // 处理单位为KG类的情况
+    //           if (packingBoolen) {
+    //             return {
+    //               assetCode: row.categoryCode + row.index,
+    //               batchNum: row.batchNo,
+    //               num
+    //             };
+    //           } else {
+    //             if (row.isUnpack) {
+    //               if (measureBoolen) {
+    //                 // 处理单位不为KG类,计量单位为KG类的情况
+    //                 let num = row.packingQuantity;
+    //                 let splitIndex = row.packingSpecificationOption.findIndex(
+    //                   (item) =>
+    //                     item.conversionUnit == row.packingUnit &&
+    //                     item.packageUnit != item.conversionUnit
+    //                 );
+    //                 for (; splitIndex > 1; splitIndex--) {
+    //                   num = this.$math.format(
+    //                     num *
+    //                     row.packingSpecificationOption[splitIndex]
+    //                       .packageCell,
+    //                     14
+    //                   );
+    //                 }
+    //                 return {
+    //                   assetCode: row.categoryCode + row.index,
+    //                   batchNum: row.batchNo,
+    //                   num
+    //                 };
+    //               } else {
+    //                 console.log('拆包情况------:', row.measureQuantity, row.packingSpecificationOption[1]?.packageCell);
+
+    //                 // 处理拆包到最小包装单元数量的情况
+    //                 let num = Math.ceil(
+    //                   row.measureQuantity / row.packingSpecificationOption[1]?.packageCell
+    //                 );
+    //                 return {
+    //                   assetCode: row.categoryCode + row.index,
+    //                   batchNum: row.batchNo,
+    //                   num: num
+    //                 };
+    //               }
+    //             } else {
+    //               return {
+    //                 assetCode: row.categoryCode + row.index,
+    //                 batchNum: row.batchNo,
+    //                 num: row.packingQuantity
+    //               };
+    //             }
+    //           }
+    //         }
+    //       });
+    //       let filterPackingCodePrams = packingCodePrams.filter(
+    //         (item) => item.assetCode
+    //       );
+    //       let { data } = await storageApi.getAssetNum(filterPackingCodePrams);
+    //       console.log('data-----11111111111111111---', data);
+    //       let packingCodeList = [];
+    //       packingCodePrams.forEach((item, index) => {
+    //         packingCodeList[index] = data.filter(
+    //           (ite) => ite.assetCode == item.assetCode
+    //         );
+    //       });
+    //       // 批量生成包装
+    //       this.productList.map((row, index) => {
+    //         if (!row.isSave) {
+    //           this.generateWrappers(row, index, packingCodeList[index]);
+    //           this.$set(this.productList[index], 'isSave', true);
+    //           console.log('this.productList[index]----', this.productList[index]);
+    //           console.log('row----', row);
+
+    //           this.$set(
+    //             this.productList[index],
+    //             'warehouseId',
+    //             row.warehouseId
+    //           );
+    //           this.$set(
+    //             this.productList[index],
+    //             'warehouseName',
+    //             row.warehouseName
+    //           );
+
+    //           this.$set(
+    //             this.productList[index],
+    //             'warehouseIds',
+    //             [row.warehouseId]
+    //           );
+    //           this.$set(
+    //             this.productList[index],
+    //             'warehouseNames',
+    //             [row.warehouseName]
+    //           );
+    //         }
+    //       });
+    //       // 加载虚拟列表数据(分页)
+    //       // this.pickingFetchData();
+    //       // this.materielFetchData();
+    //     })
+    //     .catch((err) => {
+    //       console.log(err);
+    //     });
+    // },
     // 物品保存验证表单(单独)
     validateFormIndividually(index) {
       return new Promise(async (resolve) => {
@@ -2132,29 +2137,6 @@ export default {
     listEdit(row) {
       console.log(row);
       this.$set(row, 'isSave', false);
-      // // 重新计算重量
-      // const totals = Number(
-      //   this.$math.format(row.minPackingQuantity * row.packingQuantity, 14)
-      // );
-      // if (row.measureUnit == row.weightUnit) {
-      //   row.weight = Number(
-      //     this.$math.format(
-      //       row.minPackingQuantity *
-      //         1 *
-      //         Number(row.packingQuantity).toFixed(2),
-      //       14
-      //     )
-      //   );
-      // } else {
-      //   row.weight = Number(
-      //     this.$math.format(
-      //       totals *
-      //         (row.netWeight > 0 ? Number(row.netWeight).toFixed(2) : 0),
-      //       14
-      //     )
-      //   );
-      // }
-      console.log(row);
       this.deletePackingAndMaterial(row);
     },
     // 根据产品信息删除包装和物料
@@ -2189,114 +2171,139 @@ export default {
       console.log(this.pageSize);
       console.log(this.materielPageNum);
     },
-    // 产品保存操作
-    listSave(row, index) {
+    // 新增批量保存方法
+    async batchSave() {
+      try {
+        // 验证所有未保存的表单
+        await this.validateForm()
+
+        // 遍历所有产品进行保存
+        for (let i = 0; i < this.productList.length; i++) {
+          const row = this.productList[i]
+          if (!row.isSave) {
+            // 执行单个保存逻辑
+            await this.listSave(row, i)
+          }
+        }
+      } catch (error) {
+        this.$message.error('批量保存失败,请检查必填项')
+      }
+    },
+    //产品保存操作
+    async listSave(row, index) {
       console.log('row22222222', row);
-      this.validateFormIndividually(index).then(async () => {
-        // 判断单位和计量单位是否为不拆物料层规格
-        let packingBoolen = !!this.getDict('不拆物料层规格', row.packingUnit)
-          .dictValue;
-        let measureBoolen = !!this.getDict('不拆物料层规格', row.measureUnit)
-          .dictValue;
-        console.log('packingBoolen---------', packingBoolen);
-        console.log('measureBoolen---------', measureBoolen);
-        let packingNum = 0;
+      return new Promise(async (resolve, reject) => {
+        try {
+          await this.validateFormIndividually(index)
 
-        // 处理单位为KG类的情况
-        if (packingBoolen) {
+          // 判断单位和计量单位是否为不拆物料层规格
+          let packingBoolen = !!this.getDict('不拆物料层规格', row.packingUnit)
+            .dictValue;
+          let measureBoolen = !!this.getDict('不拆物料层规格', row.measureUnit)
+            .dictValue;
+          console.log('packingBoolen---------', packingBoolen);
+          console.log('measureBoolen---------', measureBoolen);
+          let packingNum = 0;
 
-          if (!row.isUnpack && row.packingUnit == '立方') {
-            packingNum = 1;
-          } else {
-            let filterArr = row.packingSpecificationOption.filter((item) => {
-              return (
-                item.packageUnit == row.packingUnit &&
-                item.packageUnit != item.conversionUnit
+          // 处理单位为KG类的情况
+          if (packingBoolen) {
+
+            if (!row.isUnpack && row.packingUnit == '立方') {
+              packingNum = 1;
+            } else {
+              let filterArr = row.packingSpecificationOption.filter((item) => {
+                return (
+                  item.packageUnit == row.packingUnit &&
+                  item.packageUnit != item.conversionUnit
+                );
+              });
+              packingNum = Math.ceil(
+                row.packingQuantity / filterArr[0].packageCell
               );
-            });
-            packingNum = Math.ceil(
-              row.packingQuantity / filterArr[0].packageCell
-            );
+            }
           }
-        }
-        // 处理单位不为KG类,计量单位为KG类的情况
-        let measureNum = row.packingQuantity;
-        let num = 0;
+          // 处理单位不为KG类,计量单位为KG类的情况
+          let measureNum = row.packingQuantity;
+          let num = 0;
 
-        if (measureBoolen) {
-          let splitIndex = row.packingSpecificationOption.findIndex(
-            (item) =>
-              item.conversionUnit == row.packingUnit &&
-              item.packageUnit != item.conversionUnit
-          );
-          for (; splitIndex > 1; splitIndex--) {
-            measureNum = this.$math.format(
-              measureNum *
-              row.packingSpecificationOption[splitIndex].packageCell,
-              14
+          if (measureBoolen) {
+            let splitIndex = row.packingSpecificationOption.findIndex(
+              (item) =>
+                item.conversionUnit == row.packingUnit &&
+                item.packageUnit != item.conversionUnit
+            );
+            for (; splitIndex > 1; splitIndex--) {
+              measureNum = this.$math.format(
+                measureNum *
+                row.packingSpecificationOption[splitIndex].packageCell,
+                14
+              );
+            }
+          } else {
+            num = Math.ceil(
+              row.measureQuantity / row.packingSpecificationOption[1]?.packageCell
             );
           }
-        } else {
-          num = Math.ceil(
-            row.measureQuantity / row.packingSpecificationOption[1]?.packageCell
-          );
-        }
-        console.log(packingNum, measureNum, num, '加油加油加油')
+          console.log(packingNum, measureNum, num, '加油加油加油')
 
-        if (row.packingSpecificationLabel?.length < 1) {
-          this.$message.error('请到主数据维护包装组信息!')
-          return;
-        }
-        // 不拆包
-        if (!row.isUnpack) {
-          if (row.packingUnit != row.measureUnit) {
-            let pNum = row.packingQuantity;
-            const { data } = await storageApi.getAssetNum([
-              {
-                assetCode: row.categoryCode + row.index,
-                batchNum: row.batchNo,
-                num: pNum,
-              }
-            ]);
-            this.generateWrappers(row, index, data)
+          if (row.packingSpecificationLabel?.length < 1) {
+            this.$message.error('请到主数据维护包装组信息!')
+            return;
+          }
+          // 不拆包
+          if (!row.isUnpack) {
+            if (row.packingUnit != row.measureUnit) {
+              let pNum = row.packingQuantity;
+              const { data } = await storageApi.getAssetNum([
+                {
+                  assetCode: row.categoryCode + row.index,
+                  batchNum: row.batchNo,
+                  num: pNum,
+                }
+              ]);
+              this.generateWrappers(row, index, data)
+            } else {
+              let pNum = 0;
+              const { data } = await storageApi.getAssetNum([
+                {
+                  assetCode: row.categoryCode + row.index,
+                  batchNum: row.batchNo,
+                  num: pNum,
+                }
+              ]);
+            }
           } else {
-            let pNum = 0;
+            //拆包
             const { data } = await storageApi.getAssetNum([
               {
                 assetCode: row.categoryCode + row.index,
                 batchNum: row.batchNo,
-                num: pNum,
+                num: packingBoolen ? packingNum : measureBoolen ? measureNum : num,
               }
             ]);
-          }
-        } else {
-          //拆包
-          const { data } = await storageApi.getAssetNum([
-            {
-              assetCode: row.categoryCode + row.index,
-              batchNum: row.batchNo,
-              num: packingBoolen ? packingNum : measureBoolen ? measureNum : num,
-            }
-          ]);
 
-          this.generateWrappers(row, index, data);
-        }
-        this.$set(this.productList[index], 'isSave', true);
-        this.$set(this.productList[index], 'warehouseId', row.warehouseId);
-        this.$set(
-          this.productList[index],
-          'warehouseName',
-          row.warehouseName
-        );
+            this.generateWrappers(row, index, data);
+          }
+          this.$set(this.productList[index], 'isSave', true)
+          this.$set(this.productList[index], 'warehouseId', row.warehouseId);
+          this.$set(
+            this.productList[index],
+            'warehouseName',
+            row.warehouseName
+          );
 
-        this.$set(this.productList[index], 'warehouseIds', row.warehouseId);
-        this.$set(
-          this.productList[index],
-          'warehouseNames',
-          row.warehouseName
-        );
+          this.$set(this.productList[index], 'warehouseIds', row.warehouseId);
+          this.$set(
+            this.productList[index],
+            'warehouseNames',
+            row.warehouseName
+          );
 
-      });
+          resolve()
+        } catch (error) {
+          reject(error)
+        }
+      })
     },
     // 生成包装
     generateWrappers(row, productIndex, packingCodeList) {
@@ -2412,6 +2419,8 @@ export default {
             barcodes: '', // 发货条码
             clientCode: row.extInfo ? row.extInfo.clientCode : '', // 客户代号
             materielDesignation: row.extInfo ? row.extInfo.materielCode : '', // 物料代号
+            supplierName: row.supplierName, // 供应商名称
+            supplierCode: row.supplierCode, // 供应商代号
             engrave: '', // 刻码
             isUnpack: row.isUnpack, // 是否允许拆包
             productionDate: productionDate, // 生产日期
@@ -2476,6 +2485,7 @@ export default {
           packingList.push(item);
         }
       } else {
+
         console.log('拆包处理', row);
         for (let index = 0; index < num; index++) {
           let measureQuantity = 1;
@@ -2501,6 +2511,7 @@ export default {
             }
           } else {
             if (row.isUnpack == 1) {
+
               console.log('1 拆--------', measureBoolen)
               if (measureBoolen) {
                 // 处理单位不为KG类,计量单位为KG类的情况
@@ -2570,6 +2581,8 @@ export default {
             barcodes: '', // 发货条码
             clientCode: row.extInfo ? row.extInfo.clientCode : '', // 客户代号
             materielDesignation: row.extInfo ? row.extInfo.materielCode : '', // 物料代号
+            supplierName: row.supplierName, // 供应商名称
+            supplierCode: row.supplierCode, // 供应商代号
             engrave: '', // 刻码
             isUnpack: row.isUnpack, // 是否允许拆包
             productionDate: productionDate, // 生产日期
@@ -2661,6 +2674,13 @@ export default {
           }
           packingList.push(item);
         }
+        const existingIndex = this.packingList.findIndex(p =>
+          p.parentIndex === row.index
+        );
+        if (existingIndex > -1) {
+          this.packingList.splice(existingIndex, 1); // 移除旧数据
+        }
+
       }
 
       // 单独点击保存并插入对应位置(包装)

+ 6 - 2
src/views/warehouseManagement/stockManagement/details.vue

@@ -154,7 +154,7 @@
             </el-table-column>
             <el-table-column v-if="clientEnvironmentId == 4" label="采购原因" align="center" prop="purpose"
               :show-overflow-tooltip="true"></el-table-column>
-            <el-table-column label="供应商" prop="supplierName" :show-overflow-tooltip="true">
+            <el-table-column label="供应商" prop="supplierName" :show-overflow-tooltip="true"width="120">
             </el-table-column>
             <el-table-column width="120" label="供应商代号" prop="supplierCode" :show-overflow-tooltip="true">
             </el-table-column>
@@ -199,9 +199,13 @@
             <el-table-column label="计量单位" prop="measureUnit" :show-overflow-tooltip="true"></el-table-column>
             <el-table-column label="物料代号" prop="materielDesignation" :show-overflow-tooltip="true">
             </el-table-column>
+            <el-table-column label="刻码" prop="engrave" :show-overflow-tooltip="true">
+            </el-table-column>
             <el-table-column label="客户代号" prop="clientCode" :show-overflow-tooltip="true">
             </el-table-column>
-            <el-table-column label="刻码" prop="engrave" :show-overflow-tooltip="true">
+            <el-table-column label="供应商" prop="supplierName" :show-overflow-tooltip="true" width="120">
+            </el-table-column>
+            <el-table-column label="供应商代号" prop="supplierCode" :show-overflow-tooltip="true" width="120">
             </el-table-column>
             <el-table-column label="总重" prop="weight" :show-overflow-tooltip="true">
             </el-table-column>