From 629fff170fca638c4aecdfe79f8050e7ea4ff1a4 Mon Sep 17 00:00:00 2001 From: wjh Date: Wed, 27 Mar 2024 13:12:52 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E5=B0=8F=E7=BB=93?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E4=B8=8D=E6=98=BE=E7=A4=BA=E8=B5=94=E5=81=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RecordItemValuationQuantity.tsx | 14 ++- .../custom-components/RecordSummary.tsx | 88 ++++++++++--------- 2 files changed, 55 insertions(+), 47 deletions(-) diff --git a/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordItemValuationQuantity.tsx b/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordItemValuationQuantity.tsx index c41c02b95..5d945635e 100644 --- a/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordItemValuationQuantity.tsx +++ b/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordItemValuationQuantity.tsx @@ -161,10 +161,14 @@ const subtotal = (rule: any, itemData: any, productCategory: any, reqWeightRules let unit: string; if (rule?.conversion_logic_id === ConversionLogics.Keep) { count = itemData.count; - unit = item ? rule.unit : productCategory.unit; + unit = item ? rule.unit || '' : productCategory.unit || ''; } else if (rule?.conversion_logic_id === ConversionLogics.Product) { 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) { count = item ? itemData.count : (itemData.count * itemData.product.weight) / 1000; unit = '吨'; @@ -181,11 +185,13 @@ const subtotal = (rule: any, itemData: any, productCategory: any, reqWeightRules ); if (!weightRule) return; 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 = '吨'; } else if (weightRule.conversion_logic_id === ConversionLogics.Product) { 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 = '吨'; } } diff --git a/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordSummary.tsx b/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordSummary.tsx index e252cc4f4..30c711d2f 100644 --- a/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordSummary.tsx +++ b/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordSummary.tsx @@ -5,7 +5,7 @@ import { CustomComponentType, CustomFC, CustomFunctionComponent } from '@hera/pl import React from 'react'; import _ from 'lodash'; import { formatCurrency, formatQuantity } from '../../utils/currencyUtils'; -import { useCachedRequest, useLeaseItems } from '../hooks'; +import { useCachedRequest, useLeaseItems, useProductFeeItems } from '../hooks'; import { RecordItems } from '../../interfaces/records'; const cache = []; export const RecordSummary = observer((): any => { @@ -75,53 +75,55 @@ export const RecordSummary = observer((): any => { // 报价小结 const quoteSummary = {}; form.values.items?.forEach((item) => { - if (!item.product || !item.count) return; - const element = _.cloneDeep(item); - // 获取产品的分类数据信息 const productCategory = reqProduct.data.data?.find( - (product) => product.category_id === element.product?.category_id, + (product) => product.category_id === item.product?.category_id, )?.category; - if (!productCategory) return; - element.product.category = productCategory; - // 基础小结 - const { calc } = summary(element, null, null); - weight.total += calc.weight / 1000; - calcProductCount(summaryProduct, calc, productCategory); - // 合同小结(租赁出入库单/租赁直发单) + if (!(JSON.stringify(productCategory?.attr) === `["6"]`)) { + if (!item.product || !item.count) return; + const element = _.cloneDeep(item); + // 获取产品的分类数据信息 + if (!productCategory) return; + 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 && !leaseItems) return; - if (form.values.category === RecordCategory.lease2lease && !inLeaseItems) return; - const in_contract = form.values.category === RecordCategory.lease ? leaseItems.data : inLeaseItems.data; - 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); + if (form.values.category === RecordCategory.lease || form.values.category === RecordCategory.lease2lease) { + if (form.values.category === RecordCategory.lease && !leaseItems) return; + if (form.values.category === RecordCategory.lease2lease && !inLeaseItems) return; + const in_contract = form.values.category === RecordCategory.lease ? leaseItems.data : inLeaseItems.data; + 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; + calcProductCount(contractSummary, ruleCalc, productCategory); + } } } });