From 5a8a09a70c306e2ddaba35e056861429763eed2f Mon Sep 17 00:00:00 2001 From: valign <78541912+cuvalign@users.noreply.github.com> Date: Mon, 6 May 2024 23:40:38 +0800 Subject: [PATCH] =?UTF-8?q?fix(mis):=20=E8=AE=A1=E8=B4=B9=E8=B0=83?= =?UTF-8?q?=E6=95=B4=E7=B2=BE=E7=A1=AE=E5=88=B0=E5=88=86=20(#1236)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 涉及到金额的显示页面,全部只展示到分,涉及到金额的输入页面,全部限制为只允许输入精确到分。涉及到金额的导出,也全部只展示到分。 1. 仪表盘: a. 账户信息:“可用余额”; 2. 用户空间: a. 已结束的作业: “作业计费合计”、“作业计费”、“详情-作业计费”; b. 集群和分区信息:“单价”; c. 操作日志中,操作内容相关; 3. 账户管理: a. 账户信息:“账户余额”、“封锁阈值”; b. 已结束的作业: “作业计费合计”、“作业计费”、“详情-作业计费”; c. 用户管理:“已用额度/用户限额”、“限额管理-当前已使用/总限额”、“限额管理-修改限额至”; d. 充值记录:“合计”、“交费金额”; e. 消费记录:“合计”、“扣费金额”; 4. 租户管理 a. 租户信息:“租户余额”、“默认账户封锁阈值”、“设置默认账户封锁阈值”; b. 作业价格表: “单价(元)”、“设置计费价格-单价(元)”; c. 已结束的作业:“租户计费"、"平台计费”、详情中的“租户计费"、"平台计费”、“租户计费合计”、“平台计费合计”; d. 账户列表中所有金额相关; e. 白名单账户列表所有金额相关; f. 账户充值限制只能充值金额精确到分; g. 账户充值记录、租户充值记录、账户消费记录、操作日志所有金额相关; 5. 平台管理: a. 作业计费价格表、租户列表、账户列表所有金额相关; b. 充值记录、账户消费记录、操作日志所有金额相关; c. 平台数据统计:消费列,金额显示精确到分:消费/充值金额,可视图表金额显示精确到分,坐标轴动态tick动态精确到分。 --- apps/mis-web/src/pageComponents/admin/DataBarChart.tsx | 7 +++++-- apps/mis-web/src/pageComponents/admin/StatisticCard.tsx | 8 +++++--- apps/mis-web/src/pageComponents/common/PaymentTable.tsx | 4 ++-- .../src/pageComponents/dashboard/AccountInfoSection.tsx | 2 +- apps/mis-web/src/pageComponents/finance/ChargeForm.tsx | 2 +- apps/mis-web/src/pageComponents/finance/ChargeTable.tsx | 4 ++-- .../src/pageComponents/job/EditableJobBillingTable.tsx | 2 +- .../src/pageComponents/job/ManageJobBillingTable.tsx | 2 +- .../src/pageComponents/tenant/AccountWhitelistTable.tsx | 2 +- apps/mis-web/src/pages/accounts/[accountName]/info.tsx | 4 ++-- apps/mis-web/src/pages/admin/statistic.tsx | 9 +++++---- apps/mis-web/src/pages/tenant/info.tsx | 4 ++-- apps/mis-web/src/utils/money.ts | 4 ++-- 13 files changed, 30 insertions(+), 24 deletions(-) diff --git a/apps/mis-web/src/pageComponents/admin/DataBarChart.tsx b/apps/mis-web/src/pageComponents/admin/DataBarChart.tsx index e3de55df28..189239d710 100644 --- a/apps/mis-web/src/pageComponents/admin/DataBarChart.tsx +++ b/apps/mis-web/src/pageComponents/admin/DataBarChart.tsx @@ -45,7 +45,10 @@ export const DataBarChart: React.FC = ({ xLabel = "", toolTipFormatter = (value) => value, }) => { - + const tickFormatter = (value: number) => { + const roundedValue = Number.isInteger(value) ? value : parseFloat(value.toFixed(2)); + return roundedValue.toString(); + }; return ( {isLoading ? : ( @@ -64,7 +67,7 @@ export const DataBarChart: React.FC = ({ label={{ value: xLabel, position: "insideBottom", offset: 0 }} height={40} /> - + diff --git a/apps/mis-web/src/pageComponents/admin/StatisticCard.tsx b/apps/mis-web/src/pageComponents/admin/StatisticCard.tsx index 2a1bb5b943..fb73d0002f 100644 --- a/apps/mis-web/src/pageComponents/admin/StatisticCard.tsx +++ b/apps/mis-web/src/pageComponents/admin/StatisticCard.tsx @@ -22,6 +22,7 @@ interface Props { loading: boolean icon: React.ReactNode | React.ForwardRefExoticComponent<{}>; iconColor?: string + precision?: number | undefined } const Container = styled.div` @@ -40,7 +41,8 @@ const iconToNode = (Icon: any, color?: string) => { const p = prefix("pageComp.admin.statisticCard."); -export const StatisticCard: React.FC = ({ title, newAddValue = 0, totalValue = 0, loading, icon, iconColor }) => +export const StatisticCard: React.FC = ({ title, newAddValue = 0, + totalValue = 0, loading, icon, iconColor, precision = 0 }) => { const t = useI18nTranslateToString(); @@ -52,7 +54,7 @@ export const StatisticCard: React.FC = ({ title, newAddValue = 0, totalVa @@ -63,7 +65,7 @@ export const StatisticCard: React.FC = ({ title, newAddValue = 0, totalVa title={`${t(p("total"))}${title}: `} value={totalValue} loading={loading} - precision={0} + precision={precision} valueStyle={{ color: "grey", marginLeft: "10px", fontSize: 14, marginBottom: 4 }} /> diff --git a/apps/mis-web/src/pageComponents/common/PaymentTable.tsx b/apps/mis-web/src/pageComponents/common/PaymentTable.tsx index bc85dcce30..aeca298820 100644 --- a/apps/mis-web/src/pageComponents/common/PaymentTable.tsx +++ b/apps/mis-web/src/pageComponents/common/PaymentTable.tsx @@ -198,7 +198,7 @@ export const PaymentTable: React.FC = ({ accountName, searchType }) => { - {data ? data.total.toFixed(3) : 0} + {data ? data.total.toFixed(2) : 0} @@ -234,7 +234,7 @@ export const PaymentTable: React.FC = ({ accountName, searchType }) => { : undefined } formatDateTime(v)} /> - v.toFixed(3)} /> + v.toFixed(2)} /> = ({ info }) => { title={t("dashboard.account.balance")} valueStyle={{ color: minOne < 0 ? "red" : undefined }} prefix={"¥"} - value={minOne.toFixed(3)} + value={minOne.toFixed(2)} /> diff --git a/apps/mis-web/src/pageComponents/finance/ChargeForm.tsx b/apps/mis-web/src/pageComponents/finance/ChargeForm.tsx index 10e0a7a771..cbad1554f0 100644 --- a/apps/mis-web/src/pageComponents/finance/ChargeForm.tsx +++ b/apps/mis-web/src/pageComponents/finance/ChargeForm.tsx @@ -112,7 +112,7 @@ export const ChargeForm: React.FC = () => { - + = ({ - {totalResultData?.totalAmount ?? 0} + {totalResultData?.totalAmount?.toFixed(2) ?? 0} @@ -300,7 +300,7 @@ export const ChargeTable: React.FC = ({ render={(_, r) => r.userId ? (`${r.userId} (${r.userName})`) : ""} /> dataIndex="time" title={t(p("time"))} render={(v) => formatDateTime(v)} /> - dataIndex="amount" title={t(p("amount"))} render={(v) => v.toFixed(3)} /> + dataIndex="amount" title={t(p("amount"))} render={(v) => v.toFixed(2)} /> dataIndex="type" title={t(pCommon("type"))} /> dataIndex="comment" diff --git a/apps/mis-web/src/pageComponents/job/EditableJobBillingTable.tsx b/apps/mis-web/src/pageComponents/job/EditableJobBillingTable.tsx index aa872d8527..d351f62d14 100644 --- a/apps/mis-web/src/pageComponents/job/EditableJobBillingTable.tsx +++ b/apps/mis-web/src/pageComponents/job/EditableJobBillingTable.tsx @@ -79,7 +79,7 @@ const EditPriceModal: React.FC ({ label: x, value: x }))} /> - + diff --git a/apps/mis-web/src/pageComponents/job/ManageJobBillingTable.tsx b/apps/mis-web/src/pageComponents/job/ManageJobBillingTable.tsx index fdf5961c32..fd54868237 100644 --- a/apps/mis-web/src/pageComponents/job/ManageJobBillingTable.tsx +++ b/apps/mis-web/src/pageComponents/job/ManageJobBillingTable.tsx @@ -276,7 +276,7 @@ const EditPriceModal: React.FC - + diff --git a/apps/mis-web/src/pageComponents/tenant/AccountWhitelistTable.tsx b/apps/mis-web/src/pageComponents/tenant/AccountWhitelistTable.tsx index cc81be3de4..cf319d6e10 100644 --- a/apps/mis-web/src/pageComponents/tenant/AccountWhitelistTable.tsx +++ b/apps/mis-web/src/pageComponents/tenant/AccountWhitelistTable.tsx @@ -134,7 +134,7 @@ export const AccountWhitelistTable: React.FC = ({ <> - {t(p("debtSum"))}:{getTotalDebtAmount(data).toFixed(3)} {t(pCommon("unit"))} + {t(p("debtSum"))}:{getTotalDebtAmount(data).toFixed(2)} {t(pCommon("unit"))} diff --git a/apps/mis-web/src/pages/accounts/[accountName]/info.tsx b/apps/mis-web/src/pages/accounts/[accountName]/info.tsx index 637ee10cf8..dc3f56b375 100644 --- a/apps/mis-web/src/pages/accounts/[accountName]/info.tsx +++ b/apps/mis-web/src/pages/accounts/[accountName]/info.tsx @@ -69,10 +69,10 @@ export const AccountInfoPage: NextPage = requireAuth( - {balance.toFixed(3)} {t("common.unit")} + {balance.toFixed(2)} {t("common.unit")} - {blockThresholdAmount.toFixed(3)} {t("common.unit")} + {blockThresholdAmount.toFixed(2)} {t("common.unit")} diff --git a/apps/mis-web/src/pages/admin/statistic.tsx b/apps/mis-web/src/pages/admin/statistic.tsx index 5db7be9187..86f43cff96 100644 --- a/apps/mis-web/src/pages/admin/statistic.tsx +++ b/apps/mis-web/src/pages/admin/statistic.tsx @@ -244,7 +244,7 @@ requireAuth((u) => u.platformRoles.includes(PlatformRole.PLATFORM_ADMIN)) return topChargeAccount?.results.map((r) => ({ x: r.accountName, - y: moneyToNumber(r.chargedAmount), + y: moneyToNumber(r.chargedAmount).toFixed(2), })) || []; }, [query, topChargeAccount]); @@ -252,7 +252,7 @@ requireAuth((u) => u.platformRoles.includes(PlatformRole.PLATFORM_ADMIN)) return topPayAccount?.results.map((r) => ({ x: r.accountName, - y: moneyToNumber(r.payAmount), + y: moneyToNumber(r.payAmount).toFixed(2), })) || []; }, [query, topPayAccount]); @@ -383,6 +383,7 @@ requireAuth((u) => u.platformRoles.includes(PlatformRole.PLATFORM_ADMIN)) loading={totalChargeAmountLoading || dailyChargeLoading} icon={MoneyCollectOutlined} iconColor="#feca57" + precision={2} /> @@ -446,7 +447,7 @@ requireAuth((u) => u.platformRoles.includes(PlatformRole.PLATFORM_ADMIN)) ({ x: d.date.format("YYYY-MM-DD"), - y: d.count, + y: d.count.toFixed(2), }))} title={t(p("chargeAmount"))} isLoading={dailyChargeLoading} @@ -468,7 +469,7 @@ requireAuth((u) => u.platformRoles.includes(PlatformRole.PLATFORM_ADMIN)) ({ x: d.date.format("YYYY-MM-DD"), - y: d.count, + y: d.count.toFixed(2), }))} title={t(p("payAmount"))} toolTipFormatter={amountToolTipFormatter} diff --git a/apps/mis-web/src/pages/tenant/info.tsx b/apps/mis-web/src/pages/tenant/info.tsx index bc7a3a418c..b2c05771ef 100644 --- a/apps/mis-web/src/pages/tenant/info.tsx +++ b/apps/mis-web/src/pages/tenant/info.tsx @@ -87,12 +87,12 @@ export const TenantInfoPage: NextPage = requireAuth((u) => u.tenantRoles. {userCount} - {moneyToNumber(balance).toFixed(3)} {t("common.unit")} + {moneyToNumber(balance).toFixed(2)} {t("common.unit")} - {moneyToNumber(defaultAccountBlockThreshold).toFixed(3)} {t("common.unit")} + {moneyToNumber(defaultAccountBlockThreshold).toFixed(2)} {t("common.unit")}