From d6e3afd100baea77829315c6affabfde64207563 Mon Sep 17 00:00:00 2001 From: shenyifei Date: Fri, 26 Dec 2025 14:54:28 +0800 Subject: [PATCH] =?UTF-8?q?refactor(purchase):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E4=BB=B7=E6=A0=BC=E8=AE=A1=E7=AE=97=E7=BB=84=E4=BB=B6=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除 MarketPriceSection 中的本地状态管理,直接使用 orderVO.pricingMethod - 将 Radio.Group 的 onChange 逻辑更新为调用 props.onChange 回调 - 更新所有引用 pricingMethod 的地方为直接使用 orderVO.pricingMethod - 删除 TaxProvisionSection 和 TaxSubsidySection 中的调试日志 - 简化组件状态更新逻辑,提高代码可维护性 --- .../purchase/section/MarketPriceSection.tsx | 32 +++++++------------ .../purchase/section/TaxProvisionSection.tsx | 1 - .../purchase/section/TaxSubsidySection.tsx | 1 - 3 files changed, 12 insertions(+), 22 deletions(-) diff --git a/packages/app-client/src/components/purchase/section/MarketPriceSection.tsx b/packages/app-client/src/components/purchase/section/MarketPriceSection.tsx index a8b5098..2308109 100644 --- a/packages/app-client/src/components/purchase/section/MarketPriceSection.tsx +++ b/packages/app-client/src/components/purchase/section/MarketPriceSection.tsx @@ -1,4 +1,3 @@ -import { useEffect, useState } from "react"; import { Text, View } from "@tarojs/components"; import { Radio } from "@nutui/nutui-react-taro"; import { OrderCalculator } from "@/utils"; @@ -13,15 +12,6 @@ export default function MarketPriceSection(props: { }) { const { orderVO, onChange, readOnly, calculator } = props; - const [pricingMethod, setPricingMethod] = - useState(); - - useEffect(() => { - if (orderVO.pricingMethod) { - setPricingMethod(orderVO.pricingMethod); - } - }, [orderVO.pricingMethod]); - // 销售金额 const saleAmount = calculator.getSalesAmount(); @@ -42,9 +32,9 @@ export default function MarketPriceSection(props: { {readOnly ? ( - {pricingMethod === "BY_GROSS_WEIGHT" + {orderVO.pricingMethod === "BY_GROSS_WEIGHT" ? "按毛重报价" - : pricingMethod === "BY_NET_WEIGHT" + : orderVO.pricingMethod === "BY_NET_WEIGHT" ? "按净重报价" : "未选择"} @@ -52,11 +42,13 @@ export default function MarketPriceSection(props: { - setPricingMethod( - value as BusinessAPI.OrderVO["pricingMethod"], - ) + onChange?.({ + ...orderVO, + pricingMethod: + value as BusinessAPI.OrderVO["pricingMethod"], + }) } > 按毛重报价 @@ -189,7 +181,7 @@ export default function MarketPriceSection(props: { 销售金额 - {pricingMethod + {orderVO.pricingMethod ? `${calculator.calculateSupplierAmount(supplier)} 元` : "-"} @@ -206,7 +198,7 @@ export default function MarketPriceSection(props: { 销售金额 - {pricingMethod ? `${saleAmount} 元` : "-"} + {orderVO.pricingMethod ? `${saleAmount} 元` : "-"} @@ -215,7 +207,7 @@ export default function MarketPriceSection(props: { 平均单价 - {pricingMethod ? `${averagePurchasePrice} 元/斤` : "-"} + {orderVO.pricingMethod ? `${averagePurchasePrice} 元/斤` : "-"} @@ -228,7 +220,7 @@ export default function MarketPriceSection(props: { ) - {pricingMethod ? `${marketPrice} 元` : "-"} + {orderVO.pricingMethod ? `${marketPrice} 元` : "-"} diff --git a/packages/app-client/src/components/purchase/section/TaxProvisionSection.tsx b/packages/app-client/src/components/purchase/section/TaxProvisionSection.tsx index 6955f1d..8f78751 100644 --- a/packages/app-client/src/components/purchase/section/TaxProvisionSection.tsx +++ b/packages/app-client/src/components/purchase/section/TaxProvisionSection.tsx @@ -11,7 +11,6 @@ export default function TaxProvisionSection(props: { const { orderVO, onChange, calculator, readOnly } = props; const orderDealer = orderVO.orderDealer; - console.log("orderDealer.taxProvision", orderDealer.taxProvision); return ( {/* 卡片形式展示计提税金信息 */} diff --git a/packages/app-client/src/components/purchase/section/TaxSubsidySection.tsx b/packages/app-client/src/components/purchase/section/TaxSubsidySection.tsx index 01cfb9b..54336f6 100644 --- a/packages/app-client/src/components/purchase/section/TaxSubsidySection.tsx +++ b/packages/app-client/src/components/purchase/section/TaxSubsidySection.tsx @@ -11,7 +11,6 @@ export default function TaxSubsidySection(props: { const { orderVO, onChange, calculator, readOnly } = props; const orderDealer = orderVO.orderDealer; - console.log("orderDealer.taxSubsidy", orderDealer.taxSubsidy); return ( {/* 卡片形式展示返点信息 */}