lijiang007 2 лет назад
Родитель
Сommit
2ae03b2bb6

+ 28 - 5
src/api/warehouseManagement/warehouseDefinition.js

@@ -45,7 +45,10 @@ export default {
   },
   },
   //仓库定义列表
   //仓库定义列表
   list: async (params) => {
   list: async (params) => {
-    const res = await request.get('/wms/warehouse/page', { params });
+    const res = await request.post(
+      '/wms/warehouse/select/warehouseList',
+      params
+    );
     if (res.data.code == 0) {
     if (res.data.code == 0) {
       return res.data.data;
       return res.data.data;
     }
     }
@@ -57,7 +60,16 @@ export default {
 
 
   //新增库区
   //新增库区
   warehouseareaSave: async (data) => {
   warehouseareaSave: async (data) => {
-    const res = await request.post('/wms/warehousearea/save', data);
+    const res = await request.post('/wms/warehouse/save', data);
+
+    return res;
+  },
+  //新增仓库
+  saveOrUpdateWarehouse: async (data) => {
+    const res = await request.post(
+      '/wms/warehouse/saveOrUpdateWarehouse',
+      data
+    );
 
 
     return res;
     return res;
   },
   },
@@ -69,8 +81,8 @@ export default {
     }
     }
   },
   },
   //删除
   //删除
-  delete: async (data) => {
-    const res = await request.post('/wms/warehouse/delete', data);
+  delete: async (id) => {
+    const res = await request.get(`/wms/warehouse/delete/${id}`);
     if (res.data.code == 0) {
     if (res.data.code == 0) {
       return res.data.message;
       return res.data.message;
     }
     }
@@ -92,9 +104,20 @@ export default {
   //详情
   //详情
   info: function (params) {
   info: function (params) {
     return request.get('/main/org/info/info', { params });
     return request.get('/main/org/info/info', { params });
-  }
+  },
   //树
   //树
   // tree: function (params) {
   // tree: function (params) {
   //     return http.asyncCall("/main/org/dept/tree", params,'get')
   //     return http.asyncCall("/main/org/dept/tree", params,'get')
   // },
   // },
+
+  //查询仓库详情
+
+  warehouseDetail: async (warehouseId) => {
+    const res = await request.post(
+      `/wms/warehouse/warehouseDetail/${warehouseId}`
+    );
+    if (res.data.code == 0) {
+      return res.data.data;
+    }
+  }
 };
 };

+ 81 - 0
src/components/CommomSelect/new-dept-select.vue

@@ -0,0 +1,81 @@
+<!-- 部门树形选择下拉框 -->
+<template>
+  <ele-tree-select
+    clearable
+    filterable
+    :value="value || ''"
+    :data="treeData"
+    label-key="name"
+    value-key="id"
+    ref="treeSelect"
+    default-expand-all
+    size="medium"
+    :placeholder="placeholder"
+    @input="updateValue"
+    v-on="$listeners"
+    v-bind="$attrs"
+    @change="changeChoose"
+  />
+</template>
+
+<script>
+  import { listOrganizations } from '@/api/system/organization';
+  export default {
+    props: {
+      // 选中的数据(v-model)
+      value: [Number, String],
+      // 提示信息
+      placeholder: {
+        type: String,
+        default: '请选择'
+      }
+    },
+    data() {
+      return {
+        treeData: []
+      };
+    },
+    created() {
+      this.getData();
+    },
+    methods: {
+      async getData(parmas = {}) {
+        const data = await listOrganizations(parmas);
+        this.treeData = this.$util.toTreeData({
+          data: data || [],
+          idField: 'id',
+          parentIdField: 'parentId'
+        });
+      },
+      // 定义一个函数来查找指定id的数据
+      findDataById(data, targetId) {
+        for (const item of data) {
+          if (item.id === targetId) {
+            return item;
+          }
+
+          if (item.children && item.children.length > 0) {
+            const foundChild = this.findDataById(item.children, targetId);
+            if (foundChild) {
+              return foundChild;
+            }
+          }
+        }
+
+        return null; // 如果未找到指定id的数据,返回null
+      },
+      /* 更新选中数据 */
+      updateValue(value) {
+        this.$emit('input', value, this.findDataById(this.treeData, value));
+      },
+
+      changeChoose(val) {
+        this.$emit(
+          'changeGroup',
+          val,
+          this.$refs.treeSelect.getNodeByValue(val)
+        );
+      }
+    }
+  };
+</script>

+ 1 - 1
src/utils/dict/index.js

@@ -22,7 +22,7 @@ export const useDictLabel = (dict) => {
     return '';
     return '';
   }
   }
   return (code) => {
   return (code) => {
-    console.log(code, 'label');
+    // console.log(code, 'label');
     const obj = dict.find((item) => (item && item.code) == code);
     const obj = dict.find((item) => (item && item.code) == code);
     return obj && obj.label;
     return obj && obj.label;
   };
   };

+ 172 - 33
src/views/warehouseManagement/warehouseDefinition/add.vue

@@ -2,7 +2,7 @@
   <div class="ele-body warehouseAdd">
   <div class="ele-body warehouseAdd">
     <el-card shadoe="never">
     <el-card shadoe="never">
       <header>
       <header>
-        <span class="title">{{ formData.code }} {{ formData.name }}</span>
+        <span class="title">{{ titleObj.code }} {{ titleObj.name }}</span>
         <div>
         <div>
           <el-button @click="$router.go(-1)">返回</el-button>
           <el-button @click="$router.go(-1)">返回</el-button>
           <el-button type="primary" @click="submit" :loading="loading"
           <el-button type="primary" @click="submit" :loading="loading"
@@ -909,18 +909,19 @@
         shelfObj: {},
         shelfObj: {},
         longWidthHeightBol: false,
         longWidthHeightBol: false,
         savedWarehouse: [],
         savedWarehouse: [],
-        savedShelves: []
+        savedShelves: [],
+        titleObj: {},
+        warehouseVO: {}
       };
       };
     },
     },
     computed: {},
     computed: {},
     created() {
     created() {
       const { query } = this.$route;
       const { query } = this.$route;
-      this.formData.code = query.code;
-      this.formData.name = query.name;
+      this.titleObj.code = query.code;
+      this.titleObj.name = query.name;
       this.formData.id = query.id;
       this.formData.id = query.id;
       this.getDetail(query.id);
       this.getDetail(query.id);
     },
     },
-
     methods: {
     methods: {
       setNUm(row) {
       setNUm(row) {
         let result = Number.isNaN(row.extInfo[0].line * row.extInfo[0].column)
         let result = Number.isNaN(row.extInfo[0].line * row.extInfo[0].column)
@@ -929,15 +930,81 @@
         row.subCount = result;
         row.subCount = result;
         return result;
         return result;
       },
       },
+      handleHouse(obj) {
+        const {
+          warehouseAreasSaveList,
+          areaGoodsshelvesList,
+          allocationReqList
+        } = obj;
+        let kqArr = [];
+        for (const key in warehouseAreasSaveList) {
+          kqArr.push({
+            name: warehouseAreasSaveList[key].name,
+            code: warehouseAreasSaveList[key].code,
+            extInfo: [
+              {
+                areaType: warehouseAreasSaveList[key].type,
+                attribute: warehouseAreasSaveList[key].attribute,
+                address: warehouseAreasSaveList[key].address,
+                areaLength: warehouseAreasSaveList[key].areaLength,
+                areaWidth: warehouseAreasSaveList[key].areaWide,
+                areaHigh: warehouseAreasSaveList[key].areaHigh
+              }
+            ],
+            subCount: warehouseAreasSaveList[key].num,
+            remark: warehouseAreasSaveList[key].areaRemark
+          });
+        }
+        let hjArr = [];
+        for (const key in areaGoodsshelvesList) {
+          hjArr.push({
+            reservoirAreaCode: areaGoodsshelvesList[key].warehouseAreaCode,
+            code: areaGoodsshelvesList[key].goodsshelvesCode,
+            extInfo: [
+              {
+                line: areaGoodsshelvesList[key].goodsshelvesLine,
+                column: areaGoodsshelvesList[key].goodsshelvesColumn,
+                areaLength: areaGoodsshelvesList[key].goodsshelvesLength,
+                areaWidth: areaGoodsshelvesList[key].goodsshelvesWide,
+                areaHigh: areaGoodsshelvesList[key].goodsshelvesHigh,
+                isRegular: areaGoodsshelvesList[key].isRegular
+              }
+            ],
+            remark: areaGoodsshelvesList[key].goodsshelvesRemark
+          });
+        }
+        let hwArr = [];
+        for (const key in allocationReqList) {
+          hwArr.push({
+            goodsShelvesCode: allocationReqList[key].goodsAllocationCode,
+            reservoirAreaCode: allocationReqList[key].warehouseAreaCode,
+            code: allocationReqList[key].goodsAllocationCode,
+            extInfo: [
+              {
+                goodsAllocationLength:
+                  allocationReqList[key].goodsAllocationLength,
+                goodsAllocationWide: allocationReqList[key].goodsAllocationWide,
+                goodsAllocationHigh: allocationReqList[key].goodsAllocationHigh,
+                weightLimit: allocationReqList[key].weightLimit,
+                volumeUnit: allocationReqList[key].volumeUnit
+              }
+            ]
+          });
+        }
+        console.log('货架', allocationReqList);
+        return { kq: kqArr, hj: hjArr, hw: hwArr };
+      },
       async getDetail(id) {
       async getDetail(id) {
-        const res = await warehouseDefinition.getById({ id });
-
+        const res = await warehouseDefinition.warehouseDetail(id);
+        this.warehouseVO = res.warehouseVO; //仓库基本信息
+        const { kq, hj, hw } = this.handleHouse(res);
+        console.log(this.handleHouse(res));
         this.areaForm = {
         this.areaForm = {
-          warehouseAreasSaveList: res.reservoirAreaList || [], //库区
-          areaGoodsshelvesList: res.goodsShelvesList || [], //货架
-          allocationReqList: res.goodsAllocationList || [] //货位
+          warehouseAreasSaveList: kq || [], //库区
+          areaGoodsshelvesList: hj || [], //货架
+          allocationReqList: hw || [] //货位
         };
         };
-
+        console.log('===', this.areaForm);
         this.formData = res;
         this.formData = res;
         //已保存库区货位 ,删除时判断
         //已保存库区货位 ,删除时判断
         this.savedWarehouse = this.areaForm.warehouseAreasSaveList.length
         this.savedWarehouse = this.areaForm.warehouseAreasSaveList.length
@@ -1435,6 +1502,7 @@
         if (this.areaForm.warehouseAreasSaveList.length === 0) {
         if (this.areaForm.warehouseAreasSaveList.length === 0) {
           return this.$message.error('请添加库区');
           return this.$message.error('请添加库区');
         }
         }
+        // ===dakai
         if (
         if (
           this.areaForm.warehouseAreasSaveList.length > 0 &&
           this.areaForm.warehouseAreasSaveList.length > 0 &&
           this.areaForm.allocationReqList.length === 0
           this.areaForm.allocationReqList.length === 0
@@ -1447,9 +1515,9 @@
         ) {
         ) {
           return this.$message.error('请添加货架');
           return this.$message.error('请添加货架');
         }
         }
-        // if (!this.checkVolume()) {
-        //   return this.$message.error('货架总体积不能大于库区体积!');
-        // }
+        if (!this.checkVolume()) {
+          return this.$message.error('货架总体积不能大于库区体积!');
+        }
 
 
         let obj = {};
         let obj = {};
         for (const item of this.areaForm.allocationReqList) {
         for (const item of this.areaForm.allocationReqList) {
@@ -1480,35 +1548,43 @@
                     //   goodsShelvesList: this.areaForm.areaGoodsshelvesList,
                     //   goodsShelvesList: this.areaForm.areaGoodsshelvesList,
                     //   reservoirAreaList: this.areaForm.warehouseAreasSaveList
                     //   reservoirAreaList: this.areaForm.warehouseAreasSaveList
                     // };
                     // };
-                    let arr = [
-                      ...this.areaForm.allocationReqList,
-                      ...this.areaForm.areaGoodsshelvesList,
-                      ...this.areaForm.warehouseAreasSaveList
-                    ];
+                    // let arr = [
+                    //   ...this.areaForm.allocationReqList, //货位
+                    //   ...this.areaForm.areaGoodsshelvesList, //货架
+                    //   ...this.areaForm.warehouseAreasSaveList //库区
+                    // ];
                     // arr.forEach((item) => {
                     // arr.forEach((item) => {
                     //   if ('isEdit' in item) {
                     //   if ('isEdit' in item) {
                     //     delete item.isEdit;
                     //     delete item.isEdit;
                     //   }
                     //   }
                     // });
                     // });
 
 
-                    const arrMap = arr.map((item) => {
-                      return {
-                        warehouseId: item.warehouseId,
-                        code: item.code,
-                        extInfo: item.extInfo,
-                        goodsShelvesCode: item.goodsShelvesCode,
-                        name: item.name,
-                        remark: item.remark,
-                        reservoirAreaCode: item.reservoirAreaCode,
-                        subCount: item.subCount,
-                        type: item.type
-                      };
-                    });
+                    // const arrMap = arr.map((item) => {
+                    //   return {
+                    //     warehouseId: item.warehouseId,
+                    //     code: item.code,
+                    //     extInfo: item.extInfo,
+                    //     goodsShelvesCode: item.goodsShelvesCode,
+                    //     name: item.name,
+                    //     remark: item.remark,
+                    //     reservoirAreaCode: item.reservoirAreaCode,
+                    //     subCount: item.subCount,
+                    //     type: item.type
+                    //   };
+                    // });
+                    const newObj = {
+                      allocationList: this.areaForm.allocationReqList, //货位
+                      areaGoodsshelvesList: this.areaForm.areaGoodsshelvesList, //货架
+                      areasList: this.areaForm.warehouseAreasSaveList //库区
+                    };
+                    // ...this.areaForm.allocationReqList, //货位
+                    //   ...this.areaForm.areaGoodsshelvesList, //货架
+                    //   ...this.areaForm.warehouseAreasSaveList //库区
 
 
                     this.loading = true;
                     this.loading = true;
                     try {
                     try {
                       let res = await warehouseDefinition.warehouseareaSave(
                       let res = await warehouseDefinition.warehouseareaSave(
-                        arrMap
+                        this.handleNewSource(newObj)
                       );
                       );
 
 
                       if (res.data.code == 0) {
                       if (res.data.code == 0) {
@@ -1540,6 +1616,69 @@
           item.id === pid;
           item.id === pid;
         });
         });
         return obj && obj.reservoirAreaCode + '-' + goodsShelvesCode;
         return obj && obj.reservoirAreaCode + '-' + goodsShelvesCode;
+      },
+      //重新处理数据,之前代码不敢动
+      handleNewSource(arr) {
+        //areasList库区
+        //areaGoodsshelvesList货架
+        //allocationList货位
+        const { areasList, areaGoodsshelvesList, allocationList } = arr;
+        let areasListArr = this.objExit(areasList).map((item) => {
+          return {
+            code: item.code,
+            name: item.name,
+            type: item.areaType,
+            attribute: item.attribute,
+            address: item.address,
+            areaLength: item.areaLength,
+            areaWidth: item.areaWidth,
+            areaHigh: item.areaHigh,
+            num: item.subCount,
+            areaRemark: item.remark
+          };
+        });
+        let areaGoodsshelvesListArr = this.objExit(areaGoodsshelvesList).map(
+          (item) => {
+            return {
+              warehouseAreaCode: item.reservoirAreaCode,
+              goodsshelvesCode: item.code,
+              goodsshelvesLine: item.line,
+              goodsshelvesColumn: item.column,
+              goodsshelvesLength: item.areaLength,
+              goodsshelvesWide: item.areaWidth,
+              goodsshelvesHigh: item.areaHigh,
+              inUseAllocationNumber: item.subCount,
+              isRegular: item.isRegular,
+              goodsshelvesRemark: item.remark
+            };
+          }
+        );
+        let allocationListArr = this.objExit(allocationList).map((item) => {
+          return {
+            warehouseAreaGoodsCode: item.code,
+            goodsAllocationCode: item.goodsShelvesCode,
+            goodsAllocationLength: item.goodsAllocationLength,
+            goodsAllocationWide: item.goodsAllocationWide,
+            goodsAllocationHigh: item.goodsAllocationHigh,
+            weightLimit: item.goodsAllocationHigh,
+            inUseAllocationNumber: item.weightLimit,
+            volumeUnit: item.volumeUnit
+          };
+        });
+        let params = {
+          areasList: areasListArr,
+          goodsshelvesList: areaGoodsshelvesListArr,
+          allocationList: allocationListArr,
+          warehousePO: this.warehouseVO
+        };
+        return params;
+      },
+      objExit(arr) {
+        let newArr = [];
+        for (const key in arr) {
+          newArr.push({ ...arr[key].extInfo[0], ...arr[key] });
+        }
+        return newArr;
       }
       }
     }
     }
   };
   };

+ 97 - 72
src/views/warehouseManagement/warehouseDefinition/components/WarehouseEdit.vue

@@ -5,7 +5,13 @@
     :before-close="cancel"
     :before-close="cancel"
     width="500px"
     width="500px"
   >
   >
-    <el-form :model="formData" :rules="rules" ref="formRef" label-width="100px">
+    <el-form
+      v-loading="loadingVis"
+      :model="formData"
+      :rules="rules"
+      ref="formRef"
+      label-width="100px"
+    >
       <el-form-item label="仓库编码" prop="code">
       <el-form-item label="仓库编码" prop="code">
         <el-input
         <el-input
           v-model="formData.code"
           v-model="formData.code"
@@ -50,62 +56,54 @@
             :key="item.id"
             :key="item.id"
             :label="item.name"
             :label="item.name"
             :value="item.id"
             :value="item.id"
-            @click.native="() => (formData.factoryName = item.name)"
+            @click.native="
+              () => (
+                (formData.factoryName = item.name),
+                (formData.factoryCodefactoryCode = item.code)
+              )
+            "
           >
           >
           </el-option>
           </el-option>
         </el-select>
         </el-select>
       </el-form-item>
       </el-form-item>
-      <!-- <el-form-item label="权属部门" prop="departmentName">
-        <selectTree
-          ref="tree"
-          id="tree-option"
-          size="small"
-          class="w100"
-          :initStr="formData.departmentName"
-          :options="deptList"
-          :props="{
-            value: 'id',
-            label: 'name',
-            children: 'children'
-          }"
-          @getValue="nodeClick"
-        />
-      </el-form-item> -->
-      <!-- <el-form-item label="权属人" prop="ownerId">
-        <el-select filterable 
+      <el-form-item label="权属部门" prop="departmentId">
+        <DeptSelect v-model="formData.departmentId" @input="nodeClick" />
+      </el-form-item>
+      <el-form-item label="权属人" prop="ownerId">
+        <el-select
+          filterable
           class="w100"
           class="w100"
           size="small"
           size="small"
           v-model="formData.ownerId"
           v-model="formData.ownerId"
           placeholder="请选择"
           placeholder="请选择"
+          @change="changeOwner"
         >
         >
           <el-option
           <el-option
             v-for="item in userList"
             v-for="item in userList"
             :key="item.id"
             :key="item.id"
             :label="item.name"
             :label="item.name"
             :value="item.id"
             :value="item.id"
-            @click.native="
-              formData.ownerName = item.trueName;
-              formData.contact = item.mobile;
-            "
           >
           >
           </el-option>
           </el-option>
         </el-select>
         </el-select>
-      </el-form-item> -->
-      <!-- <el-form-item label="仓库位置" prop="location">
+      </el-form-item>
+      <el-form-item label="仓库位置" prop="location">
         <el-cascader
         <el-cascader
           size="small"
           size="small"
           class="w100"
           class="w100"
           v-model="formData.location"
           v-model="formData.location"
           :options="locationOptions"
           :options="locationOptions"
+          @change="changeLocation"
         ></el-cascader>
         ></el-cascader>
-      </el-form-item> -->
-      <!-- <el-form-item label="详情地址" prop="address">
+      </el-form-item>
+      <el-form-item label="详情地址" prop="address">
         <el-input
         <el-input
           v-model="formData.address"
           v-model="formData.address"
           placeholder="请输入"
           placeholder="请输入"
           size="small"
           size="small"
+          @change="$forceUpdate()"
         ></el-input>
         ></el-input>
-      </el-form-item> -->
+      </el-form-item>
       <el-form-item label="备注" prop="remarks">
       <el-form-item label="备注" prop="remarks">
         <el-input
         <el-input
           type="textarea"
           type="textarea"
@@ -114,18 +112,18 @@
           size="small"
           size="small"
         ></el-input>
         ></el-input>
       </el-form-item>
       </el-form-item>
-      <!-- <el-form-item label="锁库状态" prop="lockStatus">
+      <el-form-item label="锁库状态" prop="lockStatus">
         <el-switch
         <el-switch
           v-model="formData.lockStatus"
           v-model="formData.lockStatus"
           active-text="锁库"
           active-text="锁库"
           inactive-text="开库"
           inactive-text="开库"
-          :active-value="0"
-          :inactive-value="1"
+          :active-value="1"
+          :inactive-value="0"
         ></el-switch>
         ></el-switch>
-      </el-form-item> -->
-      <el-form-item label="状态" prop="enabled">
+      </el-form-item>
+      <el-form-item label="状态" prop="status">
         <el-switch
         <el-switch
-          v-model="formData.enabled"
+          v-model="formData.status"
           active-text="开"
           active-text="开"
           inactive-text="关"
           inactive-text="关"
           :active-value="1"
           :active-value="1"
@@ -147,12 +145,13 @@
   import warehouseDefinition from '@/api/warehouseManagement/warehouseDefinition';
   import warehouseDefinition from '@/api/warehouseManagement/warehouseDefinition';
 
 
   // import selectTree from '@/components/selectTree';
   // import selectTree from '@/components/selectTree';
+  import DeptSelect from '@/components/CommomSelect/new-dept-select.vue';
 
 
   import city from '@/assets/js/city';
   import city from '@/assets/js/city';
   // import user from '@/api/main/user';
   // import user from '@/api/main/user';
 
 
   export default {
   export default {
-    // components: { selectTree },
+    components: { DeptSelect },
     data() {
     data() {
       return {
       return {
         warehouseDefinition_inventoryList: [
         warehouseDefinition_inventoryList: [
@@ -171,31 +170,30 @@
           inventoryType: '',
           inventoryType: '',
           remarks: '',
           remarks: '',
           factoryId: '',
           factoryId: '',
-          enabled: 1
-          // lockStatus: 0
+          status: 1,
+          lockStatus: 0
         },
         },
         rules: {
         rules: {
           code: [
           code: [
             { required: true, message: '请输入仓库编码', trigger: 'blur' }
             { required: true, message: '请输入仓库编码', trigger: 'blur' }
           ],
           ],
-          name: [
-            { required: true, message: '请输入仓库名称', trigger: 'blur' }
-          ],
-          inventoryType: [
-            { required: true, message: '请选择仓库类型', trigger: 'blur' }
-          ],
-          factoryId: [
-            { required: true, message: '请选择工厂名称', trigger: 'blur' }
-          ],
-          enabled: [
-            { required: true, message: '请选择仓库状态', trigger: 'blur' }
-          ]
+          name: [{ required: true, message: '请输入仓库名称', trigger: 'blur' }]
+          // inventoryType: [
+          //   { required: true, message: '请选择仓库类型', trigger: 'blur' }
+          // ],
+          // factoryId: [
+          //   { required: true, message: '请选择工厂名称', trigger: 'blur' }
+          // ],
+          // status: [
+          //   { required: true, message: '请选择仓库状态', trigger: 'blur' }
+          // ]
         },
         },
         type: '新建',
         type: '新建',
         userList: [],
         userList: [],
         deptList: [], //部门集合
         deptList: [], //部门集合
         factoryList: [], //工厂集合
         factoryList: [], //工厂集合
-        locationOptions: city
+        locationOptions: city,
+        loadingVis: false
       };
       };
     },
     },
     watch: {
     watch: {
@@ -215,19 +213,28 @@
         this.init();
         this.init();
 
 
         if (type === '修改') {
         if (type === '修改') {
+          this.loadingVis = true;
           this.$nextTick(async () => {
           this.$nextTick(async () => {
-            this.formData = Object.assign({}, row);
-            // this.formData.location = [row.province, row.city, row.area];
-
-            // console.log(this.formData.location);
-
-            // if (row.departmentCode) {
-            //   let userData = await user.list({
-            //     deptCode: row.departmentCode,
-            //     size: 9999
-            //   });
-            //   this.userList = userData.data.items;
-            // }
+            const { warehouseVO } = await warehouseDefinition.warehouseDetail(
+              row.id
+            );
+            if (warehouseVO.departmentId) {
+              let userData = await warehouseDefinition.getUserPage({
+                groupId: warehouseVO.departmentId,
+                size: 9999,
+                pageNum: 1
+              });
+              this.userList = userData.list;
+            }
+            this.formData = {
+              ...warehouseVO,
+              location: [
+                warehouseVO.province,
+                warehouseVO.city,
+                warehouseVO.area
+              ]
+            };
+            this.loadingVis = false;
           });
           });
         }
         }
 
 
@@ -284,9 +291,8 @@
 
 
             this.loading = true;
             this.loading = true;
             const res = await warehouseDefinition
             const res = await warehouseDefinition
-              .save(params)
+              .saveOrUpdateWarehouse(params)
               .finally(() => (this.loading = false));
               .finally(() => (this.loading = false));
-
             if (res.data?.code == '0') {
             if (res.data?.code == '0') {
               this.$message.success('保存成功!');
               this.$message.success('保存成功!');
               this.$emit('success');
               this.$emit('success');
@@ -300,20 +306,39 @@
         // this.$refs.tree.clearHandle();
         // this.$refs.tree.clearHandle();
         this.visible = false;
         this.visible = false;
       },
       },
-      async nodeClick(data) {
+      async nodeClick(id, data) {
         // this.formData.departmentCode = data?.code;
         // this.formData.departmentCode = data?.code;
-        this.formData.departmentName = data?.name;
-
+        this.formData.departmentId = id;
+        if (data) {
+          this.formData.departmentName = data.name;
+        }
         this.formData.ownerName = '';
         this.formData.ownerName = '';
         this.formData.ownerId = '';
         this.formData.ownerId = '';
-        if (data) {
+        if (id) {
           let userData = await warehouseDefinition.getUserPage({
           let userData = await warehouseDefinition.getUserPage({
-            groupId: data.id,
-            size: 99999
+            groupId: id,
+            size: 9999,
+            pageNum: 1
           });
           });
-
           this.userList = userData.list;
           this.userList = userData.list;
         }
         }
+      },
+      changeOwner(val) {
+        this.$forceUpdate();
+        this.$set(this.formData, 'ownerId', val);
+        this.$set(
+          this.formData,
+          'ownerName',
+          this.userList.find((item) => {
+            return item.id == val;
+          }).name
+        );
+      },
+      changeLocation(val) {
+        this.$set(this.formData, 'province', val[0]); //省
+        this.$set(this.formData, 'city', val[1]); //市
+        this.$set(this.formData, 'area', val[2]); //区
+        delete this.formData.location;
       }
       }
     }
     }
   };
   };

+ 12 - 9
src/views/warehouseManagement/warehouseDefinition/details.vue

@@ -54,12 +54,12 @@
                   <span>{{ filterFactoryId(warehouseInfo.factoryId) }}</span>
                   <span>{{ filterFactoryId(warehouseInfo.factoryId) }}</span>
                 </el-form-item>
                 </el-form-item>
               </el-col>
               </el-col>
-              <!-- <el-col :span="8">
+              <el-col :span="8">
                 <el-form-item label="权属部门">
                 <el-form-item label="权属部门">
                   <span>{{ warehouseInfo.departmentName }}</span>
                   <span>{{ warehouseInfo.departmentName }}</span>
                 </el-form-item>
                 </el-form-item>
-              </el-col> -->
-              <!-- <el-col :span="8">
+              </el-col>
+              <el-col :span="8">
                 <el-form-item label="权属人">
                 <el-form-item label="权属人">
                   <span>{{ warehouseInfo.ownerName }}</span>
                   <span>{{ warehouseInfo.ownerName }}</span>
                 </el-form-item>
                 </el-form-item>
@@ -87,7 +87,7 @@
                 <el-form-item label="创建人">
                 <el-form-item label="创建人">
                   <span>{{ warehouseInfo.createUserName }}</span>
                   <span>{{ warehouseInfo.createUserName }}</span>
                 </el-form-item>
                 </el-form-item>
-              </el-col> -->
+              </el-col>
 
 
               <!-- <el-col :span="8">
               <!-- <el-col :span="8">
               <el-form-item label="创建部门">
               <el-form-item label="创建部门">
@@ -387,11 +387,11 @@
         });
         });
         this.factoryList = res1.list;
         this.factoryList = res1.list;
 
 
-        const res = await warehouseDefinition.getById({
-          id: this.$route.query.id
-        });
-
-        this.warehouseInfo = res || {};
+        const { warehouseVO } = await warehouseDefinition.warehouseDetail(
+          this.$route.query.id
+        );
+        console.log(warehouseVO);
+        this.warehouseInfo = warehouseVO || {};
         //  warehouseAreasSaveList: res.reservoirAreaList || [], //库区
         //  warehouseAreasSaveList: res.reservoirAreaList || [], //库区
         // areaGoodsshelvesList: res.goodsShelvesList || [], //货架
         // areaGoodsshelvesList: res.goodsShelvesList || [], //货架
         // allocationReqList: res.goodsAllocationList || [] //货位
         // allocationReqList: res.goodsAllocationList || [] //货位
@@ -440,6 +440,9 @@
   };
   };
 </script>
 </script>
 <style lang="scss" scoped>
 <style lang="scss" scoped>
+  ::v-deep .el-form-item {
+    margin-bottom: 12px;
+  }
   .page {
   .page {
     padding: 10px;
     padding: 10px;
     margin: 10px 0 10px 0;
     margin: 10px 0 10px 0;

+ 13 - 10
src/views/warehouseManagement/warehouseDefinition/index.vue

@@ -104,8 +104,7 @@
           >新建仓库</el-button
           >新建仓库</el-button
         >
         >
       </div>
       </div>
-
-      <div class="warehouse-container">
+      <div class="warehouse-container" v-loading="loading">
         <div
         <div
           class="warehouse-card_item"
           class="warehouse-card_item"
           v-for="(item, index) in warehouse"
           v-for="(item, index) in warehouse"
@@ -184,11 +183,10 @@
     // mixins: [dictMixins],
     // mixins: [dictMixins],
     data() {
     data() {
       return {
       return {
+        loading: false,
         formData: {
         formData: {
           code: '',
           code: '',
           name: '',
           name: '',
-          enabled: '',
-          factoryId: '',
           inventoryType: '',
           inventoryType: '',
           emptyAllocationEnd: '',
           emptyAllocationEnd: '',
           emptyAllocationStart: ''
           emptyAllocationStart: ''
@@ -208,7 +206,7 @@
         warehouseLabel: [
         warehouseLabel: [
           {
           {
             label: '状态',
             label: '状态',
-            key: 'enabled',
+            key: 'status',
             filter: useDictLabel(warehouseDefinition_statusList)
             filter: useDictLabel(warehouseDefinition_statusList)
           },
           },
           {
           {
@@ -219,8 +217,8 @@
           { label: '库区数', key: 'areaNumber' },
           { label: '库区数', key: 'areaNumber' },
           { label: '货架数', key: 'goodNumber' },
           { label: '货架数', key: 'goodNumber' },
           { label: '货位数', key: 'allocationNumber' },
           { label: '货位数', key: 'allocationNumber' },
-          { label: '空货位数', key: 'emptyAllocationNumber' },
-          { label: '所属工厂', key: 'factoryId' }
+          { label: '空货位数', key: 'emptyAllocationNumber' }
+          // { label: '所属工厂', key: 'factoryId' }
         ]
         ]
       };
       };
     },
     },
@@ -243,8 +241,13 @@
         this.handleList();
         this.handleList();
       },
       },
       async handleList() {
       async handleList() {
-        const res = await warehouseDefinition.list(this.formData);
-        this.warehouse = res.list;
+        try {
+          this.loading = true;
+          const res = await warehouseDefinition.list(this.formData);
+          this.warehouse = res;
+        } finally {
+          this.loading = false;
+        }
       },
       },
       search() {
       search() {
         this.handleList();
         this.handleList();
@@ -290,7 +293,7 @@
         this.$confirm(`确认删除仓库${name}?`).then(async () => {
         this.$confirm(`确认删除仓库${name}?`).then(async () => {
           const isDeleted = await warehouseDefinition.isDelete(id);
           const isDeleted = await warehouseDefinition.isDelete(id);
           if (isDeleted == 1) {
           if (isDeleted == 1) {
-            const res = await warehouseDefinition.delete([id]);
+            const res = await warehouseDefinition.delete(id);
             this.$message.success('删除' + res + '!');
             this.$message.success('删除' + res + '!');
             this.handleList();
             this.handleList();
           } else {
           } else {

+ 4 - 3
vue.config.js

@@ -3,7 +3,7 @@ const { transformElementScss } = require('ele-admin/lib/utils/dynamic-theme');
 const path = require('path');
 const path = require('path');
 const { name } = require('./package.json');
 const { name } = require('./package.json');
 
 
-function resolve (dir) {
+function resolve(dir) {
   return path.join(__dirname, dir);
   return path.join(__dirname, dir);
 }
 }
 
 
@@ -31,7 +31,8 @@ module.exports = {
     proxy: {
     proxy: {
       // 当我们的本地的请求 有/api的时候,就会代理我们的请求地址向另外一个服务器发出请求
       // 当我们的本地的请求 有/api的时候,就会代理我们的请求地址向另外一个服务器发出请求
       '/api': {
       '/api': {
-        target: 'http://124.71.68.31:50001',
+        // target: 'http://124.71.68.31:50001',
+        target: 'http://192.168.1.100:18086', //朱
 
 
         changeOrigin: true, // 只有这个值为true的情况下 才表示开启跨域
         changeOrigin: true, // 只有这个值为true的情况下 才表示开启跨域
         pathRewrite: {
         pathRewrite: {
@@ -40,7 +41,7 @@ module.exports = {
       }
       }
     }
     }
   },
   },
-  chainWebpack (config) {
+  chainWebpack(config) {
     config.plugins.delete('prefetch');
     config.plugins.delete('prefetch');
     // set svg-sprite-loader
     // set svg-sprite-loader
     // config.module.rule('svg').exclude.add(resolve('./src/icons')).end();
     // config.module.rule('svg').exclude.add(resolve('./src/icons')).end();