From 5b08e9cc8a55d2caf291cf72f15a36ef5232560c Mon Sep 17 00:00:00 2001 From: lanyuanxiaoyao Date: Fri, 12 Sep 2025 17:54:18 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E6=95=B0=E5=AD=97?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- leopard-web/src/pages/stock/StockDetail.tsx | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/leopard-web/src/pages/stock/StockDetail.tsx b/leopard-web/src/pages/stock/StockDetail.tsx index 4a7d019..d7616b0 100644 --- a/leopard-web/src/pages/stock/StockDetail.tsx +++ b/leopard-web/src/pages/stock/StockDetail.tsx @@ -3,6 +3,17 @@ import {useParams} from 'react-router' import {amisRender, commonInfo, readOnlyDialogOptions, remoteMappings} from '../../util/amis.tsx' import type {Schema} from 'amis' +// 格式化财务数字显示的公共函数 +const formatFinanceNumber = (value: number): string => { + if (value >= 100000000) { + return (value / 100000000).toFixed(2) + '亿' + } else if (value >= 10000) { + return (value / 10000).toFixed(2) + '万' + } else { + return value.toLocaleString() + } +} + const financePropertyLabel = (id: string | undefined, label: string, type: string, field: string): Schema => { if (!id) { return { @@ -45,6 +56,10 @@ const financePropertyLabel = (id: string | undefined, label: string, type: strin color: '#333', }, padding: [10, 15], + formatter: (params: any) => { + const item = params[0] + return `${item.name}
${item.marker}${formatFinanceNumber(item.value)}` + }, }, grid: { left: '5%', @@ -90,6 +105,9 @@ const financePropertyLabel = (id: string | undefined, label: string, type: strin axisLabel: { color: '#999', fontSize: 12, + formatter: (value: number) => { + return formatFinanceNumber(value) + }, }, axisTick: { show: false, @@ -134,6 +152,9 @@ const financePropertyLabel = (id: string | undefined, label: string, type: strin color: '#333', fontWeight: 'bold', fontSize: 12, + formatter: (params: any) => { + return formatFinanceNumber(params.value) + }, }, }, ],