From 067df741b48688d9b70d624cee4c797fba4b4bbf Mon Sep 17 00:00:00 2001 From: lrl <252048765@qq.com> Date: Mon, 14 Jul 2025 13:24:26 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=20fen=20=E8=BD=AC=20?= =?UTF-8?q?yuan=20=E9=87=91=E9=A2=9D=E6=A0=BC=E5=BC=8F=E5=8C=96=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 vxe-table 格式化方法中添加 formatFenToYuanAmount - 该方法将 fen 单位的金额转换为 yuan 单位,并进行格式化 - 在多个模块中将 formatAmount2 替换为 formatFenToYuanAmount --- apps/web-antd/src/adapter/vxe-table.ts | 7 +++++++ apps/web-ele/src/adapter/vxe-table.ts | 7 +++++++ apps/web-ele/src/views/mall/product/spu/data.ts | 2 +- .../src/views/mall/promotion/bargain/activity/data.ts | 4 ++-- .../src/views/mall/promotion/bargain/record/data.ts | 6 +++--- .../src/views/mall/promotion/point/activity/data.ts | 4 ++-- apps/web-ele/src/views/mall/trade/afterSale/data.ts | 2 +- .../src/views/mall/trade/brokerage/withdraw/data.ts | 4 ++-- .../src/views/mall/trade/delivery/pickUpOrder/data.ts | 2 +- apps/web-ele/src/views/mall/trade/order/data.ts | 2 +- apps/web-ele/src/views/pay/demo/order/data.ts | 4 ++-- apps/web-ele/src/views/pay/demo/withdraw/data.ts | 2 +- apps/web-ele/src/views/pay/order/data.ts | 6 +++--- apps/web-ele/src/views/pay/refund/data.ts | 4 ++-- apps/web-ele/src/views/pay/transfer/data.ts | 2 +- apps/web-ele/src/views/pay/wallet/balance/data.ts | 8 ++++---- apps/web-ele/src/views/pay/wallet/rechargePackage/data.ts | 4 ++-- 17 files changed, 42 insertions(+), 28 deletions(-) diff --git a/apps/web-antd/src/adapter/vxe-table.ts b/apps/web-antd/src/adapter/vxe-table.ts index 2e8fb5bc6..69f855503 100644 --- a/apps/web-antd/src/adapter/vxe-table.ts +++ b/apps/web-antd/src/adapter/vxe-table.ts @@ -13,6 +13,7 @@ import { import { erpCountInputFormatter, erpNumberFormatter, + fenToYuan, formatPast2, isFunction, isString, @@ -343,6 +344,12 @@ setupVbenVxeTable({ return `${erpNumberFormatter(cellValue, digits)}元`; }, }); + + vxeUI.formats.add('formatFenToYuanAmount', { + tableCellFormatMethod({ cellValue }, digits = 2) { + return `${erpNumberFormatter(fenToYuan(cellValue), digits)}元`; + }, + }); }, useVbenForm, }); diff --git a/apps/web-ele/src/adapter/vxe-table.ts b/apps/web-ele/src/adapter/vxe-table.ts index a2938b977..9c36e196a 100644 --- a/apps/web-ele/src/adapter/vxe-table.ts +++ b/apps/web-ele/src/adapter/vxe-table.ts @@ -13,6 +13,7 @@ import { import { erpCountInputFormatter, erpNumberFormatter, + fenToYuan, formatPast2, isFunction, isString, @@ -297,6 +298,12 @@ setupVbenVxeTable({ return `${erpNumberFormatter(cellValue, digits)}元`; }, }); + + vxeUI.formats.add('formatFenToYuanAmount', { + tableCellFormatMethod({ cellValue }, digits = 2) { + return `${erpNumberFormatter(fenToYuan(cellValue), digits)}元`; + }, + }); }, useVbenForm, }); diff --git a/apps/web-ele/src/views/mall/product/spu/data.ts b/apps/web-ele/src/views/mall/product/spu/data.ts index 6ceb265ea..0d4c0a219 100644 --- a/apps/web-ele/src/views/mall/product/spu/data.ts +++ b/apps/web-ele/src/views/mall/product/spu/data.ts @@ -74,7 +74,7 @@ export function useGridColumns( { field: 'price', title: '价格', - formatter: 'formatAmount2', + formatter: 'formatFenToYuanAmount', }, { field: 'salesCount', diff --git a/apps/web-ele/src/views/mall/promotion/bargain/activity/data.ts b/apps/web-ele/src/views/mall/promotion/bargain/activity/data.ts index 80285f23c..b41cb3ab4 100644 --- a/apps/web-ele/src/views/mall/promotion/bargain/activity/data.ts +++ b/apps/web-ele/src/views/mall/promotion/bargain/activity/data.ts @@ -204,13 +204,13 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { field: 'bargainFirstPrice', title: '起始价格', minWidth: 100, - formatter: 'formatAmount2', + formatter: 'formatFenToYuanAmount', }, { field: 'bargainMinPrice', title: '砍价底价', minWidth: 100, - formatter: 'formatAmount2', + formatter: 'formatFenToYuanAmount', }, { field: 'recordUserCount', diff --git a/apps/web-ele/src/views/mall/promotion/bargain/record/data.ts b/apps/web-ele/src/views/mall/promotion/bargain/record/data.ts index 9bd74a66e..74d904fe5 100644 --- a/apps/web-ele/src/views/mall/promotion/bargain/record/data.ts +++ b/apps/web-ele/src/views/mall/promotion/bargain/record/data.ts @@ -72,13 +72,13 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { field: 'activity.bargainMinPrice', title: '最低价', minWidth: 100, - formatter: 'formatAmount2', + formatter: 'formatFenToYuanAmount', }, { field: 'bargainPrice', title: '当前价', minWidth: 100, - formatter: 'formatAmount2', + formatter: 'formatFenToYuanAmount', }, { field: 'activity.helpMaxCount', @@ -149,7 +149,7 @@ export function useHelpGridColumns(): VxeTableGridOptions['columns'] { field: 'reducePrice', title: '砍价金额', minWidth: 100, - formatter: 'formatAmount2', + formatter: 'formatFenToYuanAmount', }, { field: 'createTime', diff --git a/apps/web-ele/src/views/mall/promotion/point/activity/data.ts b/apps/web-ele/src/views/mall/promotion/point/activity/data.ts index 276254754..03a89bda5 100644 --- a/apps/web-ele/src/views/mall/promotion/point/activity/data.ts +++ b/apps/web-ele/src/views/mall/promotion/point/activity/data.ts @@ -86,7 +86,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { field: 'marketPrice', title: '原价', minWidth: 100, - formatter: 'formatAmount2', + formatter: 'formatFenToYuanAmount', }, { field: 'point', @@ -97,7 +97,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { field: 'price', title: '兑换金额', minWidth: 100, - formatter: 'formatAmount2', + formatter: 'formatFenToYuanAmount', }, { field: 'status', diff --git a/apps/web-ele/src/views/mall/trade/afterSale/data.ts b/apps/web-ele/src/views/mall/trade/afterSale/data.ts index fbe685f19..652757a78 100644 --- a/apps/web-ele/src/views/mall/trade/afterSale/data.ts +++ b/apps/web-ele/src/views/mall/trade/afterSale/data.ts @@ -99,7 +99,7 @@ export function useGridColumns(): VxeGridPropTypes.Columns { { field: 'refundPrice', title: '订单金额', - formatter: 'formatAmount2', + formatter: 'formatFenToYuanAmount', }, { field: 'user.nickname', diff --git a/apps/web-ele/src/views/mall/trade/brokerage/withdraw/data.ts b/apps/web-ele/src/views/mall/trade/brokerage/withdraw/data.ts index f72e5281d..34bce2063 100644 --- a/apps/web-ele/src/views/mall/trade/brokerage/withdraw/data.ts +++ b/apps/web-ele/src/views/mall/trade/brokerage/withdraw/data.ts @@ -97,13 +97,13 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { field: 'price', title: '提现金额', minWidth: 80, - formatter: 'formatAmount2', + formatter: 'formatFenToYuanAmount', }, { field: 'feePrice', title: '提现手续费', minWidth: 80, - formatter: 'formatAmount2', + formatter: 'formatFenToYuanAmount', }, { field: 'type', diff --git a/apps/web-ele/src/views/mall/trade/delivery/pickUpOrder/data.ts b/apps/web-ele/src/views/mall/trade/delivery/pickUpOrder/data.ts index f68f275fa..a02080385 100644 --- a/apps/web-ele/src/views/mall/trade/delivery/pickUpOrder/data.ts +++ b/apps/web-ele/src/views/mall/trade/delivery/pickUpOrder/data.ts @@ -81,7 +81,7 @@ export function useGridColumns(): VxeGridPropTypes.Columns { { field: 'payPrice', title: '实付金额(元)', - formatter: 'formatAmount2', + formatter: 'formatFenToYuanAmount', minWidth: 180, }, { diff --git a/apps/web-ele/src/views/mall/trade/order/data.ts b/apps/web-ele/src/views/mall/trade/order/data.ts index 6fc928244..e81813aba 100644 --- a/apps/web-ele/src/views/mall/trade/order/data.ts +++ b/apps/web-ele/src/views/mall/trade/order/data.ts @@ -166,7 +166,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { { field: 'payPrice', title: '实际支付', - formatter: 'formatAmount2', + formatter: 'formatFenToYuanAmount', minWidth: 180, }, { diff --git a/apps/web-ele/src/views/pay/demo/order/data.ts b/apps/web-ele/src/views/pay/demo/order/data.ts index 9dde3e144..db91034d1 100644 --- a/apps/web-ele/src/views/pay/demo/order/data.ts +++ b/apps/web-ele/src/views/pay/demo/order/data.ts @@ -50,12 +50,12 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { { field: 'price', title: '支付价格', - formatter: 'formatAmount2', + formatter: 'formatFenToYuanAmount', }, { field: 'refundPrice', title: '退款金额', - formatter: 'formatAmount2', + formatter: 'formatFenToYuanAmount', }, { field: 'createTime', diff --git a/apps/web-ele/src/views/pay/demo/withdraw/data.ts b/apps/web-ele/src/views/pay/demo/withdraw/data.ts index bd2ee6169..f73f65d60 100644 --- a/apps/web-ele/src/views/pay/demo/withdraw/data.ts +++ b/apps/web-ele/src/views/pay/demo/withdraw/data.ts @@ -78,7 +78,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { { field: 'price', title: '提现金额', - formatter: 'formatAmount2', + formatter: 'formatFenToYuanAmount', }, { field: 'userName', diff --git a/apps/web-ele/src/views/pay/order/data.ts b/apps/web-ele/src/views/pay/order/data.ts index cf45aa528..d3a2a522a 100644 --- a/apps/web-ele/src/views/pay/order/data.ts +++ b/apps/web-ele/src/views/pay/order/data.ts @@ -87,17 +87,17 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { { title: '支付金额', field: 'price', - formatter: 'formatAmount2', + formatter: 'formatFenToYuanAmount', }, { title: '退款金额', field: 'refundPrice', - formatter: 'formatAmount2', + formatter: 'formatFenToYuanAmount', }, { title: '手续金额', field: 'channelFeePrice', - formatter: 'formatAmount2', + formatter: 'formatFenToYuanAmount', }, { title: '订单号', diff --git a/apps/web-ele/src/views/pay/refund/data.ts b/apps/web-ele/src/views/pay/refund/data.ts index fdf384a95..2050fcd37 100644 --- a/apps/web-ele/src/views/pay/refund/data.ts +++ b/apps/web-ele/src/views/pay/refund/data.ts @@ -99,12 +99,12 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { { field: 'payPrice', title: '支付金额', - formatter: 'formatAmount2', + formatter: 'formatFenToYuanAmount', }, { field: 'refundPrice', title: '退款金额', - formatter: 'formatAmount2', + formatter: 'formatFenToYuanAmount', }, { field: 'status', diff --git a/apps/web-ele/src/views/pay/transfer/data.ts b/apps/web-ele/src/views/pay/transfer/data.ts index b59ae2f12..9da7183b6 100644 --- a/apps/web-ele/src/views/pay/transfer/data.ts +++ b/apps/web-ele/src/views/pay/transfer/data.ts @@ -120,7 +120,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { { field: 'price', title: '转账金额', - formatter: 'formatAmount2', + formatter: 'formatFenToYuanAmount', }, { field: 'status', diff --git a/apps/web-ele/src/views/pay/wallet/balance/data.ts b/apps/web-ele/src/views/pay/wallet/balance/data.ts index 59d064c5e..c1598e8ca 100644 --- a/apps/web-ele/src/views/pay/wallet/balance/data.ts +++ b/apps/web-ele/src/views/pay/wallet/balance/data.ts @@ -54,22 +54,22 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { { title: '余额', field: 'balance', - formatter: 'formatAmount2', + formatter: 'formatFenToYuanAmount', }, { title: '累计支出', field: 'totalExpense', - formatter: 'formatAmount2', + formatter: 'formatFenToYuanAmount', }, { title: '累计充值', field: 'totalRecharge', - formatter: 'formatAmount2', + formatter: 'formatFenToYuanAmount', }, { title: '冻结金额', field: 'freezePrice', - formatter: 'formatAmount2', + formatter: 'formatFenToYuanAmount', }, { title: '创建时间', diff --git a/apps/web-ele/src/views/pay/wallet/rechargePackage/data.ts b/apps/web-ele/src/views/pay/wallet/rechargePackage/data.ts index d365a6f73..40c263164 100644 --- a/apps/web-ele/src/views/pay/wallet/rechargePackage/data.ts +++ b/apps/web-ele/src/views/pay/wallet/rechargePackage/data.ts @@ -89,12 +89,12 @@ export function useGridColumns(): VxeTableGridOptions['columns'] { { field: 'payPrice', title: '支付金额', - formatter: 'formatAmount2', + formatter: 'formatFenToYuanAmount', }, { field: 'bonusPrice', title: '赠送金额', - formatter: 'formatAmount2', + formatter: 'formatFenToYuanAmount', }, { field: 'status',