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
/**
 * 利用sql生成表格
 * @author lihang
 * @date 2022-1-20
 */
layui.define(['layer','element','flow','table'],function(exports){
    var webUtil = $webUtil;
    var Class = function() {
        this.MODELNAME = "platform/plugins/Sql2Table";
        this.moduleKey = "Sql2Table";
        this.backPath = configData.compatibility?path:configData.objectServicePath;
        this.url = {
            sqlTable: 'sqlController/excute'
        };
        this.getContent = function (id,options) {
            var that = this;
            that.id=id;
            var html =[ '<div class="Sql2Table" id="Sql2Table_'+ id+ ' lay-filter="Sql2Table'+ id+ '" style="display:block; text-align: center">',
                '<table id="table_', id , '" lay-filter="table_',id , '" style="overflow-x:auto;"></table>','</div>'
                ]
            return html.join("");
        };
        this.init = function (id, options) {
            //     具体内容展示
            var that = this;
            this.sql = options.uiParseClass;
            webUtil.copyConfig(that, that.moduleKey);
            that.id=id;
            $.extend(that.sourceData,options);
        };
        this.loadForUI=function (id,sourceData){
            console.log(sourceData);
            //按照sql语句初始化页面
            var that = this;
            $webUtil.ajax("get",this.url.sqlTable, {
                sql:that.sql,
                oid:sourceData.oid
            },function (baseResult){
                var dataList = baseResult.data;
                var columnList = baseResult.obj;
                var table = layui.table;
                that.checkColumns(id);
                table.render({
                    elem: '#table_' + id,
                    id: 'table_' + id,
                    data: dataList,
                    selectMode:table.selectMode.muti,
                    cols: [columnList]
                });
            });
        }
        this.refresh = function(){
            //     具体功能实现
        };
        this.destory = function(){
            var that = this;
        };
 
        this.checkColumns = function(id){
            var table = layui.table;
            var that = this;
            if(that.columns==null || that.columns.length==0){
                that.columns = [table.getIndexColumn(),table.getCheckColumn(),{
                    field:'name',
                    title:'名称',
                    width:250
                },{
                    field:'fileExtension',
                    title:'后缀名',
                    width:100,
                    sort:true
                },{
                    field:'fileSize',
                    title:'文件大小',
                    width:110
                },{
                    field:'fileDocClassifyName',
                    title:'文档类型',
                    width:130
                }];
            }
        };
    };
    var cs = new Class();
    exports(cs.MODELNAME,cs);
});