mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-04-05 17:38:01 +08:00
126 lines
3.6 KiB
JavaScript
126 lines
3.6 KiB
JavaScript
// ***********************************************************************
|
|
// Assembly : OpenAuth.Mvc
|
|
// Author : yubaolee
|
|
// Created : 04-13-2016
|
|
//
|
|
// Last Modified By : yubaolee
|
|
// Last Modified On : 04-13-2016
|
|
// ***********************************************************************
|
|
// <copyright file="userRoleManager.js" company="www.cnblogs.com/yubaolee">
|
|
// 版权所有(C) 2015
|
|
// </copyright>
|
|
// <summary>用户分配角色模块</summary>
|
|
// ***********************************************************************
|
|
|
|
|
|
$(document).ready(function () {
|
|
$.CurrentDialog.find("#btnAccess").on("click", function () {
|
|
var ids = userRolesList.getSelectedProperties('Id');
|
|
if (ids == null) return;
|
|
|
|
$.post('/RoleManager/AccessRoles', {
|
|
userId: $('#userId').val(),
|
|
ids: ids
|
|
}, function (json) {
|
|
userRolesList.reload();
|
|
});
|
|
});
|
|
$.CurrentDialog.find("#btnDelAccess").on("click", function () {
|
|
var ids = userRolesList.getSelectedProperties('Id');
|
|
if (ids == null) return;
|
|
|
|
$.post('/RoleManager/DelAccessRoles', {
|
|
userId: $('#userId').val(),
|
|
ids: ids
|
|
}, function (json) {
|
|
userRolesList.reload();
|
|
});
|
|
});
|
|
});
|
|
|
|
//grid列表模块
|
|
function UserRolesList() {
|
|
var selectedId = '00000000-0000-0000-0000-000000000000'; //ztree选中的模块
|
|
this.maingrid = $.CurrentDialog.find('#maingrid').datagrid({
|
|
showToolbar: false,
|
|
loadType: 'GET',
|
|
filterThead: false,
|
|
target: $(this),
|
|
columns: [
|
|
{
|
|
name: 'Id',
|
|
label: '角色ID',
|
|
hide: true
|
|
},
|
|
{
|
|
name: 'Name',
|
|
label: '角色名称',
|
|
width: 100
|
|
},
|
|
{
|
|
name: 'Organizations',
|
|
label: '所属组织',
|
|
width: 100
|
|
},
|
|
{
|
|
name: 'IsBelongUser',
|
|
label: '是否已经授权',
|
|
type: 'select',
|
|
align: 'center',
|
|
items: [{ 'false': '未授权', 'true': '已授权' }],
|
|
width: 100
|
|
}
|
|
],
|
|
data: [],
|
|
fullGrid: true,
|
|
showLinenumber: true,
|
|
showCheckboxcol: true,
|
|
paging: true,
|
|
filterMult: false,
|
|
showTfoot: false,
|
|
|
|
});
|
|
this.reload = function (id) {
|
|
if (id != undefined) selectedId = id;
|
|
console.log(id);
|
|
this.maingrid.datagrid('reload', { dataUrl: '/RoleManager/LoadForOrgAndUser?orgId=' + selectedId + '&userId=' + $('#userId').val() });
|
|
}
|
|
};
|
|
UserRolesList.prototype = new Grid();
|
|
var userRolesList = new UserRolesList();
|
|
|
|
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('/OrgManager/LoadOrg', function (json) {
|
|
var zTreeObj = $.fn.zTree.init($("#tree"), setting, json);
|
|
var firstId; //tree的第一个ID
|
|
if (json.length > 0) {
|
|
firstId = json[0].Id;
|
|
} else {
|
|
firstId = -1;
|
|
}
|
|
userRolesList.reload(firstId);
|
|
zTreeObj.expandAll(true);
|
|
|
|
});
|
|
}();
|
|
function zTreeOnClick(event, treeId, treeNode) {
|
|
userRolesList.reload(treeNode.Id);
|
|
}
|
|
|