mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-11-10 03:14:45 +08:00
全面完成前端模块化!
This commit is contained in:
@@ -54,18 +54,6 @@ namespace OpenAuth.App
|
|||||||
return _repository.Find(null).ToList();
|
return _repository.Find(null).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Module> LoadTree(int firstId, string key)
|
|
||||||
{
|
|
||||||
if (key == "UserElement") //todo:因为在分配菜单页面出现的树,只能收到这个值,蛋疼
|
|
||||||
{
|
|
||||||
return LoadForUser(firstId);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return LoadForRole(firstId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 以组合的方式显示所有的模块信息
|
/// 以组合的方式显示所有的模块信息
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -97,17 +97,6 @@ namespace OpenAuth.App
|
|||||||
return _repository.Find(u => moduleIds.Contains(u.Id)).ToList();
|
return _repository.Find(u => moduleIds.Contains(u.Id)).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 为特定的用户分配角色
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="userId">The user unique identifier.</param>
|
|
||||||
/// <param name="ids">角色ID</param>
|
|
||||||
public void AssignModuleForUser(int userId, int[] ids)
|
|
||||||
{
|
|
||||||
_relevanceRepository.DeleteBy("UserAccessedOrg", userId);
|
|
||||||
_relevanceRepository.AddRelevance("UserAccessedOrg", ids.ToLookup(u => userId));
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加载特定角色的角色
|
/// 加载特定角色的角色
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -122,17 +111,6 @@ namespace OpenAuth.App
|
|||||||
return _repository.Find(u => moduleIds.Contains(u.Id)).ToList();
|
return _repository.Find(u => moduleIds.Contains(u.Id)).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 为特定的角色分配角色
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="roleId">The user unique identifier.</param>
|
|
||||||
/// <param name="ids">角色ID</param>
|
|
||||||
public void AssignModuleForRole(int roleId, int[] ids)
|
|
||||||
{
|
|
||||||
_relevanceRepository.DeleteBy("RoleAccessedOrg", roleId);
|
|
||||||
_relevanceRepository.AddRelevance("RoleAccessedOrg", ids.ToLookup(u => roleId));
|
|
||||||
}
|
|
||||||
|
|
||||||
#region 私有方法
|
#region 私有方法
|
||||||
|
|
||||||
//修改对象的级联ID,生成类似XXX.XXX.X.XX
|
//修改对象的级联ID,生成类似XXX.XXX.X.XX
|
||||||
|
|||||||
173
OpenAuth.Mvc/BllScripts/assignModule.js
Normal file
173
OpenAuth.Mvc/BllScripts/assignModule.js
Normal file
@@ -0,0 +1,173 @@
|
|||||||
|
// ***********************************************************************
|
||||||
|
// Assembly : OpenAuth.Mvc
|
||||||
|
// Author : yubaolee
|
||||||
|
// Created : 04-16-2016
|
||||||
|
//
|
||||||
|
// Last Modified By : yubaolee
|
||||||
|
// Last Modified On : 04-16-2016
|
||||||
|
// ***********************************************************************
|
||||||
|
// <copyright file="userRes.js" company="www.cnblogs.com/yubaolee">
|
||||||
|
// 版权所有(C) 2015
|
||||||
|
// </copyright>
|
||||||
|
// <summary>分配组织</summary>
|
||||||
|
// ***********************************************************************
|
||||||
|
|
||||||
|
|
||||||
|
$(document).ready(function () {
|
||||||
|
$.CurrentDialog.find("#btnAccess").on("click", function () {
|
||||||
|
var ids = ztree.getSelected();
|
||||||
|
if (ids == null) return;
|
||||||
|
|
||||||
|
$.post('/RelevanceManager/Assign', {
|
||||||
|
type: $("#moduleType").val(),
|
||||||
|
firstId: $('#firstId').val(),
|
||||||
|
secIds: ids
|
||||||
|
}, function (json) {
|
||||||
|
selected.reLoad();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
$.CurrentDialog.find("#btnDelAccess").on("click", function () {
|
||||||
|
var ids = selected.getSelected();
|
||||||
|
if (ids == null) return;
|
||||||
|
|
||||||
|
$.post('/RelevanceManager/UnAssign', {
|
||||||
|
type: $("#moduleType").val(),
|
||||||
|
firstId: $('#firstId').val(),
|
||||||
|
secIds: ids
|
||||||
|
}, function (json) {
|
||||||
|
selected.reLoad();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
//待选的树
|
||||||
|
var ztree = function () {
|
||||||
|
var moduleIds;
|
||||||
|
var zTreeObj;
|
||||||
|
var setting = {
|
||||||
|
view: {
|
||||||
|
selectedMulti: false
|
||||||
|
},
|
||||||
|
check: {
|
||||||
|
enable: true,
|
||||||
|
chkStyle: "checkbox",
|
||||||
|
chkboxType: { "Y": "", "N": "" } //去掉勾选时级联
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
key: {
|
||||||
|
name: 'Name',
|
||||||
|
title: 'Name'
|
||||||
|
},
|
||||||
|
simpleData: {
|
||||||
|
enable: true,
|
||||||
|
idKey: 'Id',
|
||||||
|
pIdKey: 'ParentId',
|
||||||
|
rootPId: 'null'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
callback: {
|
||||||
|
onClick: zTreeOnClick,
|
||||||
|
onCheck: zTreeCheck
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
function zTreeCheck(e, treeId, treeNode) {
|
||||||
|
var nodes = zTreeObj.getCheckedNodes(true);
|
||||||
|
if (nodes.length == 0) {
|
||||||
|
moduleIds = null;
|
||||||
|
} else {
|
||||||
|
moduleIds = '[' + nodes.map(function (e) { return e.Id; }).join(",") + ']';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function zTreeOnClick(event, treeId, treeNode) {
|
||||||
|
zTreeObj.checkNode(treeNode, !treeNode.checked, true, true);
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
$.getJSON('/ModuleManager/LoadForTree', function (json) {
|
||||||
|
zTreeObj = $.fn.zTree.init($.CurrentDialog.find("#tree"), setting, json);
|
||||||
|
zTreeObj.expandAll(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
getSelected: function() {
|
||||||
|
return moduleIds;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
|
||||||
|
|
||||||
|
//已分配的机构
|
||||||
|
var selected = function () {
|
||||||
|
var moduleIds;
|
||||||
|
var zTreeObj;
|
||||||
|
var setting = {
|
||||||
|
view: {
|
||||||
|
selectedMulti: false
|
||||||
|
},
|
||||||
|
check: {
|
||||||
|
enable: true,
|
||||||
|
chkStyle: "checkbox",
|
||||||
|
chkboxType: { "Y": "", "N": "" } //去掉勾选时级联
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
key: {
|
||||||
|
name: 'Name',
|
||||||
|
title: 'Name'
|
||||||
|
},
|
||||||
|
simpleData: {
|
||||||
|
enable: true,
|
||||||
|
idKey: 'Id',
|
||||||
|
pIdKey: 'ParentId',
|
||||||
|
rootPId: 'null'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
callback: {
|
||||||
|
onClick: zTreeOnClick,
|
||||||
|
onCheck: zTreeCheck
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
function zTreeCheck(e, treeId, treeNode) {
|
||||||
|
var nodes = zTreeObj.getCheckedNodes(true);
|
||||||
|
if (nodes.length == 0) {
|
||||||
|
moduleIds = null;
|
||||||
|
} else {
|
||||||
|
moduleIds = '[' + nodes.map(function (e) { return e.Id; }).join(",") + ']';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function zTreeOnClick(event, treeId, treeNode) {
|
||||||
|
zTreeObj.checkNode(treeNode, !treeNode.checked, true, true);
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
var load = function() {
|
||||||
|
var url;
|
||||||
|
var type = $("#moduleType").val();
|
||||||
|
if (type == "UserModule") {
|
||||||
|
url = '/ModuleManager/LoadForUser';
|
||||||
|
} else {
|
||||||
|
url = '/ModuleManager/LoadForRole';
|
||||||
|
}
|
||||||
|
$.getJSON(url, {
|
||||||
|
firstId: $('#firstId').val()
|
||||||
|
}, function (json) {
|
||||||
|
zTreeObj = $.fn.zTree.init($.CurrentDialog.find("#selected"), setting, json);
|
||||||
|
zTreeObj.expandAll(true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
getSelected: function () {
|
||||||
|
return moduleIds;
|
||||||
|
},
|
||||||
|
reLoad: function() {
|
||||||
|
return load();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
|
||||||
|
selected.reLoad();
|
||||||
|
|
||||||
|
//@@ sourceURL=assignOrg.js
|
||||||
@@ -106,7 +106,16 @@ var ztree = function () {
|
|||||||
},
|
},
|
||||||
callback: { onClick: zTreeOnClick }
|
callback: { onClick: zTreeOnClick }
|
||||||
};
|
};
|
||||||
$.getJSON('/ModuleManager/LoadTree?firstId=' + $('#firstId').val()+ '&key=' + $('#moduleType').val() , function (json) {
|
|
||||||
|
var url;
|
||||||
|
var type = $("#moduleType");
|
||||||
|
if (type == "UserElement") {
|
||||||
|
url = '/ModuleManager/LoadForUser';
|
||||||
|
} else {
|
||||||
|
url = '/ModuleManager/LoadForRole';
|
||||||
|
}
|
||||||
|
|
||||||
|
$.getJSON(url, { firstId: $("#firstId").val() }, function(json) {
|
||||||
var zTreeObj = $.fn.zTree.init($.CurrentDialog.find("#tree"), setting, json);
|
var zTreeObj = $.fn.zTree.init($.CurrentDialog.find("#tree"), setting, json);
|
||||||
zTreeObj.expandAll(true);
|
zTreeObj.expandAll(true);
|
||||||
});
|
});
|
||||||
|
|||||||
173
OpenAuth.Mvc/BllScripts/assignOrg.js
Normal file
173
OpenAuth.Mvc/BllScripts/assignOrg.js
Normal file
@@ -0,0 +1,173 @@
|
|||||||
|
// ***********************************************************************
|
||||||
|
// Assembly : OpenAuth.Mvc
|
||||||
|
// Author : yubaolee
|
||||||
|
// Created : 04-16-2016
|
||||||
|
//
|
||||||
|
// Last Modified By : yubaolee
|
||||||
|
// Last Modified On : 04-16-2016
|
||||||
|
// ***********************************************************************
|
||||||
|
// <copyright file="userRes.js" company="www.cnblogs.com/yubaolee">
|
||||||
|
// 版权所有(C) 2015
|
||||||
|
// </copyright>
|
||||||
|
// <summary>分配组织</summary>
|
||||||
|
// ***********************************************************************
|
||||||
|
|
||||||
|
|
||||||
|
$(document).ready(function () {
|
||||||
|
$.CurrentDialog.find("#btnAccess").on("click", function () {
|
||||||
|
var ids = ztree.getSelected();
|
||||||
|
if (ids == null) return;
|
||||||
|
|
||||||
|
$.post('/RelevanceManager/Assign', {
|
||||||
|
type: $("#moduleType").val(),
|
||||||
|
firstId: $('#firstId').val(),
|
||||||
|
secIds: ids
|
||||||
|
}, function (json) {
|
||||||
|
selected.reLoad();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
$.CurrentDialog.find("#btnDelAccess").on("click", function () {
|
||||||
|
var ids = selected.getSelected();
|
||||||
|
if (ids == null) return;
|
||||||
|
|
||||||
|
$.post('/RelevanceManager/UnAssign', {
|
||||||
|
type: $("#moduleType").val(),
|
||||||
|
firstId: $('#firstId').val(),
|
||||||
|
secIds: ids
|
||||||
|
}, function (json) {
|
||||||
|
selected.reLoad();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
//待选的树
|
||||||
|
var ztree = function () {
|
||||||
|
var moduleIds;
|
||||||
|
var zTreeObj;
|
||||||
|
var setting = {
|
||||||
|
view: {
|
||||||
|
selectedMulti: false
|
||||||
|
},
|
||||||
|
check: {
|
||||||
|
enable: true,
|
||||||
|
chkStyle: "checkbox",
|
||||||
|
chkboxType: { "Y": "", "N": "" } //去掉勾选时级联
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
key: {
|
||||||
|
name: 'Name',
|
||||||
|
title: 'Name'
|
||||||
|
},
|
||||||
|
simpleData: {
|
||||||
|
enable: true,
|
||||||
|
idKey: 'Id',
|
||||||
|
pIdKey: 'ParentId',
|
||||||
|
rootPId: 'null'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
callback: {
|
||||||
|
onClick: zTreeOnClick,
|
||||||
|
onCheck: zTreeCheck
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
function zTreeCheck(e, treeId, treeNode) {
|
||||||
|
var nodes = zTreeObj.getCheckedNodes(true);
|
||||||
|
if (nodes.length == 0) {
|
||||||
|
moduleIds = null;
|
||||||
|
} else {
|
||||||
|
moduleIds = '[' + nodes.map(function (e) { return e.Id; }).join(",") + ']';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function zTreeOnClick(event, treeId, treeNode) {
|
||||||
|
zTreeObj.checkNode(treeNode, !treeNode.checked, true, true);
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
$.getJSON('/OrgManager/LoadForTree', function (json) {
|
||||||
|
zTreeObj = $.fn.zTree.init($.CurrentDialog.find("#tree"), setting, json);
|
||||||
|
zTreeObj.expandAll(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
getSelected: function() {
|
||||||
|
return moduleIds;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
|
||||||
|
|
||||||
|
//已分配的机构
|
||||||
|
var selected = function () {
|
||||||
|
var moduleIds;
|
||||||
|
var zTreeObj;
|
||||||
|
var setting = {
|
||||||
|
view: {
|
||||||
|
selectedMulti: false
|
||||||
|
},
|
||||||
|
check: {
|
||||||
|
enable: true,
|
||||||
|
chkStyle: "checkbox",
|
||||||
|
chkboxType: { "Y": "", "N": "" } //去掉勾选时级联
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
key: {
|
||||||
|
name: 'Name',
|
||||||
|
title: 'Name'
|
||||||
|
},
|
||||||
|
simpleData: {
|
||||||
|
enable: true,
|
||||||
|
idKey: 'Id',
|
||||||
|
pIdKey: 'ParentId',
|
||||||
|
rootPId: 'null'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
callback: {
|
||||||
|
onClick: zTreeOnClick,
|
||||||
|
onCheck: zTreeCheck
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
function zTreeCheck(e, treeId, treeNode) {
|
||||||
|
var nodes = zTreeObj.getCheckedNodes(true);
|
||||||
|
if (nodes.length == 0) {
|
||||||
|
moduleIds = null;
|
||||||
|
} else {
|
||||||
|
moduleIds = '[' + nodes.map(function (e) { return e.Id; }).join(",") + ']';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function zTreeOnClick(event, treeId, treeNode) {
|
||||||
|
zTreeObj.checkNode(treeNode, !treeNode.checked, true, true);
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
var load = function() {
|
||||||
|
var url;
|
||||||
|
var type = $("#moduleType").val();
|
||||||
|
if (type == "UserAccessedOrg") {
|
||||||
|
url = '/OrgManager/LoadForUser';
|
||||||
|
} else {
|
||||||
|
url = '/OrgManager/LoadForRole';
|
||||||
|
}
|
||||||
|
$.getJSON(url, {
|
||||||
|
firstId: $('#firstId').val()
|
||||||
|
}, function (json) {
|
||||||
|
zTreeObj = $.fn.zTree.init($.CurrentDialog.find("#selected"), setting, json);
|
||||||
|
zTreeObj.expandAll(true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
getSelected: function () {
|
||||||
|
return moduleIds;
|
||||||
|
},
|
||||||
|
reLoad: function() {
|
||||||
|
return load();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}();
|
||||||
|
|
||||||
|
selected.reLoad();
|
||||||
|
|
||||||
|
//@@ sourceURL=assignOrg.js
|
||||||
@@ -241,11 +241,14 @@ function assignRoleModule(obj) {
|
|||||||
if (selected == null) return;
|
if (selected == null) return;
|
||||||
|
|
||||||
$(obj).dialog({
|
$(obj).dialog({
|
||||||
id: 'accessRoleModule',
|
id: 'accessUserOrg',
|
||||||
url: '/ModuleManager/LookupMultiForRole',
|
url: '/ModuleManager/Assign',
|
||||||
title: '为角色分配模块',
|
title: '为角色分配模块',
|
||||||
|
width: 620,
|
||||||
|
height: 500,
|
||||||
data: {
|
data: {
|
||||||
roleid: selected.Id
|
firstId: selected.Id,
|
||||||
|
key: "RoleModule"
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -257,10 +260,13 @@ function assignRoleOrg(obj) {
|
|||||||
|
|
||||||
$(obj).dialog({
|
$(obj).dialog({
|
||||||
id: 'accessRoleOrg',
|
id: 'accessRoleOrg',
|
||||||
url: '/OrgManager/LookupMultiForRole',
|
url: '/OrgManager/Assign',
|
||||||
title: '为角色分配可见机构',
|
title: '为角色分配可见部门',
|
||||||
|
width: 620,
|
||||||
|
height: 500,
|
||||||
data: {
|
data: {
|
||||||
roleid: selected.Id
|
firstId: selected.Id,
|
||||||
|
key: "RoleAccessedOrg"
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -252,11 +252,14 @@ function openUserModuleAccess(obj) {
|
|||||||
if (selected == null) return;
|
if (selected == null) return;
|
||||||
|
|
||||||
$(obj).dialog({
|
$(obj).dialog({
|
||||||
id: 'accessUserModule',
|
id: 'accessUserOrg',
|
||||||
url: '/ModuleManager/LookupMultiForUser',
|
url: '/ModuleManager/Assign',
|
||||||
title: '为用户分配模块',
|
title: '为用户分配可见部门',
|
||||||
|
width: 620,
|
||||||
|
height: 500,
|
||||||
data: {
|
data: {
|
||||||
userId: selected.Id
|
firstId: selected.Id,
|
||||||
|
key: "UserModule"
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -268,10 +271,13 @@ function openUserOrgAccess(obj) {
|
|||||||
|
|
||||||
$(obj).dialog({
|
$(obj).dialog({
|
||||||
id: 'accessUserOrg',
|
id: 'accessUserOrg',
|
||||||
url: '/OrgManager/LookupMultiForUser',
|
url: '/OrgManager/Assign',
|
||||||
title: '为用户分配可见部门',
|
title: '为用户分配可见部门',
|
||||||
|
width: 620,
|
||||||
|
height: 500,
|
||||||
data: {
|
data: {
|
||||||
userId: selected.Id
|
firstId: selected.Id,
|
||||||
|
key: "UserAccessedOrg"
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,17 +25,10 @@ namespace OpenAuth.Mvc.Controllers
|
|||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
//用于选择模块时使用
|
public ActionResult Assign(int firstId, string key)
|
||||||
public ActionResult LookUpMultiForUser(int userId)
|
|
||||||
{
|
{
|
||||||
ViewBag.UserId = userId;
|
ViewBag.FirstId = firstId;
|
||||||
return View();
|
ViewBag.ModuleType = key;
|
||||||
}
|
|
||||||
|
|
||||||
//为角色分配模块
|
|
||||||
public ActionResult LookupMultiForRole(int roleId)
|
|
||||||
{
|
|
||||||
ViewBag.RoleId = roleId;
|
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,14 +46,6 @@ namespace OpenAuth.Mvc.Controllers
|
|||||||
public string LoadForTree()
|
public string LoadForTree()
|
||||||
{
|
{
|
||||||
var orgs = SessionHelper.GetSessionUser<LoginUserVM>().Modules;
|
var orgs = SessionHelper.GetSessionUser<LoginUserVM>().Modules;
|
||||||
//添加根节点
|
|
||||||
//orgs.Add(new Module
|
|
||||||
//{
|
|
||||||
// Id = 0,
|
|
||||||
// ParentId = -1,
|
|
||||||
// Name = "根节点",
|
|
||||||
// CascadeId = "0"
|
|
||||||
//});
|
|
||||||
return JsonHelper.Instance.Serialize(orgs);
|
return JsonHelper.Instance.Serialize(orgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,100 +63,30 @@ namespace OpenAuth.Mvc.Controllers
|
|||||||
return JsonHelper.Instance.Serialize(orgs);
|
return JsonHelper.Instance.Serialize(orgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 分配菜单页面的树
|
|
||||||
/// <para>todo:key要用UserElement/RoleElement,会造成迷惑,后期优化</para>
|
|
||||||
/// </summary>
|
|
||||||
public string LoadTree(int firstId, string key)
|
|
||||||
{
|
|
||||||
var orgs = _app.LoadTree(firstId, key);
|
|
||||||
//添加根节点
|
|
||||||
orgs.Add(new Module
|
|
||||||
{
|
|
||||||
Id = 0,
|
|
||||||
ParentId = -1,
|
|
||||||
Name = "已拥有的模块",
|
|
||||||
CascadeId = "0"
|
|
||||||
});
|
|
||||||
return JsonHelper.Instance.Serialize(orgs);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加载用户模块
|
/// 加载用户模块
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="userId">The user identifier.</param>
|
/// <param name="firstId">The user identifier.</param>
|
||||||
/// <returns>System.String.</returns>
|
/// <returns>System.String.</returns>
|
||||||
public string LoadForUser(int userId)
|
public string LoadForUser(int firstId)
|
||||||
{
|
{
|
||||||
var orgs = _app.LoadForUser(userId);
|
var orgs = _app.LoadForUser(firstId);
|
||||||
//添加根节点
|
|
||||||
orgs.Add(new Module
|
|
||||||
{
|
|
||||||
Id = 0,
|
|
||||||
ParentId = -1,
|
|
||||||
Name = "用户及角色拥有的模块",
|
|
||||||
CascadeId = "0"
|
|
||||||
});
|
|
||||||
return JsonHelper.Instance.Serialize(orgs);
|
return JsonHelper.Instance.Serialize(orgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加载角色模块
|
/// 加载角色模块
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="roleId">The role identifier.</param>
|
/// <param name="firstId">The role identifier.</param>
|
||||||
/// <returns>System.String.</returns>
|
/// <returns>System.String.</returns>
|
||||||
public string LoadForRole(int roleId)
|
public string LoadForRole(int firstId)
|
||||||
{
|
{
|
||||||
var orgs = _app.LoadForRole(roleId);
|
var orgs = _app.LoadForRole(firstId);
|
||||||
//添加根节点
|
|
||||||
orgs.Add(new Module
|
|
||||||
{
|
|
||||||
Id = 0,
|
|
||||||
ParentId = -1,
|
|
||||||
Name = "已为角色分配的模块",
|
|
||||||
CascadeId = "0"
|
|
||||||
});
|
|
||||||
return JsonHelper.Instance.Serialize(orgs);
|
return JsonHelper.Instance.Serialize(orgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string AssignModuleForRole(int roleId, string moduleIds)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var ids = moduleIds.Split(',').Select(id => int.Parse(id)).ToArray();
|
|
||||||
_app.AssignModuleForRole(roleId, ids);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
BjuiResponse.message = e.Message;
|
|
||||||
BjuiResponse.statusCode = "300";
|
|
||||||
}
|
|
||||||
|
|
||||||
return JsonHelper.Instance.Serialize(BjuiResponse);
|
|
||||||
}
|
|
||||||
|
|
||||||
public string AssignModuleForUser(int userId, string moduleIds)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var ids = moduleIds.Split(',').Select(id => int.Parse(id)).ToArray();
|
|
||||||
_app.AssignModuleForUser(userId, ids);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
BjuiResponse.message = e.Message;
|
|
||||||
BjuiResponse.statusCode = "300";
|
|
||||||
}
|
|
||||||
|
|
||||||
return JsonHelper.Instance.Serialize(BjuiResponse);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region 添加编辑模块
|
#region 添加编辑模块
|
||||||
public ActionResult Add(int id = 0)
|
|
||||||
{
|
|
||||||
return View(_app.Find(id));
|
|
||||||
}
|
|
||||||
|
|
||||||
//添加或修改模块
|
//添加或修改模块
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public string Add(Module model)
|
public string Add(Module model)
|
||||||
|
|||||||
@@ -27,22 +27,10 @@ namespace OpenAuth.Mvc.Controllers
|
|||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
//用于选择模块时使用
|
public ActionResult Assign(int firstId, string key)
|
||||||
public ActionResult LookUpMultiForUser(int userId)
|
|
||||||
{
|
|
||||||
ViewBag.UserId = userId;
|
|
||||||
return View();
|
|
||||||
}
|
|
||||||
|
|
||||||
//为角色分配模块
|
|
||||||
public ActionResult LookupMultiForRole(int roleId)
|
|
||||||
{
|
|
||||||
ViewBag.RoleId = roleId;
|
|
||||||
return View();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ActionResult AddOrg()
|
|
||||||
{
|
{
|
||||||
|
ViewBag.FirstId = firstId;
|
||||||
|
ViewBag.ModuleType = key;
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,65 +63,20 @@ namespace OpenAuth.Mvc.Controllers
|
|||||||
return JsonHelper.Instance.Serialize(orgs);
|
return JsonHelper.Instance.Serialize(orgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string LoadForUser(int userId)
|
public string LoadForUser(int firstId)
|
||||||
{
|
{
|
||||||
var orgs = _orgApp.LoadForUser(userId);
|
var orgs = _orgApp.LoadForUser(firstId);
|
||||||
//添加根节点
|
//添加根节点
|
||||||
orgs.Add(new Org
|
|
||||||
{
|
|
||||||
Id = 0,
|
|
||||||
ParentId = -1,
|
|
||||||
Name = "用户及角色可访问的部门",
|
|
||||||
CascadeId = "0"
|
|
||||||
});
|
|
||||||
return JsonHelper.Instance.Serialize(orgs);
|
return JsonHelper.Instance.Serialize(orgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string LoadForRole(int roleId)
|
public string LoadForRole(int firstId)
|
||||||
{
|
{
|
||||||
var orgs = _orgApp.LoadForRole(roleId);
|
var orgs = _orgApp.LoadForRole(firstId);
|
||||||
//添加根节点
|
|
||||||
orgs.Add(new Org
|
|
||||||
{
|
|
||||||
Id = 0,
|
|
||||||
ParentId = -1,
|
|
||||||
Name = "已为角色分配的可访问部门",
|
|
||||||
CascadeId = "0"
|
|
||||||
});
|
|
||||||
return JsonHelper.Instance.Serialize(orgs);
|
return JsonHelper.Instance.Serialize(orgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string AssignOrgForRole(int roleId, string moduleIds)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var ids = moduleIds.Split(',').Select(id => int.Parse(id)).ToArray();
|
|
||||||
_orgApp.AssignModuleForRole(roleId, ids);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
BjuiResponse.message = e.Message;
|
|
||||||
BjuiResponse.statusCode = "300";
|
|
||||||
}
|
|
||||||
|
|
||||||
return JsonHelper.Instance.Serialize(BjuiResponse);
|
|
||||||
}
|
|
||||||
|
|
||||||
public string AssignOrgForUser(int userId, string moduleIds)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var ids = moduleIds.Split(',').Select(id => int.Parse(id)).ToArray();
|
|
||||||
_orgApp.AssignModuleForUser(userId, ids);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
BjuiResponse.message = e.Message;
|
|
||||||
BjuiResponse.statusCode = "300";
|
|
||||||
}
|
|
||||||
|
|
||||||
return JsonHelper.Instance.Serialize(BjuiResponse);
|
|
||||||
}
|
|
||||||
|
|
||||||
//添加组织提交
|
//添加组织提交
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
|
|||||||
@@ -151,6 +151,8 @@
|
|||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Content Include="BllScripts\assignModule.js" />
|
||||||
|
<Content Include="BllScripts\assignOrg.js" />
|
||||||
<Content Include="BllScripts\assignModuleElement.js" />
|
<Content Include="BllScripts\assignModuleElement.js" />
|
||||||
<Content Include="BllScripts\categoryManager.js" />
|
<Content Include="BllScripts\categoryManager.js" />
|
||||||
<Content Include="BllScripts\grid.js" />
|
<Content Include="BllScripts\grid.js" />
|
||||||
@@ -612,8 +614,7 @@
|
|||||||
<Content Include="Views\RoleManager\LookupMulti.cshtml" />
|
<Content Include="Views\RoleManager\LookupMulti.cshtml" />
|
||||||
<Content Include="Views\ResourceManager\AssignRes.cshtml" />
|
<Content Include="Views\ResourceManager\AssignRes.cshtml" />
|
||||||
<Content Include="Views\StockManager\Index.cshtml" />
|
<Content Include="Views\StockManager\Index.cshtml" />
|
||||||
<Content Include="Views\OrgManager\LookupMultiForRole.cshtml" />
|
<Content Include="Views\OrgManager\Assign.cshtml" />
|
||||||
<Content Include="Views\OrgManager\LookupMultiForUser.cshtml" />
|
|
||||||
<Content Include="Views\Shared\_BjuiLayout.cshtml" />
|
<Content Include="Views\Shared\_BjuiLayout.cshtml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -670,8 +671,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="Views\ModuleManager\Index.cshtml" />
|
<Content Include="Views\ModuleManager\Index.cshtml" />
|
||||||
<Content Include="Views\ModuleManager\LookupMultiForUser.cshtml" />
|
<Content Include="Views\ModuleManager\Assign.cshtml" />
|
||||||
<Content Include="Views\ModuleManager\LookupMultiForRole.cshtml" />
|
|
||||||
<None Include="Views\Home\MenuHeader.cshtml" />
|
<None Include="Views\Home\MenuHeader.cshtml" />
|
||||||
<None Include="Views\ModuleElementManager\Index.cshtml" />
|
<None Include="Views\ModuleElementManager\Index.cshtml" />
|
||||||
<Content Include="Views\ModuleElementManager\AssignModuleElement.cshtml" />
|
<Content Include="Views\ModuleElementManager\AssignModuleElement.cshtml" />
|
||||||
|
|||||||
34
OpenAuth.Mvc/Views/ModuleManager/Assign.cshtml
Normal file
34
OpenAuth.Mvc/Views/ModuleManager/Assign.cshtml
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
<div class="bjui-pageHeader">
|
||||||
|
<div class="bjui-searchBar">
|
||||||
|
<input style="display: none" id="firstId" value="@ViewBag.FirstId" />
|
||||||
|
<input style="display: none" id="moduleType" , value="@ViewBag.ModuleType" />
|
||||||
|
<div class="pull-right">
|
||||||
|
<div class="alert alert-info search-inline">
|
||||||
|
<i class="fa fa-info-circle"></i>用户可访问的模块=其角色的模块+本身可访问的模块
|
||||||
|
</div>
|
||||||
|
<button type="button" class="btn btn-green" data-num="1" data-icon="plus" id="btnAccess">
|
||||||
|
授权选中
|
||||||
|
</button>
|
||||||
|
<button type="button" class="btn btn-danger" data-num="1" data-icon="trash" id="btnDelAccess">
|
||||||
|
取消授权
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="bjui-pageContent">
|
||||||
|
<fieldset style="height: auto; float: left; width: 280px;">
|
||||||
|
<legend>系统的模块</legend>
|
||||||
|
<ul id="tree" class="ztree"></ul>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<!--已经选中的列表-->
|
||||||
|
<fieldset style="height: auto;margin-left: 310px; width: 280px">
|
||||||
|
<legend>已分配的模块</legend>
|
||||||
|
<ul id="selected" class="ztree"></ul>
|
||||||
|
</fieldset>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="~/BllScripts/grid.js"></script>
|
||||||
|
<script src="~/BllScripts/assignModule.js"></script>
|
||||||
|
|
||||||
@@ -1,123 +0,0 @@
|
|||||||
@*
|
|
||||||
选择多个模块ID,以ids的形式返回
|
|
||||||
*@
|
|
||||||
|
|
||||||
@{
|
|
||||||
ViewBag.Title = "title";
|
|
||||||
Layout = null;
|
|
||||||
}
|
|
||||||
<div class="bjui-pageContent">
|
|
||||||
<input style="display: none" id="roleId" value="@ViewBag.RoleId"/>
|
|
||||||
<div style="float: left; width: 220px; height: 240px; overflow: auto;" class="table table-bordered">
|
|
||||||
<ul id="lookupTree" class="ztree"></ul>
|
|
||||||
</div>
|
|
||||||
<!--已经选中的列表-->
|
|
||||||
<div style="margin-left: 225px">
|
|
||||||
<ul id="selected" class="ztree"></ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="bjui-pageFooter">
|
|
||||||
<ul>
|
|
||||||
<li><button type="button" class="btn-close" data-icon="close">关闭</button></li>
|
|
||||||
<li><button type="button" onclick="save()" class="btn btn-blue" data-icon="check">保存</button></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
var moduleIds;
|
|
||||||
$(document).ready(function () {
|
|
||||||
Init();
|
|
||||||
InitSelected();
|
|
||||||
});
|
|
||||||
function Init() {
|
|
||||||
var setting = {
|
|
||||||
view: {
|
|
||||||
selectedMulti: false
|
|
||||||
},
|
|
||||||
check: {
|
|
||||||
enable: true,
|
|
||||||
chkStyle: "checkbox"
|
|
||||||
},
|
|
||||||
data: {
|
|
||||||
key: {
|
|
||||||
name: 'Name',
|
|
||||||
title: 'Name'
|
|
||||||
},
|
|
||||||
simpleData: {
|
|
||||||
enable: true,
|
|
||||||
idKey: 'Id',
|
|
||||||
pIdKey: 'ParentId',
|
|
||||||
rootPId: 'null'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
callback: {
|
|
||||||
onClick: zTreeOnClick,
|
|
||||||
onCheck: zTreeCheck
|
|
||||||
}
|
|
||||||
};
|
|
||||||
$.getJSON('/ModuleManager/LoadForTree', function (json) {
|
|
||||||
var zTreeObj = $.fn.zTree.init($('#lookupTree'), setting, json);
|
|
||||||
zTreeObj.expandAll(true);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function InitSelected() {
|
|
||||||
var setting = {
|
|
||||||
|
|
||||||
data: {
|
|
||||||
key: {
|
|
||||||
name: 'Name',
|
|
||||||
title: 'Name'
|
|
||||||
},
|
|
||||||
simpleData: {
|
|
||||||
enable: true,
|
|
||||||
idKey: 'Id',
|
|
||||||
pIdKey: 'ParentId',
|
|
||||||
rootPId: 'null'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
callback: {
|
|
||||||
onClick: zTreeOnClick,
|
|
||||||
onCheck: zTreeCheck
|
|
||||||
}
|
|
||||||
};
|
|
||||||
$.post('/ModuleManager/LoadForRole', { roleId: $('#roleId').val() },
|
|
||||||
function (json) {
|
|
||||||
var zTreeObj = $.fn.zTree.init($('#selected'), setting, eval(json));
|
|
||||||
zTreeObj.expandAll(true);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function save() {
|
|
||||||
$.post('/ModuleManager/AssignModuleForRole', { roleId: $('#roleId').val(), moduleIds: moduleIds },
|
|
||||||
function (json) {
|
|
||||||
var rel = $.parseJSON(json);
|
|
||||||
if (rel.statusCode == "200") {
|
|
||||||
$(this).alertmsg('ok', rel.message);
|
|
||||||
} else {
|
|
||||||
$(this).alertmsg('error', rel.message);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function zTreeCheck(e, treeId, treeNode) {
|
|
||||||
var zTree = $.fn.zTree.getZTreeObj(treeId),
|
|
||||||
nodes = zTree.getCheckedNodes(true);
|
|
||||||
var ids = '';
|
|
||||||
for (var i = 0; i < nodes.length; i++) {
|
|
||||||
ids += ',' + nodes[i].Id;
|
|
||||||
}
|
|
||||||
if (ids.length > 0) { //去掉第一个逗号
|
|
||||||
ids = ids.substr(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
moduleIds = ids;
|
|
||||||
}
|
|
||||||
function zTreeOnClick(event, treeId, treeNode) {
|
|
||||||
var zTree = $.fn.zTree.getZTreeObj(treeId);
|
|
||||||
zTree.checkNode(treeNode, !treeNode.checked, true, true);
|
|
||||||
event.preventDefault();
|
|
||||||
}
|
|
||||||
|
|
||||||
//@@ sourceURL=lookupMulti.js
|
|
||||||
</script>
|
|
||||||
@@ -1,123 +0,0 @@
|
|||||||
@*
|
|
||||||
选择多个模块ID,以ids的形式返回
|
|
||||||
*@
|
|
||||||
|
|
||||||
@{
|
|
||||||
ViewBag.Title = "title";
|
|
||||||
Layout = null;
|
|
||||||
}
|
|
||||||
<div class="bjui-pageContent">
|
|
||||||
<input style="display: none" id="userId" value="@ViewBag.UserId"/>
|
|
||||||
<div style="float: left; width: 220px; height: 240px; overflow: auto;" class="table table-bordered">
|
|
||||||
<ul id="lookupTree" class="ztree"></ul>
|
|
||||||
</div>
|
|
||||||
<!--已经选中的列表-->
|
|
||||||
<div style="margin-left: 225px">
|
|
||||||
<ul id="selected" class="ztree"></ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="bjui-pageFooter">
|
|
||||||
<ul>
|
|
||||||
<li><button type="button" class="btn-close" data-icon="close">关闭</button></li>
|
|
||||||
<li><button type="button" onclick="save()" class="btn btn-blue" data-icon="check">保存</button></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
var moduleIds;
|
|
||||||
$(document).ready(function () {
|
|
||||||
Init();
|
|
||||||
InitSelected();
|
|
||||||
});
|
|
||||||
function Init() {
|
|
||||||
var setting = {
|
|
||||||
view: {
|
|
||||||
selectedMulti: false
|
|
||||||
},
|
|
||||||
check: {
|
|
||||||
enable: true,
|
|
||||||
chkStyle: "checkbox"
|
|
||||||
},
|
|
||||||
data: {
|
|
||||||
key: {
|
|
||||||
name: 'Name',
|
|
||||||
title: 'Name'
|
|
||||||
},
|
|
||||||
simpleData: {
|
|
||||||
enable: true,
|
|
||||||
idKey: 'Id',
|
|
||||||
pIdKey: 'ParentId',
|
|
||||||
rootPId: 'null'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
callback: {
|
|
||||||
onClick: zTreeOnClick,
|
|
||||||
onCheck: zTreeCheck
|
|
||||||
}
|
|
||||||
};
|
|
||||||
$.getJSON('/ModuleManager/LoadForTree', function (json) {
|
|
||||||
var zTreeObj = $.fn.zTree.init($('#lookupTree'), setting, json);
|
|
||||||
zTreeObj.expandAll(true);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function InitSelected() {
|
|
||||||
var setting = {
|
|
||||||
|
|
||||||
data: {
|
|
||||||
key: {
|
|
||||||
name: 'Name',
|
|
||||||
title: 'Name'
|
|
||||||
},
|
|
||||||
simpleData: {
|
|
||||||
enable: true,
|
|
||||||
idKey: 'Id',
|
|
||||||
pIdKey: 'ParentId',
|
|
||||||
rootPId: 'null'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
callback: {
|
|
||||||
onClick: zTreeOnClick,
|
|
||||||
onCheck: zTreeCheck
|
|
||||||
}
|
|
||||||
};
|
|
||||||
$.post('/ModuleManager/LoadForUser', { userId: $('#userId').val() },
|
|
||||||
function (json) {
|
|
||||||
var zTreeObj = $.fn.zTree.init($('#selected'), setting, eval(json));
|
|
||||||
zTreeObj.expandAll(true);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function save() {
|
|
||||||
$.post('/ModuleManager/AssignModuleForUser', { userId: $('#userId').val(), moduleIds: moduleIds },
|
|
||||||
function (json) {
|
|
||||||
var rel = $.parseJSON(json);
|
|
||||||
if (rel.statusCode == "200") {
|
|
||||||
$(this).alertmsg('ok', rel.message);
|
|
||||||
} else {
|
|
||||||
$(this).alertmsg('error', rel.message);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function zTreeCheck(e, treeId, treeNode) {
|
|
||||||
var zTree = $.fn.zTree.getZTreeObj(treeId),
|
|
||||||
nodes = zTree.getCheckedNodes(true);
|
|
||||||
var ids = '';
|
|
||||||
for (var i = 0; i < nodes.length; i++) {
|
|
||||||
ids += ',' + nodes[i].Id;
|
|
||||||
}
|
|
||||||
if (ids.length > 0) { //去掉第一个逗号
|
|
||||||
ids = ids.substr(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
moduleIds = ids;
|
|
||||||
}
|
|
||||||
function zTreeOnClick(event, treeId, treeNode) {
|
|
||||||
var zTree = $.fn.zTree.getZTreeObj(treeId);
|
|
||||||
zTree.checkNode(treeNode, !treeNode.checked, true, true);
|
|
||||||
event.preventDefault();
|
|
||||||
}
|
|
||||||
|
|
||||||
//@@ sourceURL=lookupMulti.js
|
|
||||||
</script>
|
|
||||||
34
OpenAuth.Mvc/Views/OrgManager/Assign.cshtml
Normal file
34
OpenAuth.Mvc/Views/OrgManager/Assign.cshtml
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
<div class="bjui-pageHeader">
|
||||||
|
<div class="bjui-searchBar">
|
||||||
|
<input style="display: none" id="firstId" value="@ViewBag.FirstId" />
|
||||||
|
<input style="display: none" id="moduleType" , value="@ViewBag.ModuleType" />
|
||||||
|
<div class="pull-right">
|
||||||
|
<div class="alert alert-info search-inline">
|
||||||
|
<i class="fa fa-info-circle"></i>用户可访问的机构=其角色的机构+本身可访问的机构
|
||||||
|
</div>
|
||||||
|
<button type="button" class="btn btn-green" data-num="1" data-icon="plus" id="btnAccess">
|
||||||
|
授权选中
|
||||||
|
</button>
|
||||||
|
<button type="button" class="btn btn-danger" data-num="1" data-icon="trash" id="btnDelAccess">
|
||||||
|
取消授权
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="bjui-pageContent">
|
||||||
|
<fieldset style="height: auto; float: left; width: 280px;">
|
||||||
|
<legend>系统的机构</legend>
|
||||||
|
<ul id="tree" class="ztree"></ul>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<!--已经选中的列表-->
|
||||||
|
<fieldset style="height: auto;margin-left: 310px; width: 280px">
|
||||||
|
<legend>已分配的机构</legend>
|
||||||
|
<ul id="selected" class="ztree"></ul>
|
||||||
|
</fieldset>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="~/BllScripts/grid.js"></script>
|
||||||
|
<script src="~/BllScripts/assignOrg.js"></script>
|
||||||
|
|
||||||
@@ -1,123 +0,0 @@
|
|||||||
@*
|
|
||||||
选择多个模块ID,以ids的形式返回
|
|
||||||
*@
|
|
||||||
|
|
||||||
@{
|
|
||||||
ViewBag.Title = "title";
|
|
||||||
Layout = null;
|
|
||||||
}
|
|
||||||
<div class="bjui-pageContent">
|
|
||||||
<input style="display: none" id="roleId" value="@ViewBag.RoleId"/>
|
|
||||||
<div style="float: left; width: 220px; height: 240px; overflow: auto;" class="table table-bordered">
|
|
||||||
<ul id="lookupTree" class="ztree"></ul>
|
|
||||||
</div>
|
|
||||||
<!--已经选中的列表-->
|
|
||||||
<div style="margin-left: 225px">
|
|
||||||
<ul id="selected" class="ztree"></ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="bjui-pageFooter">
|
|
||||||
<ul>
|
|
||||||
<li><button type="button" class="btn-close" data-icon="close">关闭</button></li>
|
|
||||||
<li><button type="button" onclick="save()" class="btn btn-blue" data-icon="check">保存</button></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
var moduleIds;
|
|
||||||
$(document).ready(function () {
|
|
||||||
Init();
|
|
||||||
InitSelected();
|
|
||||||
});
|
|
||||||
function Init() {
|
|
||||||
var setting = {
|
|
||||||
view: {
|
|
||||||
selectedMulti: false
|
|
||||||
},
|
|
||||||
check: {
|
|
||||||
enable: true,
|
|
||||||
chkStyle: "checkbox"
|
|
||||||
},
|
|
||||||
data: {
|
|
||||||
key: {
|
|
||||||
name: 'Name',
|
|
||||||
title: 'Name'
|
|
||||||
},
|
|
||||||
simpleData: {
|
|
||||||
enable: true,
|
|
||||||
idKey: 'Id',
|
|
||||||
pIdKey: 'ParentId',
|
|
||||||
rootPId: 'null'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
callback: {
|
|
||||||
onClick: zTreeOnClick,
|
|
||||||
onCheck: zTreeCheck
|
|
||||||
}
|
|
||||||
};
|
|
||||||
$.getJSON('/OrgManager/LoadForTree', function (json) {
|
|
||||||
var zTreeObj = $.fn.zTree.init($('#lookupTree'), setting, json);
|
|
||||||
zTreeObj.expandAll(true);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function InitSelected() {
|
|
||||||
var setting = {
|
|
||||||
|
|
||||||
data: {
|
|
||||||
key: {
|
|
||||||
name: 'Name',
|
|
||||||
title: 'Name'
|
|
||||||
},
|
|
||||||
simpleData: {
|
|
||||||
enable: true,
|
|
||||||
idKey: 'Id',
|
|
||||||
pIdKey: 'ParentId',
|
|
||||||
rootPId: 'null'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
callback: {
|
|
||||||
onClick: zTreeOnClick,
|
|
||||||
onCheck: zTreeCheck
|
|
||||||
}
|
|
||||||
};
|
|
||||||
$.post('/OrgManager/LoadForRole', { roleId: $('#roleId').val() },
|
|
||||||
function (json) {
|
|
||||||
var zTreeObj = $.fn.zTree.init($('#selected'), setting, eval(json));
|
|
||||||
zTreeObj.expandAll(true);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function save() {
|
|
||||||
$.post('/OrgManager/AssignOrgForRole', { roleId: $('#roleId').val(), moduleIds: moduleIds },
|
|
||||||
function (json) {
|
|
||||||
var rel = $.parseJSON(json);
|
|
||||||
if (rel.statusCode == "200") {
|
|
||||||
$(this).alertmsg('ok', rel.message);
|
|
||||||
} else {
|
|
||||||
$(this).alertmsg('error', rel.message);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function zTreeCheck(e, treeId, treeNode) {
|
|
||||||
var zTree = $.fn.zTree.getZTreeObj(treeId),
|
|
||||||
nodes = zTree.getCheckedNodes(true);
|
|
||||||
var ids = '';
|
|
||||||
for (var i = 0; i < nodes.length; i++) {
|
|
||||||
ids += ',' + nodes[i].Id;
|
|
||||||
}
|
|
||||||
if (ids.length > 0) { //去掉第一个逗号
|
|
||||||
ids = ids.substr(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
moduleIds = ids;
|
|
||||||
}
|
|
||||||
function zTreeOnClick(event, treeId, treeNode) {
|
|
||||||
var zTree = $.fn.zTree.getZTreeObj(treeId);
|
|
||||||
zTree.checkNode(treeNode, !treeNode.checked, true, true);
|
|
||||||
event.preventDefault();
|
|
||||||
}
|
|
||||||
|
|
||||||
//@@ sourceURL=lookupMultiForRole.js
|
|
||||||
</script>
|
|
||||||
@@ -1,123 +0,0 @@
|
|||||||
@*
|
|
||||||
选择多个模块ID,以ids的形式返回
|
|
||||||
*@
|
|
||||||
|
|
||||||
@{
|
|
||||||
ViewBag.Title = "title";
|
|
||||||
Layout = null;
|
|
||||||
}
|
|
||||||
<div class="bjui-pageContent">
|
|
||||||
<input style="display: none" id="userId" value="@ViewBag.UserId"/>
|
|
||||||
<div style="float: left; width: 220px; height: 240px; overflow: auto;" class="table table-bordered">
|
|
||||||
<ul id="lookupTree" class="ztree"></ul>
|
|
||||||
</div>
|
|
||||||
<!--已经选中的列表-->
|
|
||||||
<div style="margin-left: 225px">
|
|
||||||
<ul id="selected" class="ztree"></ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="bjui-pageFooter">
|
|
||||||
<ul>
|
|
||||||
<li><button type="button" class="btn-close" data-icon="close">关闭</button></li>
|
|
||||||
<li><button type="button" onclick="save()" class="btn btn-blue" data-icon="check">保存</button></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
|
||||||
var moduleIds;
|
|
||||||
$(document).ready(function () {
|
|
||||||
Init();
|
|
||||||
InitSelected();
|
|
||||||
});
|
|
||||||
function Init() {
|
|
||||||
var setting = {
|
|
||||||
view: {
|
|
||||||
selectedMulti: false
|
|
||||||
},
|
|
||||||
check: {
|
|
||||||
enable: true,
|
|
||||||
chkStyle: "checkbox"
|
|
||||||
},
|
|
||||||
data: {
|
|
||||||
key: {
|
|
||||||
name: 'Name',
|
|
||||||
title: 'Name'
|
|
||||||
},
|
|
||||||
simpleData: {
|
|
||||||
enable: true,
|
|
||||||
idKey: 'Id',
|
|
||||||
pIdKey: 'ParentId',
|
|
||||||
rootPId: 'null'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
callback: {
|
|
||||||
onClick: zTreeOnClick,
|
|
||||||
onCheck: zTreeCheck
|
|
||||||
}
|
|
||||||
};
|
|
||||||
$.getJSON('/OrgManager/LoadForTree', function (json) {
|
|
||||||
var zTreeObj = $.fn.zTree.init($('#lookupTree'), setting, json);
|
|
||||||
zTreeObj.expandAll(true);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function InitSelected() {
|
|
||||||
var setting = {
|
|
||||||
|
|
||||||
data: {
|
|
||||||
key: {
|
|
||||||
name: 'Name',
|
|
||||||
title: 'Name'
|
|
||||||
},
|
|
||||||
simpleData: {
|
|
||||||
enable: true,
|
|
||||||
idKey: 'Id',
|
|
||||||
pIdKey: 'ParentId',
|
|
||||||
rootPId: 'null'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
callback: {
|
|
||||||
onClick: zTreeOnClick,
|
|
||||||
onCheck: zTreeCheck
|
|
||||||
}
|
|
||||||
};
|
|
||||||
$.post('/OrgManager/LoadForUser', { userId: $('#userId').val() },
|
|
||||||
function (json) {
|
|
||||||
var zTreeObj = $.fn.zTree.init($('#selected'), setting, eval(json));
|
|
||||||
zTreeObj.expandAll(true);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function save() {
|
|
||||||
$.post('/OrgManager/AssignOrgForUser', { userId: $('#userId').val(), moduleIds: moduleIds },
|
|
||||||
function (json) {
|
|
||||||
var rel = $.parseJSON(json);
|
|
||||||
if (rel.statusCode == "200") {
|
|
||||||
$(this).alertmsg('ok', rel.message);
|
|
||||||
} else {
|
|
||||||
$(this).alertmsg('error', rel.message);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function zTreeCheck(e, treeId, treeNode) {
|
|
||||||
var zTree = $.fn.zTree.getZTreeObj(treeId),
|
|
||||||
nodes = zTree.getCheckedNodes(true);
|
|
||||||
var ids = '';
|
|
||||||
for (var i = 0; i < nodes.length; i++) {
|
|
||||||
ids += ',' + nodes[i].Id;
|
|
||||||
}
|
|
||||||
if (ids.length > 0) { //去掉第一个逗号
|
|
||||||
ids = ids.substr(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
moduleIds = ids;
|
|
||||||
}
|
|
||||||
function zTreeOnClick(event, treeId, treeNode) {
|
|
||||||
var zTree = $.fn.zTree.getZTreeObj(treeId);
|
|
||||||
zTree.checkNode(treeNode, !treeNode.checked, true, true);
|
|
||||||
event.preventDefault();
|
|
||||||
}
|
|
||||||
|
|
||||||
//@@ sourceURL=lookupMulti.js
|
|
||||||
</script>
|
|
||||||
Reference in New Issue
Block a user