feat: add formatNumber

This commit is contained in:
xingyu4j
2025-05-27 15:31:06 +08:00
parent d46c17293c
commit 64cd606c87
3 changed files with 99 additions and 0 deletions

View File

@@ -283,6 +283,22 @@ setupVbenVxeTable({
return cellValue.toFixed(digits);
},
});
vxeUI.formats.add('formatFraction', {
tableCellFormatMethod({ cellValue }) {
if (cellValue === null || cellValue === undefined) {
return '0.00';
}
if (isString(cellValue)) {
cellValue = Number.parseFloat(cellValue);
}
// 如果非 number则直接返回空串
if (Number.isNaN(cellValue)) {
return '0.00';
}
return `${(cellValue / 100).toFixed(2)}`;
},
});
},
useVbenForm,
});