save
This commit is contained in:
parent
5d4287411a
commit
bbb723b540
@ -285,8 +285,8 @@ class UploadController extends Crud
|
||||
if($size == 0) {
|
||||
return("0 Bytes");
|
||||
}
|
||||
$sizename = array(" Bytes", " KB", " MB", " GB", " TB", " PB", " EB", " ZB", " YB");
|
||||
return round($size/pow(1024, ($i = floor(log($size, 1024)))), 2) . $sizename[$i];
|
||||
$size_name = array(" Bytes", " KB", " MB", " GB", " TB", " PB", " EB", " ZB", " YB");
|
||||
return round($size/pow(1024, ($i = floor(log($size, 1024)))), 2) . $size_name[$i];
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -117,7 +117,7 @@
|
||||
layui.use(["laydate"], function() {
|
||||
layui.laydate.render({
|
||||
elem: "#created_at",
|
||||
range: ["#created_at-date-start", "#created_at-date-end"],
|
||||
range: ["#created_at-date-start", "#created_at-date-end"],
|
||||
type: 'datetime',
|
||||
});
|
||||
})
|
||||
@ -134,9 +134,9 @@
|
||||
el: "#category",
|
||||
name: "category",
|
||||
initValue: initValue,
|
||||
data: e.data,
|
||||
model: {"icon":"hidden","label":{"type":"text"}},
|
||||
clickClose: 'true',
|
||||
data: e.data,
|
||||
model: {"icon":"hidden","label":{"type":"text"}},
|
||||
clickClose: 'true',
|
||||
radio: 'true',
|
||||
})
|
||||
}
|
||||
@ -158,14 +158,18 @@
|
||||
},{
|
||||
title: "主键",
|
||||
field: "id",
|
||||
width: 80,
|
||||
sort: true,
|
||||
},{
|
||||
title: "名字",
|
||||
field: "name",
|
||||
},{
|
||||
title: "url",
|
||||
title: "文件",
|
||||
field: "url",
|
||||
templet: function (d) {
|
||||
if (['jpg', 'jpeg', 'png', 'gif', 'bmp', 'webp', 'svg'].indexOf(d.ext.toLowerCase()) !== -1) {
|
||||
return '<img src="' + encodeURI(d['url']) + '" style="max-width:32px;max-height:32px;" />';
|
||||
}
|
||||
return '<a href="' + encodeURI(d['url']) + '" target="_blank">' + util.escape(d['url']) + '</a>';
|
||||
}
|
||||
},{
|
||||
@ -179,9 +183,13 @@
|
||||
},{
|
||||
title: "文件大小",
|
||||
field: "file_size",
|
||||
templet: function (d) {
|
||||
return formatSize(d.file_size);
|
||||
}
|
||||
},{
|
||||
title: "mime类型",
|
||||
field: "mime_type",
|
||||
hide: true,
|
||||
},{
|
||||
title: "图片宽度",
|
||||
field: "image_width",
|
||||
@ -394,6 +402,20 @@
|
||||
scrollPos: 'fixed'
|
||||
});
|
||||
}
|
||||
|
||||
// 格式化文件大小
|
||||
let formatSize = function(value) {
|
||||
if(null == value || '' === value){
|
||||
return "0 Bytes";
|
||||
}
|
||||
let unitArr = ["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"];
|
||||
let index = 0;
|
||||
let srcSize = parseFloat(value);
|
||||
index = Math.floor(Math.log(srcSize) / Math.log(1024));
|
||||
let size =srcSize / Math.pow(1024, index);
|
||||
size = size.toFixed(2);
|
||||
return size + unitArr[index];
|
||||
}
|
||||
})
|
||||
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user