fix: 修复 MALL 商品列表/选择器「价格」列展示原始的「分」(web-antd / web-ele)

商品列表 [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 处理。
dev
YunaiV 2026-05-02 19:38:50 +08:00
parent 228c5463da
commit 8020b4b743
4 changed files with 18 additions and 26 deletions

View File

@ -89,10 +89,10 @@ export function useGridColumns(
},
{
field: 'price',
title: '商品售价',
title: '商品售价(元)',
minWidth: 90,
align: 'center',
formatter: 'formatAmount2',
formatter: 'formatFenToYuanAmount',
},
{
field: 'salesCount',

View File

@ -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',

View File

@ -88,10 +88,10 @@ export function useGridColumns(
},
{
field: 'price',
title: '商品售价',
title: '商品售价(元)',
minWidth: 90,
align: 'center',
formatter: 'formatAmount2',
formatter: 'formatFenToYuanAmount',
},
{
field: 'salesCount',

View File

@ -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',