OpenAuth.Net/OpenAuth.Mvc/BllScripts/roleModuleElement.js
yubaolee 2c521e3244 修复datagrid高度问题
发布新的初始数据,主要是前端模块化后统一了add()/edit()/del()等函数名称
2016-04-17 23:49:53 +08:00

116 lines
3.7 KiB
JavaScript

// ***********************************************************************
// Assembly : OpenAuth.Mvc
// Author : yubaolee
// Created : 04-13-2016
//
// Last Modified By : yubaolee
// Last Modified On : 04-13-2016
// ***********************************************************************
// <copyright file="RoleModuleElement.js" company="www.cnblogs.com/yubaolee">
// 版权所有(C) 2015
// </copyright>
// <summary>为角色分配模块菜单</summary>
// ***********************************************************************
$(document).ready(function () {
$.CurrentDialog.find("#btnAccess").on("click", function () {
var ids = roleMenuList.getSelectedProperties('Id');
if (ids == null) return;
$.post("/ModuleElementManager/AssignForRole",
{
RoleId: $('#roleId').val(),
menuIds: ids,
}, function (json) {
roleMenuList.reload();
});
});
$.CurrentDialog.find("#btnDelAccess").on("click", function () {
var ids = roleMenuList.getSelectedProperties('Id');
if (ids == null) return;
$.post("/ModuleElementManager/CancelForRole",{
RoleId: $('#roleId').val(),
menuIds: ids,
}, function (json) {
roleMenuList.reload();
});
});
});
//grid列表模块
function RoleMEGrid() {
var selectedId = 0; //ztree选中的模块
this.maingrid = $.CurrentDialog.find('#maingrid').datagrid({
showToolbar: false,
filterThead: false,
target: $(this),
columns: [
{
name: 'Id',
label: '元素名称',
hide: true
},
{
name: 'Name',
label: '元素名称',
width: 80
},
{
name: 'ModuleName',
label: '所属模块',
width: 80
},
{
name: 'Accessed',
label: '是否已经授权',
type: 'select',
align: 'center',
items: [{ 'false': '未授权', 'true': '已授权' }],
width: 80
}
],
dataUrl: '/ModuleElementManager/LoadForRole?moduleId=' + selectedId + '&RoleId=' + $('#roleId').val(),
fullGrid: true,
showLinenumber: true,
showCheckboxcol: true,
paging: true,
filterMult: false,
showTfoot: false
});
this.reload = function(id) {
if (id != undefined) selectedId = id;
this.maingrid.datagrid('reload', { dataUrl: '/ModuleElementManager/LoadForRole?moduleId=' + selectedId + '&RoleId=' + $('#roleId').val() });
};
};
RoleMEGrid.prototype = new Grid();
var roleMenuList = new RoleMEGrid();
var ztree = function () {
var setting = {
view: { selectedMulti: false },
data: {
key: {
name: 'Name',
title: 'Name'
},
simpleData: {
enable: true,
idKey: 'Id',
pIdKey: 'ParentId',
rootPId: 'null'
}
},
callback: { onClick: zTreeOnClick }
};
$.getJSON('/ModuleManager/LoadForRole?RoleId=' + $('#roleId').val(), function (json) {
var zTreeObj = $.fn.zTree.init($.CurrentDialog.find("#tree"), setting, json);
zTreeObj.expandAll(true);
});
}();
function zTreeOnClick(event, treeId, treeNode) {
roleMenuList.reload(treeNode.Id);
}
//@@ sourceURL=RoleModuleElement.js