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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/**
 * 枚举类型
 * @author weidy@2020-07-27
 */
layui.define(['layer','element','form','table','util'],function(exports){
    var Class = function(){
        this.MODELNAME = "platform/objectService/OsEnum";
        this.moduleKey = "OsEnum";
        this.id='OsEnum';
        this.sourceData={};
        this.columns = [];
        this.backPath =  configData.compatibility?path:configData.objectServicePath;
        this.url={
            controller:(configData.compatibility?"webEnumController/":'enumController/'),
            dataGrid:'gridEnum',
            listItems:'gridEnumItemByOid'
        };
        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">',
                            that.getToolbarHtml(),
                            '<table id="table_', that.id , '" lay-filter="',that.id , '" style="overflow-x:auto;"></table>',
                        '</div>',
                        '<div class="layui-south" >',
                            '<table id="detail_table_',that.id ,'" lay-filter="detail_table_', that.id ,'"></table>',
                        '</div>',
                    '</div>'
            ].join("");
            return html;
        };
        this.getToolbarHtml =function(){
            var that = this;
            var html = [
                '<div layui-filter="toolbar_button_',that.id,'" class="layui-btn-container">',
                    '<button class="layui-btn layui-btn-sm" layui-filter="toolbar_',that.id,'_ADD"><i class="layui-icon layui-icon-add-1"></i>添加</button>',
                    '<button class="layui-btn layui-btn-sm" layui-filter="toolbar_',that.id,'_EDIT"><i class="layui-icon layui-icon-edit"></i>修改</button>',
                    '<button class="layui-btn layui-btn-sm" layui-filter="toolbar_',that.id,'_DEL"><i class="layui-icon layui-icon-delete"></i>删除</button>',
                    '<button class="layui-btn layui-btn-sm" layui-filter="toolbar_',that.id,'_refresh"><i class="layui-icon layui-icon-refresh"></i>刷新</button>',
                    '<button class="layui-btn layui-btn-sm" layui-filter="toolbar_',that.id,'_refresh"><i class="layui-icon layui-icon-search"></i>查看应用范围</button>',
                '</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: 25,
                    page: 1
                },
                selectMode:table.selectMode.muti,
                cols: [that.columns],
                rowClick:function(filter,data){
                    if(data){
                        that.gridItemsByOid(data.oid);
                    }
                },
                done:function(res, cur, count){
                    if(!that.firstGridLoad) {
                        that.initDetailTable(((res && res.data) ? res.data[0].oid : ""));
                        that.firstGridLoad = true;
                    }else{
                        if(count>0){
                            that.gridItemsByOid(res.data[0].oid);
                        }
                    }
                }
            });
            $webUtil.createSearchHtml({
                id:'英文名称',
                name:'中文名称'
            },$("[layui-filter='toolbar_button_" + that.id + "']"),'table_' + that.id);
            $webUtil.bindDefultButtonLisenter(that, that.id);
        };
        this.checkColumns = function(){
            var that = this;
            var table = layui.table;
            if(that.columns==null || that.columns.length==0){//如果其他地方想使用这个组件的时候,可以自定义列
                that.columns = [table.getIndexColumn(),table.getCheckColumn(),{
                    field:'id',
                    title:'枚举英文名称',
                    width:150
                },{
                    field:'name',
                    title:'枚举中文',
                    width:150
                },{
                    field:'description',
                    title:'描述',
                    width:250
                },{
                    field:'enumValueDataTypeText',
                    title:'数据类型',
                    width:80
                }];
            }
        };
        this.gridItemsByOid = function(pkEnum){
            var that = this;
            if($webUtil.isNull(pkEnum)){
                return;
            }
            layui.table.reload("detail_" + that.id,{
                where:{
                    pkEnum: pkEnum
                }
            });
        };
        this.initDetailTable = function(pkEnum){
            var that = this;
            var table = layui.table;
            that.checkDetailColumns();
            table.render({
                elem: '#detail_table_' + that.id,
                id: 'detail_' + that.id,
                backPath:that.backPath,
                url: that.url.controller +  that.url.listItems,
                where:{
                    pkEnum:pkEnum
                },
                cols: [that.detailColumns]
            });
        };
        this.checkDetailColumns = function () {
            var that = this;
            var table = layui.table;
            if(that.detailColumns==null || that.detailColumns.length==0){//如果其他地方想使用这个组件的时候,可以自定义列
                that.detailColumns = [table.getIndexColumn(),table.getCheckColumn(),{
                    field:'id',
                    title:'枚举值',
                    width:150
                },{
                    field:'name',
                    title:'枚举名称',
                    width:200
                },{
                    field:'description',
                    title:'描述',
                    width:280
                }];
            }
        };
        this.refresh = function(){
            var that = this;
            layui.table.reload("table_" + that.id);
        };
    };
    var cs = new Class();
    exports(cs.MODELNAME,cs);
});