新增Table.api.formatter.toggle,文件大小格式化,更新后需要压缩打包后台的JS

pull/64/head
zhangqingtian@pxjy.com 2018-05-16 11:08:14 +08:00
parent ac6aa072a2
commit cb77b7c985
2 changed files with 14 additions and 1 deletions

View File

@ -30,7 +30,7 @@ define(['jquery', 'bootstrap', 'backend', 'form', 'table'], function ($, undefin
{field: 'imageheight', title: __('Imageheight'), sortable: true},
{field: 'imagetype', title: __('Imagetype'), formatter:Table.api.formatter.search},
{field: 'storage', title: __('Storage'), formatter: Table.api.formatter.search},
{field: 'filesize', title: __('Filesize'), operate: 'BETWEEN', sortable: true},
{field: 'filesize', title: __('Filesize'), operate: 'BETWEEN', sortable: true, formatter: Table.api.formatter.filesize},
{field: 'mimetype', title: __('Mimetype'), formatter:Table.api.formatter.search},
{
field: 'createtime',

View File

@ -458,6 +458,19 @@ define(['jquery', 'bootstrap', 'moment', 'moment/locale/zh-cn', 'bootstrap-table
} else {
return value ? Moment(parseInt(value) * 1000).format(datetimeFormat) : __('None');
}
},
filesize: function (value, row, index) {
if(value == null || value == ''){
return "0 Bytes";
}
var unitArr = new Array("Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB");
var i = 0;
var srcsize = parseFloat(value);
i = Math.floor(Math.log(srcsize) / Math.log(1024));
var size = srcsize / Math.pow(1024,i);
//保留的小数位数
size = size.toFixed(2);
return size + unitArr[i];
},
operate: function (value, row, index) {
var table = this.table;