Ldc
2024-04-07 0652600959e5e3b5796fb6e8da129704ca95347a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/**
 * 文件预览
 * @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:'<div id="' + options.id + '_preview"></div>',
                             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);
});