소스 검색

feat: 添加工厂选择变更处理,优化仓库列表过滤逻辑

xieyong 3 주 전
부모
커밋
f0ab7bf05c
1개의 변경된 파일과 15개의 추가작업 그리고 3개의 파일을 삭제
  1. 15 3
      src/BIZComponents/selectStockLedger/item-search.vue

+ 15 - 3
src/BIZComponents/selectStockLedger/item-search.vue

@@ -17,6 +17,7 @@
               v-model="params.factoryId"
               clearable
               class="w100"
+              @change="onFactoryChange"
             >
               <el-option
                 v-for="item in factoryList"
@@ -211,7 +212,6 @@
         dimension: '2',
         keyWord: '',
         colorKey: '',
-        factoryId: '',
         color: ''
       };
       return {
@@ -239,7 +239,7 @@
             label: '未质检'
           }
         ],
-        warehouseList: [],
+        allWarehouseList: [],
         dimension: '1',
         factoryList: []
       };
@@ -263,6 +263,14 @@
       // 是否开启响应式布局
       styleResponsive() {
         return this.$store.state.theme.styleResponsive;
+      },
+      warehouseList() {
+        if (!this.params.factoryId) {
+          return [];
+        }
+        return this.allWarehouseList.filter(
+          (item) => item.factoryId === this.params.factoryId
+        );
       }
     },
     created() {
@@ -282,7 +290,11 @@
       //搜索数据源
       async getArguInfo() {
         const { data } = await getWarehouseList();
-        this.warehouseList = data;
+        this.allWarehouseList = data;
+      },
+      // 切换工厂时从已加载的仓库列表中过滤
+      async onFactoryChange(factoryId) {
+        this.params.warehouseId = '';
       },
       /* 搜索 */
       search() {