var RolePermissonManager = { InTable: undefined, IntableItems: undefined, // 绑定菜单Table SetTable: function (result) { // 设定列s var cols = [ { // liudl Edit '' 替换权限放开全选功能 titleHtml: '权限', name: 'Sel', width: 20, align: 'center', lockWidth: false, sortable: false, renderer: function (data, item, rowIndex) { var html = ""; if (data == 1) { html += ''; } else { html += ''; } return html; } }, { title: '菜单编号', name: 'ResNum', width: 120, align: 'center', hidden: false, lockWidth: false, sortable: true, renderer: function (data, item, rowIndex) { return data; } }, { title: '菜单名称', name: 'ResName', width: 160, align: 'center', lockWidth: false, sortable: true, renderer: function (data, item, rowIndex) { return data; } }, ]; if (RolePermissonManager.InTable == undefined) { var ht = masterUI.MMGridHeight(); RolePermissonManager.InTable = $("#tabInfo").mmGrid({ cols: cols, items: result.Result.List, checkCol: false, // 选择框 indexCol:true, nowrap: true, fullWidthRows: true, remoteSort: true, multiSelect: false, height: ht / 2 - 25 }); } else { RolePermissonManager.InTable.load(result.Result.List); } }, // 刷新Table数据源 load: function (args) { try { var opts = this.opts; this._hideMessage(); this._loadCount = this._loadCount + 1; if ($.isArray(args)) { //加载本地数据 this._loadNative(args); } else if (opts.url) { this._loadAjax(args); } else if (opts.items) { this._loadNative(opts.items); } else { this._loadNative([]); } } catch (e) { this._showLoadError(); throw e; } }, // 获取菜单Table当前行信息 GetSelect: function () { var list = []; if (RolePermissonManager.InTable != undefined) { var rows = RolePermissonManager.InTable.selectedRows(); if (rows != undefined && rows.length > 0) { for (var i = 0; i < rows.length; i++) { list.push(rows[i].ResNum); } } } return list; }, // 获取菜单信息 PageClick: function (PageIndex, PageSize, parentNum) { var resNum = $("#Resnum").html(); $.jBox.tip("正在努力加载数据...", "loading"); var param = {}; param["RoleName"] = parentNum; param["RoleNum"] = resNum; param["PageIndex"] = PageIndex; param["PageSize"] = PageSize; var data = JSON.stringify(param); $.gitAjax({ url: "/SystemSet/RoleAjax/GetResNumMenu", data: { ajaxdata: data }, type: "post", dataType: "json", success: function (result) { // result = 后台返回值 $.jBox.closeTip(); RolePermissonManager.SetTable(result); RolePermissonManager.BindBtnItems('NULL', 'NULL'); } }); }, // 绑定菜单Table SetBtnTable: function (result) { // 设定列   var cols = [ { title: '权限', name: 'Sel', width: 20, align: 'center', lockWidth: false, sortable: false, renderer: function (data, item, rowIndex) { var html = ""; if (data == 1) { html += ''; } else { html += ''; } return html; } }, { title: '角色编号', name: 'RoleNum', width: 80, align: 'center', hidden: true, lockWidth: false, sortable: true, renderer: function (data, item, rowIndex) { return data; } }, { title: '功能编号', name: 'ResNum', width: 120, align: 'center', hidden: false, lockWidth: false, sortable: true, renderer: function (data, item, rowIndex) { return data; } }, { title: '功能名称', name: 'ResName', width: 160, align: 'center', lockWidth: false, sortable: true, renderer: function (data, item, rowIndex) { return data; } }, //{ // title: '角色Id', name: 'Guid', width: 160, align: 'center', lockWidth: false, sortable: true, renderer: function (data, item, rowIndex) { // return data; // } //}, ]; if (RolePermissonManager.IntableItems == undefined) { var ht = masterUI.MMGridHeight(); RolePermissonManager.IntableItems = $("#tabInfoItem").mmGrid({ cols: cols, items: result.Result.List, checkCol: false, // 选择框 indexCol: true, nowrap: true, fullWidthRows: true, remoteSort: true, multiSelect: false, height: ht / 2 - 30 }); } else { RolePermissonManager.IntableItems.load(result.Result.List); } }, // 设定按钮权限 CheckBoxClick: function (rowIndex) { var list = []; if (RolePermissonManager.IntableItems != undefined) { var row = RolePermissonManager.IntableItems.row(rowIndex); var parentRow = RolePermissonManager.InTable.selectedRows(); list.push(row.RoleNum); list.push(row.ResNum); list.push(row.Sel); list.push(parentRow[0].ResNum); list.push(row.Guid); } if (list.length > 0) { var param = {}; param["RoleNum"] = list[0]; param["ResNum"] = list[1]; param["Sel"] = list[2]; param["ParentNum"] = list[3]; param["Guid"] = list[4]; var data = JSON.stringify(param); $.gitAjax({ url: "/SystemSet/RoleAjax/SetRoleRelation", data: { ajaxdata: data }, type: "post", dataType: "json", success: function (result) { // result = 后台返回值 RolePermissonManager.SetCheckBox(rowIndex, list[2]); RolePermissonManager.SetBtnTable(result); } }); } }, // 设定菜单权限 CheckBoxRsMenuClick: function (rowIndex) { var row = RolePermissonManager.InTable.row(rowIndex); var param = {}; param["RoleNum"] = $("#Resnum").html(); param["ResNum"] = row.ResNum; param["Sel"] = row.Sel; param["ParentNum"] = $("#parentNum").val(); param["Guid"] = $("#Resguid").html(); var data = JSON.stringify(param); $.gitAjax({ url: "/SystemSet/RoleAjax/SetResMenus", data: { ajaxdata: data }, type: "post", dataType: "json", success: function (result) { // result = 后台返回值 // 刷新按钮权限 RolePermissonManager.InTable.select(rowIndex); var param1 = {}; param["RoleName"] = $("#parentNum").val(); param["RoleNum"] = $("#Resnum").html();; param["PageIndex"] = 0; param["PageSize"] = 10; var data = JSON.stringify(param); $.gitAjax({ url: "/SystemSet/RoleAjax/GetResNumMenu", data: { ajaxdata: data }, type: "post", dataType: "json", success: function (result) { // result = 后台返回值 RolePermissonManager.SetTable(result); RolePermissonManager.InTable.select(rowIndex); } }); RolePermissonManager.SetBtnTable(result); } }); }, // 设定功能模块权限 CheckBoxAllClick: function () { var ResNum = $("#parentNum").val(); var Sel = $("#viewRes").prop('checked'); var RoleNum = $("#Resnum").html(); var RoleGuid = $("#Resguid").html(); var param = {}; if (Sel == true) { param["Sel"] = "0"; } else { param["Sel"] = "1"; } param["RoleNum"] = RoleNum; param["parentNum"] = ResNum; param["Guid"] = RoleGuid; var data = JSON.stringify(param); $.gitAjax({ url: "/SystemSet/RoleAjax/SetRelation", data: { ajaxdata: data }, type: "post", dataType: "json", success: function (result) { // result = 后台返回值 RolePermissonManager.PageClick(1, 10, ResNum); } }); RolePermissonManager.BindBtnItems('NULL', 'NULL'); }, // 根据按钮权限改变Table中视图权限 SetCheckBox: function(rowIndex,Sel) { var IntableRowNum = RolePermissonManager.InTable.selectedRowsIndex(); var rowNum = RolePermissonManager.IntableItems.rowsLength(); var bl = false; for (var i = 0; i < rowNum;i++) { if (i == rowIndex) { continue; } var row = RolePermissonManager.IntableItems.row(i); if (row.Sel == Sel) { bl = true; } } if (Sel == 1) { if (!bl) { $("#cb" + IntableRowNum).prop("checked", false); } } else { $("#cb" + IntableRowNum).prop("checked", true); } }, // 加载按钮权限 BindBtnItems: function (roleName, roleNum, roleGuid) { var param = {}; param["RoleName"] = roleName; param["RoleNum"] = roleNum; param["guid"] = roleGuid; var data = JSON.stringify(param); $.gitAjax({ url: "/SystemSet/RoleAjax/GetResBtnitems", data: { ajaxdata: data }, type: "post", dataType: "json", success: function (result) { // result = 后台返回值 $.jBox.closeTip(); RolePermissonManager.SetBtnTable(result); } }); }, ToolBar: function () { //功能模块下拉框值改变触发 $("#parentNum").change(function () { $("#viewRes").prop("checked", false); var parentNum = ($(this).val()); RolePermissonManager.PageClick(1, 10, parentNum); }); // 选择页面加载功能按钮 $("#tabInfo").click(function () { var list = RolePermissonManager.GetSelect(); if (list.length > 0) { var roleName = list[0]; var roleNum = $("#Resnum").html(); var roleGuid = $("#Resguid").html(); RolePermissonManager.BindBtnItems(roleName, roleNum, roleGuid); } }); } }