OpenAuth.Net/OpenAuth.Mvc/Views/RoleManager/Index.cshtml
2016-01-05 10:03:35 +08:00

205 lines
5.8 KiB
Plaintext

@{
string _prefix = "Role";
var _treeId = _prefix + "Tree";
var _gridId = _prefix + "Grid";
var _treeDetail = _prefix + "Detail";
}
@{ Html.RenderAction("MenuHeader", "Home");}
<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: '流水号'
, hide: true
},
{
name: 'Name',
label: '角色名称',
width:100
},
{
name: 'Status',
label: '当前状态',
type: 'select',
align: 'center',
items:[{'0':'正常','1':'禁用'}],
width:50
},
{
name: 'Type',
label: '角色类型',
type: 'select',
align: 'center',
items: [{ '0': '管理员','1':'普通角色' }],
width:50
},
{
name: 'CreateTime',
label: '创建时间'
, type: 'date',
width: 150,
pattern: 'yyyy-MM-dd HH:mm:ss'
},
{
name: 'OrgCascadeId',
label: '所属部门节点语义ID',
width:100
},
{
name: 'OrgName',
label: '所属部门名称',
width:100
}
],
dataUrl: 'RoleManager/Load?orgId=' + selectedId,
fullGrid: true,
showLinenumber: true,
showCheckboxcol: true,
paging: true,
filterMult: false,
showTfoot: true,
height: '700'
});
}
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('OrgManager/LoadOrg', function (json) {
var zTreeObj = $.fn.zTree.init($('#@_treeId'), setting, json);
zTreeObj.expandAll(true);
});
}
//删除
function delRole() {
var selected = getSelected('#@_gridId', 2);
if (selected == null) return;
$.getJSON('RoleManager/Delete?Id=' + selected, function (data) {
if (data.statusCode == "200")
refreshRoleGrid();
else {
$(this).alertmsg('warn', data.message);
}
});
}
//自定义的编辑按钮
function editRole() {
var selected = getSelected('#@_gridId',2);
if (selected == null) return;
$(this).dialog({
id: 'editDialog',
url: '/RoleManager/Add?id=' + selected,
title: '编辑',
onClose:function() {
refreshRoleGrid();
}
});
}
function refreshRoleGrid() {
$('#@_gridId').datagrid('refresh');
// loadDataGrid();
}
//为角色分配模块
function assignRoleModule(obj) {
var selected = getSelected('#@_gridId',2);
if (selected == null) return;
$(obj).dialog({
id: 'accessRoleModule',
url: '/ModuleManager/LookupMultiForRole',
title: '为角色分配模块',
data: {
roleid: selected
}
});
}
//为角色分配资源
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) {
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>