From 24d53d6c83bd9650926e26036908ba1f3ffea990 Mon Sep 17 00:00:00 2001 From: shenyifei Date: Sun, 28 Dec 2025 08:43:04 +0800 Subject: [PATCH] =?UTF-8?q?feat(audit):=20=E6=B7=BB=E5=8A=A0=E5=AE=A1?= =?UTF-8?q?=E6=89=B9=E5=92=8C=E5=AE=A1=E6=A0=B8=E6=9F=A5=E7=9C=8B=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=B9=B6=E4=BC=98=E5=8C=96=E5=8F=91=E8=B4=A7=E5=8D=95?= =?UTF-8?q?=E6=8D=AE=E7=94=9F=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在审批列表中添加老板查看审批按钮,仅在审批成功时显示 - 在审核列表中添加审核员查看审核按钮,仅在审核成功时显示 - 修复发货单据组件中重量计算使用净重而非毛重的问题 - 移除采购交付表单中的调试日志输出 - 将审批页面标题从"采购单审核"改为"采购单审批" - 在审批页面中添加供应商采购单价列表展示功能,支持展开收起 - 优化审批页面成本明细显示,添加到货日期信息 - 修复审批页面中返点金额的条件判断逻辑 - 优化审批页面利润显示颜色,正利润显示为蓝色,负利润显示为红色 - 添加返回首页按钮到审批页面底部操作栏 - 重构发货单据页面数据加载逻辑,优化模板配置更新流程 - 移除发货单据页面中未使用的经销商返点客户列表状态管理 - 优化发货单据页面的预览和生成方法参数传递 --- .../src/components/audit/ApprovalList.tsx | 22 ++++ .../src/components/audit/AuditList.tsx | 22 ++++ .../components/delivery/section/OtherInfo.tsx | 12 +- .../purchase/section/DeliveryFormSection.tsx | 3 - .../src/pages/approval/audit.config.ts | 2 +- .../app-client/src/pages/approval/audit.tsx | 104 +++++++++++++++--- packages/app-client/src/pages/audit/audit.tsx | 33 +++--- .../src/pages/delivery/document.tsx | 98 ++++++++++------- .../utils/classes/templates/PdfTemplate.ts | 3 +- 9 files changed, 214 insertions(+), 85 deletions(-) diff --git a/packages/app-client/src/components/audit/ApprovalList.tsx b/packages/app-client/src/components/audit/ApprovalList.tsx index 1bef52a..1251540 100644 --- a/packages/app-client/src/components/audit/ApprovalList.tsx +++ b/packages/app-client/src/components/audit/ApprovalList.tsx @@ -342,6 +342,28 @@ export default function ApprovalList(props: IApprovalListProps) { )} + {auditVO.state === "AUDIT_SUCCESS" && + auditVO.type === "BOSS_AUDIT" && + userRoleVO.slug === "boss" && ( + <> + + + )} diff --git a/packages/app-client/src/components/audit/AuditList.tsx b/packages/app-client/src/components/audit/AuditList.tsx index 4267516..cf0a025 100644 --- a/packages/app-client/src/components/audit/AuditList.tsx +++ b/packages/app-client/src/components/audit/AuditList.tsx @@ -357,6 +357,28 @@ export default function AuditList(props: IAuditListProps) { 再次编辑 )} + + {auditVO.state === "AUDIT_SUCCESS" && + userRoleVO.slug === "reviewer" && ( + <> + + + )} diff --git a/packages/app-client/src/components/delivery/section/OtherInfo.tsx b/packages/app-client/src/components/delivery/section/OtherInfo.tsx index 1835e61..9e873fe 100644 --- a/packages/app-client/src/components/delivery/section/OtherInfo.tsx +++ b/packages/app-client/src/components/delivery/section/OtherInfo.tsx @@ -1,4 +1,5 @@ import { View } from "@tarojs/components"; +import { Fragment } from "react"; export default function OtherInfo(props: { module: any }) { const { module } = props; @@ -40,9 +41,9 @@ export default function OtherInfo(props: { module: any }) { )} - {config.data?.map((item: any) => { + {config.data?.map((item: any, number: number) => { return ( - <> + {config.showGrade && ( 品名: @@ -64,17 +65,14 @@ export default function OtherInfo(props: { module: any }) { {config.unitPriceUnit === "1" ? "元/斤" : "元/公斤"} - + ); })} 大约重量: - {config.data?.reduce( - (acc: any, cur: any) => acc + cur.grossWeight, - 0, - )} + {config.data?.reduce((acc: any, cur: any) => acc + cur.netWeight, 0)} diff --git a/packages/app-client/src/components/purchase/section/DeliveryFormSection.tsx b/packages/app-client/src/components/purchase/section/DeliveryFormSection.tsx index 6dd5307..36b3941 100644 --- a/packages/app-client/src/components/purchase/section/DeliveryFormSection.tsx +++ b/packages/app-client/src/components/purchase/section/DeliveryFormSection.tsx @@ -96,9 +96,6 @@ export default function DeliveryFormSection(props: { const moduleList = updateTemplateConfig(template, convertedData); - console.log("moduleList", moduleList); - console.log("orderShip", orderShip); - return ( <> (); const [orderVO, setOrderVO] = useState(); + // 控制供应商采购单价列表展开状态 + const [showAllSuppliers, setShowAllSuppliers] = useState(false); + const init = async ( orderId: BusinessAPI.OrderVO["orderId"], auditId: BusinessAPI.AuditVO["auditId"], @@ -83,6 +88,9 @@ export default hocAuth(function Page(props: CommonComponent) { ) : 0; + const estimatedArrivalDate = orderVO.orderShipList[0].estimatedArrivalDate; + + const personalProfit = calculator.getPersonalProfit(); return ( <> 收购单价 - - - {formatUnitPrice(calculator.getAveragePurchasePrice())} - - 元/斤 - + {/**/} + {/* */} + {/* {formatUnitPrice(calculator.getAveragePurchasePrice())}*/} + {/* */} + {/* 元/斤*/} + {/**/} + + {/* 供应商采购单价列表 */} + {orderVO.orderSupplierList && + orderVO.orderSupplierList.length > 0 && ( + + {orderVO.orderSupplierList + .slice(0, showAllSuppliers ? undefined : 3) + .map((supplier) => ( + + + {supplier.name} + + + + {formatUnitPrice(supplier.purchasePrice || 0)} + + 元/斤 + + + ))} + + {/* 查看更多按钮 */} + {orderVO.orderSupplierList.length > 3 && ( + setShowAllSuppliers(!showAllSuppliers)} + > + + {showAllSuppliers ? "收起" : "查看更多"} + + + + )} + + )} 市场报价 - - {formatUnitPrice(calculator.getAverageSalesPrice())} 元 + + {formatUnitPrice(calculator.getAverageSalesPrice())} 元/斤 - + 采购信息 @@ -153,7 +202,15 @@ export default hocAuth(function Page(props: CommonComponent) { - 成本明细 + + 成本明细 + + 到货日期: + {estimatedArrivalDate + ? dayjs(estimatedArrivalDate).format("YYYY-MM-DD") + : "暂无"} + + @@ -221,7 +278,7 @@ export default hocAuth(function Page(props: CommonComponent) { )} - {orderVO.orderRebate && ( + {orderVO.orderRebate?.amount && ( 个人返点 @@ -257,8 +314,13 @@ export default hocAuth(function Page(props: CommonComponent) { 分成利润 - - ¥{calculator.getShareProfit()} 元 + 0, + "text-red-500": personalProfit < 0, + })} + > + ¥{personalProfit} 元 @@ -267,6 +329,20 @@ export default hocAuth(function Page(props: CommonComponent) { {/* 按钮操作 */} + + + {auditVO?.type === "BOSS_AUDIT" && auditVO.state === "WAITING_AUDIT" && ( <> diff --git a/packages/app-client/src/pages/audit/audit.tsx b/packages/app-client/src/pages/audit/audit.tsx index 6669cc6..565ce52 100644 --- a/packages/app-client/src/pages/audit/audit.tsx +++ b/packages/app-client/src/pages/audit/audit.tsx @@ -256,9 +256,6 @@ export default hocAuth(function Page(props: CommonComponent) { // 控制快速导航的显示状态 const [quickNavExpanded, setQuickNavExpanded] = useState(false); - const [dealerRebateCustomerVOList, setDealerRebateCustomerVOList] = - useState(); - // 暂存操作 const handleSave = () => { setSaveDialogVisible(true); @@ -504,19 +501,23 @@ export default hocAuth(function Page(props: CommonComponent) { orderVO.orderShipList = [convertOrderToOrderShip(orderVO)]; } - const { - data: { data: dealerRebateCustomerVOList }, - } = await business.dealerRebateCustomer.listDealerRebateCustomer({ - dealerRebateCustomerListQry: { - dealerId: orderVO?.orderDealer?.dealerId!, - status: true, - }, - }); + if (!orderVO.orderRebate) { + const { + data: { data: dealerRebateCustomerVOList }, + } = await business.dealerRebateCustomer.listDealerRebateCustomer({ + dealerRebateCustomerListQry: { + dealerId: orderVO?.orderDealer?.dealerId!, + status: true, + }, + }); - if (dealerRebateCustomerVOList && dealerRebateCustomerVOList.length > 0) { - setDealerRebateCustomerVOList(dealerRebateCustomerVOList || []); - orderVO.orderRebate = - dealerRebateCustomerVOList[0] as BusinessAPI.OrderRebate; + if ( + dealerRebateCustomerVOList && + dealerRebateCustomerVOList.length > 0 + ) { + orderVO.orderRebate = + dealerRebateCustomerVOList[0] as BusinessAPI.OrderRebate; + } } orderVO.orderCostList.map((item) => { @@ -656,7 +657,7 @@ export default hocAuth(function Page(props: CommonComponent) { } }, []); - if (!orderVO || !dealerRebateCustomerVOList || !costList) { + if (!orderVO || !costList) { return; } diff --git a/packages/app-client/src/pages/delivery/document.tsx b/packages/app-client/src/pages/delivery/document.tsx index edf9273..72d051e 100644 --- a/packages/app-client/src/pages/delivery/document.tsx +++ b/packages/app-client/src/pages/delivery/document.tsx @@ -76,7 +76,6 @@ export default hocAuth(function Page(props: CommonComponent) { const [orderVO, setOrderVO] = useState(); const [orderShipVO, setOrderShipVO] = useState(); - const [deliveryTemplate, setDeliveryTemplate] = useState(); const [pdfUrl, setPdfUrl] = useState(); const [picUrl, setPicUrl] = useState(); @@ -87,31 +86,46 @@ export default hocAuth(function Page(props: CommonComponent) { orderShipId: BusinessAPI.OrderShipVO["orderShipId"], ) => { setLoading(true); - const { data } = await business.order.showOrder({ + const { + data: { data: orderVO }, + } = await business.order.showOrder({ orderShowQry: { orderId, orderShipId, }, }); - const orderVO = data.data; if (orderVO) { setOrderVO(orderVO); + + const { + data: { data: dealerVO }, + } = await business.dealer.showDealer({ + dealerShowQry: { + dealerId: orderVO?.orderVehicle.dealerId, + }, + }); + + const template = JSON.parse(dealerVO?.deliveryTemplate!); + // 将 orderShipVO 转换为 examples 的数据格式,然后再替换 moduleList 里面的 config 数据 + const convertedData = convertOrderShipVOToExamplesFormat(orderVO); + const moduleList = await updateTemplateConfig( + template, + convertedData, + orderVO, + ); + setModuleList(moduleList); + const orderShip = orderVO.orderShipList[0]; setOrderShipVO(orderShip); if (orderShip.pdfUrl || orderShip.picUrl) { setStep(3); setPdfUrl(orderShip.pdfUrl); setPicUrl(orderShip.picUrl); + } else { + const [pdfUrl, picUrl] = await capturePreview(moduleList); + await updateFile(moduleList, orderVO, pdfUrl, picUrl); + setStep(3); } - - const { data } = await business.dealer.showDealer({ - dealerShowQry: { - dealerId: orderShip?.dealerId, - }, - }); - - const deliveryTemplate = data.data?.deliveryTemplate!; - setDeliveryTemplate(deliveryTemplate); } setLoading(false); }; @@ -122,27 +136,6 @@ export default hocAuth(function Page(props: CommonComponent) { } }, [orderId, orderShipId]); - const refresh = async ( - deliveryTemplate: string, - orderVO: BusinessAPI.OrderVO, - ) => { - const template = JSON.parse(deliveryTemplate); - // 将 orderShipVO 转换为 examples 的数据格式,然后再替换 moduleList 里面的 config 数据 - const convertedData = convertOrderShipVOToExamplesFormat(orderVO); - const updatedTemplate = await updateTemplateConfig( - template, - convertedData, - orderVO, - ); - setModuleList(updatedTemplate); - }; - - useEffect(() => { - if (deliveryTemplate && orderVO) { - refresh(deliveryTemplate, orderVO).then(); - } - }, [orderVO, deliveryTemplate]); - // 更新模板配置 const updateTemplateConfig = async ( template: any[], @@ -166,7 +159,10 @@ export default hocAuth(function Page(props: CommonComponent) { }; // 预览确认 - const previewAndConfirm = () => { + const previewAndConfirm = ( + moduleList: any[], + orderVO: BusinessAPI.OrderVO, + ) => { if (step === 2) { // 显示确认对话框 Dialog.open("dialog", { @@ -176,7 +172,8 @@ export default hocAuth(function Page(props: CommonComponent) { cancelText: "取消", onConfirm: async () => { // 截图预览内容 - await capturePreview(); + const [pdfUrl, picUrl] = await capturePreview(moduleList); + await updateFile(moduleList, orderVO, pdfUrl, picUrl); Dialog.close("dialog"); // 进入第三步 setStep(3); @@ -202,7 +199,10 @@ export default hocAuth(function Page(props: CommonComponent) { }; // 生成发货单据 - const generateShippingDocument = async () => { + const generateShippingDocument = async ( + moduleList: any[], + orderVO: BusinessAPI.OrderVO, + ) => { // 显示确认对话框 Dialog.open("dialog", { title: "生成发货单据", @@ -211,7 +211,8 @@ export default hocAuth(function Page(props: CommonComponent) { cancelText: "取消", onConfirm: async () => { // 截图预览内容 - await capturePreview(); + const [pdfUrl, picUrl] = await capturePreview(moduleList); + await updateFile(moduleList, orderVO, pdfUrl, picUrl); Dialog.close("dialog"); // 进入第三步 setStep(3); @@ -223,7 +224,7 @@ export default hocAuth(function Page(props: CommonComponent) { }; // 截图预览内容 - const capturePreview = async () => { + const capturePreview = async (moduleList: any[]) => { const template = new PdfTemplate(moduleList); const { data: { data: pdfData }, @@ -242,13 +243,22 @@ export default hocAuth(function Page(props: CommonComponent) { setPdfUrl(pdfData?.path); setPicUrl(picData?.path); + return [pdfData?.path!, picData?.path!]; + }; + + const updateFile = async ( + moduleList: any[], + orderVO: BusinessAPI.OrderVO, + pdfUrl: string, + picUrl: string, + ) => { const orderShip = orderVO?.orderShipList[0]; // 存储 至 orderShip previewUrl if (orderShip) { let formData: BusinessAPI.OrderShipGenerateDocumentCmd = { orderShipId: orderShip?.orderShipId, - pdfUrl: pdfData?.path as string, - picUrl: picData?.path as string, + pdfUrl: pdfUrl as string, + picUrl: picUrl as string, }; // 检查各模块中的必填字段是否已填写 for (const module of moduleList) { @@ -314,6 +324,10 @@ export default hocAuth(function Page(props: CommonComponent) { setStep(1); }; + if (!orderVO) { + return; + } + return ( <> previewAndConfirm(moduleList, orderVO)} > 下一步 @@ -394,7 +408,7 @@ export default hocAuth(function Page(props: CommonComponent) { type="primary" block size={"large"} - onClick={generateShippingDocument} + onClick={() => generateShippingDocument(moduleList, orderVO)} > 生成发货单据 diff --git a/packages/app-client/src/utils/classes/templates/PdfTemplate.ts b/packages/app-client/src/utils/classes/templates/PdfTemplate.ts index 383ec51..c79a9ad 100644 --- a/packages/app-client/src/utils/classes/templates/PdfTemplate.ts +++ b/packages/app-client/src/utils/classes/templates/PdfTemplate.ts @@ -2,7 +2,6 @@ export class PdfTemplate { private moduleList: any[]; constructor(moduleList: any[]) { - console.log("moduleList",moduleList) this.moduleList = moduleList; } @@ -577,7 +576,7 @@ export class PdfTemplate {
${config.data?.reduce( - (acc: any, cur: any) => acc + cur.grossWeight, + (acc: any, cur: any) => acc + cur.netWeight, 0, )}