mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-09-19 01:58:01 +08:00
修复部分BUG,完成为角色分配菜单的界面
This commit is contained in:
@@ -13,10 +13,12 @@
|
||||
// ***********************************************************************
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Entity.Validation;
|
||||
using System.Web.Mvc;
|
||||
using Infrastructure;
|
||||
using OpenAuth.App;
|
||||
using OpenAuth.App.ViewModel;
|
||||
using OpenAuth.Domain;
|
||||
using OpenAuth.Mvc.Models;
|
||||
|
||||
@@ -68,5 +70,19 @@ namespace OpenAuth.Mvc.Controllers
|
||||
}
|
||||
return JsonHelper.Instance.Serialize(_bjuiResponse);
|
||||
}
|
||||
|
||||
#region 为角色分配菜单
|
||||
|
||||
public ActionResult AssignForRole(int roleId)
|
||||
{
|
||||
ViewBag.RoleId = roleId;
|
||||
return View();
|
||||
}
|
||||
|
||||
public string Load(int roleId, int orgId)
|
||||
{
|
||||
return JsonHelper.Instance.Serialize(_app.LoadWithAccess("RoleElement", roleId, orgId));
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -625,6 +625,7 @@
|
||||
<Content Include="Views\ModuleManager\LookupMultiForRole.cshtml" />
|
||||
<None Include="Views\Home\MenuHeader.cshtml" />
|
||||
<None Include="Views\ModuleElementManager\Index.cshtml" />
|
||||
<Content Include="Views\ModuleElementManager\AssignForRole.cshtml" />
|
||||
<None Include="Views\OrgManager\AddOrg.cshtml" />
|
||||
<Content Include="Views\OrgManager\LookupParent.cshtml" />
|
||||
<Content Include="Views\UserManager\Index.cshtml" />
|
||||
|
132
OpenAuth.Mvc/Views/ModuleElementManager/AssignForRole.cshtml
Normal file
132
OpenAuth.Mvc/Views/ModuleElementManager/AssignForRole.cshtml
Normal file
@@ -0,0 +1,132 @@
|
||||
@{
|
||||
string _prefix = "assignForRole";
|
||||
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" data-toggle="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 gridid = '#@_gridId';
|
||||
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: '元素名称',
|
||||
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/Load?orgId=' + 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('ModuleManager/LoadForTree', function (json) {
|
||||
var zTreeObj = $.fn.zTree.init($('#@_treeId'), setting, json);
|
||||
zTreeObj.expandAll(true);
|
||||
});
|
||||
}
|
||||
|
||||
//授权选中的
|
||||
function assign() {
|
||||
var selected = getSelected(gridid, 2);
|
||||
if (selected == null) return;
|
||||
|
||||
$(this).dialog({
|
||||
id: 'assign',
|
||||
url: '/ModuleManager/Add?id=' + selected,
|
||||
title: '编辑',
|
||||
onClose: function () {
|
||||
refreshGrid();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function refreshGrid() {
|
||||
$('#@_gridId').datagrid('refresh');
|
||||
// loadDataGrid();
|
||||
}
|
||||
//@@ sourceURL=ModuleManagerIndex.js
|
||||
</script>
|
@@ -170,5 +170,19 @@
|
||||
});
|
||||
}
|
||||
|
||||
//为角色分配菜单
|
||||
function openAssignElement(obj) {
|
||||
var selected = getSelected(gridid, 2);
|
||||
if (selected == null) return;
|
||||
|
||||
$(obj).dialog({
|
||||
id: 'assignElement',
|
||||
url: '/ModuleElementManager/AssignForRole?roleId=' + selected,
|
||||
title: '为角色分配菜单',
|
||||
width: 700,
|
||||
height:380
|
||||
});
|
||||
}
|
||||
|
||||
//@@ sourceURL=RoleManagerIndex.js
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user