Pārlūkot izejas kodu

feat: 入库对话框优化仓库列表查询逻辑并增加工厂ID过滤条件

yusheng 9 mēneši atpakaļ
vecāks
revīzija
9ae5e70dcc

+ 25 - 11
src/views/warehouseManagement/components/WarehousingDialog.vue

@@ -24,7 +24,7 @@
             </el-select>
           </el-form-item>
         </el-col>
-        <el-col :span="4" style="margin-top: 3px;">
+        <el-col :span="4" style="margin-top: 3px">
           <el-button type="primary" @click="addTableData">添加</el-button>
         </el-col>
         <el-col :span="6">
@@ -149,24 +149,38 @@
         this.tableDate.splice(index, 1);
       },
       async getWarehouseList(categoryType) {
-        const res = await warehouseDefinition.list({
+        let params = {
           inventoryType: categoryType
-        });
+        };
+
+        if (this.$store.state.user.info.factoryId) {
+          params['factoryId'] = this.$store.state.user.info.factoryId;
+        }
+        const res = await warehouseDefinition.list(params);
         this.warehouseList = res.map((item) => {
           return { ...item, name: item.name };
         });
       },
       async getBatchWarehouseList(batch) {
-        const res = await warehouseDefinition.list({});
-        if (!batch.length) {
-          this.warehouseList = res.map((item) => {
-            return { ...item, name: item.name };
-          });
-          return;
+        let params = {};
+
+        if (this.$store.state.user.info.factoryId) {
+          params['factoryId'] = this.$store.state.user.info.factoryId;
         }
+        if (batch?.length == 1) {
+          params['inventoryType'] = batch[0];
+        }
+
+        const res = await warehouseDefinition.list(params);
+        // if (!batch.length) {
+        //   this.warehouseList = res.map((item) => {
+        //     return { ...item, name: item.name };
+        //   });
+        //   return;
+        // }
 
-        let filter = res.filter((item) => batch.includes(item.inventoryType));
-        this.warehouseList = filter.map((item) => {
+        // let filter = res.filter((item) => batch.includes(item.inventoryType));
+        this.warehouseList = res.map((item) => {
           return { ...item, name: item.name };
         });
       },