/** * 集中授权 * @author xurc@2020/11/04 */ layui.define(['layer','element','form','table','util'],function(exports){ var Class = function(){ this.MODELNAME = "platform/securityManage/VciSmRightCenter"; this.moduleKey = "VciSmRightCenter"; this.id = 'VciSmRightCenter'; this.sourceData = {}; this.columns = []; this.backPath = configData.compatibility?path:configData.frameworkPath;//默认流程和项目的路径是一样的 this.url={ controller:'roleFunctionController/', classifyTree:'roleQueryController/refTree', oneTree:'treeFunctionByRole', submit:'roleAuthorityChanges', del:'removeAuthority' }; 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(){ var that = this; var html = ""; html = [ '
', '
', '', '
', '
', '', '', '
', '
' ].join(""); return html; }; this.getToolbarHtml =function(){ var that = this; return ['
',//主列表的按钮 '', '', '', '', '', '', '
'].join(""); }; this.init=function(){ //基础的html被添加后,再执行初始化 var that = this; $webUtil.copyConfig(that,that.moduleKey); $webUtil.bindDefultButtonLisenter(that, that.id); that.initMainTree(); }; this.initMainTree = function() { var that = this; var tree = layui.tree; var scrollHeight = window.innerHeight; var treeUL = $('[layui-filter="tree_' + that.id + '"]'); var treeHeight = scrollHeight - 200; treeUL.parent().height(treeHeight); treeUL.parent().width(180); tree.init("tree_" + that.id, treeUL, { url: that.url.classifyTree, backPath: that.backPath, extraParams: { isMuti: false, isQueryAllColumn: true }, noApi:true, showSearch:true, click: function (item, elem, options) { that.currentItemOid = item.oid; that.currentItemAttributes = item.attributes; if(tree.config['oneTree_' + that.id] != undefined) { that.reload(); } else { that.initOneTree(); } } }); }; this.initOneTree = function(){ var that = this; var tree = layui.tree; var scrollHeight = window.innerHeight; var treeUL = $('[layui-filter="oneTree_' + that.id + '"]'); var treeHeight = scrollHeight - 200; treeUL.parent().height(treeHeight); tree.init("oneTree_" + that.id, treeUL, { url: that.url.controller + that.url.oneTree, backPath: that.backPath, extraParams: { isQueryAllColumn: true, roleOid:that.currentItemOid }, noApi:true, showSearch:true, isMuti: true, click: function (item, elem, options) { }, done: function (thisFilter) { } }); }; this.SUBMIT = function(){ // 授权 var that = this; var tree = layui.tree; if(that.currentItemOid == undefined) { $webUtil.showErrorMsg("请先选择一个角色!"); return false; } if($webUtil.objIsNull(tree.getAllData)) { $webUtil.showErrorMsg("至少选择一个功能模块!"); return false; } var submitData = {}; submitData.roleOid =that.currentItemOid submitData.roleAuthorityDTOList = {}; var list = []; $.each(tree.getAllData,function(k,v) { list.push({ functionOid: k }); }); submitData.roleAuthorityDTOList = list; // return false $webUtil.manualAjax('post',that.url.controller + that.url.submit,JSON.stringify(submitData),function (result) { if(result.success){ $webUtil.showErrorMsg("授权成功",that.reload()); }else{ $webUtil.showErrorMsg(result.msg); } },function (xhr,error) { $webUtil.showErrorMsg("访问服务器出现了错误,可能服务器没有开启,或者连接失败"); },that.backPath); }; this.AllCHECK = function(){ // 全选 var that = this; var tree = layui.tree; if(that.currentItemOid == undefined) { $webUtil.showErrorMsg("请先选择一个角色!"); return false; } tree.allSelect("oneTree_"+ that.id); }; this.NOCHECK = function(){ // 全不选 var that = this; var tree = layui.tree; if(that.currentItemOid == undefined) { $webUtil.showErrorMsg("请先选择一个角色!"); return false; } tree.allUnSelect("oneTree_"+ that.id); }; this.FCHECK = function(){ // 反选 var that = this; var tree = layui.tree; if(that.currentItemOid == undefined) { $webUtil.showErrorMsg("请先选择一个角色!"); return false; } tree.reverseChecked("oneTree_"+ that.id); }; this.DEL = function(){ // 移除权限 var that = this; if(that.currentItemOid == undefined) { $webUtil.showErrorMsg("请先选择一个角色!"); return false; } var submitData = { roleOid:that.currentItemOid } $webUtil.ajax('post',that.url.controller + that.url.del,submitData,function (result) { if(result.success){ $webUtil.showErrorMsg("移除权限成功"); that.reload(); }else{ $webUtil.showErrorMsg(result.msg); } },function (xhr,error) { $webUtil.showErrorMsg("访问服务器出现了错误,可能服务器没有开启,或者连接失败"); },that.backPath); } this.refresh = function(parentNodeOid){ var that = this; var tree = layui.tree; if($webUtil.isNotNull(parentNodeOid)){ tree.reloadNode("tree_" + that.id,parentNodeOid); }else { tree.reload("tree_" + that.id); } }; this.reload = function(){ var that = this; var tree = layui.tree; tree.reload("oneTree_" + that.id,{ url: that.url.controller + that.url.oneTree, backPath: that.backPath, extraParams: { isQueryAllColumn: true, roleOid:that.currentItemOid }, noApi:true, showSearch:true, isMuti: true, }); }; }; var cs = new Class(); exports(cs.MODELNAME,cs); });