田源
2024-04-07 2ac55ce0edf4870a29691b56bfad59f4830a11a2
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
/**
 * markdown文件预览
 * @author weidy@2021-3-16
 * @constructor
 */
layui.define(['layer','element','form','table','tree'],function(exports){
    var MD = function(){
        this.MODELNAME = "platform/objectService/VciMd";
        this.moduleKey = "VciMd";
        this.id='VciMd';
        this.sourceData={};
        this.backPath = configData.compatibility?path:configData.objectServicePath;
        this.url={
            controller:'mdController/',
            tree:'treeAllMD'
        };
        this.getContent=function(){
            var that = this;
            var html = "";
            html = [
                that.getToolbarHtml(),
                '<div class="layui-layout" style="display:block;overflow-y: hidden">',
                    '<div class="layui-vci-tree" style="width:200px;float: left;background-color:#ffffff;overflow-y: auto;padding-top: 10px;">',
                        '<ul layui-filter="tree_',that.id,'" style="overflow-x: auto;"><ul>',
                    '</div>',
                    '<div class="layui-layout-border" style="display:block;margin-top:0px;margin-left:205px;">',
                        '<div class="layui-center" style="overflow-y:auto;" id="md_',that.id,'">',
                        '</div>',
                    '</div>',
                '</div>'
            ].join("");
            return html;
        };
        this.getToolbarHtml = function(){
            var that = this;
            return ['<div layui-filter="toolbar_',that.id, '" class="layui-btn-container">',//主列表的按钮
                '<button class="layui-btn layui-btn-sm" layui-filter="toolbar_',that.id,'_refresh"><i class="layui-icon layui-icon-refresh"></i>刷新</button>',
                '</div>'].join("");
        };
        this.init=function(){//基础的html被添加后,再执行初始化
            var that = this;
            $webUtil.copyConfig(that,that.moduleKey);
            var tree = layui.tree;
            var scrollHeight =  window.innerHeight;
            var treeUL = $('[layui-filter="tree_' + that.id + '"]');
            var treeHeight = scrollHeight - 200;
            treeUL.parent().height(treeHeight);
            tree.init("tree_" + that.id, treeUL, {
                url: that.url.controller + that.url.tree,
                backPath: that.backPath,
                showSearch:true,
                loadType:tree.loadType.all,
                click: function (item, elem, options) {
                    that.showMd(item.oid);
                }
            });
            $webUtil.bindDefultButtonLisenter(that, that.id);
        };
        this.showMd = function (fileName) {
            var that = this;
            $("#md_" + that.id).html('<iframe src="' + projectName +'jslib/layui-2.2.5-debug/lay/platform/objectService/md.html?url=' + (that.backPath + "doc/" + fileName + "?" + TOKEN_KEY + "=" + $webUtil.getToken()) + '" frameborder="none" width="100%" height="' + (window.innerHeight - 250) + '"></iframe>');
        };
        this.refresh = function(){
            var that = this;
            var tree = layui.tree;
            tree.reload("tree_" + that.id);
        };
    };
    var md = new MD();
    exports(md.MODELNAME,md);
});