From e96e97c9ae8c8727ae4cd757c8db589688166546 Mon Sep 17 00:00:00 2001 From: chenjinlong <$chenjinlong> Date: Wed, 20 Jan 2021 21:47:48 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90FileInfo=E3=80=91=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modular/system/fileInfo/file_info.js | 51 ++++++++++--------- .../system/fileInfo/file_info_details.js | 4 +- .../modular/system/fileInfo/file_info.html | 9 +--- 3 files changed, 30 insertions(+), 34 deletions(-) diff --git a/src/main/webapp/assets/modular/system/fileInfo/file_info.js b/src/main/webapp/assets/modular/system/fileInfo/file_info.js index 693d6cc6..7d9f5ca2 100644 --- a/src/main/webapp/assets/modular/system/fileInfo/file_info.js +++ b/src/main/webapp/assets/modular/system/fileInfo/file_info.js @@ -19,6 +19,12 @@ layui.use(['table', 'form', 'func', 'HttpRequest', 'util', 'upload'], function ( return [[ {type: 'checkbox'}, {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 ''; + }, align: 'center', unresize: true + }, {field: 'fileLocation', sort: true, title: '存储位置'}, {field: 'fileOriginName', 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} ]]; }; - - + /* 点击图片放大 */ + $(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({ elem: '#btnUpload' //绑定元素 - ,url: Feng.ctxPath + '/sysFileInfo/upload?secretFlag=N' //上传接口 - ,done: function(res){ + , url: Feng.ctxPath + '/sysFileInfo/upload?secretFlag=N' //上传接口 + , done: function (res) { //上传完毕回调 Feng.success("上传成功!"); 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) { func.open({ @@ -95,29 +108,19 @@ layui.use(['table', 'form', 'func', 'HttpRequest', 'util', 'upload'], function ( // 下载 FileInfo.onFileDownload = function (data) { - if (data.secretFlag === 'Y'){ - window.location.href = Feng.ctxPath + '/sysFileInfo/privateDownload?fileId='+ data.fileId; - }else { - window.location.href = Feng.ctxPath + '/sysFileInfo/publicDownload?fileId='+ data.fileId; + if (data.secretFlag === 'Y') { + window.location.href = Feng.ctxPath + '/sysFileInfo/privateDownload?fileId=' + data.fileId; + } else { + window.location.href = Feng.ctxPath + '/sysFileInfo/publicDownload?fileId=' + data.fileId; } } // 预览 FileInfo.openPreview = function (data) { var imgUrl = Feng.ctxPath + '/sysFileInfo/previewByObjectName?fileBucket=' + data.fileBucket + '&fileObjectName=' + data.fileObjectName; - - layer.photos({ - photos: { "data": [{"src": imgUrl}] } - ,anim: 0 - }); - - - - + layer.photos({photos: {"data": [{"src": imgUrl}]}, shade: .1, closeBtn: true}); }; - - // 渲染表格 var tableResult = table.render({ elem: '#' + FileInfo.tableId, @@ -144,9 +147,9 @@ layui.use(['table', 'form', 'func', 'HttpRequest', 'util', 'upload'], function ( FileInfo.openDetails(data); } else if (event === 'delete') { FileInfo.onDeleteFile(data); - }else if (event === 'download'){ + } else if (event === 'download') { FileInfo.onFileDownload(data); - }else if(event === 'preview'){ + } else if (event === 'preview') { FileInfo.openPreview(data); } }); diff --git a/src/main/webapp/assets/modular/system/fileInfo/file_info_details.js b/src/main/webapp/assets/modular/system/fileInfo/file_info_details.js index e79493b4..6a4eb36f 100644 --- a/src/main/webapp/assets/modular/system/fileInfo/file_info_details.js +++ b/src/main/webapp/assets/modular/system/fileInfo/file_info_details.js @@ -3,12 +3,10 @@ layui.use(['layer', 'form', 'admin', 'HttpRequest'], function () { var form = layui.form; var HttpRequest = layui.HttpRequest; - - //获取详情信息,填充表单 var httpRequest = new HttpRequest(Feng.ctxPath + "/sysFileInfo/detail?fileId=" + Feng.getUrlParam("fileId"),'get'); var result = httpRequest.start(); form.val("fileInfoForm", result.data); - + console.log(result) }); diff --git a/src/main/webapp/pages/modular/system/fileInfo/file_info.html b/src/main/webapp/pages/modular/system/fileInfo/file_info.html index 44c148a8..7a0551c9 100644 --- a/src/main/webapp/pages/modular/system/fileInfo/file_info.html +++ b/src/main/webapp/pages/modular/system/fileInfo/file_info.html @@ -27,7 +27,7 @@