Sfoglia il codice sorgente

入库 计量单位是KG的不拆,只能拆到自己选择的单位。没有维护包装规格不分包装明细

yijing 1 anno fa
parent
commit
198bce03e8

+ 92 - 109
src/views/warehouseManagement/components/WarehousingDialog.vue

@@ -1,24 +1,13 @@
 <template>
 <template>
-  <el-dialog
-    :visible.sync="visible"
-    title="仓库"
-    @before-close="cancel"
-    width="50%"
-    :close-on-click-modal="false"
-  >
+  <el-dialog :visible.sync="visible" title="仓库" @before-close="cancel" width="50%" :close-on-click-modal="false">
     <el-form :model="formData" label-width="100px">
     <el-form :model="formData" label-width="100px">
       <el-row>
       <el-row>
         <el-col :span="9">
         <el-col :span="9">
           <el-form-item label="选择仓库">
           <el-form-item label="选择仓库">
             <el-select filterable v-model="warehouseId" @change="changeWarehouse">
             <el-select filterable v-model="warehouseId" @change="changeWarehouse">
-              <el-option
-                v-for="(item, index) in warehouseList"
-                :key="index"
-                :label="item.name"
-                :value="item.id"
-              ></el-option>
-            </el-select> </el-form-item
-        ></el-col>
+              <el-option v-for="(item, index) in warehouseList" :key="index" :label="item.name"
+                :value="item.id"></el-option>
+            </el-select> </el-form-item></el-col>
         <el-col :span="6">
         <el-col :span="6">
           <el-button type="primary" @click="addTableData">添加</el-button>
           <el-button type="primary" @click="addTableData">添加</el-button>
         </el-col>
         </el-col>
@@ -26,8 +15,7 @@
           <el-form-item label="总包装数量">
           <el-form-item label="总包装数量">
             <span class="red_color">
             <span class="red_color">
               {{ this.packingQuantity }}
               {{ this.packingQuantity }}
-            </span></el-form-item
-          >
+            </span></el-form-item>
         </el-col>
         </el-col>
       </el-row>
       </el-row>
     </el-form>
     </el-form>
@@ -37,17 +25,12 @@
       <el-table-column label="仓库名称" prop="warehouseName"></el-table-column>
       <el-table-column label="仓库名称" prop="warehouseName"></el-table-column>
       <el-table-column label="包装数量" prop="packingQuantity" width="300">
       <el-table-column label="包装数量" prop="packingQuantity" width="300">
         <template slot-scope="{ row, $index }">
         <template slot-scope="{ row, $index }">
-          <el-input-number
-            v-model="row.packingQuantity"
-            :min="1"
-          ></el-input-number>
+          <el-input-number v-model="row.packingQuantity" :min="1"></el-input-number>
         </template>
         </template>
       </el-table-column>
       </el-table-column>
       <el-table-column width="120" label="操作" fixed="right">
       <el-table-column width="120" label="操作" fixed="right">
         <template slot-scope="{ row, $index }">
         <template slot-scope="{ row, $index }">
-          <el-button type="text" @click="delItem($index)" size="small"
-            >删除</el-button
-          >
+          <el-button type="text" @click="delItem($index)" size="small">删除</el-button>
         </template>
         </template>
       </el-table-column>
       </el-table-column>
     </el-table>
     </el-table>
@@ -59,100 +42,100 @@
 </template>
 </template>
 
 
 <script>
 <script>
-  import warehouseDefinition from '@/api/warehouseManagement/warehouseDefinition';
-  export default {
-    data() {
-      return {
-        packingQuantity: 1,
-        tableDate: [],
-        visible: false,
-        warehouseList: [], //仓库
-        formData: {},
-        warehouseId: '',
-        currentIndex: 0
-      };
+import warehouseDefinition from '@/api/warehouseManagement/warehouseDefinition';
+export default {
+  data() {
+    return {
+      packingQuantity: 1,
+      tableDate: [],
+      visible: false,
+      warehouseList: [], //仓库
+      formData: {},
+      warehouseId: '',
+      currentIndex: 0
+    };
+  },
+  methods: {
+    changeWarehouse() {
+      this.tableDate = []
     },
     },
-    methods: {
-      changeWarehouse() {
-        this.tableDate=[]
-      },
-      cancel() {
+    cancel() {
+      this.visible = false;
+    },
+    handleSelect() {
+      if (this.tableDate.length == 0) {
+        return this.$message.warning('请添加仓库!');
+      }
+      let total = this.tableDate.reduce(
+        (total, currentObj) =>
+          Number(total) + Number(currentObj.packingQuantity),
+        0
+      );
+      if (total == this.packingQuantity) {
+        this.$emit('selection', this.tableDate, this.currentIndex);
         this.visible = false;
         this.visible = false;
-      },
-      handleSelect() {
-        if (this.tableDate.length == 0) {
-          return this.$message.warning('请添加仓库!');
-        }
-        let total = this.tableDate.reduce(
-          (total, currentObj) =>
-            Number(total) + Number(currentObj.packingQuantity),
-          0
+      } else {
+        this.$message.warning('总包装数量与仓库包装数量不一致!');
+      }
+    },
+    addTableData() {
+      if (this.tableDate.length < this.packingQuantity) {
+        let list = this.tableDate.filter(
+          (item) => item.warehouseId == this.warehouseId
         );
         );
-        if (total == this.packingQuantity) {
-          this.$emit('selection', this.tableDate, this.currentIndex);
-          this.visible = false;
-        } else {
-          this.$message.warning('总包装数量与仓库包装数量不一致!');
-        }
-      },
-      addTableData() {
-        if (this.tableDate.length < this.packingQuantity) {
-          let list = this.tableDate.filter(
-            (item) => item.warehouseId == this.warehouseId
-          );
-          if (list.length > 0) {
-            return this.$message.warning('该仓库已存在!');
-          }
-          this.tableDate.push({
-            packingQuantity: this.packingQuantity,
-            warehouseName: this.warehouseList.filter(
-              (item) => item.id == this.warehouseId
-            )[0].name,
-            warehouseId: this.warehouseId
-          });
-        } else {
-          this.$message.warning('仓库数量已满!');
+        if (list.length > 0) {
+          return this.$message.warning('该仓库已存在!');
         }
         }
-      },
-      delItem(index) {
-        if (index == 0 && this.tableDate.length == 1) {
-          return this.$message.warning('请至少保存一条数据!');
-        }
-        this.tableDate.splice(index, 1);
-      },
-      async getWarehouseList() {
-        const res = await warehouseDefinition.list({});
-        console.log(res);
-        this.warehouseList = res.map((item) => {
-          return { ...item, name: item.factoryName + '-' + item.name };
+        this.tableDate.push({
+          packingQuantity: this.packingQuantity,
+          warehouseName: this.warehouseList.filter(
+            (item) => item.id == this.warehouseId
+          )[0].name,
+          warehouseId: this.warehouseId
         });
         });
-      },
-      open(packingQuantity, idx, warehouseId, warehouseName) {
-        console.log('仓库id',packingQuantity, warehouseId, warehouseName);
+      } else {
+        this.$message.warning('请维护包装规格后再添加仓库!');
+      }
+    },
+    delItem(index) {
+      if (index == 0 && this.tableDate.length == 1) {
+        return this.$message.warning('请至少保存一条数据!');
+      }
+      this.tableDate.splice(index, 1);
+    },
+    async getWarehouseList(categoryType) {
+      const res = await warehouseDefinition.list({ inventoryType: categoryType });
+      console.log(res);
+      this.warehouseList = res.map((item) => {
+        return { ...item, name: item.factoryName + '-' + item.name };
+      });
+    },
+    open(packingQuantity, idx, warehouseId, warehouseName, categoryType) {
+      console.log('仓库id', packingQuantity, warehouseId, warehouseName);
 
 
-        this.warehouseId = '';
-        this.tableDate = [];
-        this.currentIndex = idx;
-        this.packingQuantity = packingQuantity;
-        this.visible = true;
-        this.getWarehouseList();
-        if (warehouseId && warehouseName) {
-          this.warehouseId = warehouseId;
-          this.tableDate.push({
-            packingQuantity: packingQuantity,
-            warehouseName: warehouseName,
-            warehouseId: warehouseId
-          });
-        }
+      this.warehouseId = '';
+      this.tableDate = [];
+      this.currentIndex = idx;
+      this.packingQuantity = packingQuantity;
+      this.visible = true;
+      this.getWarehouseList(categoryType);
+      if (warehouseId && warehouseName) {
+        this.warehouseId = warehouseId;
+        this.tableDate.push({
+          packingQuantity: packingQuantity,
+          warehouseName: warehouseName,
+          warehouseId: warehouseId
+        });
       }
       }
     }
     }
-  };
+  }
+};
 </script>
 </script>
 
 
 <style lang="scss" scoped>
 <style lang="scss" scoped>
-  .red_color {
-    font-size: 20px;
-    font-weight: bold;
-    color: red;
-  }
+.red_color {
+  font-size: 20px;
+  font-weight: bold;
+  color: red;
+}
 </style>
 </style>

+ 225 - 241
src/views/warehouseManagement/stockManagement/add.vue

@@ -173,8 +173,7 @@
               <el-table-column label="单重" align="center" prop="singleWeight" :show-overflow-tooltip="true" width="120">
               <el-table-column label="单重" align="center" prop="singleWeight" :show-overflow-tooltip="true" width="120">
                 <template slot-scope="{ row, $index }">
                 <template slot-scope="{ row, $index }">
                   <el-input-number :disabled="row.isSave" v-model="row.singleWeight" placeholder="请输入" :precision="2"
                   <el-input-number :disabled="row.isSave" v-model="row.singleWeight" placeholder="请输入" :precision="2"
-                    :min="0" controls-position="right" @input="inputsingleWeight(row, $index)" :controls="false"
-                    style="width: 100%"></el-input-number>
+                    :min="0" controls-position="right" :controls="false" style="width: 100%"></el-input-number>
                   <template slot="append">
                   <template slot="append">
                     {{ row.measureUnit }}
                     {{ row.measureUnit }}
                   </template>
                   </template>
@@ -182,8 +181,7 @@
               </el-table-column>
               </el-table-column>
               <el-table-column label="总重" align="center" prop="weight" width="120" :show-overflow-tooltip="true">
               <el-table-column label="总重" align="center" prop="weight" width="120" :show-overflow-tooltip="true">
                 <template slot-scope="{ row, $index }">
                 <template slot-scope="{ row, $index }">
-                  <el-input :disabled="row.isSave" v-model="row.weight" placeholder="请输入"
-                    @input="inputWeight(row, $index)"></el-input>
+                  <el-input :disabled="row.isSave" v-model="row.weight" placeholder="请输入"></el-input>
                   <template slot="append">
                   <template slot="append">
                     {{ row.measureUnit }}
                     {{ row.measureUnit }}
                   </template>
                   </template>
@@ -298,9 +296,9 @@
           <el-table-column label="编码" prop="categoryCode" width="130" :show-overflow-tooltip="true"></el-table-column>
           <el-table-column label="编码" prop="categoryCode" width="130" :show-overflow-tooltip="true"></el-table-column>
           <el-table-column label="名称" prop="categoryName" width="150" :show-overflow-tooltip="true"></el-table-column>
           <el-table-column label="名称" prop="categoryName" width="150" :show-overflow-tooltip="true"></el-table-column>
           <el-table-column label="批次号" prop="batchNo" width="70"></el-table-column>
           <el-table-column label="批次号" prop="batchNo" width="70"></el-table-column>
-          <el-table-column :label="`包装编码`" prop="packageNo" width="200" :show-overflow-tooltip="true"></el-table-column>
+          <el-table-column label="包装编码" prop="packageNo" width="200" :show-overflow-tooltip="true"></el-table-column>
           <el-table-column label="包装数量" prop="packingQuantity" width="80"></el-table-column>
           <el-table-column label="包装数量" prop="packingQuantity" width="80"></el-table-column>
-          <el-table-column label="单位" prop="packingUnit"></el-table-column>
+          <el-table-column label="包装单位" prop="packingUnit"></el-table-column>
           <el-table-column label="计量数量" prop="measureQuantity" :show-overflow-tooltip="true"></el-table-column>
           <el-table-column label="计量数量" prop="measureQuantity" :show-overflow-tooltip="true"></el-table-column>
           <el-table-column label="计量单位" prop="measureUnit"></el-table-column>
           <el-table-column label="计量单位" prop="measureUnit"></el-table-column>
           <!-- <el-table-column label="允许拆包" prop="isUnpack">
           <!-- <el-table-column label="允许拆包" prop="isUnpack">
@@ -309,6 +307,8 @@
             </template>
             </template>
           </el-table-column> -->
           </el-table-column> -->
           <el-table-column label="仓库" :show-overflow-tooltip="true" prop="warehouseName" width="200"></el-table-column>
           <el-table-column label="仓库" :show-overflow-tooltip="true" prop="warehouseName" width="200"></el-table-column>
+          <el-table-column label="供应商" align="center" prop="supplierName" width="200" :show-overflow-tooltip="true">
+          </el-table-column>
           <el-table-column label="供应商代号" prop="supplierCode" width="130">
           <el-table-column label="供应商代号" prop="supplierCode" width="130">
           </el-table-column>
           </el-table-column>
           <el-table-column label="物料代号" prop="materielDesignation" width="130">
           <el-table-column label="物料代号" prop="materielDesignation" width="130">
@@ -768,61 +768,29 @@ export default {
         (item) => item.id == val
         (item) => item.id == val
       )[0].serialNo;
       )[0].serialNo;
     },
     },
-    inputsingleWeight(row, index) {
-      if (
-        row.weight === null ||
-        row.weight === undefined ||
-        isNaN(row.weight) ||
-        row.weight < 0
-      ) {
-        row.weight = 0;
-      } else {
-        if (row.singleWeight && row.singleWeight > 0) {
-          console.log(row.singleWeight, row.measureQuantity)
-          this.productList[index].weight = Number(row.singleWeight) * Number(row.measureQuantity);
-        } else {
-          this.productList[index].weight = 0;
-        }
-      }
-    },
-    inputWeight(row, index) {
-      if (
-        row.weight === null ||
-        row.weight === undefined ||
-        isNaN(row.weight) ||
-        row.weight < 0
-      ) {
-        row.weight = 0;
-      }
-      row.singleWeight = row.measureQuantity
-        ? Number(row.weight) / row.measureQuantity
-        : 0;
-    },
+
+    // inputWeight(row, index) {
+    //   if (
+    //     row.weight === null ||
+    //     row.weight === undefined ||
+    //     isNaN(row.weight) ||
+    //     row.weight < 0
+    //   ) {
+    //     row.weight = 0;
+    //   }
+    //   row.singleWeight = row.measureQuantity
+    //     ? Number(row.weight) / row.measureQuantity
+    //     : 0;
+    // },
     // 计算最小单元数量
     // 计算最小单元数量
     async computeNum(row, index, isClear) {
     async computeNum(row, index, isClear) {
       // 清空仓库(包装数量输入)
       // 清空仓库(包装数量输入)
       if (isClear) {
       if (isClear) {
-        // this.$set(this.productList[index], 'warehouseId', '');
-        // this.$set(this.productList[index], 'warehouseName', '');
-
         if (row.packingQuantity < 0) {
         if (row.packingQuantity < 0) {
           this.$set(this.productList[index], 'packingQuantity', 1);
           this.$set(this.productList[index], 'packingQuantity', 1);
         } else if (row.packingQuantity > 9999) {
         } else if (row.packingQuantity > 9999) {
           this.$set(this.productList[index], 'packingQuantity', 9999);
           this.$set(this.productList[index], 'packingQuantity', 9999);
         }
         }
-
-        // else {
-        //   const reg = /^[0-9]+\.[0-9]+$/;
-        //   console.log(reg.test(row.packingQuantity));
-        //   if (reg.test(row.packingQuantity)) {
-        //     this.$set(this.productList[index], 'packingQuantity', '');
-        //   }
-        //   // this.$set(
-        //   //   this.productList[index],
-        //   //   'packingQuantity',
-        //   //   row.packingQuantity.replace(/[^\d\.{2,}]/g, '')
-        //   // );
-        // }
       }
       }
       //如果有包装数量和包装单位
       //如果有包装数量和包装单位
       if (row.packingQuantity && row.packingUnit) {
       if (row.packingQuantity && row.packingUnit) {
@@ -872,9 +840,9 @@ export default {
         }
         }
         console.log(total, 'total');
         console.log(total, 'total');
         // 除了计量单位是KG以外计算总重  总重量 = 单重singleWeight * 数量measureQuantity(计量数量);
         // 除了计量单位是KG以外计算总重  总重量 = 单重singleWeight * 数量measureQuantity(计量数量);
-        if (row.measuringUnit != 'KG') {
-          row.weight = Number(row.singleWeight) * Number(row.measureQuantity);
-        }
+        // if (row.measuringUnit != 'KG') {
+        //   row.weight = Number(row.singleWeight) * Number(row.measureQuantity);
+        // }
 
 
         //计量数量
         //计量数量
         row.measureQuantity = this.changeCount(total);
         row.measureQuantity = this.changeCount(total);
@@ -1973,11 +1941,16 @@ export default {
                       num
                       num
                     };
                     };
                   } else {
                   } else {
+                    console.log('拆包情况------:', row.measureQuantity, row.packingSpecificationOption[1]?.packageCell);
+
                     // 处理拆包到最小包装单元数量的情况
                     // 处理拆包到最小包装单元数量的情况
+                    let num = Math.ceil(
+                      row.measureQuantity / row.packingSpecificationOption[1]?.packageCell
+                    );
                     return {
                     return {
                       assetCode: row.categoryCode + row.index,
                       assetCode: row.categoryCode + row.index,
                       batchNum: row.batchNo,
                       batchNum: row.batchNo,
-                      num: row.measureQuantity
+                      num: num
                     };
                     };
                   }
                   }
                 } else {
                 } else {
@@ -2006,6 +1979,9 @@ export default {
             if (!row.isSave) {
             if (!row.isSave) {
               this.generateWrappers(row, index, packingCodeList[index]);
               this.generateWrappers(row, index, packingCodeList[index]);
               this.$set(this.productList[index], 'isSave', true);
               this.$set(this.productList[index], 'isSave', true);
+              console.log('this.productList[index]----', this.productList[index]);
+              console.log('row----', row);
+
               this.$set(
               this.$set(
                 this.productList[index],
                 this.productList[index],
                 'warehouseId',
                 'warehouseId',
@@ -2020,12 +1996,12 @@ export default {
               this.$set(
               this.$set(
                 this.productList[index],
                 this.productList[index],
                 'warehouseIds',
                 'warehouseIds',
-                row.warehouseId
+                [row.warehouseId]
               );
               );
               this.$set(
               this.$set(
                 this.productList[index],
                 this.productList[index],
                 'warehouseNames',
                 'warehouseNames',
-                row.warehouseName
+                [row.warehouseName]
               );
               );
             }
             }
           });
           });
@@ -2138,6 +2114,8 @@ export default {
           .dictValue;
           .dictValue;
         let measureBoolen = !!this.getDict('不拆物料层规格', row.measureUnit)
         let measureBoolen = !!this.getDict('不拆物料层规格', row.measureUnit)
           .dictValue;
           .dictValue;
+        console.log('packingBoolen---------', packingBoolen);
+        console.log('measureBoolen---------', measureBoolen);
         let packingNum = 0;
         let packingNum = 0;
         // 处理单位为KG类的情况
         // 处理单位为KG类的情况
         if (packingBoolen) {
         if (packingBoolen) {
@@ -2153,6 +2131,8 @@ export default {
         }
         }
         // 处理单位不为KG类,计量单位为KG类的情况
         // 处理单位不为KG类,计量单位为KG类的情况
         let measureNum = row.packingQuantity;
         let measureNum = row.packingQuantity;
+        let num = 0;
+
         if (measureBoolen) {
         if (measureBoolen) {
           let splitIndex = row.packingSpecificationOption.findIndex(
           let splitIndex = row.packingSpecificationOption.findIndex(
             (item) =>
             (item) =>
@@ -2166,13 +2146,13 @@ export default {
               14
               14
             );
             );
           }
           }
+        } else {
+          num = Math.ceil(
+            row.measureQuantity / row.packingSpecificationOption[1]?.packageCell
+          );
+          console.log(num, 'numnumnumnumnumnumnumnumnumnumnumnumnumnumnumnumnumnum33')
         }
         }
 
 
-        let num = Math.ceil(
-          row.measureQuantity / row.packingSpecificationOption[1]?.packageCell
-        );
-        console.log(num, 'numnumnumnumnumnumnumnumnumnumnumnumnumnumnumnumnumnum')
-
         if (row.packingSpecificationLabel?.length < 1) {
         if (row.packingSpecificationLabel?.length < 1) {
           return this.$message.error('请到主数据维护包装组信息!')
           return this.$message.error('请到主数据维护包装组信息!')
         } else {
         } else {
@@ -2206,167 +2186,12 @@ export default {
         // this.materielFetchData();
         // this.materielFetchData();
       });
       });
     },
     },
-    //入库明细删除
-    listDel(row, index) {
-      this.productList.splice(index, 1);
-      this.deletePackingAndMaterial(row);
-    },
-    // 打开仓库弹框
-    handleWareHouse(row, idx) {
-      if (row.isSave) {
-        return false;
-      }
-      let packingBoolen = !!this.getDict('不拆物料层规格', row.packingUnit)
-        .dictValue;
-      let measureBoolen = !!this.getDict('不拆物料层规格', row.measureUnit)
-        .dictValue;
-      if (idx > -1) {
-        if (row.packingQuantity > 0) {
-          console.log(packingBoolen, '111')
-          if (packingBoolen) {
-            let filterArr = row.packingSpecificationOption.filter((item) => {
-              return (
-                item.packageUnit == row.packingUnit &&
-                item.packageUnit != item.conversionUnit
-              );
-            });
-            console.log(filterArr);
-            let num = Math.ceil(
-              row.packingQuantity / filterArr[0].packageCell
-            );
-            this.$refs.wareHouseDailogRef.open(
-              num,
-              idx,
-              row.warehouseId,
-              row.warehouseName + ''
-            );
-          } else {
-            console.log(measureBoolen, '222')
-            let num = row.packingQuantity;
-            if (measureBoolen) {
-
-              let splitIndex = row.packingSpecificationOption.findIndex(
-                (item) =>
-                  item.conversionUnit == row.packingUnit &&
-                  item.packageUnit != item.conversionUnit
-              );
-              for (; splitIndex > 1; splitIndex--) {
-                console.log(splitIndex);
-                num = this.$math.format(
-                  num *
-                  row.packingSpecificationOption[splitIndex].packageCell,
-                  14
-                );
-              }
-              this.$refs.wareHouseDailogRef.open(
-                num,
-                idx,
-                row.warehouseId,
-                row.warehouseName + ''
-              );
-            } else {
-              let num = Math.ceil(
-                row.measureQuantity / row.packingSpecificationOption[1]?.packageCell
-              );
-              this.$refs.wareHouseDailogRef.open(num, idx, row.warehouseId, row.warehouseName + '');
-            }
-          }
-        } else {
-          this.$message.error('请先填写包装数量!');
-        }
-      } else {
-        // 批量设置
-        let boolen = this.productList.every(
-          (item) =>
-            item.packingQuantity == this.productList[0].packingQuantity
-        );
-        if (boolen) {
-          if (row.packingQuantity > 0) {
-            if (packingBoolen) {
-              let filterArr = row.packingSpecificationOption.filter(
-                (item) => {
-                  return (
-                    item.packingUnit == row.packingUnit &&
-                    item.packingUnit != item.conversionUnit
-                  );
-                }
-              );
-              let num = Math.ceil(
-                row.packingQuantity / filterArr[0].packageCell
-              );
-              this.$refs.wareHouseDailogRef.open(num, idx);
-            } else {
-              this.$refs.wareHouseDailogRef.open(
-                row.isUnpack
-                  ? measureBoolen
-                    ? row.packingQuantity
-                    : row.measureQuantity
-                  : row.packingQuantity,
-                idx
-              );
-            }
-          } else {
-            this.$message.error('请先填写包装数量!');
-          }
-        } else {
-          this.$message.error('请保证产品包装数量一致!');
-        }
-      }
-    },
-    wareHouseSelection(argum, idx) {
-      // 方便包装遍历获取仓库id和名称
-      let warehouseIds = [];
-      let warehouseNames = [];
-      argum.forEach((item) => {
-        for (let index = 0; index < item.packingQuantity; index++) {
-          warehouseIds.push(item.warehouseId);
-          warehouseNames.push(item.warehouseName);
-        }
-      });
-      console.log(argum, 'argumargumargumargumargumargum');
-      if (idx > -1) {
-        this.$set(
-          this.productList[idx],
-          'warehouseId',
-          argum.map((item) => item.warehouseId).join(',')
-        );
-        this.$set(
-          this.productList[idx],
-          'warehouseName',
-          argum.map((item) => item.warehouseName).join(',')
-        );
-        this.$set(this.productList[idx], 'warehouseIds', warehouseIds);
-        this.$set(this.productList[idx], 'warehouseNames', warehouseNames);
-      } else {
-        this.productList.map((item, index) => {
-          this.$set(
-            this.productList[index],
-            'warehouseId',
-            argum.map((item) => item.warehouseId).join(',')
-          );
-          this.$set(
-            this.productList[index],
-            'warehouseName',
-            argum.map((item) => item.warehouseName).join(',')
-          );
-          this.$set(this.productList[index], 'warehouseIds', warehouseIds);
-          this.$set(
-            this.productList[index],
-            'warehouseNames',
-            warehouseNames
-          );
-        });
-      }
-      this.$forceUpdate();
-    },
     // 生成包装
     // 生成包装
     generateWrappers(row, productIndex, packingCodeList) {
     generateWrappers(row, productIndex, packingCodeList) {
       console.log('包装数据--------', row);
       console.log('包装数据--------', row);
 
 
-      // console.log('是否拆包----', row.isUnpack);
-      console.log('包装规格----', row.packingSpecificationOption);
+      // console.log('包装规格----', row.packingSpecificationOption);
       console.log('计量单位----', row.measureUnit);
       console.log('计量单位----', row.measureUnit);
-      console.log('包装编码----', packingCodeList);
       let packingList = [];
       let packingList = [];
       let obj = this.getNowDate();
       let obj = this.getNowDate();
       let productionDate = '';
       let productionDate = '';
@@ -2423,12 +2248,13 @@ export default {
             //     14
             //     14
             //   );
             //   );
             // }
             // }
-            let num = Math.ceil(
+            num = Math.ceil(
               row.measureQuantity / row.packingSpecificationOption[1]?.packageCell
               row.measureQuantity / row.packingSpecificationOption[1]?.packageCell
             );
             );
           }
           }
         } else {
         } else {
-          num = this.productList.length;
+          num = row.packingQuantity;
+          console.log('计量单位KG  不拆--------', num)
         }
         }
       }
       }
       console.log('num-----------', num);
       console.log('num-----------', num);
@@ -2473,17 +2299,16 @@ export default {
               }
               }
             }
             }
           } else {
           } else {
-            measureQuantity = row.measureQuantity;
+            if (row.packingQuantity) {
+              measureQuantity = row.measureQuantity / row.packingQuantity;
+            }
+            console.log(measureQuantity, 'measureQuantity')
           }
           }
         }
         }
         let item = {
         let item = {
           index: row.index + '-' + index, // 包装索引
           index: row.index + '-' + index, // 包装索引
-          warehouseId: row.warehouseIds
-            ? row.warehouseIds[index]
-            : row.warehouseIds, // 仓库id
-          warehouseName: row.warehouseNames
-            ? row.warehouseNames[index]
-            : row.warehouseNames, // 仓库名称
+          warehouseId: row.warehouseId, // 仓库id
+          warehouseName: row.warehouseName, // 仓库名称
           categoryName: row.categoryName, // 产品名称
           categoryName: row.categoryName, // 产品名称
           categoryCode: row.categoryCode, // 产品编码
           categoryCode: row.categoryCode, // 产品编码
           categoryModel: row.categoryModel, // 物品型号
           categoryModel: row.categoryModel, // 物品型号
@@ -2494,19 +2319,18 @@ export default {
           batchNo: row.batchNo, // 批次号
           batchNo: row.batchNo, // 批次号
           packageNo: packingCodeList[index]?.onlyCode, // 包装编码
           packageNo: packingCodeList[index]?.onlyCode, // 包装编码
           packingQuantity: 1, // 包装数量
           packingQuantity: 1, // 包装数量
-          // packingUnit: row.isUnpack
-          //   ? packingBoolen
-          //     ? filterArr[0].conversionUnit
-          //     : measureBoolen
-          //       ? row.packingSpecificationOption[1]
-          //         ? row.packingSpecificationOption[1].conversionUnit
-          //         : row.packingSpecificationOption[0].conversionUnit
-          //       : row.measureUnit
-          //   : packingBoolen
-          //     ? filterArr[0].conversionUnit
-          //     : row.packingUnit,
-          // packingUnit: row.packingUnit,
-          packingUnit: row.packingSpecificationOption[1]?.conversionUnit,
+          packingUnit: row.isUnpack
+            ? packingBoolen
+              ? filterArr[0].conversionUnit
+              : measureBoolen
+                ? row.packingSpecificationOption[1]
+                  ? row.packingSpecificationOption[1].conversionUnit
+                  : row.packingSpecificationOption[0].conversionUnit
+                : row.measureUnit
+            : packingBoolen
+              ? filterArr[0].conversionUnit
+              : row.packingUnit,
+
           measureQuantity: row.isUnpack
           measureQuantity: row.isUnpack
             ? packingBoolen
             ? packingBoolen
               ? measureQuantity
               ? measureQuantity
@@ -2642,6 +2466,166 @@ export default {
       //   }
       //   }
       // }
       // }
     },
     },
+    //入库明细删除
+    listDel(row, index) {
+      this.productList.splice(index, 1);
+      this.deletePackingAndMaterial(row);
+    },
+    // 打开仓库弹框
+    handleWareHouse(row, idx) {
+      console.log(row, `rowrowrowrow打开仓库弹框`)
+      if (row.isSave) {
+        return false;
+      }
+      let packingBoolen = !!this.getDict('不拆物料层规格', row.packingUnit)
+        .dictValue;
+      let measureBoolen = !!this.getDict('不拆物料层规格', row.measureUnit)
+        .dictValue;
+      if (idx > -1) {
+        if (row.packingQuantity > 0) {
+          console.log(packingBoolen, '111')
+          if (packingBoolen) {
+            let filterArr = row.packingSpecificationOption.filter((item) => {
+              return (
+                item.packageUnit == row.packingUnit &&
+                item.packageUnit != item.conversionUnit
+              );
+            });
+            console.log(filterArr, 'ffff');
+            console.log(row, 'rrrrr');
+            let num = Math.ceil(
+              row.packingQuantity / filterArr[0].packageCell
+            );
+            this.$refs.wareHouseDailogRef.open(
+              num,
+              idx,
+              row.warehouseId,
+              row.warehouseName + '',
+              row.categoryLevelPathIdParent
+            );
+          } else {
+            console.log(measureBoolen, '222')
+            let num = row.packingQuantity;
+            if (measureBoolen) {
+
+              let splitIndex = row.packingSpecificationOption.findIndex(
+                (item) =>
+                  item.conversionUnit == row.packingUnit &&
+                  item.packageUnit != item.conversionUnit
+              );
+              for (; splitIndex > 1; splitIndex--) {
+                console.log(splitIndex);
+                num = this.$math.format(
+                  num *
+                  row.packingSpecificationOption[splitIndex].packageCell,
+                  14
+                );
+              }
+              this.$refs.wareHouseDailogRef.open(
+                num,
+                idx,
+                row.warehouseId,
+                row.warehouseName + '',
+                row.categoryLevelPathIdParent
+              );
+            } else {
+
+              let num = Math.ceil(
+                row.measureQuantity / row.packingSpecificationOption[1]?.packageCell
+              );
+              this.$refs.wareHouseDailogRef.open(num ? num : 0, idx, row.warehouseId, row.warehouseName + '',
+                row.categoryLevelPathIdParent);
+            }
+          }
+        } else {
+          this.$message.error('请先填写包装数量!');
+        }
+      } else {
+        // 批量设置
+        let boolen = this.productList.every(
+          (item) =>
+            item.packingQuantity == this.productList[0].packingQuantity
+        );
+        if (boolen) {
+          if (row.packingQuantity > 0) {
+            if (packingBoolen) {
+              let filterArr = row.packingSpecificationOption.filter(
+                (item) => {
+                  return (
+                    item.packingUnit == row.packingUnit &&
+                    item.packingUnit != item.conversionUnit
+                  );
+                }
+              );
+              let num = Math.ceil(
+                row.packingQuantity / filterArr[0].packageCell
+              );
+              this.$refs.wareHouseDailogRef.open(num, idx);
+            } else {
+              this.$refs.wareHouseDailogRef.open(
+                row.isUnpack
+                  ? measureBoolen
+                    ? row.packingQuantity
+                    : row.measureQuantity
+                  : row.packingQuantity,
+                idx
+              );
+            }
+          } else {
+            this.$message.error('请先填写包装数量!');
+          }
+        } else {
+          this.$message.error('请保证产品包装数量一致!');
+        }
+      }
+    },
+    wareHouseSelection(argum, idx) {
+      // 方便包装遍历获取仓库id和名称
+      let warehouseIds = [];
+      let warehouseNames = [];
+      argum.forEach((item) => {
+        for (let index = 0; index < item.packingQuantity; index++) {
+          warehouseIds.push(item.warehouseId);
+          warehouseNames.push(item.warehouseName);
+        }
+      });
+      console.log(argum, 'argumargumargumargumargumargum');
+      if (idx > -1) {
+        this.$set(
+          this.productList[idx],
+          'warehouseId',
+          argum.map((item) => item.warehouseId).join(',')
+        );
+        this.$set(
+          this.productList[idx],
+          'warehouseName',
+          argum.map((item) => item.warehouseName).join(',')
+        );
+        this.$set(this.productList[idx], 'warehouseIds', warehouseIds);
+        this.$set(this.productList[idx], 'warehouseNames', warehouseNames);
+      } else {
+        this.productList.map((item, index) => {
+          this.$set(
+            this.productList[index],
+            'warehouseId',
+            argum.map((item) => item.warehouseId).join(',')
+          );
+          this.$set(
+            this.productList[index],
+            'warehouseName',
+            argum.map((item) => item.warehouseName).join(',')
+          );
+          this.$set(this.productList[index], 'warehouseIds', warehouseIds);
+          this.$set(
+            this.productList[index],
+            'warehouseNames',
+            warehouseNames
+          );
+        });
+      }
+      this.$forceUpdate();
+    },
+
     // 生成物料
     // 生成物料
     generateMaterial(row) {
     generateMaterial(row) {
       let materialList = [];
       let materialList = [];

+ 1 - 1
src/views/warehouseManagement/warehouseDefinition/components/WarehouseEdit.vue

@@ -13,7 +13,7 @@
           clearable
           clearable
           v-model="formData.inventoryType"
           v-model="formData.inventoryType"
         /> -->
         /> -->
-        <el-select filterable size="small" class="w100" v-model="formData.inventoryType" placeholder="请选择"
+        <el-select multiple filterable size="small" class="w100" v-model="formData.inventoryType" placeholder="请选择"
           @visible-change="changeInventoryType">
           @visible-change="changeInventoryType">
           <el-option v-for="item in inventoryTypeList" :key="item.id" :label="item.name" :value="item.id">
           <el-option v-for="item in inventoryTypeList" :key="item.id" :label="item.name" :value="item.id">
           </el-option>
           </el-option>