feat: 统一使用 utils

This commit is contained in:
xingyu4j
2025-11-18 17:22:12 +08:00
parent 03a5af3ba3
commit 114114fc32
5 changed files with 12 additions and 28 deletions

View File

@@ -7,6 +7,7 @@ import {
erpCountInputFormatter,
erpNumberFormatter,
fenToYuan,
formatFileSize,
formatPast2,
} from '@vben/utils';
@@ -205,12 +206,7 @@ setupVbenVxeTable({
vxeUI.formats.add('formatFileSize', {
tableCellFormatMethod({ cellValue }, digits = 2) {
if (!cellValue) return '0 B';
const unitArr = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
const index = Math.floor(Math.log(cellValue) / Math.log(1024));
const size = cellValue / 1024 ** index;
const formattedSize = size.toFixed(digits);
return `${formattedSize} ${unitArr[index]}`;
return formatFileSize(cellValue, digits);
},
});
},