/** * 服务对象页面 * @author weidy * @date 2020-12-10 */ layui.define(['layer','element','form','table','dynamicCondition','upload' ],function(exports){ var webUtil = $webUtil; var Class = function(){ this.MODELNAME = "platform/monitor/VciSqlTool"; this.moduleKey = "VciSqlTool"; this.backPath = configData.compatibility?path:configData.adminServicePath; this.id = "VciSqlTool"; this.url = { controller:'vciDataBaseConnectController/', executeSql:'executeSql', executeQuerySql:'executeQuerySql' }; this.getContent=function(){ var that = this; var html = ""; html = [ '
', '
', '
', that.getToolbarHtml(), '', '
', '
' , '
', '
', '
', '
' ].join(""); return html; }; this.getToolbarHtml =function(){ var that = this; var html = [ '
', '
', '', '', '', '
' ].join(""); return html; }; this.createSearchHtml = function () { var that = this; $webUtil.createSelectHtml(that.backPath+'vciDataBaseConnectController/comboxDatabase',$("[layui-filter='toolbar_" + that.id + "_select']"),'sql_select'); webUtil.bindDefultButtonLisenter(that, that.id); }; this.init = function(){ var that = this; webUtil.copyConfig(that,that.moduleKey); layui.table.render({ elem: '#table_' + that.id, id: 'table_' + that.id, data:[], emptyText:'', limit:-1, cols: [[]] }); that.createSearchHtml(); }; this.SQLQUERY = function (){ var that = this; var sql = $("#sql_" + that.id).val(); if($webUtil.isNull(sql)){ sql = $("#sql_" + that.id).text(); } if($webUtil.isNotNull(sql)){ that.clearTable(); $webUtil.post(that.url.controller + that.url.executeQuerySql,{sql:sql,databaseId:$('#sql_select').val()},function (result){ if(result.success){ if(result.data.length > 0) { var record = result.data[0]; var cols = [layui.table.getIndexColumn()]; for(var key in record){ cols.push({ field:key, title:key }); } layui.table.reload('table_' + that.id,{ data: result.data, cols: [cols] }); } }else{ $webUtil.showErrorMsg(result.msg); } },function (xhr,error){ $webUtil.showErrorMsg("执行SQL查询出错,可能是服务没有启动"); },that.backPath); } }; this.SQLEXECUTE = function () { var that = this; var sql = $("#sql_" + that.id).val(); if($webUtil.isNull(sql)){ sql = $("#sql_" + that.id).text(); } if($webUtil.isNotNull(sql)) { that.clearTable(); $webUtil.post(that.url.controller + that.url.executeSql, {sql: sql,databaseId:$('#sql_select').val()}, function (result) { if (result.success) { $webUtil.showMsgFromResult(result,"执行成功。受影响行数" + result.obj); } else { $webUtil.showErrorMsg(result.msg); } }, function (xhr, error) { $webUtil.showErrorMsg("执行SQL查询出错,可能是服务没有启动"); }, that.backPath); } }; this.RESETSQL = function () { var that = this; $("#sql_" + that.id).text(""); $("#sql_" + that.id).val(""); }; this.clearTable = function (){ var that = this; layui.table.reload("table_" + that.id, {cols:[[]]}); }; }; var cs = new Class(); exports(cs.MODELNAME,cs); });