diff --git a/src/components/bill/list.tsx b/src/components/bill/list.tsx index ca6c704..a0645a3 100644 --- a/src/components/bill/list.tsx +++ b/src/components/bill/list.tsx @@ -113,7 +113,7 @@ export const BillList: React.FC = (props) => { title: t('bill.title_actual_payment_amount'), dataIndex: 'actual_payment_amount', width: 150, - render: (_) => (), + render: (_,record) => (), }, { title: t('bill.title_pay_method'), diff --git a/src/components/money-format.tsx b/src/components/money-format.tsx index 93dcf58..c488601 100644 --- a/src/components/money-format.tsx +++ b/src/components/money-format.tsx @@ -2,11 +2,37 @@ import React from "react"; type MoneyFormatProps = { money?: number | string | null; - currency?: 'US$' | 'HK$' | 'RMB'; + currency?: string; +} +const AsiaPayCurrencyConfig: { + [key: string]: string +} = { + '344': 'HKD', + '840': 'USD', + "702": 'SGD', + "156": 'CNY(RMB)', + "392": 'JPY', + "901": 'TWD', + "036": 'AUD', + "978": 'EUR', + "826": 'GBP', + "124": 'CAD', + "446": 'MOP', + "608": 'PHP', + "764": 'THB', + "458": 'MYR', + "360": 'IDR', + "410": 'KRW', + "682": 'SAR', + "554": 'NZD', + "784": 'AED', + "096": 'BND', + "704": 'VND', + "356": 'INR', } -function formatCurrency(amount: string | number) { - if(amount === '0' || amount === '0.00') { +function formatMoneyNumber(amount: string | number) { + if (amount === '0' || amount === '0.00') { return '0.00'; } // 将金额转换为字符串,并限制小数点后两位 @@ -25,8 +51,16 @@ function formatCurrency(amount: string | number) { return (isNegative ? '-' : '') + formattedIntPart + '.' + decimalPart; } -const MoneyFormat: React.FC = ({money, currency = 'HK$'}) => { +const formatCurrency = (currency = 'HKD') => { + if (currency && /^\d{3}$/.test(currency)) { + return AsiaPayCurrencyConfig[currency] || currency || 'HKD'; + } + return currency || 'HKD'; +} + +const MoneyFormat: React.FC = ({money, currency = 'HKD'}) => { // 将货币数字转换为千分位格式且带2位小数 - return (money||money==0||money=='0') ?{currency} {formatCurrency(money)}:null; + return (money || money == 0 || money == '0') ? + {formatCurrency(currency)} {formatMoneyNumber(money)} : null; } export default MoneyFormat; \ No newline at end of file diff --git a/src/types/bill.d.ts b/src/types/bill.d.ts index b3404ca..990ec03 100644 --- a/src/types/bill.d.ts +++ b/src/types/bill.d.ts @@ -52,7 +52,7 @@ declare type BillModel = { payment_amount?: number; actual_payment_amount?: null | number; payment_method?: null | string | number; - currency?: null | string | number; + currency?: string; payment_channel?: null | string | number; expiration_time?: BaseDate; status: string;