feat:【antd】调整 formatNumber 为 formatAmount3 保留 3 位,formatAmount2 保留 2 位

This commit is contained in:
YunaiV
2025-10-04 14:53:31 +08:00
parent ceabd731ba
commit 3182a86b80
13 changed files with 59 additions and 33 deletions

View File

@@ -332,13 +332,13 @@ setupVbenVxeTable({
}, },
}); });
// add by 星语:数量格式化,例如说:金额 // add by 星语:数量格式化,保留 3 位
vxeUI.formats.add('formatNumber', { vxeUI.formats.add('formatAmount3', {
tableCellFormatMethod({ cellValue }) { tableCellFormatMethod({ cellValue }) {
return erpCountInputFormatter(cellValue); return erpCountInputFormatter(cellValue);
}, },
}); });
// add by 星语:数量格式化,保留 2 位
vxeUI.formats.add('formatAmount2', { vxeUI.formats.add('formatAmount2', {
tableCellFormatMethod({ cellValue }, digits = 2) { tableCellFormatMethod({ cellValue }, digits = 2) {
return `${erpNumberFormatter(cellValue, digits)}`; return `${erpNumberFormatter(cellValue, digits)}`;

View File

@@ -43,7 +43,7 @@ export function useDetailListColumns(
{ {
field: 'count', field: 'count',
title: '数量', title: '数量',
formatter: 'formatNumber', formatter: 'formatAmount3',
}, },
{ {
field: 'totalPrice', field: 'totalPrice',

View File

@@ -452,18 +452,19 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
{ {
field: 'totalCount', field: 'totalCount',
title: '总数量', title: '总数量',
formatter: 'formatAmount3',
minWidth: 120, minWidth: 120,
}, },
{ {
field: 'totalPrice', field: 'totalPrice',
title: '应付金额', title: '应付金额',
formatter: 'formatNumber', formatter: 'formatAmount2',
minWidth: 120, minWidth: 120,
}, },
{ {
field: 'paymentPrice', field: 'paymentPrice',
title: '已付金额', title: '已付金额',
formatter: 'formatNumber', formatter: 'formatAmount2',
minWidth: 120, minWidth: 120,
}, },
{ {
@@ -564,23 +565,25 @@ export function useOrderGridColumns(): VxeTableGridOptions['columns'] {
{ {
field: 'totalCount', field: 'totalCount',
title: '总数量', title: '总数量',
formatter: 'formatAmount3',
minWidth: 120, minWidth: 120,
}, },
{ {
field: 'inCount', field: 'inCount',
title: '入库数量', title: '入库数量',
formatter: 'formatAmount3',
minWidth: 120, minWidth: 120,
}, },
{ {
field: 'totalProductPrice', field: 'totalProductPrice',
title: '金额合计', title: '金额合计',
formatter: 'formatNumber', formatter: 'formatAmount2',
minWidth: 120, minWidth: 120,
}, },
{ {
field: 'totalPrice', field: 'totalPrice',
title: '含税金额', title: '含税金额',
formatter: 'formatNumber', formatter: 'formatAmount2',
minWidth: 120, minWidth: 120,
}, },
]; ];

View File

@@ -379,34 +379,37 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
{ {
field: 'totalCount', field: 'totalCount',
title: '总数量', title: '总数量',
formatter: 'formatAmount3',
minWidth: 120, minWidth: 120,
}, },
{ {
field: 'inCount', field: 'inCount',
title: '入库数量', title: '入库数量',
formatter: 'formatAmount3',
minWidth: 120, minWidth: 120,
}, },
{ {
field: 'returnCount', field: 'returnCount',
title: '退货数量', title: '退货数量',
formatter: 'formatAmount3',
minWidth: 120, minWidth: 120,
}, },
{ {
field: 'totalProductPrice', field: 'totalProductPrice',
title: '金额合计', title: '金额合计',
formatter: 'formatNumber', formatter: 'formatAmount2',
minWidth: 120, minWidth: 120,
}, },
{ {
field: 'totalPrice', field: 'totalPrice',
title: '含税金额', title: '含税金额',
formatter: 'formatNumber', formatter: 'formatAmount2',
minWidth: 120, minWidth: 120,
}, },
{ {
field: 'depositPrice', field: 'depositPrice',
title: '支付订金', title: '支付订金',
formatter: 'formatNumber', formatter: 'formatAmount2',
minWidth: 120, minWidth: 120,
}, },
{ {

View File

@@ -452,6 +452,7 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
{ {
field: 'totalCount', field: 'totalCount',
title: '总数量', title: '总数量',
formatter: 'formatAmount3',
minWidth: 120, minWidth: 120,
}, },
{ {
@@ -572,28 +573,31 @@ export function useOrderGridColumns(): VxeTableGridOptions['columns'] {
{ {
field: 'totalCount', field: 'totalCount',
title: '总数量', title: '总数量',
formatter: 'formatAmount3',
minWidth: 120, minWidth: 120,
}, },
{ {
field: 'inCount', field: 'inCount',
title: '入库数量', title: '入库数量',
formatter: 'formatAmount3',
minWidth: 120, minWidth: 120,
}, },
{ {
field: 'returnCount', field: 'returnCount',
title: '退货数量', title: '退货数量',
formatter: 'formatAmount3',
minWidth: 120, minWidth: 120,
}, },
{ {
field: 'totalProductPrice', field: 'totalProductPrice',
title: '金额合计', title: '金额合计',
formatter: 'formatNumber', formatter: 'formatAmount2',
minWidth: 120, minWidth: 120,
}, },
{ {
field: 'totalPrice', field: 'totalPrice',
title: '含税金额', title: '含税金额',
formatter: 'formatNumber', formatter: 'formatAmount2',
minWidth: 120, minWidth: 120,
}, },
]; ];

View File

@@ -409,34 +409,37 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
{ {
field: 'totalCount', field: 'totalCount',
title: '总数量', title: '总数量',
formatter: 'formatAmount3',
minWidth: 120, minWidth: 120,
}, },
{ {
field: 'outCount', field: 'outCount',
title: '出库数量', title: '出库数量',
formatter: 'formatAmount3',
minWidth: 120, minWidth: 120,
}, },
{ {
field: 'returnCount', field: 'returnCount',
title: '退货数量', title: '退货数量',
formatter: 'formatAmount3',
minWidth: 120, minWidth: 120,
}, },
{ {
field: 'totalProductPrice', field: 'totalProductPrice',
title: '金额合计', title: '金额合计',
formatter: 'formatNumber', formatter: 'formatAmount2',
minWidth: 120, minWidth: 120,
}, },
{ {
field: 'totalPrice', field: 'totalPrice',
title: '含税金额', title: '含税金额',
formatter: 'formatNumber', formatter: 'formatAmount2',
minWidth: 120, minWidth: 120,
}, },
{ {
field: 'depositPrice', field: 'depositPrice',
title: '收取订金', title: '收取订金',
formatter: 'formatNumber', formatter: 'formatAmount2',
minWidth: 120, minWidth: 120,
}, },
{ {

View File

@@ -197,7 +197,7 @@ export function useFormSchema(formType: string): VbenFormSchema[] {
componentProps: { componentProps: {
precision: 2, precision: 2,
min: 0, min: 0,
disabled: true disabled: true,
}, },
rules: z.number().min(0).optional(), rules: z.number().min(0).optional(),
}, },
@@ -456,18 +456,19 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
{ {
field: 'totalCount', field: 'totalCount',
title: '总数量', title: '总数量',
formatter: 'formatAmount3',
minWidth: 120, minWidth: 120,
}, },
{ {
field: 'totalPrice', field: 'totalPrice',
title: '应收金额', title: '应收金额',
formatter: 'formatNumber', formatter: 'formatAmount2',
minWidth: 120, minWidth: 120,
}, },
{ {
field: 'receiptPrice', field: 'receiptPrice',
title: '已收金额', title: '已收金额',
formatter: 'formatNumber', formatter: 'formatAmount2',
minWidth: 120, minWidth: 120,
}, },
{ {
@@ -505,7 +506,6 @@ export function useOrderGridFormSchema(): VbenFormSchema[] {
componentProps: { componentProps: {
placeholder: '请输入订单单号', placeholder: '请输入订单单号',
allowClear: true, allowClear: true,
disabled: true,
}, },
}, },
{ {
@@ -528,10 +528,8 @@ export function useOrderGridFormSchema(): VbenFormSchema[] {
label: '订单时间', label: '订单时间',
component: 'RangePicker', component: 'RangePicker',
componentProps: { componentProps: {
placeholder: ['开始时间', '结束时间'], ...getRangePickerDefaultProps(),
showTime: true, allowClear: true,
format: 'YYYY-MM-DD HH:mm:ss',
valueFormat: 'YYYY-MM-DD HH:mm:ss',
}, },
}, },
]; ];
@@ -576,23 +574,25 @@ export function useOrderGridColumns(): VxeTableGridOptions['columns'] {
{ {
field: 'totalCount', field: 'totalCount',
title: '总数量', title: '总数量',
formatter: 'formatAmount3',
minWidth: 120, minWidth: 120,
}, },
{ {
field: 'outCount', field: 'outCount',
title: '出库数量', title: '出库数量',
formatter: 'formatAmount3',
minWidth: 120, minWidth: 120,
}, },
{ {
field: 'totalProductPrice', field: 'totalProductPrice',
title: '金额合计', title: '金额合计',
formatter: 'formatNumber', formatter: 'formatAmount2',
minWidth: 120, minWidth: 120,
}, },
{ {
field: 'totalPrice', field: 'totalPrice',
title: '含税金额', title: '含税金额',
formatter: 'formatNumber', formatter: 'formatAmount2',
minWidth: 120, minWidth: 120,
}, },
]; ];

View File

@@ -232,11 +232,13 @@ export function useSaleReturnItemTableColumns(): VxeTableGridOptions['columns']
{ {
field: 'totalCount', field: 'totalCount',
title: '原数量', title: '原数量',
formatter: 'formatAmount3',
minWidth: 120, minWidth: 120,
}, },
{ {
field: 'returnCount', field: 'returnCount',
title: '已退货数量', title: '已退货数量',
formatter: 'formatAmount3',
minWidth: 120, minWidth: 120,
}, },
{ {
@@ -449,18 +451,19 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
{ {
field: 'totalCount', field: 'totalCount',
title: '总数量', title: '总数量',
formatter: 'formatAmount3',
minWidth: 120, minWidth: 120,
}, },
{ {
field: 'totalPrice', field: 'totalPrice',
title: '应退金额', title: '应退金额',
formatter: 'formatNumber', formatter: 'formatAmount2',
minWidth: 120, minWidth: 120,
}, },
{ {
field: 'refundPrice', field: 'refundPrice',
title: '已退金额', title: '已退金额',
formatter: 'formatNumber', formatter: 'formatAmount2',
minWidth: 120, minWidth: 120,
}, },
{ {
@@ -569,23 +572,25 @@ export function useOrderGridColumns(): VxeTableGridOptions['columns'] {
{ {
field: 'totalCount', field: 'totalCount',
title: '总数量', title: '总数量',
formatter: 'formatAmount3',
minWidth: 120, minWidth: 120,
}, },
{ {
field: 'returnCount', field: 'returnCount',
title: '已退货数量', title: '已退货数量',
formatter: 'formatAmount3',
minWidth: 120, minWidth: 120,
}, },
{ {
field: 'totalProductPrice', field: 'totalProductPrice',
title: '金额合计', title: '金额合计',
formatter: 'formatNumber', formatter: 'formatAmount2',
minWidth: 120, minWidth: 120,
}, },
{ {
field: 'totalPrice', field: 'totalPrice',
title: '含税金额', title: '含税金额',
formatter: 'formatNumber', formatter: 'formatAmount2',
minWidth: 120, minWidth: 120,
}, },
]; ];

View File

@@ -288,11 +288,13 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
{ {
field: 'totalCount', field: 'totalCount',
title: '数量', title: '数量',
formatter: 'formatAmount3',
minWidth: 100, minWidth: 100,
}, },
{ {
field: 'totalPrice', field: 'totalPrice',
title: '金额', title: '金额',
formatter: 'formatAmount2',
minWidth: 100, minWidth: 100,
}, },
{ {

View File

@@ -141,6 +141,7 @@ export function useStockInItemTableColumns(
minWidth: 120, minWidth: 120,
slots: { default: 'count' }, slots: { default: 'count' },
className: createRequiredValidation(isValidating, 'count'), className: createRequiredValidation(isValidating, 'count'),
formatter: 'formatAmount3',
}, },
{ {
field: 'productPrice', field: 'productPrice',

View File

@@ -287,11 +287,13 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
{ {
field: 'totalCount', field: 'totalCount',
title: '数量', title: '数量',
formatter: 'formatAmount3',
minWidth: 100, minWidth: 100,
}, },
{ {
field: 'totalPrice', field: 'totalPrice',
title: '金额', title: '金额',
formatter: 'formatAmount2',
minWidth: 100, minWidth: 100,
}, },
{ {

View File

@@ -149,6 +149,7 @@ export function useStockInItemTableColumns(
minWidth: 120, minWidth: 120,
slots: { default: 'count' }, slots: { default: 'count' },
className: createRequiredValidation(isValidating, 'count'), className: createRequiredValidation(isValidating, 'count'),
formatter: 'formatAmount3',
}, },
{ {
field: 'productPrice', field: 'productPrice',
@@ -304,11 +305,13 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
{ {
field: 'totalCount', field: 'totalCount',
title: '数量', title: '数量',
formatter: 'formatAmount3',
minWidth: 100, minWidth: 100,
}, },
{ {
field: 'totalPrice', field: 'totalPrice',
title: '价格', title: '价格',
formatter: 'formatAmount2',
minWidth: 100, minWidth: 100,
}, },
{ {

View File

@@ -318,8 +318,8 @@ setupVbenVxeTable({
}, },
}); });
// add by 星语:数量格式化,例如说:金额 // add by 星语:数量格式化,保留 3 位
vxeUI.formats.add('formatNumber', { vxeUI.formats.add('formatAmount3', {
tableCellFormatMethod({ cellValue }) { tableCellFormatMethod({ cellValue }) {
if (cellValue === null || cellValue === undefined) { if (cellValue === null || cellValue === undefined) {
return ''; return '';
@@ -327,7 +327,7 @@ setupVbenVxeTable({
return erpCountInputFormatter(cellValue); return erpCountInputFormatter(cellValue);
}, },
}); });
// add by 星语:数量格式化,保留 2 位
vxeUI.formats.add('formatAmount2', { vxeUI.formats.add('formatAmount2', {
tableCellFormatMethod({ cellValue }, digits = 2) { tableCellFormatMethod({ cellValue }, digits = 2) {
return `${erpNumberFormatter(cellValue, digits)}`; return `${erpNumberFormatter(cellValue, digits)}`;