feat: vxe add formatAmount

pull/86/head
xingyu4j 2025-04-29 22:33:33 +08:00
parent 3e6a23db16
commit 43bfd8bd39
1 changed files with 16 additions and 1 deletions

View File

@ -30,7 +30,7 @@ setupVbenVxeTable({
},
toolbarConfig: {
import: false, // 是否导入
export: false, // 否导出
export: false, // 否导出
refresh: true, // 是否刷新
print: false, // 是否打印
zoom: true, // 是否缩放
@ -259,6 +259,21 @@ setupVbenVxeTable({
// 这里可以自行扩展 vxe-table 的全局配置,比如自定义格式化
// vxeUI.formats.add
vxeUI.formats.add('formatAmount', {
cellFormatMethod({ cellValue }, digits = 2) {
if (cellValue === null || cellValue === undefined) {
return '';
}
if (isString(cellValue)) {
cellValue = Number.parseFloat(cellValue);
}
// 如果非 number则直接返回空串
if (Number.isNaN(cellValue)) {
return '';
}
return cellValue.toFixed(digits);
},
});
},
useVbenForm,
});