修复:综合浏览系统文件全文检索页面文件大小不显示的bug

master
guoxin 1 year ago
parent edeb3b904b
commit 632105fa9e
  1. 17
      shandan-browser/src/main/resources/static/js/browser.js

@ -457,7 +457,7 @@ layui.use(['layer', 'listPage', 'globalTree', 'gtable', 'form', 'element', 'drop
searchFieldNames: 'search',
url: `${ctx}/search/full/file?metaId=${id}`,
height: 'full-110',
where: {searchFields: THeadSetLayer.filterConfigData(fileTableId).filter(conf=>conf.isShow).map(conf => conf.colName).join(',')},
where: {searchFields: THeadSetLayer.filterConfigData(fileTableId).filter(conf => conf.isShow).map(conf => conf.colName).join(',')},
request: {pageName: 'page', limitName: 'size'},
defaultToolbar: [{title: '列表配置', layEvent: 'theadSet2', icon: 'layui-icon-cols'}],
autoSort: false,
@ -610,6 +610,7 @@ class THeadSetLayer {
exerciseData: data => data.exerciseData ? '是' : '否',
resourceType: data => data.resourceType === 'file' ? '文件' : '数据库表',
fileSize: data => {
return fileSizeFormat(data.fileSize, 'M');
}
}
@ -635,3 +636,17 @@ class THeadSetLayer {
return [cols];
}
}
const units = ['B', 'K', 'M', 'G', 'T', 'P'];
function fileSizeFormat(size, initUnit = 'B') {
initUnit = initUnit.toUpperCase();
const i = units.indexOf(initUnit);
if (size > 1024 && i < units.length - 1) {
return fileSizeFormat(size / 1024, units[i + 1]);
} else if (size < 1 && i > -1) {
return fileSizeFormat(size * 1024, units[i - 1]);
} else {
return Math.round(size * 100) / 100 + initUnit;
}
}