mirror of
https://gitee.com/wonderful-code/buildadmin
synced 2024-11-23 07:40:18 +00:00
refactor:优化附件管理的文件大小计算
This commit is contained in:
parent
f704903f92
commit
e025faf92d
@ -87,10 +87,10 @@ const baTable = new baTableClass(new baTableApi(routineAttachment), {
|
||||
label: t('routine.attachment.size'),
|
||||
prop: 'size',
|
||||
align: 'center',
|
||||
formatter: (row: TableRow, column: TableColumn, cellValue: string, index: number) => {
|
||||
var size = parseFloat(cellValue)
|
||||
var i = Math.floor(Math.log(size) / Math.log(1024))
|
||||
return parseInt((size / Math.pow(1024, i)).toFixed(i < 2 ? 0 : 2)) * 1 + ' ' + ['B', 'KB', 'MB', 'GB', 'TB'][i]
|
||||
formatter: (row: TableRow, column: TableColumn, cellValue: string) => {
|
||||
const size = parseFloat(cellValue)
|
||||
const i = Math.floor(Math.log(size) / Math.log(1024))
|
||||
return (size / Math.pow(1024, i)).toFixed(i < 1 ? 0 : 2) + ' ' + ['B', 'KB', 'MB', 'GB', 'TB'][i]
|
||||
},
|
||||
operator: 'RANGE',
|
||||
sortable: 'custom',
|
||||
|
Loading…
Reference in New Issue
Block a user