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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/**
 * web调用的api
 * @author weidy
 */
layui.define(['layer','element','form','table','util'],function(exports){
    var Class = function(){
        this.MODELNAME = "platform/objectService/OsWebApi";
        this.moduleKey = "OsWebApi";
        this.id='OsWebApi';
        this.sourceData={};
        this.columns = [];
        this.backPath =  configData.compatibility?path:configData.objectServicePath;
        this.url={
            controller:'webApiController/',
            dataGrid:'gridWebApi',
            listMethods:'gridWebApiMethodByApiOid'
        };
        this.buttonIconMap = {
            SEARCH:'layui-icon-refresh-2',
            SENIORSEARCH:'layui-icon-query',
            ADD:'layui-icon-add-1',
            EDIT:'layui-icon-edit',
            DELETE:'layui-icon-delete'
        };
        this.getContent=function(){//返回这个组件的基础html
            var that = this;
            var html = "";
            html = [
                    '<div class="layui-layout-border">',
                        '<div class="layui-center">',
                            '<div layui-filter="toolbar_button_',that.id,'" class="layui-btn-container">',
                            '</div>',
                            '<table id="table_', that.id , '" lay-filter="',that.id , '" style="overflow-x:auto;"></table>',
                            '<div id="toolbar_column_',that.id ,'" style="display:none;"></div>',
                        '</div>',
                    '</div>'
            ].join("");
            return html;
        };
        this.init=function(){//基础的html被添加后,再执行初始化
            var that = this;
            $webUtil.copyConfig(that,that.moduleKey);
            var table = layui.table;
            that.checkColumns();//主列表中列。
            that.firstGridLoad = false;
            table.render({
                elem: '#table_' + that.id,
                id: 'table_' + that.id,
                url:  that.url.controller + that.url.dataGrid,
                backPath:that.backPath,
                page: {
                    limit: 30,
                    page: 1
                },
                selectMode:table.selectMode.muti,
                cols: [that.columns],
                done:function(res,cur,total){
                    if(!that.fristMainLoad ){
                        table.on('tool(' + that.id + ')',function(obj){
                            var data = obj.data;//当前选择行的数据
                            var layEvent = obj.event;//点的是什么按钮
                            if(layEvent == 'listMethods'){
                                that.showMethods(data.oid,data.text);
                            }
                        });
                        that.fristMainLoad = true;
                    }
                }
            });
            $webUtil.createSearchHtml({
                showtext:'接口中文名称',
                name:'接口名称'
            },$("[layui-filter='toolbar_button_" + that.id + "']"),'table_' + that.id);
            $webUtil.bindDefultButtonLisenter(that, that.id);
            document.getElementById("toolbar_column_" + that.id).innerHTML =
                    '<a class="layui-btn layui-btn-intable" lay-event="listMethods">查看方法</a>';
        };
        this.checkColumns = function(){
            var that = this;
            var table = layui.table;
            if(that.columns==null || that.columns.length==0){//如果其他地方想使用这个组件的时候,可以自定义列
                that.columns = [table.getIndexColumn(),{
                    field:'name',
                    title:'名称',
                    width:600
                },{
                    field:'text',
                    title:'中文',
                    width:250
                },{
                    field:'ts',
                    title:'最后修改时间',
                    width:150,
                    templet:function(d){
                        return $webUtil.formateDateTime(d.ts);
                    }
                },{
                    field:'options',
                    title:'操作',
                    width:80,
                    toolbar:'#toolbar_column_' + that.id
                }];
            }    
        };
        this.showMethods = function(apiOid,text){
            var that = this;
            portal.showTabByMenu(that.id + "_methods_" + apiOid,{
                id:that.id + "_methods_" + apiOid,
                text:"查看后台接口[" + text + "]",
                bsUrl:'USEJS:platform/objectService/OsWebMethods?apiOid=' + apiOid,
            });
        };
    };
    var cs = new Class();
    exports(cs.MODELNAME,cs);
});