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

224 lines
6.3 KiB
Plaintext

@{
string _prefix = "user";
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;
var grid;
$(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',
attrs: { readonly: 'readonly' },
hide: true
},
{
name: 'Account',
label: '用户账号',
width: 142,
attrs: { readonly: 'readonly' }
},
{
name: 'Name',
label: '姓名/昵称',
width: 226
},
{
name: 'Organizations',
label: '所属机构',
width: 150
},
{
name: 'Status',
label: '状态',
type: 'select',
align: 'center',
width: 80,
items: [{ '0': '正常' }, { '1': '禁用' }]
},
{
name: 'Sex',
label: '性别',
type: 'select',
align: 'center',
width: 80,
items: [{ '0': '男' }, { '1': '女' }]
},
{
name: 'CreateTime',
label: '登记日期',
type: 'date',
width: 180,
pattern: 'yyyy-MM-dd HH:mm:ss'
}
],
dataUrl: 'UserManager/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 delUser() {
var selected = getSelected('#@_gridId', 2);
if (selected == null) return;
$.getJSON('UserManager/Delete?Id=' + selected, function (data) {
if (data.statusCode == "200")
refreshGrid();
else {
$(this).alertmsg('warn', data.message);
}
});
}
//自定义的编辑按钮
function editUser() {
var selected = getSelected('#@_gridId', 2);
if (selected == null) return;
$(this).dialog({
id: 'editDialog',
url: '/UserManager/Add?id=' + selected,
title: '编辑',
onClose: function () {
refreshUserGrid();
}
});
}
function refreshUserGrid() {
$('#@_gridId').datagrid('refresh');
}
//用户模块授权按钮
function openUserModuleAccess(obj) {
var selected = getSelected('#@_gridId', 2);
if (selected == null) return;
$(obj).dialog({
id: 'accessUserModule',
url: '/ModuleManager/LookupMultiForUser',
title: '为用户分配模块',
data: {
userId: selected
}
});
}
//用户角色授权
function openUserRoleAccess(obj) {
var selected = getSelected('#@_gridId', 2);
if (selected == null) return;
$(obj).dialog({
id: 'accessUserRole',
url: '/RoleManager/LookupMulti',
title: '为用户分配角色',
width: 600,
height: 380,
data: {
userId: selected
}
});
}
//为用户分配资源
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) {
var selected = getSelected('#@_gridId', 2);
if (selected == null) return;
$(obj).dialog({
id: 'assignElement',
url: '/ModuleElementManager/AssignForUser?userId=' + selected,
title: '为用户分配菜单',
width: 700,
height: 380
});
}
//@@ sourceURL=userManagerIndex.js
</script>