Преглед на файлове

fix:5712【库存调拨】新建操作,界面所属工厂,没有过滤所属工厂的仓库,都显示,需也带上显示所属工厂

mlchen преди 2 седмици
родител
ревизия
2f829ae37c
променени са 1 файла, в които са добавени 47 реда и са изтрити 18 реда
  1. 47 18
      src/views/warehouseManagement/inventoryAllocation/add.vue

+ 47 - 18
src/views/warehouseManagement/inventoryAllocation/add.vue

@@ -93,7 +93,7 @@
                       <el-option
                         v-for="item in outTreeList"
                         :disabled="item.hiden"
-                        :label="item.name"
+                        :label="warehouseLabel(item)"
                         :value="item.id"
                         :key="item.name"
                       >
@@ -319,7 +319,7 @@
                       <el-option
                         v-for="item in inTreeList"
                         :disabled="item.hiden"
-                        :label="item.name"
+                        :label="warehouseLabel(item)"
                         :value="item.id"
                         :key="item.name"
                       >
@@ -1023,7 +1023,6 @@
         this.factoryId = baseInfo.factoriesId;
         this.allocateId = baseInfo.type;
         this.transferOrderId = baseInfo.id;
-        await this.getTreeData(); // 初始仓库
         this.params = {
           code: baseInfo.allotCode,
           name: baseInfo.name,
@@ -1045,6 +1044,7 @@
           inFreightId: '', // 调入货位
           inFreightName: ''
         };
+        await this.getTreeData(this.factoryId, this.params.targetFactoriesId);
 
         console.log('baseInfo------', baseInfo);
         // 兼容旧数据
@@ -1128,16 +1128,26 @@
         console.log(dataList);
         console.log(baseInfo);
       },
-      factoryChange() {
+      async factoryChange() {
         // this.params.inWarehouseName = this.params.outWarehouseName;
         this.params.targetFactoriesId = this.factoryId;
         console.log('this.params------', this.params);
         this.reset();
-        this.getTreeData();
+        await this.getTreeData(this.factoryId, this.params.targetFactoriesId);
       },
-      targetFactoryChange() {
-        // this.reset();
-        // this.getTreeData();
+      async targetFactoryChange() {
+        this.params.inWarehouseId = '';
+        this.params.inWarehouseName = '';
+        this.params.inCargoAreaId = '';
+        this.params.inCargoAreaName = '';
+        this.params.inShelvesId = '';
+        this.params.inShelvesName = '';
+        this.params.inFreightId = '';
+        this.params.inFreightName = '';
+        this.inCargoAreaList = [];
+        this.inShelvesList = [];
+        this.inFreightList = [];
+        await this.getTreeData(this.factoryId, this.params.targetFactoriesId);
       },
       search() {
         return new Promise((resolve, reject) => {
@@ -1326,6 +1336,10 @@
         });
         this.factoryList = res.list;
       },
+      // 返回带工厂名的仓库选项标签。
+      warehouseLabel(item) {
+        return item.factoryName ? `${item.factoryName}-${item.name}` : item.name;
+      },
       async outWarehouseChange(val) {
         console.log('val------', val);
         this.outCargoAreaList = this.outTreeList.filter(
@@ -1514,21 +1528,36 @@
         this.total = data.count;
         this.productList = data.list;
       },
-      async getTreeData() {
+      // 分别按调出和调入工厂加载仓库树。
+      async getTreeData(
+        outFactoryId = this.factoryId,
+        inFactoryId = this.params.targetFactoriesId
+      ) {
         try {
           this.treeLoading = true;
-          let res = await storageApi.getWarehouseTrees({
-            factoriesId: this.factoryId
-          });
-          this.treeLoading = false;
-          if (res?.code === '0') {
-            this.outTreeList = res.data;
-            this.inTreeList = res.data;
-          }
+          const [outRes, inRes] = await Promise.all([
+            storageApi.getWarehouseTrees({ factoryId: outFactoryId }),
+            storageApi.getWarehouseTrees({ factoryId: inFactoryId })
+          ]);
+          this.outTreeList = (outRes?.code === '0' ? outRes.data : []).map(
+            (item) => ({
+              ...item,
+              hiden: this.allocateId == 2 && item.id == this.params.inWarehouseId
+            })
+          );
+          this.inTreeList = (inRes?.code === '0' ? inRes.data : []).map(
+            (item) => ({
+              ...item,
+              hiden: this.allocateId == 2 && item.id == this.params.outWarehouseId
+            })
+          );
         } catch (error) {
           console.log(error);
+          this.outTreeList = [];
+          this.inTreeList = [];
+        } finally {
+          this.treeLoading = false;
         }
-        this.treeLoading = false;
       },
       deleted(row, index) {
         console.log('deleted~~~', row.id, index);