fix: 修改小结组件不显示赔偿

This commit is contained in:
wjh 2024-03-27 13:12:52 +08:00
parent 404a7b663b
commit 629fff170f
2 changed files with 55 additions and 47 deletions

View File

@ -161,10 +161,14 @@ const subtotal = (rule: any, itemData: any, productCategory: any, reqWeightRules
let unit: string; let unit: string;
if (rule?.conversion_logic_id === ConversionLogics.Keep) { if (rule?.conversion_logic_id === ConversionLogics.Keep) {
count = itemData.count; count = itemData.count;
unit = item ? rule.unit : productCategory.unit; unit = item ? rule.unit || '' : productCategory.unit || '';
} else if (rule?.conversion_logic_id === ConversionLogics.Product) { } else if (rule?.conversion_logic_id === ConversionLogics.Product) {
count = productCategory.convertible ? itemData.count * itemData.product.ratio : itemData.count; count = productCategory.convertible ? itemData.count * itemData.product.ratio : itemData.count;
unit = item ? rule.unit : productCategory.convertible ? productCategory.conversion_unit : productCategory.unit; unit = item
? rule.unit || ''
: productCategory.convertible
? productCategory.conversion_unit || ''
: productCategory.unit || '';
} else if (rule?.conversion_logic_id === ConversionLogics.ProductWeight) { } else if (rule?.conversion_logic_id === ConversionLogics.ProductWeight) {
count = item ? itemData.count : (itemData.count * itemData.product.weight) / 1000; count = item ? itemData.count : (itemData.count * itemData.product.weight) / 1000;
unit = '吨'; unit = '吨';
@ -181,11 +185,13 @@ const subtotal = (rule: any, itemData: any, productCategory: any, reqWeightRules
); );
if (!weightRule) return; if (!weightRule) return;
if (weightRule.conversion_logic_id === ConversionLogics.Keep) { if (weightRule.conversion_logic_id === ConversionLogics.Keep) {
count = ((itemData.count || 0) * weightRule.weight) / 1000; count = item ? (itemData.count || 0) * weightRule.weight : ((itemData.count || 0) * weightRule.weight) / 1000;
unit = '吨'; unit = '吨';
} else if (weightRule.conversion_logic_id === ConversionLogics.Product) { } else if (weightRule.conversion_logic_id === ConversionLogics.Product) {
const sacl = productCategory.convertible ? itemData.product.ratio : 1; const sacl = productCategory.convertible ? itemData.product.ratio : 1;
count = ((itemData.count || 0) * sacl * weightRule.weight) / 1000; count = item
? (itemData.count || 0) * sacl * weightRule.weight
: ((itemData.count || 0) * sacl * weightRule.weight) / 1000;
unit = '吨'; unit = '吨';
} }
} }

View File

@ -5,7 +5,7 @@ import { CustomComponentType, CustomFC, CustomFunctionComponent } from '@hera/pl
import React from 'react'; import React from 'react';
import _ from 'lodash'; import _ from 'lodash';
import { formatCurrency, formatQuantity } from '../../utils/currencyUtils'; import { formatCurrency, formatQuantity } from '../../utils/currencyUtils';
import { useCachedRequest, useLeaseItems } from '../hooks'; import { useCachedRequest, useLeaseItems, useProductFeeItems } from '../hooks';
import { RecordItems } from '../../interfaces/records'; import { RecordItems } from '../../interfaces/records';
const cache = []; const cache = [];
export const RecordSummary = observer((): any => { export const RecordSummary = observer((): any => {
@ -75,53 +75,55 @@ export const RecordSummary = observer((): any => {
// 报价小结 // 报价小结
const quoteSummary = {}; const quoteSummary = {};
form.values.items?.forEach((item) => { form.values.items?.forEach((item) => {
if (!item.product || !item.count) return;
const element = _.cloneDeep(item);
// 获取产品的分类数据信息
const productCategory = reqProduct.data.data?.find( const productCategory = reqProduct.data.data?.find(
(product) => product.category_id === element.product?.category_id, (product) => product.category_id === item.product?.category_id,
)?.category; )?.category;
if (!productCategory) return; if (!(JSON.stringify(productCategory?.attr) === `["6"]`)) {
element.product.category = productCategory; if (!item.product || !item.count) return;
// 基础小结 const element = _.cloneDeep(item);
const { calc } = summary(element, null, null); // 获取产品的分类数据信息
weight.total += calc.weight / 1000; if (!productCategory) return;
calcProductCount(summaryProduct, calc, productCategory); element.product.category = productCategory;
// 合同小结(租赁出入库单/租赁直发单) // 基础小结
const { calc } = summary(element, null, null);
weight.total += calc.weight / 1000;
calcProductCount(summaryProduct, calc, productCategory);
// 合同小结(租赁出入库单/租赁直发单)
if (form.values.category === RecordCategory.lease || form.values.category === RecordCategory.lease2lease) { if (form.values.category === RecordCategory.lease || form.values.category === RecordCategory.lease2lease) {
if (form.values.category === RecordCategory.lease && !leaseItems) return; if (form.values.category === RecordCategory.lease && !leaseItems) return;
if (form.values.category === RecordCategory.lease2lease && !inLeaseItems) return; if (form.values.category === RecordCategory.lease2lease && !inLeaseItems) return;
const in_contract = form.values.category === RecordCategory.lease ? leaseItems.data : inLeaseItems.data; const in_contract = form.values.category === RecordCategory.lease ? leaseItems.data : inLeaseItems.data;
const { ruleCalc } = summary(element, in_contract, reqWeightRules, recordData); const { ruleCalc } = summary(element, in_contract, reqWeightRules, recordData);
contractWeight.total += ruleCalc.weight / 1000;
calcProductCount(contractSummary, ruleCalc, productCategory);
if (form.values.category === RecordCategory.lease2lease && outLeaseItems) {
// 还需要生成出库合同小结
const out_contract = outLeaseItems.data;
const { ruleCalc } = summary(element, out_contract, reqWeightRules, recordData);
outContractWeight.total += ruleCalc.weight / 1000;
calcProductCount(outContractSummary, ruleCalc, productCategory);
}
}
// 采购出入库/采购直发小结
if (form.values.category === RecordCategory.purchase || form.values.category === RecordCategory.purchase2lease) {
const priceRules = leaseData?.map((rule) => {
return {
conversion_logic_id: rule.conversion_logic.id,
products: rule.product,
unit_price: rule.unit_price,
};
});
const { ruleCalc } = summary(element, priceRules, reqWeightRules, recordData);
priceWeight.total += ruleCalc.weight / 1000;
allPrice.total += ruleCalc.price;
calcProductCount(quoteSummary, ruleCalc, productCategory);
if (form.values.category === RecordCategory.purchase2lease && inLeaseItems) {
const in_contract = inLeaseItems.data;
const { ruleCalc } = summary(element, in_contract, null, recordData);
contractWeight.total += ruleCalc.weight / 1000; contractWeight.total += ruleCalc.weight / 1000;
calcProductCount(contractSummary, ruleCalc, productCategory); calcProductCount(contractSummary, ruleCalc, productCategory);
if (form.values.category === RecordCategory.lease2lease && outLeaseItems) {
// 还需要生成出库合同小结
const out_contract = outLeaseItems.data;
const { ruleCalc } = summary(element, out_contract, reqWeightRules, recordData);
outContractWeight.total += ruleCalc.weight / 1000;
calcProductCount(outContractSummary, ruleCalc, productCategory);
}
}
// 采购出入库/采购直发小结
if (form.values.category === RecordCategory.purchase || form.values.category === RecordCategory.purchase2lease) {
const priceRules = leaseData?.map((rule) => {
return {
conversion_logic_id: rule.conversion_logic.id,
products: rule.product,
unit_price: rule.unit_price,
};
});
const { ruleCalc } = summary(element, priceRules, reqWeightRules, recordData);
priceWeight.total += ruleCalc.weight / 1000;
allPrice.total += ruleCalc.price;
calcProductCount(quoteSummary, ruleCalc, productCategory);
if (form.values.category === RecordCategory.purchase2lease && inLeaseItems) {
const in_contract = inLeaseItems.data;
const { ruleCalc } = summary(element, in_contract, null, recordData);
contractWeight.total += ruleCalc.weight / 1000;
calcProductCount(contractSummary, ruleCalc, productCategory);
}
} }
} }
}); });