Просмотр исходного кода

新增入库,根据物品类型获取仓库

huang_an 1 год назад
Родитель
Сommit
f3cc90146f

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

@@ -15,7 +15,18 @@ import request from '@/utils/request';
 // export async function warehouseSave(data) {
 //   return request.post('/warehouseGoodsshelves/newWarehouse/save', data);
 // }
+
 export default {
+  // 根据type查分类树组
+  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);
+        }
       }
     }
   };

+ 50 - 15
src/views/warehouseManagement/stockManagement/add.vue

@@ -267,6 +267,7 @@
                     <el-input
                       :ref="'packingQuantity' + $index"
                       type="number"
+                      placeholder="请输入"
                       @keyup.native="
                         moveFocus(
                           $event,
@@ -998,7 +999,8 @@
         pageSize: 20, // 物料和包装列表条数
         pickingPageNum: 1, // 包装虚拟分页页数
         materielPageNum: 1, // 物料虚拟分页页数
-        packingSpecificationOption: [] // 包装规格下拉
+        packingSpecificationOption: [], // 包装规格下拉
+        proData: {}
       };
     },
     computed: {
@@ -1180,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) {
@@ -1207,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 &&
@@ -1406,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() {
@@ -1754,6 +1761,8 @@
         });
         obj.warehouseIds = warehouseId;
         obj.warehouseNames = warehouseName;
+        console.log('入库数据', obj);
+        return;
         // 是否需要审核(0审核 1跳过审核)
         if (obj.bizType == '12') {
           obj.isSkip = 1;
@@ -2062,6 +2071,7 @@
       },
       // 添加物品明细
       async addGoods(data) {
+        this.proData = data;
         // 获取批次号
         const batchNo = await getCode('lot_number_code');
         // 获取供应商
@@ -2423,6 +2433,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();
@@ -2455,7 +2479,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) {
@@ -2481,7 +2510,9 @@
                     ? num
                     : row.measureQuantity
                   : row.packingQuantity,
-                idx
+                idx,
+                row.warehouseId,
+                row.warehouseName + ''
               );
             }
           } else {
@@ -2697,8 +2728,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, // 物品型号

+ 1 - 1
src/views/warehouseManagement/stockManagement/components/selectType.vue

@@ -267,7 +267,7 @@
         this.initData();
       },
       onConfirm() {
-        console.log([...this.memoSelection, ...this.multipleSelection]);
+        console.log([...this.memoSelection, ...this.multipleSelection], '确认');
         this.$emit('selectTableData', [
           ...this.memoSelection,
           ...this.multipleSelection

+ 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,