|
|
@@ -1464,7 +1464,7 @@
|
|
|
let codeList = this.saleProductList.map((item) => {
|
|
|
return item.productCode || item.categoryCode;
|
|
|
});
|
|
|
- storageApi.getListByNameOrModeType({ codeList, queryConditions: this.saleProductList }).then(async (res) => {
|
|
|
+ storageApi.getListByNameOrModeType({ codeList }).then(async (res) => {
|
|
|
if (res.length <= 0) {
|
|
|
this.$message.warning('未获取到物品信息!');
|
|
|
return;
|
|
|
@@ -1473,7 +1473,6 @@
|
|
|
this.formData.extInfo.assetType = Array.from(
|
|
|
new Set(res.map((item) => item.categoryLevelPathIdParent))
|
|
|
);
|
|
|
- console.log(this.formData.extInfo.assetType, '类型类型');
|
|
|
|
|
|
// 获取批次号
|
|
|
const batchNo1 = await getCode('lot_number_code');
|
|
|
@@ -1486,7 +1485,6 @@
|
|
|
await storageApi.getCategoryPackageDisposition({
|
|
|
categoryIds: res.map((item) => item.id)
|
|
|
});
|
|
|
- console.log(packingSpecification);
|
|
|
|
|
|
this.packingSpecificationOption = res.map((item) => {
|
|
|
return packingSpecification
|
|
|
@@ -1494,93 +1492,59 @@
|
|
|
.sort((a, b) => a.sort - b.sort);
|
|
|
});
|
|
|
|
|
|
- this.productList = res.map((item, index) => {
|
|
|
- let filtersItem = this.saleProductList.find(
|
|
|
- (detailItem) =>
|
|
|
- (item.code == detailItem.productCode ||
|
|
|
- item.code == detailItem.categoryCode) && item.colorKey == detailItem.colorKey && item.modelType == detailItem.modelType && item.batchNo == detailItem.batchNo
|
|
|
- );
|
|
|
- // let filtersItem = this.saleProductList.filter(
|
|
|
- // (detailItem) =>
|
|
|
- // detailItem.productCode || detailItem.categoryCode == item.code
|
|
|
- // )[0];
|
|
|
+ // 预处理:建立 res 的 Map 索引,用于快速查找物品详情
|
|
|
+ const resMap = new Map(
|
|
|
+ res.map((item) => [item.code, item])
|
|
|
+ );
|
|
|
|
|
|
- // 显示规格
|
|
|
- let packingSpecificationLabel = this.packingSpecificationOption[
|
|
|
- index
|
|
|
- ]
|
|
|
- .map((item) => {
|
|
|
- if (item.sort > 0) {
|
|
|
- return `${item.packageCell}${item.packageUnit}/${item.conversionUnit}`;
|
|
|
- }
|
|
|
- })
|
|
|
- .filter((item) => !!item);
|
|
|
+ // 预处理:获取包装规格选项
|
|
|
+ const newSpecificationOption = this.getNewSpecificationOption(this.packingSpecificationOption);
|
|
|
|
|
|
- const newSpecificationOption = this.getNewSpecificationOption(
|
|
|
- this.packingSpecificationOption
|
|
|
- );
|
|
|
- console.log(newSpecificationOption, '啵啵啵啵啵啵啵啵啵啵啵啵2');
|
|
|
+ // 预处理:计算包装规格显示标签
|
|
|
+ const packingSpecificationLabels = (this.packingSpecificationOption || []).map((specArr) =>
|
|
|
+ (specArr || [])
|
|
|
+ .filter((s) => s.sort > 0)
|
|
|
+ .map((s) => `${s.packageCell}${s.packageUnit}/${s.conversionUnit}`)
|
|
|
+ );
|
|
|
+
|
|
|
+ // 以 saleProductList 为主循环,匹配 res 中的物品信息
|
|
|
+ this.productList = this.saleProductList.map((saleItem, index) => {
|
|
|
+ // 通过 productCode 或 categoryCode 匹配 res 中的物品详情
|
|
|
+ const item = resMap.get(saleItem.productCode) || resMap.get(saleItem.categoryCode);
|
|
|
|
|
|
- console.log(filtersItem, 'filtersItemfiltersItemfiltersItem');
|
|
|
+ if (!item) return null;
|
|
|
+
|
|
|
+ // 显示规格
|
|
|
+ let packingSpecificationLabel = packingSpecificationLabels[index] || [];
|
|
|
|
|
|
- let warehouseId = filtersItem.warehouseId;
|
|
|
- let warehouseName = filtersItem.warehouseName;
|
|
|
- let measureQuantity =
|
|
|
- filtersItem.totalCountNew || filtersItem.totalCount || 0;
|
|
|
- // let measureQuantityOld = filtersItem.totalCount || 0;
|
|
|
+ let warehouseId = saleItem.warehouseId;
|
|
|
+ let warehouseName = saleItem.warehouseName;
|
|
|
+ let measureQuantity = saleItem.totalCountNew || saleItem.totalCount || 0;
|
|
|
if (
|
|
|
- (filtersItem.sendTotalWeight ||
|
|
|
- filtersItem.receiveTotalWeight) &&
|
|
|
+ (saleItem.sendTotalWeight || saleItem.receiveTotalWeight) &&
|
|
|
item.weightUnit == item.measuringUnit
|
|
|
) {
|
|
|
- measureQuantity =
|
|
|
- filtersItem.sendTotalWeight || filtersItem.receiveTotalWeight;
|
|
|
+ measureQuantity = saleItem.sendTotalWeight || saleItem.receiveTotalWeight;
|
|
|
}
|
|
|
- let packingQuantity =
|
|
|
- filtersItem.totalCountNew ||
|
|
|
- filtersItem.purchaseCount ||
|
|
|
- filtersItem.totalCount ||
|
|
|
- 0;
|
|
|
- console.log(packingQuantity, 'packingQudasdasdantity');
|
|
|
- let packingUnit =
|
|
|
- filtersItem.purchaseUnit || filtersItem.measuringUnit || '';
|
|
|
-
|
|
|
- let unitPrice = filtersItem.singlePrice || 0;
|
|
|
- let pricingWay = filtersItem.pricingWay || '';
|
|
|
- let singleWeight =
|
|
|
- filtersItem.singleWeight ||
|
|
|
- this.detailProductList[0]?.singleWeight ||
|
|
|
- 0;
|
|
|
- let weight =
|
|
|
- filtersItem.sendTotalWeight ||
|
|
|
- filtersItem.receiveTotalWeight ||
|
|
|
- singleWeight * measureQuantity;
|
|
|
- console.log(weight, 'weight');
|
|
|
- // if(weight){
|
|
|
+ let packingQuantity = saleItem.totalCountNew || saleItem.purchaseCount || saleItem.totalCount || 0;
|
|
|
+ let packingUnit = saleItem.purchaseUnit || saleItem.measuringUnit || '';
|
|
|
+ let unitPrice = saleItem.singlePrice || 0;
|
|
|
+ let pricingWay = saleItem.pricingWay || '';
|
|
|
+ let singleWeight = saleItem.singleWeight || this.detailProductList[0]?.singleWeight || 0;
|
|
|
+ let weight = saleItem.sendTotalWeight || saleItem.receiveTotalWeight || singleWeight * measureQuantity;
|
|
|
|
|
|
- // }
|
|
|
// 获取相同仓库
|
|
|
let warehouseIds = [];
|
|
|
let warehouseNames = [];
|
|
|
- for (let i = 0; i < filtersItem.totalCount; i++) {
|
|
|
- warehouseIds.push(filtersItem.warehouseId);
|
|
|
- warehouseNames.push(filtersItem.warehouseName);
|
|
|
- }
|
|
|
- let totalMoney = filtersItem.totalPrice || 0;
|
|
|
- console.log(
|
|
|
- filtersItem,
|
|
|
- 'filtersItemfiltersItemfiltersItemfiltersItemfiltersItem'
|
|
|
- );
|
|
|
-
|
|
|
- let batchNo = '';
|
|
|
- if (filtersItem.batchNo) {
|
|
|
- batchNo = filtersItem.batchNo;
|
|
|
- } else {
|
|
|
- batchNo = batchNo1;
|
|
|
+ for (let i = 0; i < saleItem.totalCount; i++) {
|
|
|
+ warehouseIds.push(saleItem.warehouseId);
|
|
|
+ warehouseNames.push(saleItem.warehouseName);
|
|
|
}
|
|
|
+ let totalMoney = saleItem.totalPrice || 0;
|
|
|
+ let batchNo = saleItem.batchNo || batchNo1;
|
|
|
|
|
|
return {
|
|
|
- index: this.productList.length + index,
|
|
|
+ index: index,
|
|
|
categoryId: item.id, // 物品id
|
|
|
categoryName: item.name, // 物品名称
|
|
|
categoryCode: item.code, // 物品编码
|
|
|
@@ -1590,50 +1554,20 @@
|
|
|
batchNo: batchNo, // 批次号
|
|
|
supplierListOptions: supplierList[item.id], // 供应商列表
|
|
|
supplierId: this.form.supplierId, // 供应商id
|
|
|
- productionRequirements: filtersItem.productionRequirements, //生产要求
|
|
|
- supplierCode:
|
|
|
- this.bizType == 2 || this.bizType == 7
|
|
|
- ? filtersItem.supplierMark
|
|
|
- : item.supplierCode, // 供应商代号
|
|
|
+ productionRequirements: saleItem.productionRequirements, // 生产要求
|
|
|
+ supplierCode: this.bizType == 2 || this.bizType == 7 ? saleItem.supplierMark : item.supplierCode, // 供应商代号
|
|
|
supplierName: this.form.supplierName, // 供应商名称
|
|
|
approvalNumber: item.approvalNumber, // 批准文号
|
|
|
packingSpecification: item.packingSpecification, // 包装规格
|
|
|
- packingSpecificationOption: newSpecificationOption[index], // 包装规格选项
|
|
|
+ packingSpecificationOption: newSpecificationOption?.[index] || [], // 包装规格选项
|
|
|
packingSpecificationLabel: packingSpecificationLabel, // 包装规格显示
|
|
|
- // minPackingQuantity: minPackingQuantity, // 最小包装单元数量
|
|
|
- packingQuantity:
|
|
|
- this.saleProductList[index] &&
|
|
|
- this.saleProductList[index].isAllPackageData &&
|
|
|
- this.saleProductList[index].isAllPackageData == 1
|
|
|
- ? this.saleProductList[index].packingCount
|
|
|
- : packingQuantity, // 包装数量
|
|
|
- packingUnit:
|
|
|
- this.saleProductList[index] &&
|
|
|
- this.saleProductList[index].isAllPackageData &&
|
|
|
- this.saleProductList[index].isAllPackageData == 1
|
|
|
- ? this.saleProductList[index].packingUnit
|
|
|
- : packingUnit, // 单位
|
|
|
- measureQuantity:
|
|
|
- this.saleProductList[index] &&
|
|
|
- this.saleProductList[index].isAllPackageData &&
|
|
|
- this.saleProductList[index].isAllPackageData == 1
|
|
|
- ? this.saleProductList[index].quantity
|
|
|
- : measureQuantity, // 计量数量
|
|
|
- // measureQuantityOld,
|
|
|
- measureUnit:
|
|
|
- this.saleProductList[index] &&
|
|
|
- this.saleProductList[index].isAllPackageData &&
|
|
|
- this.saleProductList[index].isAllPackageData == 1
|
|
|
- ? this.saleProductList[index].measuringUnit
|
|
|
- : item.measuringUnit, // 计量单位
|
|
|
- packingUnitId:
|
|
|
- filtersItem.purchaseUnitId || filtersItem.saleUnitId,
|
|
|
- modelKey: filtersItem.modelKey
|
|
|
- ? filtersItem.modelKey.split(',')
|
|
|
- : '', // 机型
|
|
|
- colorKey: filtersItem.colorKey
|
|
|
- ? filtersItem.colorKey.split(',')
|
|
|
- : '', // 颜色
|
|
|
+ packingQuantity: saleItem.isAllPackageData == 1 ? saleItem.packingCount : packingQuantity, // 包装数量
|
|
|
+ packingUnit: saleItem.isAllPackageData == 1 ? saleItem.packingUnit : packingUnit, // 单位
|
|
|
+ measureQuantity: saleItem.isAllPackageData == 1 ? saleItem.quantity : measureQuantity, // 计量数量
|
|
|
+ measureUnit: saleItem.isAllPackageData == 1 ? saleItem.measuringUnit : item.measuringUnit, // 计量单位
|
|
|
+ packingUnitId: saleItem.purchaseUnitId || saleItem.saleUnitId,
|
|
|
+ modelKey: saleItem.modelKey ? saleItem.modelKey.split(',') : [], // 机型
|
|
|
+ colorKey: saleItem.colorKey ? saleItem.colorKey.split(',') : [], // 颜色
|
|
|
measureType: item.measureType, // 计量方式
|
|
|
netWeight: item.netWeight > -1 ? item.netWeight : 0, // 净重
|
|
|
singleWeight: singleWeight || 0, // 单重重量
|
|
|
@@ -1641,29 +1575,23 @@
|
|
|
weightUnit: item.weightUnit, // 重量单位
|
|
|
totalMoney: totalMoney, // 总价
|
|
|
unitPrice: item.unitPrice || unitPrice, // 单价
|
|
|
- pricingWay: pricingWay, //计价方式
|
|
|
+ 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: saleItem.guaranteePeriodDeadline, // 保质期截止日期
|
|
|
+ detailProductionDate: saleItem.productionDate, // 生产日期
|
|
|
+ provenance: saleItem.provenance, // 产地
|
|
|
isUnpack: item.isUnpack, // 是否允许拆包
|
|
|
warehouseId, // 仓库id
|
|
|
warehouseName, // 仓库名称
|
|
|
warehouseIds,
|
|
|
warehouseNames,
|
|
|
- qualityControl: filtersItem?.isComeCheck // 是否需要质检
|
|
|
+ qualityControl: saleItem?.isComeCheck // 是否需要质检
|
|
|
};
|
|
|
- });
|
|
|
- console.log(this.productList, 'this.productListtttttttttttt');
|
|
|
+ }).filter(Boolean);
|
|
|
+
|
|
|
this.$nextTick(() => {
|
|
|
this.batchSave();
|
|
|
- // this.listSaveArrs()
|
|
|
});
|
|
|
});
|
|
|
}
|