【FileInfo】优化

pull/65/head
chenjinlong 4 years ago
parent e475f3bf18
commit e96e97c9ae

@ -19,6 +19,12 @@ layui.use(['table', 'form', 'func', 'HttpRequest', 'util', 'upload'], function (
return [[ return [[
{type: 'checkbox'}, {type: 'checkbox'},
{field: 'fileId', hide: true, title: '主键id'}, {field: 'fileId', hide: true, title: '主键id'},
{
title: '图片', templet: function (d) {
var url = d.imgUrl || Feng.ctxPath + '/sysFileInfo/previewByObjectName?fileBucket=' + d.fileBucket + '&fileObjectName=' + d.fileObjectName;
return '<img data-index="' + (d.LAY_INDEX - 1) + '" src="' + url + '" class="tb-img-circle" tb-img alt=""/>';
}, align: 'center', unresize: true
},
{field: 'fileLocation', sort: true, title: '存储位置'}, {field: 'fileLocation', sort: true, title: '存储位置'},
{field: 'fileOriginName', sort: true, title: '文件名称'}, {field: 'fileOriginName', sort: true, title: '文件名称'},
{field: 'secretFlag', sort: true, title: '是否机密'}, {field: 'secretFlag', sort: true, title: '是否机密'},
@ -33,22 +39,30 @@ layui.use(['table', 'form', 'func', 'HttpRequest', 'util', 'upload'], function (
{align: 'center', toolbar: '#tableBar', title: '操作', width: 230} {align: 'center', toolbar: '#tableBar', title: '操作', width: 230}
]]; ]];
}; };
/* 点击图片放大 */
$(document).off('click.tbImg').on('click.tbImg', '[tb-img]', function () {
var imgList = table.cache[FileInfo.tableId].map(function (d) {
return {
alt: d.nickName,
src: d.imgUrl || Feng.ctxPath + '/sysFileInfo/previewByObjectName?fileBucket=' + d.fileBucket + '&fileObjectName=' + d.fileObjectName
}
});
layer.photos({photos: {data: imgList, start: $(this).data('index')}, shade: .1, closeBtn: true});
});
//上传 //上传
var uploadInst = upload.render({ var uploadInst = upload.render({
elem: '#btnUpload' //绑定元素 elem: '#btnUpload' //绑定元素
,url: Feng.ctxPath + '/sysFileInfo/upload?secretFlag=N' //上传接口 , url: Feng.ctxPath + '/sysFileInfo/upload?secretFlag=N' //上传接口
,done: function(res){ , done: function (res) {
//上传完毕回调 //上传完毕回调
Feng.success("上传成功!"); Feng.success("上传成功!");
FileInfo.search(); FileInfo.search();
} }
,error: function(err){ , error: function (err) {
//请求异常回调 //请求异常回调
Feng.error("上传失败!"+ err.message); Feng.error("上传失败!" + err.message);
} }
}); });
@ -65,7 +79,6 @@ layui.use(['table', 'form', 'func', 'HttpRequest', 'util', 'upload'], function (
}; };
// 点击详情 // 点击详情
FileInfo.openDetails = function (data) { FileInfo.openDetails = function (data) {
func.open({ func.open({
@ -95,29 +108,19 @@ layui.use(['table', 'form', 'func', 'HttpRequest', 'util', 'upload'], function (
// 下载 // 下载
FileInfo.onFileDownload = function (data) { FileInfo.onFileDownload = function (data) {
if (data.secretFlag === 'Y'){ if (data.secretFlag === 'Y') {
window.location.href = Feng.ctxPath + '/sysFileInfo/privateDownload?fileId='+ data.fileId; window.location.href = Feng.ctxPath + '/sysFileInfo/privateDownload?fileId=' + data.fileId;
}else { } else {
window.location.href = Feng.ctxPath + '/sysFileInfo/publicDownload?fileId='+ data.fileId; window.location.href = Feng.ctxPath + '/sysFileInfo/publicDownload?fileId=' + data.fileId;
} }
} }
// 预览 // 预览
FileInfo.openPreview = function (data) { FileInfo.openPreview = function (data) {
var imgUrl = Feng.ctxPath + '/sysFileInfo/previewByObjectName?fileBucket=' + data.fileBucket + '&fileObjectName=' + data.fileObjectName; var imgUrl = Feng.ctxPath + '/sysFileInfo/previewByObjectName?fileBucket=' + data.fileBucket + '&fileObjectName=' + data.fileObjectName;
layer.photos({photos: {"data": [{"src": imgUrl}]}, shade: .1, closeBtn: true});
layer.photos({
photos: { "data": [{"src": imgUrl}] }
,anim: 0
});
}; };
// 渲染表格 // 渲染表格
var tableResult = table.render({ var tableResult = table.render({
elem: '#' + FileInfo.tableId, elem: '#' + FileInfo.tableId,
@ -144,9 +147,9 @@ layui.use(['table', 'form', 'func', 'HttpRequest', 'util', 'upload'], function (
FileInfo.openDetails(data); FileInfo.openDetails(data);
} else if (event === 'delete') { } else if (event === 'delete') {
FileInfo.onDeleteFile(data); FileInfo.onDeleteFile(data);
}else if (event === 'download'){ } else if (event === 'download') {
FileInfo.onFileDownload(data); FileInfo.onFileDownload(data);
}else if(event === 'preview'){ } else if (event === 'preview') {
FileInfo.openPreview(data); FileInfo.openPreview(data);
} }
}); });

@ -3,12 +3,10 @@ layui.use(['layer', 'form', 'admin', 'HttpRequest'], function () {
var form = layui.form; var form = layui.form;
var HttpRequest = layui.HttpRequest; var HttpRequest = layui.HttpRequest;
//获取详情信息,填充表单 //获取详情信息,填充表单
var httpRequest = new HttpRequest(Feng.ctxPath + "/sysFileInfo/detail?fileId=" + Feng.getUrlParam("fileId"),'get'); var httpRequest = new HttpRequest(Feng.ctxPath + "/sysFileInfo/detail?fileId=" + Feng.getUrlParam("fileId"),'get');
var result = httpRequest.start(); var result = httpRequest.start();
form.val("fileInfoForm", result.data); form.val("fileInfoForm", result.data);
console.log(result)
}); });

@ -27,7 +27,7 @@
<button id="btnSearch" class="layui-btn icon-btn"><i class="layui-icon">&#xe615;</i>搜索</button> <button id="btnSearch" class="layui-btn icon-btn"><i class="layui-icon">&#xe615;</i>搜索</button>
</div> </div>
<div class="layui-inline"> <div class="layui-inline">
<button id="btnUpload" class="layui-btn icon-btn"><i class="layui-icon">&#xe681;</i>上传文件</button> <button id="btnUpload" class="layui-btn icon-btn"><i class="layui-icon">&#xe681;</i>上传图片</button>
</div> </div>
</div> </div>
</div> </div>
@ -39,15 +39,10 @@
</div> </div>
<script type="text/html" id="tableBar"> <script type="text/html" id="tableBar">
<a class="layui-btn layui-btn-xs" lay-event="download">下载</a> <a class="layui-btn layui-btn-xs" lay-event="download">下载</a>
<a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="details">详情</a> <a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="details">详情</a>
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delete">删除</a> <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delete">删除</a>
<!--<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="preview">预览</a>-->
<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="preview">预览</a>
</script> </script>
@} @}

Loading…
Cancel
Save