Преглед изворни кода

仓库定义修改仓库类型接口。根据数量和单位获取仓库

huang_an пре 1 година
родитељ
комит
ddc947ba6d

+ 9 - 0
src/api/warehouseManagement/warehouseDefinition.js

@@ -16,6 +16,15 @@ import request from '@/utils/request';
 //   return request.post('/warehouseGoodsshelves/newWarehouse/save', data);
 // }
 export default {
+  getTreeByGroup: async (params) => {
+    const res = await request.get('/main/categoryLevel/getProduceTreeByPid', {
+      params
+    });
+    if (res.data.code == 0) {
+      return res.data.data;
+    }
+    return Promise.reject(new Error(res.data.message));
+  },
   //条件查询工厂
   getFactoryarea: async (params) => {
     const res = await request.get('/main/factoryarea/page', { params });

+ 12 - 2
src/views/warehouseManagement/components/WarehousingDialog.vue

@@ -86,7 +86,6 @@
           0
         );
         if (total == this.packingQuantity) {
-          console.log(this.tableDate);
           this.$emit('selection', this.tableDate, this.currentIndex);
           this.visible = false;
         } else {
@@ -125,13 +124,24 @@
           return { ...item, name: item.factoryName + '-' + item.name };
         });
       },
-      open(packingQuantity, idx) {
+      open(packingQuantity, idx, warehouseId, warehouseName) {
+        console.log('仓库id', 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: this.packingQuantity,
+            warehouseName: warehouseName,
+            warehouseId: warehouseId
+          });
+          // this.$emit('selection', this.tableDate, this.currentIndex);
+        }
       }
     }
   };

+ 79 - 35
src/views/warehouseManagement/stockManagement/add.vue

@@ -267,6 +267,7 @@
                     <el-input
                       :ref="'packingQuantity' + $index"
                       type="number"
+                      placeholder="请输入"
                       @keyup.native="
                         moveFocus(
                           $event,
@@ -284,7 +285,7 @@
                 </template>
               </el-table-column>
               <el-table-column
-                label="包装单位"
+                label="单位"
                 align="center"
                 prop="packingUnit"
                 width="100"
@@ -578,10 +579,7 @@
             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"
@@ -1001,7 +999,8 @@
         pageSize: 20, // 物料和包装列表条数
         pickingPageNum: 1, // 包装虚拟分页页数
         materielPageNum: 1, // 物料虚拟分页页数
-        packingSpecificationOption: [] // 包装规格下拉
+        packingSpecificationOption: [], // 包装规格下拉
+        proData: {}
       };
     },
     computed: {
@@ -1065,7 +1064,7 @@
                 batchNo: batchNo, // 批次号
                 minPackingQuantity: item.quantity, // 最小包装单元数量
                 packingQuantity: 1, // 包装数量
-                packingUnit: item.packingUnit, // 包装单位
+                packingUnit: item.packingUnit, // 单位
                 measureQuantity: 0, // 计量数量
                 measureUnit: item.measuringUnit, // 计量单位
                 netWeight: item.netWeight > -1 ? item.netWeight : 0, // 净重
@@ -1183,14 +1182,11 @@
         )[0].name;
       },
       // 计算最小单元数量
-      computeNum(row, index, isClear) {
-        console.log(row);
-        console.log(row.packingQuantity);
-        console.log(row.packingUnit);
+      async computeNum(row, index, isClear) {
         // 清空仓库(包装数量输入)
         if (isClear) {
-          this.$set(this.productList[index], 'warehouseId', '');
-          this.$set(this.productList[index], 'warehouseName', '');
+          // this.$set(this.productList[index], 'warehouseId', '');
+          // this.$set(this.productList[index], 'warehouseName', '');
           if (row.packingQuantity < 0) {
             this.$set(this.productList[index], 'packingQuantity', 1);
           } else if (row.packingQuantity > 9999) {
@@ -1210,8 +1206,16 @@
           // }
         }
         if (row.packingQuantity && row.packingUnit) {
-          console.log(index);
-          console.log(row.packingSpecificationOption);
+          //获取仓库
+          const res = await warehouseDefinition.list({
+            inventoryType: this.proData[0]?.categoryLevelPathIdParent
+          });
+          if (res.length > 0) {
+            let name = res[0]?.factoryName + '-' + res[0]?.name;
+            console.log('仓库-----------------------------', res);
+            this.$set(this.productList[index], 'warehouseId', res[0].id);
+            this.$set(this.productList[index], 'warehouseName', name);
+          }
           let startIndex = row.packingSpecificationOption.findIndex((ite) => {
             return (
               row.measuringUnit == ite.packingUnit &&
@@ -1231,7 +1235,7 @@
             );
           }
           row.measureQuantity = this.changeCount(total);
-          // 判断包装单位和计量单位是否为不拆物料层规格
+          // 判断单位和计量单位是否为不拆物料层规格
           let packingBoolen = !!this.getDict('不拆物料层规格', row.packingUnit)
             .dictValue;
           let measureBoolen = !!this.getDict('不拆物料层规格', row.measureUnit)
@@ -1409,8 +1413,8 @@
       },
       // 获取物品列表
       async getListItems() {
-        const { data } = await getTreeByGroup({ type: 2 });
-        this.goodsLists = data;
+        const res2 = await warehouseDefinition.getTreeByGroup({ type: 1 });
+        this.goodsLists = res2;
       },
       // 打开单据来源弹窗
       openDocumentSourceDialog() {
@@ -1689,7 +1693,7 @@
                 batchNo: batchNo, // 批次号
                 minPackingQuantity: 1, // 最小包装单元数量
                 packingQuantity: filterArray[0]['数量'], // 包装数量
-                packingUnit: item.packingUnit, // 包装单位
+                packingUnit: item.packingUnit, // 单位
                 measureQuantity: 0, // 计量数量
                 measureUnit: item.measuringUnit, // 计量单位
                 netWeight: item.netWeight > -1 ? item.netWeight : 0, // 净重
@@ -1757,6 +1761,20 @@
         });
         obj.warehouseIds = warehouseId;
         obj.warehouseNames = warehouseName;
+
+        obj.outInDetailList.map((item) => {
+          item.outInDetailRecordRequestList =
+            item.outInDetailRecordRequestList.map((packingItem) => {
+              delete packingItem.warehouseId;
+              delete packingItem.warehouseName;
+              return {
+                ...packingItem
+              };
+            });
+        });
+
+        console.log('入库数据', obj);
+
         // 是否需要审核(0审核 1跳过审核)
         if (obj.bizType == '12') {
           obj.isSkip = 1;
@@ -2065,6 +2083,7 @@
       },
       // 添加物品明细
       async addGoods(data) {
+        this.proData = data;
         // 获取批次号
         const batchNo = await getCode('lot_number_code');
         // 获取供应商
@@ -2118,7 +2137,7 @@
             packingSpecificationLabel: packingSpecificationLabel, // 包装规格显示
             minPackingQuantity: '', // 最小包装单元数量
             packingQuantity: '', // 包装数量
-            packingUnit: '', // 包装单位
+            packingUnit: '', // 单位
             measureQuantity: 0, // 计量数量
             measureUnit: item.measuringUnit, // 计量单位
             netWeight: item.netWeight > -1 ? item.netWeight : 0, // 净重
@@ -2182,7 +2201,7 @@
           .then(async () => {
             // 批量获取包装编码并处理
             let packingCodePrams = this.productList.map((row) => {
-              // 判断包装单位和计量单位是否为不拆物料层规格
+              // 判断单位和计量单位是否为不拆物料层规格
               let packingBoolen = !!this.getDict(
                 '不拆物料层规格',
                 row.packingUnit
@@ -2206,7 +2225,7 @@
               if (row.isSave) {
                 return {};
               } else {
-                // 处理包装单位为KG类的情况
+                // 处理单位为KG类的情况
                 if (packingBoolen) {
                   return {
                     assetCode: row.categoryCode + row.index,
@@ -2216,7 +2235,7 @@
                 } else {
                   if (row.isUnpack) {
                     if (measureBoolen) {
-                      // 处理包装单位不为KG类,计量单位为KG类的情况
+                      // 处理单位不为KG类,计量单位为KG类的情况
                       let num = row.packingQuantity;
                       let splitIndex = row.packingSpecificationOption.findIndex(
                         (item) =>
@@ -2376,13 +2395,13 @@
       // 产品保存操作
       listSave(row, index) {
         this.validateFormIndividually(index).then(async () => {
-          // 判断包装单位和计量单位是否为不拆物料层规格
+          // 判断单位和计量单位是否为不拆物料层规格
           let packingBoolen = !!this.getDict('不拆物料层规格', row.packingUnit)
             .dictValue;
           let measureBoolen = !!this.getDict('不拆物料层规格', row.measureUnit)
             .dictValue;
           let packingNum = 0;
-          // 处理包装单位为KG类的情况
+          // 处理单位为KG类的情况
           if (packingBoolen) {
             let filterArr = row.packingSpecificationOption.filter((item) => {
               return (
@@ -2394,7 +2413,7 @@
               row.packingQuantity / filterArr[0].packageCell
             );
           }
-          // 处理包装单位不为KG类,计量单位为KG类的情况
+          // 处理单位不为KG类,计量单位为KG类的情况
           let measureNum = row.packingQuantity;
           if (measureBoolen) {
             let splitIndex = row.packingSpecificationOption.findIndex(
@@ -2426,6 +2445,20 @@
           ]);
           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.pickingFetchData();
           // this.materielFetchData();
@@ -2458,7 +2491,12 @@
               let num = Math.ceil(
                 row.packingQuantity / filterArr[0].packageCell
               );
-              this.$refs.wareHouseDailogRef.open(num, idx);
+              this.$refs.wareHouseDailogRef.open(
+                num,
+                idx,
+                row.warehouseId,
+                row.warehouseName + ''
+              );
             } else {
               let num = row.packingQuantity;
               if (measureBoolen) {
@@ -2484,7 +2522,9 @@
                     ? num
                     : row.measureQuantity
                   : row.packingQuantity,
-                idx
+                idx,
+                row.warehouseId,
+                row.warehouseName + ''
               );
             }
           } else {
@@ -2599,14 +2639,14 @@
           purchaseDate = `${obj.year}-${obj.month}-${obj.strDate} ${obj.hour}:${obj.minute}:${obj.second}`;
           this.curDateType = 'purchaseDate';
         }
-        // 判断包装单位和计量单位是否为不拆物料层规格
+        // 判断单位和计量单位是否为不拆物料层规格
         let packingBoolen = !!this.getDict('不拆物料层规格', row.packingUnit)
           .dictValue;
         let measureBoolen = !!this.getDict('不拆物料层规格', row.measureUnit)
           .dictValue;
         let num = row.packingQuantity;
         let filterArr = [];
-        // 处理包装单位为KG类的情况
+        // 处理单位为KG类的情况
         if (packingBoolen) {
           filterArr = row.packingSpecificationOption.filter((item) => {
             return (
@@ -2618,7 +2658,7 @@
         } else {
           if (row.isUnpack) {
             if (measureBoolen) {
-              // 处理包装单位不为KG类,计量单位为KG类的情况
+              // 处理单位不为KG类,计量单位为KG类的情况
               let splitIndex = row.packingSpecificationOption.findIndex(
                 (item) =>
                   item.conversionUnit == row.packingUnit &&
@@ -2653,7 +2693,7 @@
         console.log('num-----------', num);
         for (let index = 0; index < num; index++) {
           let measureQuantity = 1;
-          // 处理包装单位为KG类,计算每桶KG值
+          // 处理单位为KG类,计算每桶KG值
           if (packingBoolen) {
             console.log(
               this.$math.format(filterArr[0].packageCell * (index + 1), 14)
@@ -2668,7 +2708,7 @@
           } else {
             if (!row.isUnpack) {
               if (measureBoolen) {
-                // 处理包装单位不为KG类,计量单位为KG类的情况
+                // 处理单位不为KG类,计量单位为KG类的情况
                 let splitIndex = row.packingSpecificationOption.findIndex(
                   (item) =>
                     item.conversionUnit == row.packingUnit &&
@@ -2700,8 +2740,12 @@
           }
           let item = {
             index: row.index + '-' + index, // 包装索引
-            warehouseId: row.warehouseIds[index], // 仓库id
-            warehouseName: row.warehouseNames[index], // 仓库名称
+            warehouseId: row.warehouseIds
+              ? row.warehouseIds[index]
+              : row.warehouseIds, // 仓库id
+            warehouseName: row.warehouseNames
+              ? row.warehouseNames[index]
+              : row.warehouseNames, // 仓库名称
             categoryName: row.categoryName, // 产品名称
             categoryCode: row.categoryCode, // 产品编码
             categoryModel: row.categoryModel, // 物品型号

+ 33 - 3
src/views/warehouseManagement/warehouseDefinition/components/WarehouseEdit.vue

@@ -28,11 +28,27 @@
         ></el-input>
       </el-form-item>
       <el-form-item label="仓库类型" prop="inventoryType">
-        <DictSelection
+        <!-- <DictSelection
           dictName="仓库类型"
           clearable
           v-model="formData.inventoryType"
-        />
+        /> -->
+        <el-select
+          filterable
+          size="small"
+          class="w100"
+          v-model="formData.inventoryType"
+          placeholder="请选择"
+          @visible-change="changeInventoryType"
+        >
+          <el-option
+            v-for="item in inventoryTypeList"
+            :key="item.id"
+            :label="item.name"
+            :value="item.id"
+          >
+          </el-option>
+        </el-select>
       </el-form-item>
       <el-form-item label="所属工厂" prop="factoryId">
         <el-select
@@ -151,6 +167,7 @@
           code: '',
           name: '',
           inventoryType: '',
+          inventoryName: '',
           remarks: '',
           factoryId: '',
           status: 1,
@@ -184,6 +201,7 @@
         type: '新建',
         userList: [],
         deptList: [], //部门集合
+        inventoryTypeList: [],
         factoryList: [], //工厂集合
         locationOptions: city,
         loadingVis: false
@@ -205,6 +223,7 @@
               code: '',
               name: '',
               inventoryType: '',
+              inventoryName: '',
               remarks: '',
               factoryId: '',
               status: 1,
@@ -248,7 +267,6 @@
                 ],
                 inventoryType: warehouseVO.inventoryType + ''
               };
-              console.log(this.formData);
               this.loadingVis = false;
             }, 2000);
           });
@@ -257,6 +275,7 @@
             code: '',
             name: '',
             inventoryType: '',
+            inventoryName: '',
             remarks: '',
             factoryId: '',
             status: 1,
@@ -298,6 +317,17 @@
 
         // let data = org.factorys({ status: true });
         this.factoryList = res.list;
+
+        const res2 = await warehouseDefinition.getTreeByGroup({ type: 1 });
+        this.inventoryTypeList = res2;
+      },
+      changeInventoryType(val) {
+        console.log(val, '1');
+        let data = this.inventoryTypeList.find((item) => {
+          return item.id == this.formData.inventoryType;
+        });
+        this.formData.inventoryName = data?.name;
+        console.log(this.formData.inventoryName);
       },
 
       handleSave() {

+ 30 - 10
src/views/warehouseManagement/warehouseDefinition/index.vue

@@ -14,11 +14,27 @@
           ></el-col>
           <el-col :span="4">
             <el-form-item label="仓库类型" prop="inventoryType">
-              <DictSelection
+              <!-- <DictSelection
                 dictName="仓库类型"
                 clearable
                 v-model="formData.inventoryType"
-              /> </el-form-item
+              /> -->
+              <el-select
+                filterable
+                size="small"
+                class="w100"
+                v-model="formData.inventoryType"
+                placeholder="请选择"
+                :clearable="true"
+              >
+                <el-option
+                  v-for="item in inventoryTypeList"
+                  :key="item.id"
+                  :label="item.name"
+                  :value="item.id"
+                >
+                </el-option>
+              </el-select> </el-form-item
           ></el-col>
           <el-col :span="4">
             <el-form-item label="所属工厂" prop="factoryId">
@@ -196,12 +212,12 @@
           </el-table-column>
           <el-table-column
             label="仓库类型"
-            prop="inventoryType"
+            prop="inventoryName"
             :show-overflow-tooltip="true"
           >
-            <template slot-scope="{ row, $index }">
+            <!-- <template slot-scope="{ row, $index }">
               {{ getDictValue('仓库类型', row.inventoryType) }}
-            </template>
+            </template> -->
           </el-table-column>
           <el-table-column
             label="库区数"
@@ -295,17 +311,18 @@
           },
           {
             label: '仓库类型',
-            key: 'inventoryType',
-            filter: (value) => {
-              return this.getDictValue('仓库类型', value);
-            }
+            key: 'inventoryName'
+            // filter: (value) => {
+            //   return this.getDictValue('仓库类型', value);
+            // }
           },
           { label: '库区数', key: 'areaNumber' },
           { label: '货架数', key: 'goodNumber' },
           { label: '货位数', key: 'allocationNumber' },
           { label: '空货位数', key: 'emptyAllocationNumber' },
           { label: '所属工厂', key: 'factoryId' }
-        ]
+        ],
+        inventoryTypeList: []
       };
     },
     async created() {
@@ -323,6 +340,9 @@
         this.isTable = !this.isTable;
       },
       async initData() {
+        const res2 = await warehouseDefinition.getTreeByGroup({ type: 1 });
+        this.inventoryTypeList = res2;
+
         //获取工厂车间列表
         const res = await warehouseDefinition.getFactoryarea({
           pageNum: 1,