/** * 利用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 =[ '
', '
','
' ] 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); });