/** * 文件预览 * @author weidy@2020/8/27 */ layui.define(['layer','FilePreviewBase'],function(exports){ var Class = function(){ this.MODELNAME = "vciFilePreview"; this.moduleKey = "vciFilePreview"; this.id='vciFilePreview'; this.sourceData={}; this.columns = []; this.backPath = configData.compatibility?path:configData.fileServicePath; this.processPath = configData.compatibility?path:configData.processServicePath; this.url={ preview:'vciFileQueryController/previewFile', downloadByFileOid:'vciFileDownloadController/downloadByFileOid' }; this.showType = { tab:"tab", inner:"inner", dialog:'dialog' }; this.doPreview = function(fileoid,fileName,options){ //执行预览 var that = this; var url = $webUtil.isNull(options.url)?that.url.preview:options.url //后台主要是控制权限 $webUtil.post(url,{ownbizOid:options.ownbizOid,ownbizBtm:options.ownbizBtm,fileOid:fileoid},function(result){ if(result.success){ //直接调用预览的页面 //弹出窗口,还是选项卡显示 options.viewType = (options.viewType?options.viewType:"active"); var title = '预览【' + fileName + "】"; if(that.showType.tab == options.showType){ //在系统上新打开选项卡 portal.showTabByMenu(options.id + "_preview",{ text:title, id:options.id + "_preview", multiCompent:true, url:'usejs:FilePreviewBase?fileOids=' + fileoid + "&reswitch=" + (options.reswitch?options.reswitch:"true") + "&viewtype=" + options.viewType + "&hideRightPanel=" + (options.hideRightPanel?options.hideRightPanel:false) }); }else if(that.showType.inner == options.showType){ //嵌入预览的组件,需要传递一个元素的id var preview = layui['FilePreviewBase']; $("#" + options.elem).html(preview.getContent(options.id)); $("#" + options.elem+" div").eq(1).hide() preview.init(options.id,{ id:options.id, fileOids:fileoid, reswitch:(options.reswitch?options.reswitch:"true"), viewtype:options.viewType, hideRightPanel:(options.hideRightPanel?options.hideRightPanel:false), showType:that.showType.inner }); }else { //默认是弹出窗口 $webUtil.dialog({ content:'
', title:title, fullScreen:true, success:function(layero){ var preview = layui['FilePreviewBase']; $("#" + options.id + "_preview").html(preview.getContent(options.id)); preview.init(options.id,{ id:options.id, fileOids:fileoid, reswitch:(options.reswitch?options.reswitch:"true"), viewtype:options.viewType, hideRightPanel:(options.hideRightPanel?options.hideRightPanel:false) }); } }); } }else if(result.code == "notsupportpreview"){ $webUtil.showMsg("您选择的文件不支持预览,将为您跳转至下载文件",function(){ var iframeId = MD5(fileoid + $webUtil.getSystemVar($webUtil.systemValueKey.userOid)); $webUtil.fileDownload(that.backPath + that.url.downloadByFileOid + "?fileOids=" + fileoid +"&downloadUUID=" + iframeId) }); }else{ $webUtil.showErrorMsg(result.msg); } },function(xhr,error){ $webUtil.showErrorMsg("在验证是否可以预览的时候出现了错误,可能是文件服务没有启动"); },options.inProcess?that.processPath:that.backPath); }; }; var cs = new Class(); exports(cs.MODELNAME,cs); });