Преглед изворни кода

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

695593266@qq.com пре 2 месеци
родитељ
комит
03cd900845

+ 37 - 24
src/views/warehouseManagement/inventoryAllocation/add.vue

@@ -392,7 +392,7 @@
                 v-model="row.quantity" 
                 controls-position="right" 
                 :min="0" 
-                :max="row.measureQuantity"
+                :max="row.availableQuantity"
                 :precision="2"
                 style="width: 100%"
               ></el-input-number>
@@ -545,6 +545,12 @@
             showOverflowTooltip: true,
             minWidth: 110
           },
+          {
+            prop: 'availableQuantity',
+            label: '可用数量',
+            align: 'center',
+            showOverflowTooltip: true,
+          },
           {
             prop: 'measureQuantity',
             label: '计量数量',
@@ -913,13 +919,20 @@
           warehouseAreaGoodsId: this.params.outShelvesId,
           warehouseAreaGoodsShelvesId: this.params.outFreightId
         };
-        const data = await storageApi[
+        let data = await storageApi[
           this.dimension == 1 ? 'getProductList' : this.dimension == 2 ? 'getBatchList' : 'getPackingList'
         ]({
           ...params,
           pageNum: page,
           size: limit
         });
+        console.log('data------', data);
+        data.list = data.list.map(item => {
+          const measure = Number(item.measureQuantity) || 0;
+          const lock = Number(item.lockQuantity) || 0;
+          item.availableQuantity = (measure * 100 - lock * 100) / 100;
+          return item;
+        })
         return data;
       },
       onDone(res) {
@@ -1075,14 +1088,14 @@
           if(!this.params.targetFactoriesId){
             this.searchState.hasError = true;
             const errorMsg = '调入工厂不能为空';
-            this.$message.error(errorMsg);
+            this.$message.warning(errorMsg);
             return reject(new Error(errorMsg));
           }
 
           if(!this.params.inWarehouseId){
             this.searchState.hasError = true;
             const errorMsg = '调入仓库不能为空';
-            this.$message.error(errorMsg);
+            this.$message.warning(errorMsg);
             return reject(new Error(errorMsg));
           }
 
@@ -1090,7 +1103,7 @@
           if(this.tableData.some((item) => !item.quantity || item.quantity <= 0)) {
             this.searchState.hasError = true;
             const errorMsg = '调拨数量不能为0';
-            this.$message.error(errorMsg);
+            this.$message.warning(errorMsg);
             return reject(new Error(errorMsg));
           }
 
@@ -1101,7 +1114,7 @@
                 this.productList = [];
                 this.searchState.hasError = true;
                 const errorMsg = '调入货位不能与调出货位相同';
-                this.$message.error(errorMsg);
+                this.$message.warning(errorMsg);
                 return reject(new Error(errorMsg));
               }
             } else if (!this.params.inFreightId && !this.params.outFreightId) {
@@ -1110,7 +1123,7 @@
                   this.productList = [];
                   this.searchState.hasError = true;
                   const errorMsg = '调入货架不能与调出货架相同';
-                  this.$message.error(errorMsg);
+                  this.$message.warning(errorMsg);
                   return reject(new Error(errorMsg));
                 }
               } else if (!this.params.inShelvesId && !this.params.outShelvesId) {
@@ -1119,7 +1132,7 @@
                     this.productList = [];
                     this.searchState.hasError = true;
                     const errorMsg = '调入库区不能与调出库区相同';
-                    this.$message.error(errorMsg);
+                    this.$message.warning(errorMsg);
                     return reject(new Error(errorMsg));
                   }
                 } else if (
@@ -1129,27 +1142,27 @@
                   this.productList = [];
                   this.searchState.hasError = true;
                   const errorMsg = '调入库区与调出库区不能为空';
-                  this.$message.error(errorMsg);
+                  this.$message.warning(errorMsg);
                   return reject(new Error(errorMsg));
                 } else {
                   this.productList = [];
                   this.searchState.hasError = true;
                   const errorMsg = '调入库区与调出库区必须同时填写';
-                  this.$message.error(errorMsg);
+                  this.$message.warning(errorMsg);
                   return reject(new Error(errorMsg));
                 }
               } else {
                 this.productList = [];
                 this.searchState.hasError = true;
                 const errorMsg = '调入货架与调出货架必须同时填写';
-                this.$message.error(errorMsg);
+                this.$message.warning(errorMsg);
                 return reject(new Error(errorMsg));
               }
             } else {
               this.productList = [];
               this.searchState.hasError = true;
               const errorMsg = '调入货位与调出货位必须同时填写';
-              this.$message.error(errorMsg);
+              this.$message.warning(errorMsg);
               return reject(new Error(errorMsg));
             }
             // 验证通过,获取产品列表
@@ -1546,14 +1559,14 @@
             const saleOrderNos = params.allotApplyAddPOBuilders.map((item) => item.saleOrderNos);
           
             if (new Set(customerNames).size !== 1, new Set(saleOrderNos).size !== 1) {
-              return this.$message.error('不同客户,不同销售订单的产品不允许调拨');
+              return this.$message.warning('不同客户,不同销售订单的产品不允许调拨');
             } 
             storageApi.allotApplySave(params).then(() => {
               this.$message.success('保存成功');
               this.$router.go(-1);
             });
           } else {
-            this.$message.error('请调入相关数据');
+            this.$message.warning('请调入相关数据');
           }
         }).catch((error) => {
           // 验证失败,不提交数据
@@ -1637,7 +1650,7 @@
       },
       tuneClick(id, name, boolen) {
         if (!this.currentPullAreaId) {
-          return this.$message.error('请先选择调出库');
+          return this.$message.warning('请先选择调出库');
         }
         if (boolen) {
           return false;
@@ -1655,10 +1668,10 @@
       },
       async merge() {
         if (!this.params.outWarehouseId) {
-          return this.$message.error('请先选择调出仓库');
+          return this.$message.warning('请先选择调出仓库');
         }
         if (!this.params.inWarehouseId) {
-          return this.$message.error('请先选择调入仓库');
+          return this.$message.warning('请先选择调入仓库');
         }
         if (this.selection.length > 0) {
           console.log(this.selection);
@@ -1712,7 +1725,7 @@
                 console.log(this.selection[i].areaId);
                 console.log(this.params.inCargoAreaId);
                 if (this.selection[i].areaId == this.params.inCargoAreaId) {
-                  return this.$message.error('所选物品库区与调入库区重复');
+                  return this.$message.warning('所选物品库区与调入库区重复');
                 }
               }
             } else if (this.params.inShelvesId && !this.params.inFreightId) {
@@ -1724,7 +1737,7 @@
                     this.selection[i].goodsShelfId == this.params.inShelvesId
                   ) {
                     // 货架相同
-                    return this.$message.error(
+                    return this.$message.warning(
                       '所选物品库区/货架与调入库区/货架重复'
                     );
                   } else {
@@ -1748,7 +1761,7 @@
                       this.params.inFreightId
                     ) {
                       // 货位相同
-                      return this.$message.error(
+                      return this.$message.warning(
                         '所选物品库区/货架/货位与调入库区/货架/货位重复'
                       );
                     } else {
@@ -1762,7 +1775,7 @@
                 }
               }
             } else {
-              return this.$message.error('调入库区不能为空');
+              return this.$message.warning('调入库区不能为空');
             }
 
             this.selectionIds = this.selectionIds.concat(
@@ -1778,7 +1791,7 @@
                   saleOrderNos: item.saleOrderInfo?.saleOrderNos || '',
                   customerNames: item.saleOrderInfo?.customerNames || '',
                   outInDetailRecordId: item.id,
-                  quantity: item.quantity || item.measureQuantity,
+                  quantity: item.quantity || item.availableQuantity,
                   categoryId: item.categoryId,
                   warehouseId: this.params.outWarehouseId,
                   warehouseName: this.params.outWarehouseName,
@@ -1824,10 +1837,10 @@
             );
             console.log('this.tableData---------', this.tableData);
           } else {
-            this.$message.error('请选择正确的行');
+            this.$message.warning('请选择正确的行');
           }
         } else {
-          this.$message.error('请选择调出物品信息');
+          this.$message.warning('请选择调出物品信息');
         }
       }
     }

+ 36 - 5
src/views/warehouseManagement/statisticalReports/transceiverDetails/add.vue

@@ -317,7 +317,7 @@
             label: '出入库类型',
             align: 'center',
             showOverflowTooltip: true,
-            width: 150
+            width: 130
           },
           {
             prop: 'assetType',
@@ -325,7 +325,7 @@
             label: '物品类型',
             align: 'center',
             showOverflowTooltip: true,
-            width: 150
+            width: 130
           },
           {
             prop: 'categoryNames',
@@ -341,18 +341,48 @@
             showOverflowTooltip: true,
             width: 150
           },
+          {
+            prop: 'batchNo',
+            label: '批次号',
+            align: 'center',
+            showOverflowTooltip: true,
+            width: 120
+          },
+          {
+            prop: 'totalQuantity',
+            label: '数量',
+            align: 'center',
+            showOverflowTooltip: true,
+            width: 120
+          },
+          {
+            prop: 'colorKey',
+            label: '颜色',
+            align: 'center',
+            showOverflowTooltip: true,
+            width: 150
+          },
+          {
+            prop: 'modelKey',
+            label: '机型',
+            align: 'center',
+            showOverflowTooltip: true,
+            width: 120
+          },
           {
             prop: 'sourceBizNo',
             label: '来源单据',
             align: 'center',
-            showOverflowTooltip: true
+            showOverflowTooltip: true,
+            width: 120
           },
 
           {
             prop: 'createUserName',
             label: '操作人',
             align: 'center',
-            showOverflowTooltip: true
+            showOverflowTooltip: true,
+            width: 120
           },
           {
             width: 160,
@@ -365,7 +395,8 @@
             prop: 'verifyName',
             label: '审核人',
             align: 'center',
-            showOverflowTooltip: true
+            showOverflowTooltip: true,
+            width: 120
           }
           // {
           //   prop: 'verifyStatus',

+ 6 - 10
src/views/warehouseManagement/stockManagement/add.vue

@@ -369,7 +369,6 @@
                     clearable
                     v-model="row.modelKey"
                     :isOne="$index === 0"
-                    multiple
                     filterable
                     allow-create
                     default-first-option
@@ -384,7 +383,6 @@
                     clearable
                     v-model="row.colorKey"
                     :isOne="$index === 0"
-                    multiple
                     filterable
                     allow-create
                     default-first-option
@@ -645,7 +643,6 @@
                 clearable
                 v-model="row.modelKey"
                 :isOne="false"
-                multiple
                 filterable
                 allow-create
                 default-first-option
@@ -660,7 +657,6 @@
                 clearable
                 v-model="row.colorKey"
                 :isOne="false"
-                multiple
                 filterable
                 allow-create
                 default-first-option
@@ -2293,10 +2289,10 @@
             // 处理包装数据
             this.packingList = this.packingList.map((packingItem) => {
               if (packingItem.modelKey) {
-                packingItem.modelKey = packingItem.modelKey.toString();
+                packingItem.modelKey = packingItem.modelKey;
               }
               if (packingItem.colorKey) {
-                packingItem.colorKey = packingItem.colorKey.toString();
+                packingItem.colorKey = packingItem.colorKey;
               }
               return {
                 ...packingItem,
@@ -2310,10 +2306,10 @@
             // 处理产品数据
             this.productList = this.productList.map((productItem) => {
               if (productItem.modelKey) {
-                productItem.modelKey = productItem.modelKey.toString();
+                productItem.modelKey = productItem.modelKey;
               }
               if (productItem.colorKey) {
-                productItem.colorKey = productItem.colorKey.toString();
+                productItem.colorKey = productItem.colorKey;
               }
               return {
                 ...productItem,
@@ -2770,8 +2766,8 @@
             categoryCode: item.code, // 物品编码
             categoryModel: item.modelType, // 物品型号
             specification: item.specification, // 规格
-            modelKey: item.modelKey ? item.modelKey.split(',') : '', // 机型
-            colorKey: item.colorKey ? item.colorKey.split(',') : '', // 颜色
+            modelKey: item.modelKey ? item.modelKey : '', // 机型
+            colorKey: item.colorKey ? item.colorKey : '', // 颜色
             color: item.color,
             brandNum: item.brandNum, // 牌号
             batchNo: item.batchNo || batchNo, // 批次号

+ 213 - 97
src/views/warehouseManagement/warehouseDefinition/add.vue

@@ -303,9 +303,9 @@
                     >添加货架</el-button
                   >
 
-                  <!-- <el-button type="text" v-if="!row.isEdit" @click="editArea(row, $index)"
+                  <el-button type="text" v-if="!row.isEdit" @click="editArea(row, $index)"
                     >编辑</el-button
-                  > -->
+                  >
 
                   <el-button type="text" @click="removeArea($index, row)"
                     >删除库区</el-button
@@ -538,7 +538,7 @@
                   <span v-else>{{ scope.row.remark }}</span>
                 </template>
               </el-table-column>
-              <el-table-column label="操作" fixed="right" min-width="120" align="center">
+              <el-table-column label="操作" fixed="right" min-width="140" align="center">
                 <template slot-scope="{ $index, row }">
                   <el-button
                     type="text"
@@ -546,6 +546,12 @@
                     @click="saveGoods($index, row)"
                     >保存</el-button
                   >
+                  <el-button
+                    type="text"
+                    v-if="!row.isEdit"
+                    @click="editGoods($index, row)"
+                    >编辑</el-button
+                  >
                   <el-button type="text" @click="removeGoods($index, row)"
                     >删除货架</el-button
                   >
@@ -1065,9 +1071,7 @@
         const res = await warehouseDefinition.warehouseDetail(id);
         this.warehouseVO = res.warehouseVO; //仓库基本信息
         const { kq, hj, hw } = this.handleHouse(res);
-        console.log('kq~~', kq);
-        console.log('hj~~', hj);
-        console.log('hw~~', hw);
+
         this.areaForm = {
           warehouseAreasSaveList: kq || [], //库区
           areaGoodsshelvesList: hj || [], //货架
@@ -1135,8 +1139,9 @@
           inputErrorMessage: '请输入正整数'
         })
           .then(({ value }) => {
-            row.subCount = +row.subCount + +value;
             let obj = this.areaForm.warehouseAreasSaveList[index];
+            // 同步更新库区的货架数量
+            obj.subCount = +obj.subCount + +value;
 
             const pre =
               this.areaForm.areaGoodsshelvesList[
@@ -1184,6 +1189,17 @@
             item.extInfo[0].goodsAllocationWide;
         }
       },
+      async editGoods(index, row) {
+        // 校验该货架是否可编辑
+        if (row.id) {
+          const canEdit = await warehouseDefinition.isGoodsshelvesCanDelete(row.id);
+          if (!canEdit) {
+            return this.$message.warning('该货架已上架产品,无法编辑修改。');
+          }
+        }
+        console.log(index, row);
+        this.$set(this.areaForm.areaGoodsshelvesList[index], 'isEdit', true);
+      },
       saveGoods(index, row) {
         // 需要校验的字段 areaGoodsshelvesList
         let list = Object.keys(this.areaCoodsRules),
@@ -1245,53 +1261,91 @@
         if (flag) {
           this.$set(obj, 'isEdit', false);
           this.shelfObj = obj; //储存货架对象
-          let num = obj.extInfo[0].line * obj.extInfo[0].column;
 
-          this.areaIndex = index;
-          this.generateAllocation(num, obj);
-        }
-      },
-      generateAllocation(num, obj) {
-        console.log(obj);
-        const rows = Number(obj.extInfo[0].line); // 行数
-        const cols = Number(obj.extInfo[0].column); // 列数
-        
-        // 按行优先遍历:行从1到rows,列从1到cols
-        for (let row = 1; row <= rows; row++) {
-          for (let col = 1; col <= cols; col++) {
-            // 货位编号规则:货架编号-行号-列号
-            const allocationCode = `${obj.code}-${row}-${col}`;
-            
-            this.areaForm.allocationReqList.push({
-              warehouseAreaCode: obj.reservoirAreaCode,
-              warehouseAreaGoodsCode: obj.code,
-              goodsAllocationCode: allocationCode,
-              // allocationBarcode: '',
-              code: allocationCode,
+          const newRows = Number(obj.extInfo[0].line);
+          const newCols = Number(obj.extInfo[0].column);
+          const newAllocationCount = newRows * newCols;
 
-              extInfo: [
-                {
-                  goodsAllocationWide: Number(obj.extInfo[0].areaWidth),
-                  goodsAllocationHigh: Number(
-                    obj.extInfo[0].areaHigh / rows
-                  ).toFixed(0),
-                  goodsAllocationLength: Number(
-                    obj.extInfo[0].areaLength / cols
-                  ).toFixed(0),
-                  weightLimit: '',
-                  volumeUnit:
-                    Number(obj.extInfo[0].areaLength / cols).toFixed(0) *
-                    Number(obj.extInfo[0].areaHigh / rows).toFixed(0) *
-                    Number(obj.extInfo[0].areaWidth)
+          // 获取该货架原来的货位数量
+          const existingAllocationList = this.areaForm.allocationReqList.filter(
+            (item) => item.goodsShelvesCode === obj.code
+          );
+          const oldAllocationCount = existingAllocationList.length;
+          const diff = newAllocationCount - oldAllocationCount;
+
+          if (diff > 0) {
+            // 货位数量增加,在该货架已有货位后面插入新的货位
+            const lastAllocation = existingAllocationList[existingAllocationList.length - 1];
+            let startRow = 1, startCol = 1;
+            if (lastAllocation) {
+              // 解析最后一个货位的行号和列号
+              const lastCode = lastAllocation.goodsAllocationCode;
+              const parts = lastCode.split('-');
+              if (parts.length >= 2) {
+                startRow = parseInt(parts[parts.length - 2]) || 1;
+                startCol = parseInt(parts[parts.length - 1]) || 0;
+                startCol++;
+                if (startCol > newCols) {
+                  startCol = 1;
+                  startRow++;
                 }
-              ],
-              goodsShelvesCode: obj.code,
-              reservoirAreaCode: obj.reservoirAreaCode,
-              warehouseId: this.formData.id,
+              }
+            }
 
-              type: 3,
-              isEdit: true
-            });
+            // 找到该货架最后一个货位在数组中的索引
+            let lastIndex = this.areaForm.allocationReqList.findIndex(
+              (item) => item.goodsShelvesCode === obj.code
+            );
+            if (lastIndex === -1) lastIndex = this.areaForm.allocationReqList.length - 1;
+
+            // 生成新货位
+            const newAllocations = [];
+            for (let i = 0; i < diff; i++) {
+              const rowNum = startRow + Math.floor((startCol + i - 1) / newCols);
+              const colNum = ((startCol + i - 1) % newCols) + 1;
+              const allocationCode = `${obj.code}-${rowNum}-${colNum}`;
+
+              newAllocations.push({
+                warehouseAreaCode: obj.reservoirAreaCode,
+                warehouseAreaGoodsCode: obj.code,
+                goodsAllocationCode: allocationCode,
+                code: allocationCode,
+                extInfo: [
+                  {
+                    goodsAllocationWide: Number(obj.extInfo[0].areaWidth),
+                    goodsAllocationHigh: Number(
+                      obj.extInfo[0].areaHigh / newRows
+                    ).toFixed(0),
+                    goodsAllocationLength: Number(
+                      obj.extInfo[0].areaLength / newCols
+                    ).toFixed(0),
+                    weightLimit: '',
+                    volumeUnit:
+                      Number(obj.extInfo[0].areaLength / newCols).toFixed(0) *
+                      Number(obj.extInfo[0].areaHigh / newRows).toFixed(0) *
+                      Number(obj.extInfo[0].areaWidth)
+                  }
+                ],
+                goodsShelvesCode: obj.code,
+                reservoirAreaCode: obj.reservoirAreaCode,
+                warehouseId: this.formData.id,
+                type: 3,
+                isEdit: true
+              });
+            }
+
+            // 在该货架最后一个货位后面插入
+            this.areaForm.allocationReqList.splice(lastIndex + 1, 0, ...newAllocations);
+          } else if (diff < 0) {
+            // 货位数量减少,从末尾删除货位
+            let deleteCount = Math.abs(diff);
+            for (let i = this.areaForm.allocationReqList.length - 1; i >= 0 && deleteCount > 0; i--) {
+              const allocation = this.areaForm.allocationReqList[i];
+              if (allocation.goodsShelvesCode === obj.code) {
+                this.areaForm.allocationReqList.splice(i, 1);
+                deleteCount--;
+              }
+            }
           }
         }
       },
@@ -1349,13 +1403,7 @@
         ) {
           return this.$message.warning('库区编号不能重复!');
         }
-        this.hjCodeIndex = index;
-        this.hjCodeFalg = true;
-      },
-      handleMine() {
-        const index = this.hjCodeIndex;
-        const ruleName = this.hjForm.code;
-        // console.log('名称', ruleName + index + 1);
+
         this.$refs.areaFormName.validate((val) => {
           if (val) {
             this.$set(
@@ -1365,56 +1413,119 @@
             );
 
             let obj = this.areaForm.warehouseAreasSaveList[index];
-            let num = this.areaForm.warehouseAreasSaveList[index].subCount;
+            const newSubCount = obj.subCount;
 
-            const pre =
-              this.areaForm.areaGoodsshelvesList[
-                this.areaForm.areaGoodsshelvesList.length - 1
-              ];
-            let preCode = 0;
-            if (pre) {
-              preCode = +(pre.code?.substr(1) || 0);
-            }
-            let codeEng = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
-            let currentLetterIndex = 0;
+            // 获取该库区原有的货架列表
+            const existingShelfList = this.areaForm.areaGoodsshelvesList.filter(
+              (item) => item.reservoirAreaCode === obj.code
+            );
+            const oldSubCount = existingShelfList.length;
+
+            // 计算差值
+            const diff = newSubCount - oldSubCount;
 
-            if (ruleName.length > 0) {
-              // 计算初始索引
-              let multiplier = Math.pow(codeEng.length, ruleName.length - 1);
-              for (let i = 0; i < ruleName.length; i++) {
-                currentLetterIndex +=
-                  (codeEng.indexOf(ruleName[i]) + 1) * multiplier;
-                multiplier /= codeEng.length;
+            if (diff > 0) {
+              if (this.editType === 'add') {
+                // 添加库区时,弹出规则货架编号弹窗
+                this.hjCodeIndex = index;
+                this.hjCodeFalg = true;
+              } else {
+                // 编辑库区时,直接添加空白货架行
+                for (let i = 0; i < diff; i++) {
+                  this.areaForm.areaGoodsshelvesList.push({
+                    reservoirAreaCode: obj.code,
+                    warehouseId: this.formData.id,
+                    code: '',
+                    type: 2,
+                    extInfo: [
+                      {
+                        line: '',
+                        column: '',
+                        areaLength: '',
+                        areaWidth: '',
+                        areaHigh: '',
+                        isRegular: 1
+                      }
+                    ],
+                    subCount: '',
+                    remark: '',
+                    isEdit: true
+                  });
+                }
               }
+            } else if (diff < 0) {
+              // 货架数量减少,从末尾开始删除货架及其对应的货位
+              let deleteCount = Math.abs(diff);
+              for (let i = this.areaForm.areaGoodsshelvesList.length - 1; i >= 0 && deleteCount > 0; i--) {
+                const shelf = this.areaForm.areaGoodsshelvesList[i];
+                if (shelf.reservoirAreaCode === obj.code) {
+                  const shelfCode = shelf.code;
+                  // 删除该货架对应的货位
+                  this.areaForm.allocationReqList = this.areaForm.allocationReqList.filter(
+                    (item) => item.goodsShelvesCode !== shelfCode
+                  );
+                  // 删除货架
+                  this.areaForm.areaGoodsshelvesList.splice(i, 1);
+                  deleteCount--;
+                }
+              }
+              // 更新库区的货架数量
+              const remainingCount = this.areaForm.areaGoodsshelvesList.filter(
+                (item) => item.reservoirAreaCode === obj.code
+              ).length;
+              this.areaForm.warehouseAreasSaveList[index].subCount = remainingCount;
             }
+          }
+        });
+      },
+      handleMine() {
+        const index = this.hjCodeIndex;
+        const ruleName = this.hjForm.code;
+        this.$refs.areaFormName.validate((val) => {
+          if (val) {
+            this.$set(
+              this.areaForm.warehouseAreasSaveList[index],
+              'isEdit',
+              false
+            );
 
-            for (let i = 0; i < num; i++) {
-              let currentLetter = '';
-
-              // 获取当前字母
-              let index = currentLetterIndex;
-              let dividend = codeEng.length;
-              let remainder;
-              let quotient;
-              let code = '';
+            let obj = this.areaForm.warehouseAreasSaveList[index];
 
-              while (index > 0) {
-                remainder = index % dividend;
-                quotient = Math.floor(index / dividend);
+            // 获取该库区原有的货架数量
+            const existingShelfList = this.areaForm.areaGoodsshelvesList.filter(
+              (item) => item.reservoirAreaCode === obj.code
+            );
+            const oldSubCount = existingShelfList.length;
+            const newSubCount = obj.subCount;
+            const diff = newSubCount - oldSubCount;
 
-                if (remainder === 0) {
-                  remainder = codeEng.length;
-                  quotient--;
+            // 货架数量增加,添加新的货架
+            for (let i = 0; i < diff; i++) {
+              let code = '';
+              if (this.hjForm.type === 1) {
+                // 字母规则:从输入的字母开始递增(A, B, C...)
+                let codeEng = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
+                let startIndex = codeEng.indexOf(ruleName.toUpperCase());
+                if (startIndex === -1) startIndex = 0;
+                let letterIndex = startIndex + i;
+                
+                if (letterIndex < codeEng.length) {
+                  code = codeEng[letterIndex];
+                } else {
+                  // 超过26个字母时使用 AA, AB...
+                  let quotient = Math.floor(letterIndex / codeEng.length);
+                  let remainder = letterIndex % codeEng.length;
+                  code = codeEng[quotient - 1] + codeEng[remainder];
                 }
-
-                code = codeEng[remainder - 1] + code;
-                index = quotient;
+              } else {
+                // 数字规则:ruleName + 数字
+                code = ruleName + (i + 1);
               }
 
               let obj1111 = {
                 reservoirAreaCode: obj.code,
                 warehouseId: this.formData.id,
-                code: this.hjForm.type === 1 ? code : ruleName + (i + 1),
+                code: code,
                 type: 2,
                 extInfo: [
                   {
@@ -1432,8 +1543,6 @@
               };
 
               this.areaForm.areaGoodsshelvesList.push(obj1111);
-
-              currentLetterIndex++; // 自增索引
             }
 
             this.hjCodeFalg = false;
@@ -1507,7 +1616,14 @@
           this.areaForm.warehouseAreasSaveList[areaIndex].subCount = afterCount;
         }
       },
-      editArea(row, index) {
+      async editArea(row, index) {
+        // 校验该库区是否可编辑
+        if (row.id) {
+          const canEdit = await warehouseDefinition.isAreaCanDelete(row.id);
+          if (!canEdit) {
+            return this.$message.warning('该库区已上架产品,无法编辑修改。');
+          }
+        }
         this.editType = 'edit';
         row.isEdit = true;
         this.$set(this.areaForm.warehouseAreasSaveList[index], 'isEdit', true);

+ 1 - 1
vue.config.js

@@ -35,7 +35,7 @@ module.exports = {
         // target: 'http://124.71.68.31:50001',
         // target: 'http://192.168.1.132:18086',
         // target: 'http://192.168.1.105:18086', //开发
-        // target: 'http://192.168.1.251:18086', //开发
+        target: 'http://192.168.1.251:18086', //开发
         // target: 'http://192.168.1.251:18186', //测试
         // target: 'http://192.168.1.125:18086',