diff --git a/packages/app-client/src/components/purchase/module/MelonFarmer.tsx b/packages/app-client/src/components/purchase/module/MelonFarmer.tsx index d34b472..79d17ff 100644 --- a/packages/app-client/src/components/purchase/module/MelonFarmer.tsx +++ b/packages/app-client/src/components/purchase/module/MelonFarmer.tsx @@ -696,6 +696,16 @@ export default forwardRef( ...supplierVO1, }); + if (supplierVO1.wechatQr) { + setPicList([ + { + url: supplierVO1.wechatQr, + name: "wechat-qrcode", + status: "success", + }, + ]); + } + // 清除所有错误状态 setNameError((prev) => ({ ...prev, diff --git a/packages/app-client/src/components/purchase/module/OrderCost.tsx b/packages/app-client/src/components/purchase/module/OrderCost.tsx index ace25dc..e6a6b93 100644 --- a/packages/app-client/src/components/purchase/module/OrderCost.tsx +++ b/packages/app-client/src/components/purchase/module/OrderCost.tsx @@ -40,6 +40,8 @@ export interface IOrderCostProps { onEmptyBoxChange?: (orderPackageList: BusinessAPI.OrderPackage[]) => void; onAdd: () => void; costItemVOList: BusinessAPI.CostItemVO[]; + foreman: string; + setForeman: (foreman: string) => void; } export default forwardRef( @@ -52,6 +54,8 @@ export default forwardRef( onEmptyBoxChange, emptyBoxList: defaultEmptyBoxList, costItemVOList, + foreman, + setForeman, } = IOrderCostProps; console.log("defaultEmptyBoxList", defaultEmptyBoxList); @@ -70,7 +74,6 @@ export default forwardRef( const [boxBrandList, setBoxBrandList] = useState(); const [emptyBoxCostItem, setEmptyBoxCostItem] = useState(); - console.log("emptyBoxCostItem", emptyBoxCostItem); // 批量添加空箱相关状态 const [selectedBrand, setSelectedBrand] = useState(null); @@ -177,10 +180,8 @@ export default forwardRef( ); }, [emptyBoxList, packageTypeEnabled.EMPTY]); - // 总的工头姓名状态 - const [principal, setPrincipal] = useState(""); // 工头姓名错误状态 - const [principalError, setPrincipalError] = useState(false); + const [foremanError, setForemanError] = useState(false); // 初始化空箱品牌数据 const initBoxBrandList = async () => { @@ -329,17 +330,6 @@ export default forwardRef( }; }) || []), ]); - - // 初始化总的工头姓名(如果有启用且费用承担方为"我方"的项目) - const enabledUsItems = initialList.filter( - (item) => - item.selected && - item.payerType === "US" && - item.costType === "HUMAN_COST", - ); - if (enabledUsItems.length > 0 && enabledUsItems[0].principal) { - setPrincipal(enabledUsItems[0].principal || ""); - } } }; @@ -376,14 +366,14 @@ export default forwardRef( item.selected && item.payerType === "US" ) { - return { ...item, principal }; + return { ...item, principal: foreman }; } return item; }); onChange(updatedList); } - }, [costItemList, principal]); + }, [costItemList, foreman]); // 错误状态 const [countError, setCountError] = useState<{ [key: string]: boolean }>( @@ -439,7 +429,7 @@ export default forwardRef( // 校验工头姓名 const validatePrincipal = (value: string) => { const isValid = value.trim().length > 0; - setPrincipalError(!isValid); + setForemanError(!isValid); return isValid; }; @@ -461,8 +451,8 @@ export default forwardRef( }; // 处理工头姓名变化 - const handlePrincipalChange = (value: string) => { - setPrincipal(value); + const handleForemanChange = (value: string) => { + setForeman(value); // 如果有启用且费用承担方为"我方"的项目,则校验工头姓名 const enabledUsItems = costItemList?.filter( @@ -509,8 +499,6 @@ export default forwardRef( } }); - console.log("costItemList", costItemList); - // 校验总的工头姓名(如果有启用且费用承担方为"我方"的项目) const enabledUsItems = costItemList.filter( (item) => @@ -518,13 +506,12 @@ export default forwardRef( item.selected && item.payerType === "US", ); - console.log("enabledUsItems", enabledUsItems); + + isValid = true; if (enabledUsItems.length > 0) { - if (!validatePrincipal(principal)) { + if (!validatePrincipal(foreman)) { isValid = false; } - } else { - isValid = true; } if (!isValid) { @@ -1422,20 +1409,20 @@ export default forwardRef( 工头叫什么名字 { - handlePrincipalChange(value); + handleForemanChange(value); }} - onBlur={() => handlePrincipalBlur(principal)} + onBlur={() => handlePrincipalBlur(foreman)} /> - {principalError && ( + {foremanError && ( 工头叫啥子填一下 diff --git a/packages/app-client/src/components/purchase/module/PurchasePreview.tsx b/packages/app-client/src/components/purchase/module/PurchasePreview.tsx index 713342a..9eda17d 100644 --- a/packages/app-client/src/components/purchase/module/PurchasePreview.tsx +++ b/packages/app-client/src/components/purchase/module/PurchasePreview.tsx @@ -334,17 +334,24 @@ export default function PurchasePreview(props: IPurchasePreviewProps) { ? "瓜农承担费用" : "未指定"} - {costItem.payerType === "US" && ( - - 工头:{costItem.principal} - - )} 共 {costItem.count} {costItem.unit} ))} + {purchaseOrder.orderCostList?.some( + (costItem: CostItem) => + costItem.costType === "HUMAN_COST" && + costItem.payerType === "US", + ) && ( + + 工头 + + {purchaseOrder.foreman} + + + )} 总人数 diff --git a/packages/app-client/src/components/purchase/section/LaborInfoSection.tsx b/packages/app-client/src/components/purchase/section/LaborInfoSection.tsx index c61b8f6..cc11996 100644 --- a/packages/app-client/src/components/purchase/section/LaborInfoSection.tsx +++ b/packages/app-client/src/components/purchase/section/LaborInfoSection.tsx @@ -37,7 +37,7 @@ export default function LaborInfoSection(props: { unitPrice: "", // 单价 amount: "", // 金额 payerType: "US", // 费用承担方,默认我方 - principal: "", // 工头姓名 + principal: "", // 负责人 requireQuantityAndPrice: false, }); @@ -175,7 +175,7 @@ export default function LaborInfoSection(props: { - 工头:{humanCosts?.[0].principal} + 工头:{purchaseOrderVO.foreman} 工头垫付 {/* 工头垫付 */} {workerAdvanceCosts.map((item, index) => { - // 初始化编辑值,包括费用承担方和工头姓名 + // 初始化编辑值,包括费用承担方和负责人 initEditValues( item.orderCostId, item.count, @@ -243,7 +243,7 @@ export default function LaborInfoSection(props: { 产地垫付 {/* 产地垫付 */} {productionAdvanceCosts.map((item, index) => { - // 初始化编辑值,包括费用承担方和工头姓名 + // 初始化编辑值,包括费用承担方和负责人 initEditValues( item.orderCostId, item.count, @@ -403,7 +403,7 @@ export default function LaborInfoSection(props: { : "元", // 单位 unitPrice: "", // 单价 amount: "", // 金额 - principal: "", // 工头姓名 + principal: "", // 负责人 requireQuantityAndPrice: selectedItem.requireQuantityAndPrice, })); @@ -535,7 +535,7 @@ export default function LaborInfoSection(props: { unitPrice: "", // 单价 amount: "", // 金额 payerType: "", // 费用承担方,默认我方 - principal: "", // 工头姓名 + principal: "", // 负责人 requireQuantityAndPrice: false, }); }} @@ -612,7 +612,7 @@ export default function LaborInfoSection(props: { unitPrice: "", // 单价 amount: "", // 金额 payerType: "", // 费用承担方,默认我方 - principal: "", // 工头姓名 + principal: "", // 负责人 requireQuantityAndPrice: false, }); }} @@ -776,7 +776,7 @@ export default function LaborInfoSection(props: { ...prev, [item.orderCostId]: { ...tempEditValues[item.orderCostId], - // 如果费用承担方是瓜农,清空工头姓名 + // 如果费用承担方是瓜农,清空负责人 principal: tempEditValues[item.orderCostId]?.payerType === "OTHER" @@ -989,7 +989,7 @@ export default function LaborInfoSection(props: { ...prev, [item.orderCostId]: { ...tempEditValues[item.orderCostId], - // 如果费用承担方是瓜农,清空工头姓名 + // 如果费用承担方是瓜农,清空负责人 principal: tempEditValues[item.orderCostId]?.payerType === "OTHER" diff --git a/packages/app-client/src/components/purchase/section/WorkerAdvanceSection.tsx b/packages/app-client/src/components/purchase/section/WorkerAdvanceSection.tsx index 8a30067..759c716 100644 --- a/packages/app-client/src/components/purchase/section/WorkerAdvanceSection.tsx +++ b/packages/app-client/src/components/purchase/section/WorkerAdvanceSection.tsx @@ -165,7 +165,7 @@ export default function WorkerAdvanceSection(props: { {humanCosts && humanCosts.length > 0 && ( - 工头:{humanCosts?.[0].principal} + 工头:{purchaseOrderVO.foreman} 收购单价 - - + + {formatUnitPrice(calculator.getAveragePurchasePrice())} 元/斤 @@ -73,9 +76,9 @@ export default hocAuth(function Page(props: CommonComponent) { 市场报价 - - - {formatUnitPrice(calculator.getAverageSalesPrice())} + + + {formatUnitPrice(calculator.getAverageSalesPrice())} 元 元/斤 @@ -90,14 +93,14 @@ export default hocAuth(function Page(props: CommonComponent) { 西瓜采购成本 - ¥{formatCurrency(calculator.getSupplierPurchaseCost())} + ¥{formatCurrency(calculator.getSupplierPurchaseCost())} 元 {purchaseOrderVO.orderDealer?.freightCostFlag && ( 运输费 - ¥{purchaseOrderVO.orderVehicle.price} + ¥{purchaseOrderVO.orderVehicle.price} 元 )} @@ -109,7 +112,7 @@ export default hocAuth(function Page(props: CommonComponent) { > {item.name} - ¥{item.price * item.count} + ¥{item.price * item.count} 元 {item.name === "人工费" && ( @@ -128,7 +131,7 @@ export default hocAuth(function Page(props: CommonComponent) { 公司返点 - ¥{purchaseOrderVO.orderDealer?.taxSubsidy} + ¥{purchaseOrderVO.orderDealer?.taxSubsidy} 元 )} @@ -137,7 +140,7 @@ export default hocAuth(function Page(props: CommonComponent) { 计提税金 - ¥{purchaseOrderVO.orderDealer?.taxProvision} + ¥{purchaseOrderVO.orderDealer?.taxProvision} 元 )} @@ -146,7 +149,7 @@ export default hocAuth(function Page(props: CommonComponent) { 调诚信志远分成 - ¥{purchaseOrderVO.orderDealer?.costDifference} + ¥{purchaseOrderVO.orderDealer?.costDifference} 元 )} @@ -155,7 +158,7 @@ export default hocAuth(function Page(props: CommonComponent) { 成本合计 - ¥{calculator.getMelonCost1()} + ¥{calculator.getMelonCost1()} 元 @@ -171,7 +174,7 @@ export default hocAuth(function Page(props: CommonComponent) { 分成利润 - ¥{calculator.getShareProfit()} + ¥{calculator.getShareProfit()} 元 diff --git a/packages/app-client/src/pages/purchase/purchaser/create.tsx b/packages/app-client/src/pages/purchase/purchaser/create.tsx index 336703c..86ae02d 100644 --- a/packages/app-client/src/pages/purchase/purchaser/create.tsx +++ b/packages/app-client/src/pages/purchase/purchaser/create.tsx @@ -1,14 +1,7 @@ import hocAuth from "@/hocs/auth"; import { CommonComponent, CostItem, SupplierVO } from "@/types/typings"; import { View } from "@tarojs/components"; -import { - Button, - Dialog, - SafeArea, - Toast, - Tour, - TourList, -} from "@nutui/nutui-react-taro"; +import { Button, Dialog, SafeArea, Toast, Tour, TourList } from "@nutui/nutui-react-taro"; import { purchase } from "@/constant"; import { useEffect, useRef, useState } from "react"; import { @@ -23,7 +16,7 @@ import { SupplierList, TicketUpload, Weigh, - WeighRef, + WeighRef } from "@/components"; import { business } from "@/services"; import { generateShortId } from "@/utils/generateShortId"; @@ -190,7 +183,10 @@ export default hocAuth(function Page(props: CommonComponent) { (item: CostItem) => ({ ...item, // 设置默认选中, - selected: item.count > 0, + selected: + item.selected || + item.costType !== "PACKAGING_MATERIALS" || + item.count > 0, }), ) as any; setOrderCostList(orderCostList1); @@ -414,6 +410,7 @@ export default hocAuth(function Page(props: CommonComponent) { const { data } = await business.purchaseOrder.savePurchaseOrderStep3({ orderId: orderId, active: active + 1, + foreman: purchaseOrder.foreman, orderCostList: purchaseOrder.orderCostList.filter( (item: CostItem) => item.selected, ), @@ -880,6 +877,13 @@ export default hocAuth(function Page(props: CommonComponent) { setOrderPackageList(emptyBoxList); }} costItemVOList={costItemVOList} + foreman={purchaseOrder?.foreman || ""} + setForeman={(foreman) => { + setPurchaseOrder((prev) => ({ + ...prev!, + foreman, + })); + }} /> )} diff --git a/packages/app-client/src/services/business/typings.d.ts b/packages/app-client/src/services/business/typings.d.ts index 55a5a36..615d6b6 100644 --- a/packages/app-client/src/services/business/typings.d.ts +++ b/packages/app-client/src/services/business/typings.d.ts @@ -3467,6 +3467,8 @@ declare namespace BusinessAPI { active?: number; /** 产地负责人 */ originPrincipal?: string; + /** 工头 */ + foreman?: string; /** 备注 */ remark?: string; /** 车辆信息 */ @@ -3582,6 +3584,8 @@ declare namespace BusinessAPI { orderId: string; /** 步骤标识 */ active?: number; + /** 工头 */ + foreman?: string; /** 采购订单费用信息 */ orderCostList: OrderCost[]; /** 采购订单包装箱信息 */ @@ -3625,6 +3629,8 @@ declare namespace BusinessAPI { active?: number; /** 产地负责人 */ originPrincipal?: string; + /** 工头 */ + foreman?: string; /** 报价方式:1_按毛重报价;2_按净重报价; */ pricingMethod?: "BY_GROSS_WEIGHT" | "BY_NET_WEIGHT"; /** 销售金额 */