Explorar o código

feat: 仓储-仓库定义新增仓库类型单选改多选

liujt hai 9 meses
pai
achega
82e771985c

+ 21 - 15
src/views/warehouseManagement/warehouseDefinition/components/WarehouseEdit.vue

@@ -37,9 +37,10 @@
           filterable
           size="small"
           class="w100"
+          multiple
           v-model="formData.inventoryType"
           placeholder="请选择"
-          @visible-change="changeInventoryType"
+          @change="changeInventoryType"
         >
           <el-option
             v-for="item in inventoryTypeList"
@@ -175,8 +176,8 @@
         formData: {
           code: '',
           name: '',
-          inventoryType: '',
-          inventoryName: '',
+          inventoryType: [],
+          inventoryName: [],
           remarks: '',
           factoryId: '',
           status: 1,
@@ -233,8 +234,8 @@
             this.formData = {
               code: '',
               name: '',
-              inventoryType: '',
-              inventoryName: '',
+              inventoryType: [],
+              inventoryName: [],
               remarks: '',
               factoryId: '',
               status: 1,
@@ -276,7 +277,8 @@
                   warehouseVO.city,
                   warehouseVO.area
                 ],
-                inventoryType: warehouseVO.inventoryType + ''
+                inventoryType: warehouseVO.inventoryType.split(','),
+                inventoryName: warehouseVO.inventoryName.split(',')
               };
               this.loadingVis = false;
             }, 2000);
@@ -285,8 +287,8 @@
           this.formData = {
             code: '',
             name: '',
-            inventoryType: '',
-            inventoryName: '',
+            inventoryType: [],
+            inventoryName: [],
             remarks: '',
             factoryId: '',
             status: 1,
@@ -334,18 +336,22 @@
       },
       changeInventoryType(val) {
         console.log(val, '1');
-        let data = this.inventoryTypeList.find((item) => {
-          return item.id == this.formData.inventoryType;
-        });
-        console.log(data);
-        this.formData.inventoryName = data?.name;
-        console.log(this.formData.inventoryName);
+        // 根据选中的仓库类型ID数组,获取对应的名称数组
+        const inventoryNames = val.map(typeId => {
+          const item = this.inventoryTypeList.find(item => item.id === typeId);
+          return item ? item.name : '';
+        }).filter(name => name !== '');
+        
+        this.formData.inventoryName = inventoryNames;
+        console.log('仓库类型名称数组:', this.formData.inventoryName);
       },
 
       handleSave() {
         this.$refs.formRef.validate(async (value) => {
           if (value) {
-            const params = Object.assign(this.formData);
+            let params = Object.assign(this.formData);
+            params.inventoryType = params.inventoryType.join(',');
+            params.inventoryName = params.inventoryName.join(',');
 
             // if (params.location?.length) {
             //   const [province, city, area] = params.location;