Procházet zdrojové kódy

Merge branch 'dev' of http://110.41.163.243:9980/kd-aiot/kd-aiot-frontend-wms into dengfei

695593266@qq.com před 1 měsícem
rodič
revize
4f8afb8bc4

+ 19 - 192
src/views/warehouseManagement/warehouseDefinition/add.vue

@@ -307,7 +307,7 @@
                     >编辑</el-button
                   > -->
 
-                  <el-button type="text" @click="remove1($index, row)"
+                  <el-button type="text" @click="removeArea($index, row)"
                     >删除库区</el-button
                   >
                 </template>
@@ -546,7 +546,7 @@
                     @click="saveGoods($index, row)"
                     >保存</el-button
                   >
-                  <el-button type="text" @click="removeGoods1($index, row)"
+                  <el-button type="text" @click="removeGoods($index, row)"
                     >删除货架</el-button
                   >
                 </template>
@@ -969,8 +969,6 @@
         multipleSelection: [],
         shelfObj: {},
         longWidthHeightBol: false,
-        savedWarehouse: [],
-        savedShelves: [],
         titleObj: {},
         warehouseVO: {}
       };
@@ -998,9 +996,9 @@
       },
       handleHouse(obj) {
         const {
-          warehouseAreasSaveList,
-          areaGoodsshelvesList,
-          allocationReqList
+          warehouseAreasSaveList,   // 库区
+          areaGoodsshelvesList,    // 货架
+          allocationReqList   // 货位
         } = obj;
         let kqArr = [];
         for (const key in warehouseAreasSaveList) {
@@ -1027,8 +1025,8 @@
         for (const key in areaGoodsshelvesList) {
           hjArr.push({
             ...areaGoodsshelvesList[key],
-            reservoirAreaCode: areaGoodsshelvesList[key].warehouseAreaCode,
-            code: areaGoodsshelvesList[key].goodsshelvesCode,
+            reservoirAreaCode: areaGoodsshelvesList[key].warehouseAreaCode,  // 库区code
+            code: areaGoodsshelvesList[key].goodsshelvesCode,  // 货架code
             extInfo: [
               {
                 line: areaGoodsshelvesList[key].goodsshelvesLine,
@@ -1046,9 +1044,9 @@
         for (const key in allocationReqList) {
           hwArr.push({
             ...allocationReqList[key],
-            reservoirAreaCode: allocationReqList[key].warehouseAreaCode,
-            goodsShelvesCode: allocationReqList[key].goodsAllocationCode,
-            code: allocationReqList[key].warehouseAreaCode,
+            reservoirAreaCode: allocationReqList[key].warehouseAreaCode,  // 库区code
+            goodsShelvesCode: allocationReqList[key].warehouseAreaGoodsCode,  // 货架code
+            code: allocationReqList[key].goodsAllocationCode,  // 货位code
             extInfo: [
               {
                 goodsAllocationLength:
@@ -1067,7 +1065,9 @@
         const res = await warehouseDefinition.warehouseDetail(id);
         this.warehouseVO = res.warehouseVO; //仓库基本信息
         const { kq, hj, hw } = this.handleHouse(res);
-        // console.log(this.handleHouse(res));
+        console.log('kq~~', kq);
+        console.log('hj~~', hj);
+        console.log('hw~~', hw);
         this.areaForm = {
           warehouseAreasSaveList: kq || [], //库区
           areaGoodsshelvesList: hj || [], //货架
@@ -1075,13 +1075,6 @@
         };
         console.log('===', this.areaForm);
         this.formData = res;
-        //已保存库区货位 ,删除时判断
-        this.savedWarehouse = this.areaForm.warehouseAreasSaveList.length
-          ? this.areaForm.warehouseAreasSaveList.map((i) => i.id)
-          : [];
-        this.savedShelves = this.areaForm.areaGoodsshelvesList.length
-          ? this.areaForm.areaGoodsshelvesList.map((i) => i.id)
-          : [];
       },
       checkVolume() {
         console.log(this.areaForm);
@@ -1176,35 +1169,6 @@
             }
           })
           .catch(() => {});
-        // let obj = this.areaForm.warehouseAreasSaveList[index],
-        //   list = this.areaForm.areaGoodsshelvesList.filter(
-        //     item => item.reservoirAreaCode === obj.code
-        //   )
-        // if (obj.id) {
-        //   if (list.length == obj.num)
-        //     return this.$message.error('添加货架数量达到上限')
-        //   let num = obj.num - list.length
-        //   for (var i = 0; i < num; i++) {
-        //     this.areaForm.areaGoodsshelvesList.push({
-        //       reservoirAreaCode: obj.code,
-        //       warehouseAreaId: obj.id,
-        //       warehouseAreaName: obj.name,
-        //       code: `C${pushZero(
-        //         this.areaForm.areaGoodsshelvesList.length + 1
-        //       )}`,
-        //
-        //       goodsshelvesColumn: '',
-        //
-        //
-        //       // goodsshelvesBarcode: '',
-        //       remark: '',
-        //       warehouseName: this.formData.name,
-        //       isEdit: true
-        //     })
-        //   }
-        // } else {
-        //   this.saveArea(index)
-        // }
       },
       onBlur(item, name, name1) {
         // name当前货位的长宽高,name1货架的长宽高
@@ -1477,56 +1441,11 @@
           }
         });
       },
-      async removeGoods(idx, { id, code, reservoirAreaCode }) {
-        if (
-          this.areaForm.areaGoodsshelvesList.filter(
-            (item) => item.reservoirAreaCode === reservoirAreaCode
-          ).length === 1
-        ) {
-          return this.$message.warning('至少保留一个货架!');
-        }
-        if (this.savedShelves.includes(id)) {
-          let list = this.areaForm.allocationReqList
-            .filter((item) => item.goodsShelvesCode === code)
-            .map((i) => i.id);
-
-          const res = await existGoods(list);
-
-          if (res?.success && res.data) {
-            return this.$message.warning('此货架下货位有关联货物,无法删除!');
-          }
-        }
-
-        this.areaForm.allocationReqList =
-          this.areaForm.allocationReqList.filter(
-            (item) =>
-              item.goodsShelvesCode !== code ||
-              reservoirAreaCode !== item.reservoirAreaCode
-          );
-        let areasIndex = this.areaForm.warehouseAreasSaveList.findIndex(
-          (item) =>
-            item.code ===
-            this.areaForm.areaGoodsshelvesList[idx].reservoirAreaCode
-        );
-        this.areaForm.areaGoodsshelvesList.splice(idx, 1);
-        if (
-          this.areaForm.warehouseAreasSaveList[areasIndex].subCount - 1 <=
-          0
-        ) {
-          this.areaForm.warehouseAreasSaveList.splice(areasIndex, 1);
-        } else {
-          this.$set(
-            this.areaForm.warehouseAreasSaveList[areasIndex],
-            'num',
-            this.areaForm.warehouseAreasSaveList[areasIndex].subCount - 1
-          );
-        }
-      },
-      removeGoods1(idx, { id, code, reservoirAreaCode }) {
+      removeGoods(idx, { id, code, reservoirAreaCode }) {
         //  warehouseAreasSaveList: res.reservoirAreaList || [], //库区
         // areaGoodsshelvesList: res.goodsShelvesList || [], //货架
         // allocationReqList: res.goodsAllocationList || [] //货位
-        console.log('removeGoods1~~', idx, id, code, reservoirAreaCode);
+        console.log('removeGoods~~', idx, id, code, reservoirAreaCode);
         if (
           this.areaForm.areaGoodsshelvesList.filter(
             (item) => item.reservoirAreaCode === reservoirAreaCode
@@ -1552,6 +1471,8 @@
                 this.areaForm.allocationReqList.filter(
                   (item) => item.goodsShelvesCode !== code
                 );
+
+                console.log('removeGoods~~', this.areaForm.areaGoodsshelvesList, this.areaForm.allocationReqList)
               // 更新对应库区的货架数量
               this.updateAreaSubCount(reservoirAreaCode, beforeCount);
               this.$message.warning('已在本地删除,保存之后生效!');
@@ -1592,8 +1513,8 @@
         this.$set(this.areaForm.warehouseAreasSaveList[index], 'isEdit', true);
         console.log('editArea~~', row, index, this.areaForm.warehouseAreasSaveList[index]);
       },
-      remove1(index, { id, code }) {
-        console.log('remove1~~', index, id, code);
+      removeArea(index, { id, code }) {
+        console.log('removeArea~~', index, id, code);
         this.$confirm(`是否删除这个库区`)
           .then(async () => {
             if (id) {
@@ -1627,45 +1548,6 @@
           })
           .catch((err) => {});
       },
-      async remove(index, { id, code }) {
-        // 判断关联货物
-        console.log(this.savedWarehouse, id, this.savedWarehouse.includes(id));
-        if (this.savedWarehouse.includes(id)) {
-          let list = this.areaForm.areaGoodsshelvesList
-            .filter((item) => item.reservoirAreaCode === code)
-            .map((i) =>
-              this.areaForm.allocationReqList.filter(
-                (item) => item.goodsShelvesCode === i.code
-              )
-            )
-            .flat()
-            .map((i) => i.id);
-
-          const res = await existGoods(list);
-
-          if (res?.success && res.data) {
-            return this.$message.warning('此库区下货位有关联货物,无法删除!');
-          }
-        }
-        // 货架code
-        let list = [];
-        this.areaForm.areaGoodsshelvesList.forEach((item) => {
-          if (item.reservoirAreaCode === code) {
-            list.push(item.code);
-          }
-        });
-        this.areaForm.areaGoodsshelvesList =
-          this.areaForm.areaGoodsshelvesList.filter(
-            (item) => item.reservoirAreaCode !== code
-          );
-        this.areaForm.allocationReqList =
-          this.areaForm.allocationReqList.filter(
-            (item) =>
-              !list.includes(item.goodsShelvesCode) ||
-              code !== item.reservoirAreaCode
-          );
-        this.areaForm.warehouseAreasSaveList.splice(index, 1);
-      },
       addArea() {
         this.editType = 'add';
         const pre =
@@ -1722,23 +1604,6 @@
         if (!this.checkVolume()) {
           return this.$message.warning('货架总体积不能大于库区体积!');
         }
-
-        // let obj = {};
-        // for (const item of this.areaForm.allocationReqList) {
-        //   const area = this.areaForm.areaGoodsshelvesList.find((itm) => {
-        //     return itm.reservoirAreaCode === item.code;
-        //   });
-
-        //   const id = `${
-        //     area && area.reservoirAreaCode + '-' + item.goodsShelvesCode
-        //   }-${item.code}`;
-
-        //   if (obj[id]) {
-        //    
-        //   } else {
-        //     obj[id] = 1;
-        //   }
-        // }
         
         let codeS=this.areaForm.allocationReqList?.map(item=>{
           return item.reservoirAreaCode+'_'+item.warehouseAreaGoodsCode+'_'+item.goodsAllocationCode
@@ -1765,49 +1630,11 @@
               if (valid) {
                 this.$refs.allocationForm.validate(async (valid) => {
                   if (valid) {
-                    // let params = {
-                    //   ...this.formData,
-                    //   goodsAllocationList: this.areaForm.allocationReqList,
-                    //   goodsShelvesList: this.areaForm.areaGoodsshelvesList,
-                    //   reservoirAreaList: this.areaForm.warehouseAreasSaveList
-                    // };
-                    // let arr = [
-                    //   ...this.areaForm.allocationReqList, //货位
-                    //   ...this.areaForm.areaGoodsshelvesList, //货架
-                    //   ...this.areaForm.warehouseAreasSaveList //库区
-                    // ];
-                    // arr.forEach((item) => {
-                    //   if ('isEdit' in item) {
-                    //     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 newObj = {
                       allocationList: this.areaForm.allocationReqList, //货位
                       areaGoodsshelvesList: this.areaForm.areaGoodsshelvesList, //货架
                       areasList: this.areaForm.warehouseAreasSaveList //库区
                     };
-                    // ...this.areaForm.allocationReqList, //货位
-                    //   ...this.areaForm.areaGoodsshelvesList, //货架
-                    //   ...this.areaForm.warehouseAreasSaveList //库区
-                    // console.log('没有处理过的===', newObj);
-                    // console.log(
-                    //   '处理过的数据===',
-                    //   this.handleNewSource(newObj)
-                    // );
                     this.loading = true;
                     console.log(this.handleNewSource(newObj));
                     try {