diff --git a/packages/app-client/src/components/purchase/section/CostSummarySection.tsx b/packages/app-client/src/components/purchase/section/CostSummarySection.tsx index 0d9cfc5..70e06cb 100644 --- a/packages/app-client/src/components/purchase/section/CostSummarySection.tsx +++ b/packages/app-client/src/components/purchase/section/CostSummarySection.tsx @@ -1,5 +1,5 @@ import { Table, TableColumnProps } from "@nutui/nutui-react-taro"; -import { formatCurrency, OrderCalculator } from "@/utils"; +import { OrderCalculator } from "@/utils"; import { useState } from "react"; import { DecimalUtils } from "@/utils/classes/calculators/core/DecimalUtils"; @@ -56,14 +56,14 @@ export default function CostSummarySection(props: { { id: 1, costType: "成本合计(不含运费)", - unitCost: `${formatCurrency(unitCostWithoutFreight)}`, - amount: `${formatCurrency(costWithoutFreight)}`, + unitCost: unitCostWithoutFreight, + amount: costWithoutFreight, }, { id: 2, costType: "成本合计(含运费)", - unitCost: `${formatCurrency(unitCostWithFreight)}`, - amount: `${formatCurrency(costWithFreight)}`, + unitCost: unitCostWithFreight, + amount: costWithFreight, }, ]; diff --git a/packages/app-client/src/components/purchase/section/PackageInfoSection.tsx b/packages/app-client/src/components/purchase/section/PackageInfoSection.tsx index 40074da..c34eb63 100644 --- a/packages/app-client/src/components/purchase/section/PackageInfoSection.tsx +++ b/packages/app-client/src/components/purchase/section/PackageInfoSection.tsx @@ -22,45 +22,53 @@ export default function PackageInfoSection(props: { title: "个数", key: "boxProductCount", }, - { - title: "销售单价(元/斤)", - key: "boxSalePrice", - render: ( - value: BusinessAPI.OrderPackage & { - orderPackageId?: string; - isTotalRow?: boolean; - }, - ) => { - // 合计行不显示编辑按钮 - if (value.isTotalRow) { - return formatCurrency(value.boxSalePrice as number); - } - - return ( - { - if (!readOnly) { - e.stopPropagation(); + ...(orderVO.type === "PRODUCTION_PURCHASE" + ? [ + { + title: "销售单价(元/斤)", + key: "boxSalePrice", + render: ( + value: BusinessAPI.OrderPackage & { + orderPackageId?: string; + isTotalRow?: boolean; + }, + ) => { + // 合计行不显示编辑按钮 + if (value.isTotalRow) { + return formatCurrency(value.boxSalePrice as number); } - }} - > - - {formatCurrency(value.boxSalePrice as number)} - - {!readOnly && ( - - - - )} - - ); - }, - }, - { - title: "销售金额(元)", - key: "boxSalePayment", - }, + + return ( + { + if (!readOnly) { + e.stopPropagation(); + } + }} + > + + {formatCurrency(value.boxSalePrice as number)} + + {!readOnly && ( + + + + )} + + ); + }, + }, + { + title: "销售金额(元)", + key: "boxSalePayment", + }, + ] + : []), { title: "箱重(斤)", key: "boxProductWeight", diff --git a/packages/app-client/src/components/purchase/section/ProductionLossSection.tsx b/packages/app-client/src/components/purchase/section/ProductionLossSection.tsx index 1bcd593..2357cbe 100644 --- a/packages/app-client/src/components/purchase/section/ProductionLossSection.tsx +++ b/packages/app-client/src/components/purchase/section/ProductionLossSection.tsx @@ -1,12 +1,14 @@ import { Text, View } from "@tarojs/components"; import { PriceEditor } from "@/components"; +import { OrderCalculator } from "@/utils"; export default function ProductionLossSection(props: { orderVO: BusinessAPI.OrderVO; onChange?: (orderVO: BusinessAPI.OrderVO) => void; readOnly?: boolean; + calculator: OrderCalculator; }) { - const { orderVO, onChange, readOnly } = props; + const { orderVO, onChange, calculator, readOnly } = props; const orderDealer = orderVO.orderDealer; return ( @@ -19,7 +21,12 @@ export default function ProductionLossSection(props: { { // 更新父组件的状态 onChange?.({ diff --git a/packages/app-client/src/components/purchase/section/TaxProvisionSection.tsx b/packages/app-client/src/components/purchase/section/TaxProvisionSection.tsx index d3cbd31..6955f1d 100644 --- a/packages/app-client/src/components/purchase/section/TaxProvisionSection.tsx +++ b/packages/app-client/src/components/purchase/section/TaxProvisionSection.tsx @@ -1,12 +1,14 @@ import { Text, View } from "@tarojs/components"; import { PriceEditor } from "@/components"; +import { OrderCalculator } from "@/utils"; export default function TaxProvisionSection(props: { orderVO: BusinessAPI.OrderVO; onChange?: (orderVO: BusinessAPI.OrderVO) => void; readOnly?: boolean; + calculator: OrderCalculator; }) { - const { orderVO, onChange, readOnly } = props; + const { orderVO, onChange, calculator, readOnly } = props; const orderDealer = orderVO.orderDealer; console.log("orderDealer.taxProvision", orderDealer.taxProvision); @@ -20,7 +22,12 @@ export default function TaxProvisionSection(props: { { // 更新父组件的状态 onChange?.({ diff --git a/packages/app-client/src/components/purchase/section/TaxSubsidySection.tsx b/packages/app-client/src/components/purchase/section/TaxSubsidySection.tsx index 96354f0..01cfb9b 100644 --- a/packages/app-client/src/components/purchase/section/TaxSubsidySection.tsx +++ b/packages/app-client/src/components/purchase/section/TaxSubsidySection.tsx @@ -1,14 +1,17 @@ import { Text, View } from "@tarojs/components"; import { PriceEditor } from "@/components"; +import { OrderCalculator } from "@/utils"; export default function TaxSubsidySection(props: { orderVO: BusinessAPI.OrderVO; onChange?: (orderVO: BusinessAPI.OrderVO) => void; readOnly?: boolean; + calculator: OrderCalculator; }) { - const { orderVO, onChange, readOnly } = props; + const { orderVO, onChange, calculator, readOnly } = props; const orderDealer = orderVO.orderDealer; + console.log("orderDealer.taxSubsidy", orderDealer.taxSubsidy); return ( {/* 卡片形式展示返点信息 */} @@ -19,7 +22,12 @@ export default function TaxSubsidySection(props: { { console.log("newValue taxSubsidy", newValue); // 更新父组件的状态 diff --git a/packages/app-client/src/pages/audit/audit.tsx b/packages/app-client/src/pages/audit/audit.tsx index 1a1e0d7..238450e 100644 --- a/packages/app-client/src/pages/audit/audit.tsx +++ b/packages/app-client/src/pages/audit/audit.tsx @@ -345,8 +345,50 @@ export default hocAuth(function Page(props: CommonComponent) { return; } - // 这里应该调用提交审核API - console.log("提交老板审核:", orderVO); + if (!orderVO) { + Toast.show("toast", { + icon: "fail", + title: "提示", + content: "提交失败", + }); + return; + } + + // 公司返点(税费补贴) + if ( + (orderVO.orderDealer.taxSubsidy === null || + orderVO.orderDealer.taxSubsidy === undefined) && + orderVO.orderDealer.enableCompanyRebate + ) { + orderVO.orderDealer.taxSubsidy = calculator.getTaxSubsidy(); + } + + // 利润分成 + if ( + (orderVO.orderDealer.profitSharing === null || + orderVO.orderDealer.profitSharing === undefined) && + orderVO.orderDealer.shareAdjusted + ) { + orderVO.orderDealer.profitSharing = calculator.getPersonalProfit(); + } + + // 损失金额 + if ( + (orderVO.orderDealer.lossAmount === null || + orderVO.orderDealer.lossAmount === undefined) && + orderVO.orderDealer.enableLoss + ) { + orderVO.orderDealer.lossAmount = calculator.getLossAmount(); + } + + // 计提税金 + if ( + (orderVO.orderDealer.taxProvision === null || + orderVO.orderDealer.taxProvision === undefined) && + orderVO.orderDealer.enableAccrualTax + ) { + orderVO.orderDealer.taxProvision = calculator.getTaxProvision(); + } const { data: { data: auditVO, success, errMessage }, @@ -806,51 +848,7 @@ export default hocAuth(function Page(props: CommonComponent) { ) } orderVO={orderVO} - onChange={(orderVO) => { - const calculator = new OrderCalculator(orderVO); - console.log("calculator", calculator, section); - // 公司返点(税费补贴) - if ( - (orderVO.orderDealer.taxSubsidy === null || - orderVO.orderDealer.taxSubsidy === undefined) && - orderVO.orderDealer.enableCompanyRebate - ) { - orderVO.orderDealer.taxSubsidy = - calculator.getTaxSubsidy(); - } - - // 利润分成 - if ( - (orderVO.orderDealer.profitSharing === null || - orderVO.orderDealer.profitSharing === undefined) && - orderVO.orderDealer.shareAdjusted - ) { - orderVO.orderDealer.profitSharing = - calculator.getPersonalProfit(); - } - - // 损失金额 - if ( - (orderVO.orderDealer.lossAmount === null || - orderVO.orderDealer.lossAmount === undefined) && - orderVO.orderDealer.enableLoss - ) { - orderVO.orderDealer.lossAmount = - calculator.getLossAmount(); - } - - // 计提税金 - if ( - (orderVO.orderDealer.taxProvision === null || - orderVO.orderDealer.taxProvision === undefined) && - orderVO.orderDealer.enableAccrualTax - ) { - orderVO.orderDealer.taxProvision = - calculator.getTaxProvision(); - } - - setOrderVO(orderVO); - }} + onChange={setOrderVO} // @ts-ignore costList={costList} calculator={calculator} diff --git a/packages/app-client/src/utils/classes/calculators/modules/CostCalculator.ts b/packages/app-client/src/utils/classes/calculators/modules/CostCalculator.ts index b8d4121..393ef9f 100644 --- a/packages/app-client/src/utils/classes/calculators/modules/CostCalculator.ts +++ b/packages/app-client/src/utils/classes/calculators/modules/CostCalculator.ts @@ -55,7 +55,7 @@ export class CostCalculator { // 优先使用手动设置的税费补贴 const manualTaxSubsidy = this.order.orderDealer?.taxSubsidy; - if (manualTaxSubsidy) { + if (manualTaxSubsidy !== undefined && manualTaxSubsidy !== null) { return manualTaxSubsidy; } @@ -73,7 +73,7 @@ export class CostCalculator { // 优先使用手动设置的计提税金 const manualTaxProvision = this.order.orderDealer?.taxProvision; - if (manualTaxProvision) { + if (manualTaxProvision !== undefined && manualTaxProvision !== null) { return manualTaxProvision; }