From 2245cd84e7b76dc594165fc1ec8ebc211031fba7 Mon Sep 17 00:00:00 2001 From: lyx <2027667395@qq.com> Date: Tue, 12 Mar 2024 21:33:51 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=B0=8F=E7=BB=93=E7=90=86=E8=AE=BA?= =?UTF-8?q?=E9=87=8D=E9=87=8F=E6=9B=B4=E6=AD=A3=EF=BC=8C=E6=8A=A5=E4=BB=B7?= =?UTF-8?q?=E6=80=BB=E9=87=91=E9=A2=9D=E5=B7=A5=E5=8D=95=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=EF=BC=8C=E8=B4=AD=E9=94=80=E5=8D=95pdf=E5=B7=A5=E5=8D=95?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=8C=E8=AE=A2=E5=8D=95=E5=AF=BC=E5=85=A5?= =?UTF-8?q?hook=E5=81=9C=E7=94=A8=EF=BC=8C=E5=87=BA=E5=BA=93=E5=85=A5?= =?UTF-8?q?=E7=AD=9B=E9=80=89=E5=9F=BA=E5=9C=B0=E4=BB=93=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../custom-components/RecordSummary.tsx | 2 +- .../custom-components/RecordTotalPrice.tsx | 29 +++++++++---------- .../pdf-documents/records-documentV2.tsx | 14 +++++---- .../src/server/services/record-service.ts | 4 +-- 4 files changed, 25 insertions(+), 24 deletions(-) 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 b31d018da..51d12a635 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 @@ -199,7 +199,7 @@ const summary = (event: RecordItems, rules: any[], ruleWeight: any) => { calc.name = category.name; calc.count = count; calc.unit = unit; - calc.weight = event.product.weight; + calc.weight = event.product.weight * event.count; } else { // 2. 存在规则(实际重量情况不计算) const plain = rules.find((item) => diff --git a/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordTotalPrice.tsx b/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordTotalPrice.tsx index 5d8db1ac9..15e4e00f2 100644 --- a/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordTotalPrice.tsx +++ b/packages/plugins/@hera/plugin-rental/src/client/custom-components/RecordTotalPrice.tsx @@ -40,8 +40,7 @@ export const RecordTotalPrice = (props) => { const computeTotalPrice = () => { const about_product = form.values.items.filter( (item) => - (item?.product && item?.product?.category_id == leaseData?.product?.category_id) || - (leaseData?.product?.id > 99999 && item?.product?.id == leaseData?.product?.id - 99999), + item.product?.id === leaseData.product?.id || item.product?.category_id === leaseData.product?.id - 99999, ); if (!leaseData || !about_product) { return; @@ -49,13 +48,13 @@ export const RecordTotalPrice = (props) => { let allPrice = 0; const rule = leaseData.conversion_logic; if (!rule) return; - if (rule.id == ConversionLogics.ActualWeight) { + if (rule.id === ConversionLogics.ActualWeight) { // 分组总量项 - const weightItem = groupWeight.find( - (item) => item.products?.find((product) => product?.id == leaseData.product?.category_id), + const weightItem = groupWeight.find((item) => + item.products?.find((product) => product?.id === leaseData.product?.category_id), ); // 存在该分组相关产品items - const effectiveData = about_product.find((item) => item.product?.category_id == leaseData.product?.category_id); + const effectiveData = about_product.find((item) => item.product?.category_id === leaseData.product?.category_id); if (!effectiveData) return; if (weightItem && weightItem.weight) { allPrice = weightItem.weight * (leaseData.unit_price || 0); @@ -66,26 +65,26 @@ export const RecordTotalPrice = (props) => { for (const item of about_product) { const foundProduct = reqProduct.data.data.find((product) => product.id === item.product.id).category; const price = leaseData.unit_price || 0; - if (rule.id == ConversionLogics.Keep) { + if (rule.id === ConversionLogics.Keep) { allPrice += price * (item.count || 0); - } else if (rule.id == ConversionLogics.Product) { + } else if (rule.id === ConversionLogics.Product) { if (foundProduct.convertible && !item.product?.ratio) { console.error('产品缺少换算比例', item.product?.label); } const total = foundProduct.convertible ? item?.count * item.product?.ratio : item?.count; allPrice += price * (total || 0); - } else if (rule.id == ConversionLogics.ProductWeight) { + } else if (rule.id === ConversionLogics.ProductWeight) { allPrice += (price * (item.product?.weight || 0) * (item.count || 0)) / 1000; } else { const weightRule = reqWeightRules.data.data.find( (weight_item) => - weight_item.logic_id == rule.id && - (weight_item.product_id == item.product?.id || - weight_item.product_id == item.product?.category_id + 99999), + weight_item.logic_id === rule.id && + (weight_item.product_id === item.product?.id || + weight_item.product_id === item.product?.category_id + 99999), ); - if (weightRule && weightRule.conversion_logic_id == ConversionLogics.Keep) { + if (weightRule && weightRule.conversion_logic_id === ConversionLogics.Keep) { allPrice += price * (item.count || 0) * (weightRule.weight || 0); - } else if (weightRule && weightRule.conversion_logic_id == ConversionLogics.Product) { + } else if (weightRule && weightRule.conversion_logic_id === ConversionLogics.Product) { if (foundProduct.convertible && !item.product?.ratio) { console.error('产品缺少换算比例', item.product?.label); } @@ -132,7 +131,7 @@ export const RecordTotalPrice = (props) => { computeTotalPrice(); } }, [leaseData, products, groupWeight, recordWeight, reqProduct.loading, reqWeightRules.loading]); - return {all_price == 0 ? '-' : formatCurrency(all_price, 2)}; + return {all_price === 0 ? '-' : formatCurrency(all_price, 2)}; }; RecordTotalPrice.displayName = 'RecordTotalPrice'; diff --git a/packages/plugins/@hera/plugin-rental/src/server/pdf-documents/records-documentV2.tsx b/packages/plugins/@hera/plugin-rental/src/server/pdf-documents/records-documentV2.tsx index d50fed4e5..a2e536bf3 100644 --- a/packages/plugins/@hera/plugin-rental/src/server/pdf-documents/records-documentV2.tsx +++ b/packages/plugins/@hera/plugin-rental/src/server/pdf-documents/records-documentV2.tsx @@ -384,9 +384,11 @@ const PreviewDocument = ({ priceRule.map((item) => ( {item.name} - {item?.unit_price && item.unit_price + '元/' + item.unit} - {item.count} + {item?.unit_price && formatQuantity(item.unit_price, 2) + '元/' + item.unit} + + + {formatQuantity(item.count, 2)} {item.unit} {formatCurrency(item.all_price, 2)} @@ -415,20 +417,20 @@ const PreviewDocument = ({ {item.left_name} - {item?.left_unit_price && item.left_unit_price + '元/' + item.left_unit} + {item?.left_unit_price && formatQuantity(item.left_unit_price, 2) + '元/' + item.left_unit} - {item.left_count} + {formatQuantity(item.left_count, 2)} {item.left_unit} {formatCurrency(item.left_all_price, 2)} {item.left_comment || ''} {item.right_name} - {item?.right_unit_price && item.unit_price + '元/' + item.right_unit} + {item?.right_unit_price && formatQuantity(item.right_unit_price, 2) + '元/' + item.right_unit} - {item.right_count} + {formatQuantity(item.right_count)} {item.right_unit} diff --git a/packages/plugins/@hera/plugin-rental/src/server/services/record-service.ts b/packages/plugins/@hera/plugin-rental/src/server/services/record-service.ts index 5fa09a915..477621bcc 100644 --- a/packages/plugins/@hera/plugin-rental/src/server/services/record-service.ts +++ b/packages/plugins/@hera/plugin-rental/src/server/services/record-service.ts @@ -17,7 +17,7 @@ export class RecordService { // 订单发生变化时更新对应结算单的状态(需要重新计算) this.db.on('records.afterSave', this.updateSettlementStatus.bind(this)); // 老系统导入信息系统数据,record_import存储数据,并根据record_import数据创建对应的单子 - this.db.on('record_import.afterCreate', this.importRecord.bind(this)); + // this.db.on('record_import.afterCreate', this.importRecord.bind(this)); } /** * 处理直发单生成单 @@ -510,7 +510,7 @@ export class RecordService { // 租赁入库, out_stock = 合同中project_id, in_stock = 合同中项目的associated_company_id => 项目表id const associatedCompanyProject = await this.db .getRepository('project') - .findOne({ where: { company_id: contractProject.associated_company_id } }); + .findOne({ where: { company_id: contractProject.associated_company_id, category: '1' } }); if (values.record_category === RecordTypes.rentInStock) { out_stock = contractProject.dataValues;