Explorar el Código

fix(inspectionPlan): 库存台账按工厂级联筛选仓库

- 仓库列表改用带工厂信息的接口,选择工厂后仅显示该工厂仓库

- 切换工厂时清空已选仓库
lihaiting hace 4 días
padre
commit
82d6d5fb45
Se han modificado 1 ficheros con 57 adiciones y 39 borrados
  1. 57 39
      src/views/inspectionPlan/components/stokledger.vue

+ 57 - 39
src/views/inspectionPlan/components/stokledger.vue

@@ -27,6 +27,44 @@
             </template>
           </el-form-item>
         </el-col>
+        <el-col :span="6">
+          <el-form-item label="所属工厂" prop="factoryId">
+            <el-select
+              filterable
+              placeholder="请选择"
+              v-model="searchForm.factoryId"
+              clearable
+              class="w100"
+              @change="handleFactoryChange"
+            >
+              <el-option
+                v-for="item in factoryList"
+                :key="item.id"
+                :label="item.name"
+                :value="item.id"
+              ></el-option>
+            </el-select>
+          </el-form-item>
+        </el-col>
+        <el-col :span="6">
+          <el-form-item label="仓库">
+            <el-select
+              clearable
+              filterable
+              style="width: 100%"
+              v-model="searchForm.warehouseId"
+              placeholder="请选择"
+            >
+              <el-option
+                v-for="item in warehouseOptions"
+                :label="item.name"
+                :value="item.id"
+                :key="item.id"
+              >
+              </el-option>
+            </el-select>
+          </el-form-item>
+        </el-col>
         <el-col :span="6">
           <el-form-item label="物品编码:">
             <el-input
@@ -90,42 +128,7 @@
             ></el-input>
           </el-form-item>
         </el-col>
-        <el-col :span="6">
-          <el-form-item label="仓库">
-            <el-select
-              clearable
-              style="width: 100%"
-              v-model="searchForm.warehouseId"
-              placeholder="请选择"
-            >
-              <el-option
-                v-for="item in warehouseList"
-                :label="item.name"
-                :value="item.id"
-                :key="item.id"
-              >
-              </el-option>
-            </el-select>
-          </el-form-item>
-        </el-col>
-        <el-col :span="6">
-          <el-form-item label="所属工厂" prop="factoryId">
-            <el-select
-              filterable
-              placeholder="请选择"
-              v-model="searchForm.factoryId"
-              clearable
-              class="w100"
-            >
-              <el-option
-                v-for="item in factoryList"
-                :key="item.id"
-                :label="item.name"
-                :value="item.id"
-              ></el-option>
-            </el-select>
-          </el-form-item>
-        </el-col>
+
 
         <el-col>
           <div style="float: right">
@@ -353,7 +356,6 @@
 import warehouseDefinition from '@/api/warehouseManagement/warehouseDefinition';
 import storageApi from '@/api/warehouseManagement';
 import AssetTree from './assetTree.vue';
-import { getWarehouseList } from '@/api/classifyManage/itemInformation';
 export default {
   components: { AssetTree },
   props: {
@@ -413,6 +415,17 @@ export default {
     this.getWarehouse();
     this.getFactoryList();
   },
+  computed: {
+    // 仓库级联:仓库归属工厂,选择了工厂后只显示该工厂下的仓库
+    warehouseOptions() {
+      if (this.searchForm.factoryId) {
+        return this.warehouseList.filter(
+          (item) => item.factoryId == this.searchForm.factoryId
+        );
+      }
+      return this.warehouseList;
+    }
+  },
   watch: {
     tableData(val) {
       this.doLayout();
@@ -429,8 +442,13 @@ export default {
       this.factoryList = res.list;
     },
     async getWarehouse() {
-      const { data } = await getWarehouseList();
-      this.warehouseList = data;
+      // 用带工厂信息(factoryId/factoryName)的仓库列表接口,供工厂-仓库级联
+      const res = await warehouseDefinition.list({});
+      this.warehouseList = res || [];
+    },
+    // 切换工厂时清空已选仓库,保持级联关系
+    handleFactoryChange() {
+      this.searchForm.warehouseId = '';
     },
     doLayout() {
       let that = this;