mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-07-15 14:04:41 +08:00
增加分配界面
This commit is contained in:
parent
4aaeb28912
commit
a54c005635
@ -23,22 +23,28 @@ namespace OpenAuth.Mvc.Controllers
|
||||
return View();
|
||||
}
|
||||
|
||||
public ActionResult Assign(string firstId, string key)
|
||||
[Authenticate]
|
||||
public ActionResult Assign()
|
||||
{
|
||||
ViewBag.FirstId = firstId;
|
||||
ViewBag.ModuleType = key;
|
||||
|
||||
var moduleWithChildren = AuthUtil.GetCurrentUser().Modules
|
||||
.GenerateTree(u =>u.Id, u =>u.ParentId);
|
||||
var modules = key == Define.USERMODULE ? App.LoadForUser(firstId) : App.LoadForRole(firstId);
|
||||
|
||||
CheckModule(moduleWithChildren, modules);
|
||||
|
||||
ViewBag.Modules = BuilderModules(moduleWithChildren);
|
||||
|
||||
return View();
|
||||
}
|
||||
|
||||
//public ActionResult Assign(string firstId, string key)
|
||||
//{
|
||||
// ViewBag.FirstId = firstId;
|
||||
// ViewBag.ModuleType = key;
|
||||
|
||||
// var moduleWithChildren = AuthUtil.GetCurrentUser().Modules
|
||||
// .GenerateTree(u =>u.Id, u =>u.ParentId);
|
||||
// var modules = key == Define.USERMODULE ? App.LoadForUser(firstId) : App.LoadForRole(firstId);
|
||||
|
||||
// CheckModule(moduleWithChildren, modules);
|
||||
|
||||
// ViewBag.Modules = BuilderModules(moduleWithChildren);
|
||||
|
||||
// return View();
|
||||
//}
|
||||
|
||||
private void CheckModule(IEnumerable<TreeItem<ModuleView>> moduleWithChildren, List<Module> modules)
|
||||
{
|
||||
foreach (var module in moduleWithChildren)
|
||||
|
@ -166,6 +166,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="js\categories.js" />
|
||||
<Content Include="js\assign.js" />
|
||||
<Content Include="js\openauth.js" />
|
||||
<Content Include="js\droptree.js" />
|
||||
<Content Include="css\images.css" />
|
||||
@ -349,6 +350,7 @@
|
||||
<Content Include="Views\Shared\_Layout.cshtml" />
|
||||
<Content Include="Views\Home\MenuHeader.cshtml" />
|
||||
<Content Include="Views\Categories\Index.cshtml" />
|
||||
<Content Include="Views\ModuleManager\Assign.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Areas\FlowManage\Models\" />
|
||||
|
37
OpenAuth.Mvc/Views/ModuleManager/Assign.cshtml
Normal file
37
OpenAuth.Mvc/Views/ModuleManager/Assign.cshtml
Normal file
@ -0,0 +1,37 @@
|
||||
@section header
|
||||
{
|
||||
<link rel="stylesheet" href="/css/treetable.css" />
|
||||
}
|
||||
|
||||
<div style="display: flex;">
|
||||
<ul id="tree" class="ztree" style="display: inline-block; width: 180px; padding: 10px; border: 1px solid #ddd; overflow: auto;"></ul>
|
||||
<!--菜单列表-->
|
||||
<table class="layui-table"
|
||||
lay-data="{height: 'full-80', id:'menuList'}"
|
||||
lay-filter="menulist" lay-size="sm">
|
||||
<thead>
|
||||
<tr>
|
||||
<th lay-data="{field:'Name', width:120, sort: true, fixed: true}">名称</th>
|
||||
<th lay-data="{field:'DomId', width:80}">DomId</th>
|
||||
<th lay-data="{field:'Class', width:80}">样式</th>
|
||||
<th lay-data="{field:'Icon', width:60,templet: '#miconTpl'}">图标</th>
|
||||
<th lay-data="{field:'SortNo', width:80}">排序号</th>
|
||||
<th lay-data="{fixed: 'right', width:80, align:'center', toolbar: '#menuBar'}"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
<!--列表右边的按钮-->
|
||||
<script type="text/html" id="menuBar">
|
||||
<a class="layui-btn layui-btn-primary layui-btn-mini" lay-event="del">删除</a>
|
||||
</script>
|
||||
<script type="text/html" id="miconTpl">
|
||||
{{# if( d.Icon != null && d.Icon != ''){ }}
|
||||
<i class="layui-icon">{{ d.Icon }}</i>
|
||||
{{# } else { }}
|
||||
{{ d.Icon }}
|
||||
{{# } }}
|
||||
</script>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" src="/layui/layui.js"></script>
|
||||
<script type="text/javascript" src="/js/assign.js"></script>
|
71
OpenAuth.Mvc/js/assign.js
Normal file
71
OpenAuth.Mvc/js/assign.js
Normal file
@ -0,0 +1,71 @@
|
||||
layui.config({
|
||||
base: "/js/"
|
||||
}).use(['form','vue', 'ztree', 'layer', 'jquery', 'table','droptree','openauth'], function () {
|
||||
var form = layui.form,
|
||||
//layer = (parent == undefined || parent.layer === undefined )? layui.layer : parent.layer,
|
||||
layer = layui.layer,
|
||||
$ = layui.jquery;
|
||||
var table = layui.table;
|
||||
var openauth = layui.openauth;
|
||||
|
||||
//菜单列表
|
||||
var menucon = {}; //table的参数,如搜索key,点击tree的id
|
||||
var menuList = function (options) {
|
||||
if (options != undefined) {
|
||||
$.extend(menucon, options);
|
||||
}
|
||||
table.reload('menuList', {
|
||||
url: '/ModuleManager/LoadMenus',
|
||||
where: menucon
|
||||
});
|
||||
}
|
||||
|
||||
//左边树状机构列表
|
||||
var ztree = function () {
|
||||
var url = '/UserSession/QueryModuleList';
|
||||
var zTreeObj;
|
||||
var setting = {
|
||||
view: { selectedMulti: false },
|
||||
data: {
|
||||
key: {
|
||||
name: 'Name',
|
||||
title: 'Name'
|
||||
},
|
||||
simpleData: {
|
||||
enable: true,
|
||||
idKey: 'Id',
|
||||
pIdKey: 'ParentId',
|
||||
rootPId: 'null'
|
||||
}
|
||||
},
|
||||
callback: {
|
||||
onClick: function (event, treeId, treeNode) {
|
||||
menuList({ moduleId: treeNode.Id });
|
||||
}
|
||||
}
|
||||
};
|
||||
var load = function () {
|
||||
$.getJSON(url, function (json) {
|
||||
zTreeObj = $.fn.zTree.init($("#tree"), setting);
|
||||
zTreeObj.addNodes(null, json);
|
||||
menuList({ moduleId: json[0].Id });
|
||||
zTreeObj.expandAll(true);
|
||||
});
|
||||
};
|
||||
load();
|
||||
return {
|
||||
reload: load
|
||||
}
|
||||
}();
|
||||
|
||||
//监听菜单表格内部按钮
|
||||
table.on('tool(menulist)', function (obj) {
|
||||
var data = obj.data;
|
||||
if (obj.event === 'del') { //删除菜单
|
||||
openauth.del("/moduleManager/delMenu",
|
||||
data.Id,menuList);
|
||||
}
|
||||
});
|
||||
|
||||
//监听页面主按钮操作 end
|
||||
})
|
@ -47,8 +47,6 @@ layui.config({
|
||||
var load = function () {
|
||||
$.getJSON(url, function (json) {
|
||||
zTreeObj = $.fn.zTree.init($("#tree"), setting);
|
||||
var newNode = { Name: "根节点", Id: null, ParentId: "" };
|
||||
json.push(newNode);
|
||||
zTreeObj.addNodes(null, json);
|
||||
mainList({ typeId: "" });
|
||||
zTreeObj.expandAll(true);
|
||||
|
@ -149,7 +149,8 @@ layui.config({
|
||||
var index = layer.open({
|
||||
title: "为用户分配模块",
|
||||
type: 2,
|
||||
content: "newsAdd.html",
|
||||
area: ['800px', '500px'],
|
||||
content: "/ModuleManager/Assign",
|
||||
success: function(layero, index) {
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user