generateWrappers(row, productIndex, packingCodeList) {
  console.log(packingCodeList, 'packingCodeList')
  // 判断是否拆包，如果是不拆包，计量单位=包装单位，则不生成包装层数据
  // if (!row.isUnpack && 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);
  let packingList = [];
  let obj = this.getNowDate();
  let productionDate = '';
  let purchaseDate = '';
  if (this.formData.bizType == '1') {
      // 生产入库
      productionDate = `${obj.year}-${obj.month}-${obj.strDate} ${obj.hour}:${obj.minute}:${obj.second}`;
      this.curDateType = 'productionDate';
  } else if (this.formData.bizType == '2') {
      // 采购入库
      purchaseDate = `${obj.year}-${obj.month}-${obj.strDate} ${obj.hour}:${obj.minute}:${obj.second}`;
      this.curDateType = 'purchaseDate';
  }


  // 判断单位和计量单位是否为不拆物料层规格
  let packingBoolen = !!this.getDict('不拆物料层规格', row.packingUnit)
    .dictValue;
  let measureBoolen = !!this.getDict('不拆物料层规格', row.measureUnit)
    .dictValue;

  let num = row.packingQuantity;
  let filterArr = [];
  // 处理单位为KG类的情况
  if (packingBoolen) {
      console.log(packingBoolen, 'packingBoolenpackingBoolenpackingBoolenpackingBoolenpackingBoolenpackingBoolen')
      if (!row.isUnpack && row.packingUnit == '立方') {
          num = 1;
      } else {
          filterArr = row.packingSpecificationOption.filter((item) => {
              return (
                  item.packageUnit == row.packingUnit &&
                  item.packageUnit != item.conversionUnit
              );
          });
          num = Math.ceil(row.packingQuantity / filterArr[0]?.packageCell);
      }

  } else {
      // if (row.isUnpack == 1) {
      if (measureBoolen) {
          // 处理单位不为KG类,计量单位为KG类的情况
          let splitIndex = row.packingSpecificationOption.findIndex(
              (item) =>
                  item.conversionUnit == row.packingUnit &&
                  item.packageUnit != item.conversionUnit
          );
          for (; splitIndex > 1; splitIndex--) {
              num = this.$math.format(
                  num * row.packingSpecificationOption[splitIndex].packageCell,
                  14
              );
          }
      } else {
          num = Math.ceil(
              row.measureQuantity / row.packingSpecificationOption[1]?.packageCell
          );
      }
  }
  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 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, // 供应商编码
              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, // 采购时间
              result: 1, // 结果(1合格 2不合格)
              status: 2 // 状态(0=未质检 1待检 2已检)
          };
          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) : 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;
                      }
                  }
              }
          }
          packingList.push(item);
          console.log(
              packingList,
              'packingList！！！！！！！！！！！！！！！！！！'
          );
      }
  } else {
      for (let index = 0; index < num; 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;

                      console.log('3 拆--------', measureQuantity)

                  }
              } else {
                  console.log('4 拆--------')
                  if (row.packingQuantity) {
                      measureQuantity = row.measureQuantity / row.packingQuantity;
                  }
              }
              console.log(measureQuantity, 'measureQuantity')
          }
          console.log(filterArr[0], 'filterArr[0]')

          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, // 供应商编码
              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,

              measureQuantity: row.isUnpack
                ? packingBoolen
                  ? measureQuantity
                  : measureBoolen
                    ? row.packingSpecificationOption[1]
                      ? row.packingSpecificationOption[1].packageCell
                      : row.packingSpecificationOption[0].packageCell
                    : 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: row.extInfo ? row.extInfo.clientCode : '', // 客户代号
              materielDesignation: row.extInfo ? row.extInfo.materielCode : '', // 物料代号
              engrave: '', // 刻码
              isUnpack: row.isUnpack, // 是否允许拆包
              productionDate: productionDate, // 生产日期
              purchaseDate: purchaseDate, // 采购时间
              result: 1, // 结果(1合格 2不合格)
              status: 2 // 状态(0=未质检 1待检 2已检)
          };
          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) : 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;
                      }
                  }
              }
          }
          packingList.push(item);
          console.log(
              packingList,
              'packingList！！！！！！！！！！！！！！！！！！'
          );
      }
  }

  // 单独点击保存并插入对应位置(包装)
  if (productIndex == 0) {
      this.packingList.splice(productIndex, 0, ...packingList);
  } else {
      let packingIndex = this.packingList.findLastIndex(
          (item) =>
              item.parentIndex == this.productList[productIndex - 1].index
      );
      this.packingList.splice(packingIndex + 1, 0, ...packingList);
  }

  // 单独点击保存并插入对应位置(物料)
  // let materialList = packingList
  //   .map((item) => {
  //     if (item.isUnpack) {
  //       return this.generateMaterial(item);
  //     } else {
  //       return [];
  //     }
  //   })
  //   .flat();
  // console.log(materialList);
  // if (materialList.length > 0) {
  //   if (productIndex == 0) {
  //     this.materialList.splice(0, 0, ...materialList);
  //   } else {
  //     let preLastPackingIndex = this.packingList.findLastIndex((ite) => {
  //       return ite.parentIndex <= productIndex - 1 && ite.isUnpack;
  //     });
  //     let preLastMaterialIndex = this.materialList.findLastIndex(
  //       (ite) => {
  //         return (
  //           ite.parentIndex == this.packingList[preLastPackingIndex].index
  //         );
  //       }
  //     );
  //     this.materialList.splice(
  //       preLastMaterialIndex + 1,
  //       0,
  //       ...materialList
  //     );
  //   }
  // }
},