Jelajahi Sumber

优化包装数据处理逻辑和驳回按钮条件

yusheng 10 bulan lalu
induk
melakukan
520eaa1572

+ 1 - 1
src/views/bpm/handleTask/components/purchaseOrder/returnGoods/submit.vue

@@ -39,7 +39,7 @@
         type="danger"
         size="mini"
         @click="handleAudit(0)"
-        v-if="['storemanApprove'].includes(taskDefinitionKey)"
+
         >驳回
       </el-button>
 

+ 206 - 340
src/views/bpm/stockManagement/storage.vue

@@ -1416,7 +1416,7 @@
         // this.formData.extInfo.supplierName = this.form.supplierName;
         // this.formData.extInfo.supplierId = this.form.supplierId;
         console.log('saleProductList-------------------', this.saleProductList);
-       
+
         if (this.saleProductList?.length > 0) {
           let detailPurchaseDate;
           if (this.formData.bizType == '2' || this.formData.bizType == '10') {
@@ -1555,10 +1555,14 @@
                 pricingWay: pricingWay, //计价方式
                 purpose: '', // 用途
                 detailPurchaseDate,
-                detailExpireDate:this.saleProductList.find(product=>product.productId==item.id)?.guaranteePeriodDeadline,
-                detailProductionDate:this.saleProductList.find(product=>product.productId==item.id)?.productionDate,
-                
-                provenance:filtersItem.provenance,//产地
+                detailExpireDate: this.saleProductList.find(
+                  (product) => product.productId == item.id
+                )?.guaranteePeriodDeadline,
+                detailProductionDate: this.saleProductList.find(
+                  (product) => product.productId == item.id
+                )?.productionDate,
+
+                provenance: filtersItem.provenance, //产地
                 isUnpack: item.isUnpack, // 是否允许拆包
                 warehouseId, // 仓库id
                 warehouseName, // 仓库名称
@@ -1911,7 +1915,10 @@
                     ).index
                   : this.productList[0].index, // 产品索引
                 batchNo: this.productList[0].batchNo, // 批次号
-                packageNo: item.packageNo||item.packingCode || packingCodeList[index]?.onlyCode, // 包装编码
+                packageNo:
+                  item.packageNo ||
+                  item.packingCode ||
+                  packingCodeList[index]?.onlyCode, // 包装编码
                 packingQuantity: 1, // 包装数量
                 packingUnit: item.packingUnit, // 单位
                 measureQuantity: item.quantity, // 计量数量
@@ -3264,18 +3271,6 @@
         if (!row.measureType)
           return this.$message.warning('请到主数据维计量类型!');
 
-        // 判断是否拆包,如果是不拆包,计量单位=包装单位,则不生成包装层数据
-        if (!row.isUnpack && row.measureType != 1) {
-          // 计量单位=包装单位,则不生成包装层数据
-          if (row.measureUnit == row.packingUnit) {
-            // 直接生成物品层数据
-            this.productList[productIndex].measureQuantity =
-              row.measureQuantity;
-            this.productList[productIndex].weight = row.weight;
-            return;
-          }
-        }
-
         console.log('包装数据--------', row);
         // console.log('包装规格----', row.packingSpecificationOption);
         console.log('计量单位----', row.measureUnit);
@@ -3352,13 +3347,67 @@
         }
         console.log('num-----------', num);
 
-        if (!row.isUnpack) {
-          let packingUnit = !row.isUnpack
-            ? row.packingUnit
-            : row.packingSpecificationOption[1].conversionUnit;
-          let packingQuantity = row.packingQuantity / packingCodeList.length;
-          let measureUnit = row.measureUnit;
-          let measureQuantity = row.measureQuantity / row.packingQuantity;
+        for (let index = 0; index < packingCodeList.length; index++) {
+          let measureQuantity = 1;
+          let packingQuantity = 1;
+          let packingUnit = row.packingUnit;
+
+          // 处理单位为KG类,计算每桶KG值
+          if (packingBoolen) {
+            if (!row.isUnpack && row.packingUnit == '立方') {
+              let result =
+                row.packingQuantity /
+                row.packingSpecificationOption[1].packageCell;
+              packingQuantity = Math.ceil(result * 100) / 100;
+              console.log(packingQuantity, '包装数oppppp量');
+              measureQuantity = row.measureQuantity;
+              console.log(measureQuantity, '计量数oppppp量');
+              packingUnit = row.packingUnit;
+            } else {
+              measureQuantity =
+                Number(row.packingQuantity) >
+                this.$math.format(filterArr[0].packageCell * (index + 1), 14)
+                  ? filterArr[0].packageCell
+                  : Number(row.packingQuantity) -
+                    this.$math.format(filterArr[0].packageCell * index, 14);
+              console.log(measureQuantity, 'measureQuantity');
+            }
+          } else {
+            if (row.isUnpack == 1) {
+              console.log('1 拆--------', measureBoolen);
+              if (measureBoolen) {
+                // 处理单位不为KG类,计量单位为KG类的情况
+                let splitIndex = row.packingSpecificationOption.findIndex(
+                  (item) =>
+                    item.conversionUnit == row.packingUnit &&
+                    item.packageUnit != item.conversionUnit
+                );
+                for (; splitIndex > 0; splitIndex--) {
+                  measureQuantity = this.$math.format(
+                    measureQuantity *
+                      row.packingSpecificationOption[splitIndex].packageCell,
+                    14
+                  );
+                }
+              } else {
+                measureQuantity = row.packingSpecificationOption[1].packageCell;
+              }
+            } else {
+              console.log('4 拆--------');
+              if (row.packingQuantity) {
+                measureQuantity = row.measureQuantity / row.packingQuantity;
+              }
+            }
+            console.log(measureQuantity, 'measureQuantity');
+          }
+          let clientCode = '';
+          if (this.bizType == 2) {
+            clientCode = row?.customerMark;
+          } else if (this.bizType != 2) {
+            clientCode = row.extInfo?.clientCode;
+          }
+
+          console.log(filterArr[0], 'filterArr[0]');
           let status = null;
           //通过委外发货单编码判断是不是委外  委外收货 质检状态显示已质检
           // if (this.form.outsourceSendCode != '') {
@@ -3376,336 +3425,149 @@
           } else {
             status = 2;
           }
+          let item = {
+            index: row.index + '-' + index, // 包装索引
+            warehouseId: row.warehouseId, // 仓库id
+            warehouseName: row.warehouseName, // 仓库名称
+            categoryName: row.categoryName, // 产品名称
+            categoryCode: row.categoryCode, // 产品编码
+            categoryModel: row.categoryModel, // 物品型号
+            specification: row.specification, // 规格
+            supplierCode: row.supplierCode, // 供应商编码
+            supplierName: row.supplierName, // 供应商名称
+            brandNum: row.brandNum, // 牌号
+            parentIndex: row.index, // 产品索引
+            batchNo: row.batchNo, // 批次号
+            packageNo: packingCodeList[index]?.onlyCode, // 包装编码
+            packingQuantity: packingQuantity, // 包装数量
+
+            // packingUnit: row.isUnpack ? packingBoolen ? filterArr[0].conversionUnit : measureBoolen ? row.packingSpecificationOption[1]
+            //       ? row.packingSpecificationOption[1].conversionUnit
+            //       : row.packingSpecificationOption[0].conversionUnit
+            //     : row.measureUnit
+            //   : packingBoolen
+            //     ? row.packingUnit === '立方' ? row.packingUnit : filterArr[0]?.conversionUnit
+            //     : row.packingUnit,
+            // packingUnit: row.isUnpack ? packingBoolen ? filterArr[0].conversionUnit : measureBoolen  ? row.packingSpecificationOption[2] ?
+            //   row.packingSpecificationOption[2].conversionUnit : row.packingSpecificationOption[1].conversionUnit: row.measureUnit: packingBoolen ? filterArr[0].conversionUnit : row.packingUnit,
+
+            //!row.isUnpack &&   row.packingUnit
+
+            measureQuantity: measureQuantity, // 计量数量
+            measureUnit: row.isUnpack
+              ? measureBoolen
+                ? row.packingSpecificationOption[1]
+                  ? row.packingSpecificationOption[1].packageUnit
+                  : row.packingSpecificationOption[0].packageUnit
+                : row.measureUnit
+              : row.measureUnit, // 计量单位
+            weight: 0, // 重量
+            packingSpecificationOption: row.packingSpecificationOption, // 包装规格
+            weightUnit: row.weightUnit, // 重量单位
+            netWeight: row.netWeight, // 净重
+            barcodes: '', // 发货条码
+            clientCode: clientCode, // 客户代号
+            materielDesignation: row.extInfo ? row.extInfo.materielCode : '', // 物料代号
+            engrave: '', // 刻码
+            isUnpack: row.isUnpack, // 是否允许拆包
+            productionDate: productionDate, // 生产日期
+            purchaseDate: purchaseDate, // 采购时间
+            expireDate: expireDate, //失效日期
+
+            result: 1, // 结果(1合格 2不合格)
+            qualityControl: row.qualityControl,
+            status: status // 状态(0=未质检 1待检 2已检)
+          };
 
-          for (let index = 0; index < packingCodeList.length; index++) {
-            let item = {
-              index: row.index + '-' + index, // 包装索引
-              warehouseId: row.warehouseId, // 仓库id
-              warehouseName: row.warehouseName, // 仓库名称
-              categoryName: row.categoryName, // 产品名称
-              categoryCode: row.categoryCode, // 产品编码
-              categoryModel: row.categoryModel, // 物品型号
-              specification: row.specification, // 规格
-              supplierCode: row.supplierCode, // 供应商代号
-              supplierName: row.supplierName, // 供应商名称
-              brandNum: row.brandNum, // 牌号
-              parentIndex: row.index, // 产品索引
-              batchNo: row.batchNo, // 批次号
-              packageNo: packingCodeList[index]?.onlyCode, // 包装编码
-              packingQuantity: packingQuantity, // 包装数量
-              packingUnit: packingUnit,
-              measureQuantity: measureQuantity, // 计量数量
-              measureUnit: measureUnit, // 计量单位
-              weight: 0, // 重量
-              packingSpecificationOption: row.packingSpecificationOption, // 包装规格
-              weightUnit: row.weightUnit, // 重量单位
-              netWeight: row.netWeight, // 净重
-              barcodes: '', // 发货条码
-              clientCode: row.extInfo ? row.extInfo.clientCode : '', // 客户代号
-              materielDesignation: row.extInfo ? row.extInfo.materielCode : '', // 物料代号
-              engrave: '', // 刻码
-              isUnpack: row.isUnpack, // 是否允许拆包
-              productionDate: productionDate, // 生产日期
-              purchaseDate: purchaseDate, // 采购时间
-              expireDate: expireDate, //失效日期
-
-              result: 1, // 结果(1合格 2不合格)
-              qualityControl: row.qualityControl,
-              status: status // 状态(0=未质检 1待检 2已检)
-            };
-            let outBoolen = !!this.getDict('不拆物料层规格', item.measureUnit)
-              .dictValue;
-            if (outBoolen) {
-              // 计量单位为KG类,直接替换
-              item.weight = item.measureQuantity
-                ? Number(item.measureQuantity)
-                : 0;
+          /**
+           * packingUnit: row.isUnpack ? packingBoolen ? filterArr[0].conversionUnit : measureBoolen  ? row.packingSpecificationOption[2] ? row.packingSpecificationOption[2].conversionUnit
+           *                     : row.packingSpecificationOption[1].conversionUnit: row.measureUnit: packingBoolen ? filterArr[0].conversionUnit : row.packingUnit,
+           */
+          if (row.isUnpack) {
+            // 第二层条件: packingBoolen
+            if (packingBoolen) {
+              // 空值保护: 确保 filterArr[0] 存在
+              item.packingUnit =
+                row.packingSpecificationOption[1].conversionUnit;
             } else {
-              console.log('计量单位为不为KG类======================');
-              // 计量单位为不为KG类,重新统计计算
-              let inBoolen = !!this.getDict(
-                '不拆物料层规格',
-                item.packingSpecificationOption[0].packageUnit
-              ).dictValue;
-              let startIndex = item.packingSpecificationOption.findIndex(
-                (ite) => {
-                  return (
-                    item.measureUnit == ite.packingUnit &&
-                    ite.packingUnit != ite.conversionUnit
-                  );
-                }
-              );
-
-              let endIndex = item.packingSpecificationOption.findIndex(
-                (ite) => item.packingUnit == ite.conversionUnit
-              );
+              // 第三层条件: measureBoolen
               if (measureBoolen) {
-                let total = item.packingQuantity
-                  ? Number(item.packingQuantity)
-                  : 0;
-                for (; startIndex < endIndex; endIndex--) {
-                  total = this.$math.format(
-                    item.packingSpecificationOption[endIndex].packageCell *
-                      total,
-                    14
-                  );
-                }
-                if (inBoolen) {
-                  // 第二层为KG类
-                  item.weight = total ? Number(total) : 0;
-                } else {
-                  // 第二层不为KG类
-                  item.weight = this.$math.format(total * item.netWeight, 14);
-                }
-              } else if (!measureBoolen) {
-                if (inBoolen) {
-                  // 第二层为KG类
-                  item.weight = item.measureQuantity
-                    ? Number(item.measureQuantity)
-                    : 0;
-                } else {
-                  // 第二层不为KG类
-                  if (row.singleWeight && item.measureQuantity) {
-                    item.weight =
-                      Number(item.measureQuantity) * Number(row.singleWeight);
-                  } else {
-                    item.weight = 0;
-                  }
-                }
+                // 处理 packingSpecificationOption 的索引
+                const option =
+                  row.packingSpecificationOption?.[1] ||
+                  row.packingSpecificationOption?.[0];
+                item.packingUnit = option?.conversionUnit;
+              } else {
+                item.packingUnit =
+                  row.packingSpecificationOption[1].conversionUnit;
               }
             }
-            packingList.push(item);
-            console.log(
-              packingList,
-              'packingList!!!!!!!!!!!!!!!!!!'
-            );
           }
-        } else {
-          console.log('拆包处理', row);
-          for (let index = 0; index < packingCodeList.length; index++) {
-            let measureQuantity = 1;
-            let packingQuantity = 1;
-            let packingUnit = row.packingUnit;
-
-            // 处理单位为KG类,计算每桶KG值
-            if (packingBoolen) {
-              if (!row.isUnpack && row.packingUnit == '立方') {
-                let result =
-                  row.packingQuantity /
-                  row.packingSpecificationOption[1].packageCell;
-                packingQuantity = Math.ceil(result * 100) / 100;
-                console.log(packingQuantity, '包装数oppppp量');
-                measureQuantity = row.measureQuantity;
-                console.log(measureQuantity, '计量数oppppp量');
-                packingUnit = row.packingUnit;
-              } else {
-                measureQuantity =
-                  Number(row.packingQuantity) >
-                  this.$math.format(filterArr[0].packageCell * (index + 1), 14)
-                    ? filterArr[0].packageCell
-                    : Number(row.packingQuantity) -
-                      this.$math.format(filterArr[0].packageCell * index, 14);
-                console.log(measureQuantity, 'measureQuantity');
-              }
-            } else {
-              if (row.isUnpack == 1) {
-                console.log('1 拆--------', measureBoolen);
-                if (measureBoolen) {
-                  // 处理单位不为KG类,计量单位为KG类的情况
-                  let splitIndex = row.packingSpecificationOption.findIndex(
-                    (item) =>
-                      item.conversionUnit == row.packingUnit &&
-                      item.packageUnit != item.conversionUnit
-                  );
-                  for (; splitIndex > 0; splitIndex--) {
-                    measureQuantity = this.$math.format(
-                      measureQuantity *
-                        row.packingSpecificationOption[splitIndex].packageCell,
-                      14
-                    );
-                  }
-                } else {
-                  measureQuantity =
-                    row.packingSpecificationOption[1].packageCell;
-                }
-              } else {
-                console.log('4 拆--------');
-                if (row.packingQuantity) {
-                  measureQuantity = row.measureQuantity / row.packingQuantity;
-                }
+          let outBoolen = !!this.getDict('不拆物料层规格', item.measureUnit)
+            .dictValue;
+          if (outBoolen) {
+            // 计量单位为KG类,直接替换
+            item.weight = item.measureQuantity
+              ? Number(item.measureQuantity)
+              : 0;
+          } else {
+            console.log('计量单位为不为KG类======================');
+            // 计量单位为不为KG类,重新统计计算
+            let inBoolen = !!this.getDict(
+              '不拆物料层规格',
+              item.packingSpecificationOption[0].packageUnit
+            ).dictValue;
+            let startIndex = item.packingSpecificationOption.findIndex(
+              (ite) => {
+                return (
+                  item.measureUnit == ite.packingUnit &&
+                  ite.packingUnit != ite.conversionUnit
+                );
               }
-              console.log(measureQuantity, 'measureQuantity');
-            }
-            let clientCode = '';
-            if (this.bizType == 2) {
-              clientCode = row?.customerMark;
-            } else if (this.bizType != 2) {
-              clientCode = row.extInfo?.clientCode;
-            }
-
-            console.log(filterArr[0], 'filterArr[0]');
-            let status = null;
-            //通过委外发货单编码判断是不是委外  委外收货 质检状态显示已质检
-            // if (this.form.outsourceSendCode != '') {
-            //   status = 2;
-            // } else {
-            //   // 0未检 1待检 2 已检
-            //   if (row.qualityControl == 1) {
-            //     status = 0;
-            //   } else {
-            //     status = 2;
-            //   }
-            // }
-            if (row.qualityControl == 1) {
-              status = 0;
-            } else {
-              status = 2;
-            }
-            let item = {
-              index: row.index + '-' + index, // 包装索引
-              warehouseId: row.warehouseId, // 仓库id
-              warehouseName: row.warehouseName, // 仓库名称
-              categoryName: row.categoryName, // 产品名称
-              categoryCode: row.categoryCode, // 产品编码
-              categoryModel: row.categoryModel, // 物品型号
-              specification: row.specification, // 规格
-              supplierCode: row.supplierCode, // 供应商编码
-              supplierName: row.supplierName, // 供应商名称
-              brandNum: row.brandNum, // 牌号
-              parentIndex: row.index, // 产品索引
-              batchNo: row.batchNo, // 批次号
-              packageNo: packingCodeList[index]?.onlyCode, // 包装编码
-              packingQuantity: packingQuantity, // 包装数量
-
-              // packingUnit: row.isUnpack ? packingBoolen ? filterArr[0].conversionUnit : measureBoolen ? row.packingSpecificationOption[1]
-              //       ? row.packingSpecificationOption[1].conversionUnit
-              //       : row.packingSpecificationOption[0].conversionUnit
-              //     : row.measureUnit
-              //   : packingBoolen
-              //     ? row.packingUnit === '立方' ? row.packingUnit : filterArr[0]?.conversionUnit
-              //     : row.packingUnit,
-              // packingUnit: row.isUnpack ? packingBoolen ? filterArr[0].conversionUnit : measureBoolen  ? row.packingSpecificationOption[2] ?
-              //   row.packingSpecificationOption[2].conversionUnit : row.packingSpecificationOption[1].conversionUnit: row.measureUnit: packingBoolen ? filterArr[0].conversionUnit : row.packingUnit,
-
-              //!row.isUnpack &&   row.packingUnit
-
-              measureQuantity: measureQuantity, // 计量数量
-              measureUnit: row.isUnpack
-                ? measureBoolen
-                  ? row.packingSpecificationOption[1]
-                    ? row.packingSpecificationOption[1].packageUnit
-                    : row.packingSpecificationOption[0].packageUnit
-                  : row.measureUnit
-                : row.measureUnit, // 计量单位
-              weight: 0, // 重量
-              packingSpecificationOption: row.packingSpecificationOption, // 包装规格
-              weightUnit: row.weightUnit, // 重量单位
-              netWeight: row.netWeight, // 净重
-              barcodes: '', // 发货条码
-              clientCode: clientCode, // 客户代号
-              materielDesignation: row.extInfo ? row.extInfo.materielCode : '', // 物料代号
-              engrave: '', // 刻码
-              isUnpack: row.isUnpack, // 是否允许拆包
-              productionDate: productionDate, // 生产日期
-              purchaseDate: purchaseDate, // 采购时间
-              expireDate: expireDate, //失效日期
-
-              result: 1, // 结果(1合格 2不合格)
-              qualityControl: row.qualityControl,
-              status: status // 状态(0=未质检 1待检 2已检)
-            };
+            );
 
-            /**
-             * packingUnit: row.isUnpack ? packingBoolen ? filterArr[0].conversionUnit : measureBoolen  ? row.packingSpecificationOption[2] ? row.packingSpecificationOption[2].conversionUnit
-             *                     : row.packingSpecificationOption[1].conversionUnit: row.measureUnit: packingBoolen ? filterArr[0].conversionUnit : row.packingUnit,
-             */
-            if (row.isUnpack) {
-              // 第二层条件: packingBoolen
-              if (packingBoolen) {
-                // 空值保护: 确保 filterArr[0] 存在
-                item.packingUnit =
-                  row.packingSpecificationOption[1].conversionUnit;
+            let endIndex = item.packingSpecificationOption.findIndex(
+              (ite) => item.packingUnit == ite.conversionUnit
+            );
+            if (measureBoolen) {
+              let total = item.packingQuantity
+                ? Number(item.packingQuantity)
+                : 0;
+              for (; startIndex < endIndex; endIndex--) {
+                total = this.$math.format(
+                  item.packingSpecificationOption[endIndex].packageCell * total,
+                  14
+                );
+              }
+              if (inBoolen) {
+                // 第二层为KG类
+                item.weight = total ? Number(total) : 0;
               } else {
-                // 第三层条件: measureBoolen
-                if (measureBoolen) {
-                  // 处理 packingSpecificationOption 的索引
-                  const option =
-                    row.packingSpecificationOption?.[1] ||
-                    row.packingSpecificationOption?.[0];
-                  item.packingUnit = option?.conversionUnit;
-                } else {
-                  item.packingUnit =
-                    row.packingSpecificationOption[1].conversionUnit;
-                }
+                // 第二层不为KG类
+                item.weight = this.$math.format(total * item.netWeight, 14);
               }
-            }
-            let outBoolen = !!this.getDict('不拆物料层规格', item.measureUnit)
-              .dictValue;
-            if (outBoolen) {
-              // 计量单位为KG类,直接替换
-              item.weight = item.measureQuantity
-                ? Number(item.measureQuantity)
-                : 0;
-            } else {
-              console.log('计量单位为不为KG类======================');
-              // 计量单位为不为KG类,重新统计计算
-              let inBoolen = !!this.getDict(
-                '不拆物料层规格',
-                item.packingSpecificationOption[0].packageUnit
-              ).dictValue;
-              let startIndex = item.packingSpecificationOption.findIndex(
-                (ite) => {
-                  return (
-                    item.measureUnit == ite.packingUnit &&
-                    ite.packingUnit != ite.conversionUnit
-                  );
-                }
-              );
-
-              let endIndex = item.packingSpecificationOption.findIndex(
-                (ite) => item.packingUnit == ite.conversionUnit
-              );
-              if (measureBoolen) {
-                let total = item.packingQuantity
-                  ? Number(item.packingQuantity)
+            } else if (!measureBoolen) {
+              if (inBoolen) {
+                // 第二层为KG类
+                item.weight = item.measureQuantity
+                  ? Number(item.measureQuantity)
                   : 0;
-                for (; startIndex < endIndex; endIndex--) {
-                  total = this.$math.format(
-                    item.packingSpecificationOption[endIndex].packageCell *
-                      total,
-                    14
-                  );
-                }
-                if (inBoolen) {
-                  // 第二层为KG类
-                  item.weight = total ? Number(total) : 0;
-                } else {
-                  // 第二层不为KG类
-                  item.weight = this.$math.format(total * item.netWeight, 14);
-                }
-              } else if (!measureBoolen) {
-                if (inBoolen) {
-                  // 第二层为KG类
-                  item.weight = item.measureQuantity
-                    ? Number(item.measureQuantity)
-                    : 0;
+              } else {
+                // 第二层不为KG类
+                if (row.singleWeight && item.measureQuantity) {
+                  item.weight =
+                    Number(item.measureQuantity) * Number(row.singleWeight);
                 } else {
-                  // 第二层不为KG类
-                  if (row.singleWeight && item.measureQuantity) {
-                    item.weight =
-                      Number(item.measureQuantity) * Number(row.singleWeight);
-                  } else {
-                    item.weight = 0;
-                  }
+                  item.weight = 0;
                 }
               }
             }
-            packingList.push(item);
-            console.log(
-              packingList,
-              'packingList!!!!!!!!!!!!!!!!!!拆'
-            );
           }
+          packingList.push(item);
+          console.log(
+            packingList,
+            'packingList!!!!!!!!!!!!!!!!!!拆'
+          );
         }
 
         // 单独点击保存并插入对应位置(包装)
@@ -3724,7 +3586,11 @@
           row.measureQuantity % row.packingSpecificationOption[1]?.packageCell;
         console.log(remainder, 'remainder');
         if (remainder > 0) {
-          this.$set(this.packingList[lastIndex], 'measureQuantity', remainder);
+          let onlyCode = packingCodeList[packingCodeList.length - 1]?.onlyCode;
+          let index = this.packingList.findIndex(
+            (packingItem) => packingItem.packageNo == onlyCode
+          );
+          this.$set(this.packingList[index], 'measureQuantity', remainder);
         }
 
         // 单独点击保存并插入对应位置(物料)