mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-07-18 13:26:55 +08:00
完成资源授权,元旦节正式发布1.0版,敬请期待!
This commit is contained in:
parent
f853bd13b7
commit
935f5e5cc1
@ -68,20 +68,7 @@ namespace OpenAuth.App
|
|||||||
public List<ModuleElementVM> LoadWithAccess(string accessType, int firstId, int moduleId)
|
public List<ModuleElementVM> LoadWithAccess(string accessType, int firstId, int moduleId)
|
||||||
{
|
{
|
||||||
//TODO:多个Repository使用的是不同的Context不能进行联表查询,要用UnitOfWork处理
|
//TODO:多个Repository使用的是不同的Context不能进行联表查询,要用UnitOfWork处理
|
||||||
//var results = from element in _repository.Find(u => u.ModuleId == moduleId)
|
|
||||||
// join module in _moduleRepository.Find(null) on element.ModuleId equals module.Id
|
|
||||||
// join relev in _relevanceRepository.Find(u => u.Key == accessType && u.FirstId == firstId)
|
|
||||||
// on element.Id equals relev.SecondId into temp
|
|
||||||
// from t in temp.DefaultIfEmpty()
|
|
||||||
// select new ModuleElementVM
|
|
||||||
// {
|
|
||||||
// DomId = element.DomId,
|
|
||||||
// Id = element.Id,
|
|
||||||
// ModuleId = element.ModuleId,
|
|
||||||
// ModuleName = module.Name,
|
|
||||||
// Name = element.Name,
|
|
||||||
// Accessed = t != null
|
|
||||||
// };
|
|
||||||
var listVms = new List<ModuleElementVM>();
|
var listVms = new List<ModuleElementVM>();
|
||||||
if (moduleId == 0) return listVms;
|
if (moduleId == 0) return listVms;
|
||||||
string modulename = _moduleRepository.FindSingle(u => u.Id == moduleId).Name;
|
string modulename = _moduleRepository.FindSingle(u => u.Id == moduleId).Name;
|
||||||
|
@ -55,6 +55,7 @@
|
|||||||
<Compile Include="ViewModel\LoginUserVM.cs" />
|
<Compile Include="ViewModel\LoginUserVM.cs" />
|
||||||
<Compile Include="ViewModel\ModuleElementVM.cs" />
|
<Compile Include="ViewModel\ModuleElementVM.cs" />
|
||||||
<Compile Include="ViewModel\ModuleView.cs" />
|
<Compile Include="ViewModel\ModuleView.cs" />
|
||||||
|
<Compile Include="ViewModel\ResourceVM.cs" />
|
||||||
<Compile Include="ViewModel\RoleVM.cs" />
|
<Compile Include="ViewModel\RoleVM.cs" />
|
||||||
<Compile Include="ViewModel\UserView.cs" />
|
<Compile Include="ViewModel\UserView.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -5,6 +5,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Infrastructure;
|
using Infrastructure;
|
||||||
|
using OpenAuth.App.ViewModel;
|
||||||
|
|
||||||
namespace OpenAuth.App
|
namespace OpenAuth.App
|
||||||
{
|
{
|
||||||
@ -12,12 +13,15 @@ namespace OpenAuth.App
|
|||||||
{
|
{
|
||||||
private IResourceRepository _repository;
|
private IResourceRepository _repository;
|
||||||
private readonly ICategoryRepository _categoryRepository;
|
private readonly ICategoryRepository _categoryRepository;
|
||||||
|
private IRelevanceRepository _relevanceRepository;
|
||||||
|
|
||||||
public ResourceManagerApp(IResourceRepository repository,
|
public ResourceManagerApp(IResourceRepository repository,
|
||||||
ICategoryRepository categoryRepository)
|
ICategoryRepository categoryRepository,
|
||||||
|
IRelevanceRepository relevanceRepository)
|
||||||
{
|
{
|
||||||
_repository = repository;
|
_repository = repository;
|
||||||
_categoryRepository = categoryRepository;
|
_categoryRepository = categoryRepository;
|
||||||
|
_relevanceRepository = relevanceRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetResourceCntInOrg(int orgId)
|
public int GetResourceCntInOrg(int orgId)
|
||||||
@ -102,6 +106,57 @@ namespace OpenAuth.App
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取带有授权状态的菜单列表
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="accessType">授权类型,当前有RoleResource/UserResource</param>
|
||||||
|
/// <param name="firstId">
|
||||||
|
/// 当为RoleResource时,表示RoleId
|
||||||
|
/// 当为UserResource时,表示UserId
|
||||||
|
/// </param>
|
||||||
|
/// <param name="cId">分类ID</param>
|
||||||
|
public List<ResourceVM> LoadWithAccess(string accessType, int firstId, int cId)
|
||||||
|
{
|
||||||
|
var listVms = new List<ResourceVM>();
|
||||||
|
if (cId == 0) return listVms;
|
||||||
|
|
||||||
|
foreach (var element in _repository.LoadInOrgs(cId))
|
||||||
|
{
|
||||||
|
var accessed = _relevanceRepository.FindSingle(u => u.Key == accessType
|
||||||
|
&& u.FirstId == firstId && u.SecondId == element.Id);
|
||||||
|
listVms.Add(new ResourceVM
|
||||||
|
{
|
||||||
|
Id = element.Id,
|
||||||
|
Name = element.Name,
|
||||||
|
IsBelongUser = accessed != null,
|
||||||
|
Description = element.Description,
|
||||||
|
Key = element.Key,
|
||||||
|
Status = element.Status
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return listVms;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 为用户分配资源
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userId">用户ID</param>
|
||||||
|
/// <param name="resIds">资源ID数组</param>
|
||||||
|
public void AssignResForUser(int userId, int[] resIds)
|
||||||
|
{
|
||||||
|
_relevanceRepository.DeleteBy("UserResource", resIds);
|
||||||
|
_relevanceRepository.AddRelevance("UserResource", resIds.ToLookup(u => userId));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 为角色分配资源
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="roleId">角色ID</param>
|
||||||
|
/// <param name="resIds">资源ID数组</param>
|
||||||
|
public void AssignResForRole(int roleId, int[] resIds)
|
||||||
|
{
|
||||||
|
_relevanceRepository.DeleteBy("RoleResource", resIds);
|
||||||
|
_relevanceRepository.AddRelevance("RoleResource", resIds.ToLookup(u => roleId));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
39
OpenAuth.App/ViewModel/ResourceVM.cs
Normal file
39
OpenAuth.App/ViewModel/ResourceVM.cs
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
namespace OpenAuth.App.ViewModel
|
||||||
|
{
|
||||||
|
public class ResourceVM
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 资源表ID
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string Key { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 组织名称
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源分类标识
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public int Status { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 描述
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string Description { get; set; }
|
||||||
|
|
||||||
|
public bool IsBelongUser { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -32,11 +32,6 @@ namespace OpenAuth.Mvc.Controllers
|
|||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ActionResult LookupMulti()
|
|
||||||
{
|
|
||||||
return View();
|
|
||||||
}
|
|
||||||
|
|
||||||
public ActionResult AddOrg()
|
public ActionResult AddOrg()
|
||||||
{
|
{
|
||||||
return View();
|
return View();
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
|
|
||||||
using System;
|
|
||||||
using System.Web.Mvc;
|
|
||||||
using Infrastructure;
|
using Infrastructure;
|
||||||
using OpenAuth.App;
|
using OpenAuth.App;
|
||||||
using OpenAuth.Domain;
|
using OpenAuth.Domain;
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Web.Mvc;
|
||||||
|
|
||||||
namespace OpenAuth.Mvc.Controllers
|
namespace OpenAuth.Mvc.Controllers
|
||||||
{
|
{
|
||||||
public class ResourceManagerController : BaseController
|
public class ResourceManagerController : BaseController
|
||||||
{
|
{
|
||||||
private ResourceManagerApp _app;
|
private ResourceManagerApp _app;
|
||||||
|
|
||||||
@ -35,7 +35,6 @@ namespace OpenAuth.Mvc.Controllers
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
_app.AddOrUpdate(model);
|
_app.AddOrUpdate(model);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -53,19 +52,19 @@ namespace OpenAuth.Mvc.Controllers
|
|||||||
return JsonHelper.Instance.Serialize(_app.Load(categoryId, pageCurrent, pageSize));
|
return JsonHelper.Instance.Serialize(_app.Load(categoryId, pageCurrent, pageSize));
|
||||||
}
|
}
|
||||||
|
|
||||||
public string LoadForTree()
|
public string LoadForTree()
|
||||||
{
|
{
|
||||||
var models = _app.LoadAll();
|
var models = _app.LoadAll();
|
||||||
//添加根节点
|
//添加根节点
|
||||||
models.Add(new Resource
|
models.Add(new Resource
|
||||||
{
|
{
|
||||||
Id = 0,
|
Id = 0,
|
||||||
ParentId = -1,
|
ParentId = -1,
|
||||||
Name = "根结点",
|
Name = "根结点",
|
||||||
CascadeId = "0"
|
CascadeId = "0"
|
||||||
});
|
});
|
||||||
return JsonHelper.Instance.Serialize(models);
|
return JsonHelper.Instance.Serialize(models);
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Delete(int Id)
|
public string Delete(int Id)
|
||||||
{
|
{
|
||||||
@ -82,6 +81,63 @@ namespace OpenAuth.Mvc.Controllers
|
|||||||
return JsonHelper.Instance.Serialize(BjuiResponse);
|
return JsonHelper.Instance.Serialize(BjuiResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region 为用户分配资源
|
||||||
|
|
||||||
|
public ActionResult LookupMultiForUser(int userId)
|
||||||
|
{
|
||||||
|
ViewBag.UserId = userId;
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
public string LoadWithUserAccess(int cId, int userId)
|
||||||
|
{
|
||||||
|
return JsonHelper.Instance.Serialize(_app.LoadWithAccess("UserResource",userId, cId));
|
||||||
|
}
|
||||||
|
|
||||||
|
public string AccessForUser(int userId, string ids)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var resIds = ids.Split(',').Select(id => int.Parse(id)).ToArray();
|
||||||
|
_app.AssignResForUser(userId, resIds);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
BjuiResponse.message = e.Message;
|
||||||
|
BjuiResponse.statusCode = "300";
|
||||||
|
}
|
||||||
|
|
||||||
|
return JsonHelper.Instance.Serialize(BjuiResponse);
|
||||||
|
}
|
||||||
|
#endregion 为用户分配资源
|
||||||
|
|
||||||
|
#region 为角色分配资源
|
||||||
|
public ActionResult LookupMultiForRole(int roleId)
|
||||||
|
{
|
||||||
|
ViewBag.RoleId = roleId;
|
||||||
|
return View();
|
||||||
|
}
|
||||||
|
|
||||||
|
public string LoadWithRoleAccess(int cId, int roleId)
|
||||||
|
{
|
||||||
|
return JsonHelper.Instance.Serialize(_app.LoadWithAccess("RoleResource", roleId, cId));
|
||||||
|
}
|
||||||
|
|
||||||
|
public string AccessForRole(int roleId, string ids)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var resIds = ids.Split(',').Select(id => int.Parse(id)).ToArray();
|
||||||
|
_app.AssignResForRole(roleId, resIds);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
BjuiResponse.message = e.Message;
|
||||||
|
BjuiResponse.statusCode = "300";
|
||||||
|
}
|
||||||
|
|
||||||
|
return JsonHelper.Instance.Serialize(BjuiResponse);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -575,6 +575,8 @@
|
|||||||
<Content Include="Views\ResourceManager\Add.cshtml" />
|
<Content Include="Views\ResourceManager\Add.cshtml" />
|
||||||
<Content Include="Views\ResourceManager\Index.cshtml" />
|
<Content Include="Views\ResourceManager\Index.cshtml" />
|
||||||
<Content Include="Views\RoleManager\LookupMulti.cshtml" />
|
<Content Include="Views\RoleManager\LookupMulti.cshtml" />
|
||||||
|
<Content Include="Views\ResourceManager\LookupMultiForUser.cshtml" />
|
||||||
|
<Content Include="Views\ResourceManager\LookupMultiForRole.cshtml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="App_Data\" />
|
<Folder Include="App_Data\" />
|
||||||
|
126
OpenAuth.Mvc/Views/ResourceManager/LookupMultiForRole.cshtml
Normal file
126
OpenAuth.Mvc/Views/ResourceManager/LookupMultiForRole.cshtml
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
@{
|
||||||
|
string _prefix = "assignResForRole";
|
||||||
|
var _treeId = _prefix + "Tree";
|
||||||
|
var _gridId = _prefix + "Grid";
|
||||||
|
var _treeDetail = _prefix + "Detail";
|
||||||
|
}
|
||||||
|
<div class="bjui-pageHeader">
|
||||||
|
<div class="bjui-searchBar">
|
||||||
|
<input style="display: none" id="roleId" value="@ViewBag.RoleId" />
|
||||||
|
<div class="pull-right">
|
||||||
|
<div class="alert alert-info search-inline">
|
||||||
|
<i class="fa fa-info-circle"></i> 点击行为单选,点击复选框可多选统一授权
|
||||||
|
</div>
|
||||||
|
<button type="button" class="btn-green" data-num="1" data-icon="plus" onclick="assign()">
|
||||||
|
授权选中项目
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="bjui-pageContent tableContent">
|
||||||
|
<div class="clearfix">
|
||||||
|
<div style="float: left; width: 220px; overflow: auto;" class="table table-bordered">
|
||||||
|
<ul id="@_treeId" class="ztree"></ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="@_treeDetail" style="margin-left: 225px;">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
var selectedId = 0;
|
||||||
|
$(document).ready(function () {
|
||||||
|
initZtree();
|
||||||
|
loadDataGrid();
|
||||||
|
});
|
||||||
|
//加载数据到datagrid
|
||||||
|
function loadDataGrid() {
|
||||||
|
//b-jui的datagrid需要重新处理HTML
|
||||||
|
$('#@_treeDetail').empty()
|
||||||
|
.append('<table id="@_gridId" class="table table-bordered table-hover table-striped table-top"></table>');
|
||||||
|
|
||||||
|
$('#@_gridId').datagrid({
|
||||||
|
showToolbar: false,
|
||||||
|
filterThead: false,
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
name: 'Id',
|
||||||
|
label: '角色ID',
|
||||||
|
hide: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Name',
|
||||||
|
label: '角色名称',
|
||||||
|
width: 100
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
name: 'IsBelongUser',
|
||||||
|
label: '是否已经授权',
|
||||||
|
type: 'select',
|
||||||
|
align: 'center',
|
||||||
|
items: [{ 'false': '未授权', 'true': '已授权' }],
|
||||||
|
width: 100
|
||||||
|
}
|
||||||
|
],
|
||||||
|
dataUrl: 'ResourceManager/LoadWithRoleAccess?cId=' + selectedId + '&roleId=' + $('#roleId').val(),
|
||||||
|
fullGrid: true,
|
||||||
|
showLinenumber: true,
|
||||||
|
showCheckboxcol: true,
|
||||||
|
paging: true,
|
||||||
|
filterMult: false,
|
||||||
|
showTfoot: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function zTreeOnClick(event, treeId, treeNode) {
|
||||||
|
selectedId = treeNode.Id;
|
||||||
|
loadDataGrid();
|
||||||
|
}
|
||||||
|
|
||||||
|
function initZtree() {
|
||||||
|
var setting = {
|
||||||
|
view: { selectedMulti: false },
|
||||||
|
data: {
|
||||||
|
key: {
|
||||||
|
name: 'Name',
|
||||||
|
title: 'Name'
|
||||||
|
},
|
||||||
|
simpleData: {
|
||||||
|
enable: true,
|
||||||
|
idKey: 'Id',
|
||||||
|
pIdKey: 'ParentId',
|
||||||
|
rootPId: 'null'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
callback: { onClick: zTreeOnClick }
|
||||||
|
};
|
||||||
|
$.getJSON('CategoryManager/LoadForTree', function (json) {
|
||||||
|
var zTreeObj = $.fn.zTree.init($('#@_treeId'), setting, json);
|
||||||
|
zTreeObj.expandAll(true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//授权选中的
|
||||||
|
function assign() {
|
||||||
|
var selected = getSelectedMany('#@_gridId', 2);
|
||||||
|
if (selected == null) return;
|
||||||
|
|
||||||
|
$.post('ResourceManager/AccessForRole', {
|
||||||
|
roleId: $('#roleId').val(),
|
||||||
|
ids: selected
|
||||||
|
},
|
||||||
|
function (json) {
|
||||||
|
// var rel = $.parseJSON(json);
|
||||||
|
refreshGrid();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function refreshGrid() {
|
||||||
|
$('#@_gridId').datagrid('refresh');
|
||||||
|
// loadDataGrid();
|
||||||
|
}
|
||||||
|
//@@ sourceURL=RoleLookup.js
|
||||||
|
</script>
|
126
OpenAuth.Mvc/Views/ResourceManager/LookupMultiForUser.cshtml
Normal file
126
OpenAuth.Mvc/Views/ResourceManager/LookupMultiForUser.cshtml
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
@{
|
||||||
|
string _prefix = "assignResForUser";
|
||||||
|
var _treeId = _prefix + "Tree";
|
||||||
|
var _gridId = _prefix + "Grid";
|
||||||
|
var _treeDetail = _prefix + "Detail";
|
||||||
|
}
|
||||||
|
<div class="bjui-pageHeader">
|
||||||
|
<div class="bjui-searchBar">
|
||||||
|
<input style="display: none" id="userId" value="@ViewBag.UserId" />
|
||||||
|
<div class="pull-right">
|
||||||
|
<div class="alert alert-info search-inline">
|
||||||
|
<i class="fa fa-info-circle"></i> 点击行为单选,点击复选框可多选统一授权
|
||||||
|
</div>
|
||||||
|
<button type="button" class="btn-green" data-num="1" data-icon="plus" onclick="assign()">
|
||||||
|
授权选中项目
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="bjui-pageContent tableContent">
|
||||||
|
<div class="clearfix">
|
||||||
|
<div style="float: left; width: 220px; overflow: auto;" class="table table-bordered">
|
||||||
|
<ul id="@_treeId" class="ztree"></ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="@_treeDetail" style="margin-left: 225px;">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
var selectedId = 0;
|
||||||
|
$(document).ready(function () {
|
||||||
|
initZtree();
|
||||||
|
loadDataGrid();
|
||||||
|
});
|
||||||
|
//加载数据到datagrid
|
||||||
|
function loadDataGrid() {
|
||||||
|
//b-jui的datagrid需要重新处理HTML
|
||||||
|
$('#@_treeDetail').empty()
|
||||||
|
.append('<table id="@_gridId" class="table table-bordered table-hover table-striped table-top"></table>');
|
||||||
|
|
||||||
|
$('#@_gridId').datagrid({
|
||||||
|
showToolbar: false,
|
||||||
|
filterThead: false,
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
name: 'Id',
|
||||||
|
label: '角色ID',
|
||||||
|
hide: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Name',
|
||||||
|
label: '角色名称',
|
||||||
|
width: 100
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
name: 'IsBelongUser',
|
||||||
|
label: '是否已经授权',
|
||||||
|
type: 'select',
|
||||||
|
align: 'center',
|
||||||
|
items: [{ 'false': '未授权', 'true': '已授权' }],
|
||||||
|
width: 100
|
||||||
|
}
|
||||||
|
],
|
||||||
|
dataUrl: 'ResourceManager/LoadWithUserAccess?cId=' + selectedId + '&userId=' + $('#userId').val(),
|
||||||
|
fullGrid: true,
|
||||||
|
showLinenumber: true,
|
||||||
|
showCheckboxcol: true,
|
||||||
|
paging: true,
|
||||||
|
filterMult: false,
|
||||||
|
showTfoot: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function zTreeOnClick(event, treeId, treeNode) {
|
||||||
|
selectedId = treeNode.Id;
|
||||||
|
loadDataGrid();
|
||||||
|
}
|
||||||
|
|
||||||
|
function initZtree() {
|
||||||
|
var setting = {
|
||||||
|
view: { selectedMulti: false },
|
||||||
|
data: {
|
||||||
|
key: {
|
||||||
|
name: 'Name',
|
||||||
|
title: 'Name'
|
||||||
|
},
|
||||||
|
simpleData: {
|
||||||
|
enable: true,
|
||||||
|
idKey: 'Id',
|
||||||
|
pIdKey: 'ParentId',
|
||||||
|
rootPId: 'null'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
callback: { onClick: zTreeOnClick }
|
||||||
|
};
|
||||||
|
$.getJSON('CategoryManager/LoadForTree', function (json) {
|
||||||
|
var zTreeObj = $.fn.zTree.init($('#@_treeId'), setting, json);
|
||||||
|
zTreeObj.expandAll(true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//授权选中的
|
||||||
|
function assign() {
|
||||||
|
var selected = getSelectedMany('#@_gridId', 2);
|
||||||
|
if (selected == null) return;
|
||||||
|
|
||||||
|
$.post('ResourceManager/AccessForUser', {
|
||||||
|
userId: $('#userId').val(),
|
||||||
|
ids: selected
|
||||||
|
},
|
||||||
|
function (json) {
|
||||||
|
// var rel = $.parseJSON(json);
|
||||||
|
refreshGrid();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function refreshGrid() {
|
||||||
|
$('#@_gridId').datagrid('refresh');
|
||||||
|
// loadDataGrid();
|
||||||
|
}
|
||||||
|
//@@ sourceURL=RoleLookup.js
|
||||||
|
</script>
|
@ -169,6 +169,23 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//为角色分配资源
|
||||||
|
function openRoleReourceAccess(obj) {
|
||||||
|
var selected = getSelected('#@_gridId', 2);
|
||||||
|
if (selected == null) return;
|
||||||
|
|
||||||
|
$(obj).dialog({
|
||||||
|
id: 'accessUserRole',
|
||||||
|
url: '/ResourceManager/LookupMultiForRole',
|
||||||
|
title: '为角色分配资源',
|
||||||
|
width: 600,
|
||||||
|
height: 380,
|
||||||
|
data: {
|
||||||
|
roleId: selected
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
//为角色分配菜单
|
//为角色分配菜单
|
||||||
function assignRoleElement(obj) {
|
function assignRoleElement(obj) {
|
||||||
var selected = getSelected('#@_gridId', 2);
|
var selected = getSelected('#@_gridId', 2);
|
||||||
|
@ -190,6 +190,23 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//为用户分配资源
|
||||||
|
function openUserReourceAccess(obj) {
|
||||||
|
var selected = getSelected('#@_gridId', 2);
|
||||||
|
if (selected == null) return;
|
||||||
|
|
||||||
|
$(obj).dialog({
|
||||||
|
id: 'accessUserRole',
|
||||||
|
url: '/ResourceManager/LookupMultiForUser',
|
||||||
|
title: '为用户分配资源',
|
||||||
|
width: 600,
|
||||||
|
height: 380,
|
||||||
|
data: {
|
||||||
|
userId: selected
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
//分配菜单
|
//分配菜单
|
||||||
function openAssignUserElement(obj) {
|
function openAssignUserElement(obj) {
|
||||||
var selected = getSelected('#@_gridId', 2);
|
var selected = getSelected('#@_gridId', 2);
|
||||||
|
BIN
建表&初始化数据.sql
BIN
建表&初始化数据.sql
Binary file not shown.
Loading…
Reference in New Issue
Block a user