From 8020b4b743789675b83d18136255265d87d3b366 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 2 May 2026 19:38:50 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20MALL=20=E5=95=86?= =?UTF-8?q?=E5=93=81=E5=88=97=E8=A1=A8/=E9=80=89=E6=8B=A9=E5=99=A8?= =?UTF-8?q?=E3=80=8C=E4=BB=B7=E6=A0=BC=E3=80=8D=E5=88=97=E5=B1=95=E7=A4=BA?= =?UTF-8?q?=E5=8E=9F=E5=A7=8B=E7=9A=84=E3=80=8C=E5=88=86=E3=80=8D=EF=BC=88?= =?UTF-8?q?web-antd=20/=20web-ele=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 商品列表 [mall/product/spu/data.ts] 与商品选择器 [mall/product/spu/components/spu-select-data.ts] 的「价格」列原先 formatter: 'formatAmount2',只做了小数格式化、漏了「分转元」,导致 19900 直接显示成 19900.00(应为 199.00 元)。同文件的 marketPrice / costPrice 已正确使用 fenToYuan,唯独 price 漏了。 顺手将 spu/data.ts 的 price / marketPrice / costPrice 三列从手写闭包统一切到已注册的 formatFenToYuanAmount formatter,单位「元」从 cell 后缀挪进列标题(如「价格(元)」), 减少 8 处闭包并复用平台统一的 null/NaN 处理。 --- .../product/spu/components/spu-select-data.ts | 4 ++-- .../src/views/mall/product/spu/data.ts | 18 +++++++----------- .../product/spu/components/spu-select-data.ts | 4 ++-- .../web-ele/src/views/mall/product/spu/data.ts | 18 +++++++----------- 4 files changed, 18 insertions(+), 26 deletions(-) diff --git a/apps/web-antd/src/views/mall/product/spu/components/spu-select-data.ts b/apps/web-antd/src/views/mall/product/spu/components/spu-select-data.ts index d2f45c864..d0a9dfc9f 100644 --- a/apps/web-antd/src/views/mall/product/spu/components/spu-select-data.ts +++ b/apps/web-antd/src/views/mall/product/spu/components/spu-select-data.ts @@ -89,10 +89,10 @@ export function useGridColumns( }, { field: 'price', - title: '商品售价', + title: '商品售价(元)', minWidth: 90, align: 'center', - formatter: 'formatAmount2', + formatter: 'formatFenToYuanAmount', }, { field: 'salesCount', diff --git a/apps/web-antd/src/views/mall/product/spu/data.ts b/apps/web-antd/src/views/mall/product/spu/data.ts index 4373022bd..cc71ef707 100644 --- a/apps/web-antd/src/views/mall/product/spu/data.ts +++ b/apps/web-antd/src/views/mall/product/spu/data.ts @@ -2,7 +2,7 @@ import type { VbenFormSchema } from '#/adapter/form'; import type { VxeTableGridOptions } from '#/adapter/vxe-table'; import type { MallSpuApi } from '#/api/mall/product/spu'; -import { fenToYuan, handleTree, treeToString } from '@vben/utils'; +import { handleTree, treeToString } from '@vben/utils'; import { getCategoryList } from '#/api/mall/product/category'; import { getRangePickerDefaultProps } from '#/utils'; @@ -101,25 +101,21 @@ export function useGridColumns( }, { field: 'price', - title: '价格', + title: '价格(元)', minWidth: 100, - formatter: 'formatAmount2', + formatter: 'formatFenToYuanAmount', }, { field: 'marketPrice', - title: '市场价', + title: '市场价(元)', minWidth: 100, - formatter: ({ row }) => { - return `${fenToYuan(row.marketPrice)} 元`; - }, + formatter: 'formatFenToYuanAmount', }, { field: 'costPrice', - title: '成本价', + title: '成本价(元)', minWidth: 100, - formatter: ({ row }) => { - return `${fenToYuan(row.costPrice)} 元`; - }, + formatter: 'formatFenToYuanAmount', }, { field: 'salesCount', diff --git a/apps/web-ele/src/views/mall/product/spu/components/spu-select-data.ts b/apps/web-ele/src/views/mall/product/spu/components/spu-select-data.ts index bb1296995..693966e50 100644 --- a/apps/web-ele/src/views/mall/product/spu/components/spu-select-data.ts +++ b/apps/web-ele/src/views/mall/product/spu/components/spu-select-data.ts @@ -88,10 +88,10 @@ export function useGridColumns( }, { field: 'price', - title: '商品售价', + title: '商品售价(元)', minWidth: 90, align: 'center', - formatter: 'formatAmount2', + formatter: 'formatFenToYuanAmount', }, { field: 'salesCount', 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 f26dc8e43..5bc5695aa 100644 --- a/apps/web-ele/src/views/mall/product/spu/data.ts +++ b/apps/web-ele/src/views/mall/product/spu/data.ts @@ -2,7 +2,7 @@ import type { VbenFormSchema } from '#/adapter/form'; import type { VxeTableGridOptions } from '#/adapter/vxe-table'; import type { MallSpuApi } from '#/api/mall/product/spu'; -import { fenToYuan, handleTree, treeToString } from '@vben/utils'; +import { handleTree, treeToString } from '@vben/utils'; import { getCategoryList } from '#/api/mall/product/category'; import { getRangePickerDefaultProps } from '#/utils'; @@ -105,25 +105,21 @@ export function useGridColumns( }, { field: 'price', - title: '价格', + title: '价格(元)', minWidth: 100, - formatter: 'formatAmount2', + formatter: 'formatFenToYuanAmount', }, { field: 'marketPrice', - title: '市场价', + title: '市场价(元)', minWidth: 100, - formatter: ({ row }) => { - return `${fenToYuan(row.marketPrice)} 元`; - }, + formatter: 'formatFenToYuanAmount', }, { field: 'costPrice', - title: '成本价', + title: '成本价(元)', minWidth: 100, - formatter: ({ row }) => { - return `${fenToYuan(row.costPrice)} 元`; - }, + formatter: 'formatFenToYuanAmount', }, { field: 'salesCount',