2015-11-13 21:33:53 +08:00
|
|
|
|
@{
|
|
|
|
|
string _prefix = "user";
|
|
|
|
|
var _treeId = _prefix + "Tree";
|
|
|
|
|
var _gridId = _prefix + "Grid";
|
|
|
|
|
var _treeDetail = _prefix + "Detail";
|
|
|
|
|
}
|
|
|
|
|
<div class="bjui-pageContent">
|
2015-11-08 23:19:04 +08:00
|
|
|
|
<div class="clearfix">
|
|
|
|
|
<div style="float: left; width: 220px; overflow: auto;" class="table table-bordered">
|
2015-11-13 21:33:53 +08:00
|
|
|
|
<ul id="@_treeId" class="ztree"></ul>
|
2015-11-08 23:19:04 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
2015-11-15 23:00:08 +08:00
|
|
|
|
<div id="@_treeDetail" style="margin-left: 225px;">
|
2015-11-08 23:19:04 +08:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2015-11-15 23:00:08 +08:00
|
|
|
|
|
2015-11-08 23:19:04 +08:00
|
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
2015-11-13 21:33:53 +08:00
|
|
|
|
var gridid = '#@_gridId';
|
2015-11-08 23:19:04 +08:00
|
|
|
|
var selectedId = 0;
|
2015-11-16 23:50:00 +08:00
|
|
|
|
var grid;
|
2015-11-08 23:19:04 +08:00
|
|
|
|
$(document).ready(function () {
|
2015-11-13 21:33:53 +08:00
|
|
|
|
initZtree();
|
|
|
|
|
loadDataGrid();
|
2015-11-08 23:19:04 +08:00
|
|
|
|
});
|
|
|
|
|
//加载数据到datagrid
|
2015-11-13 21:33:53 +08:00
|
|
|
|
function loadDataGrid() {
|
2015-11-08 23:19:04 +08:00
|
|
|
|
//b-jui的datagrid需要重新处理HTML
|
2015-11-13 21:33:53 +08:00
|
|
|
|
$('#@_treeDetail').empty()
|
2015-11-15 23:00:08 +08:00
|
|
|
|
.append('<table id="@_gridId" class="table table-bordered"></table>');
|
|
|
|
|
|
2015-11-16 23:50:00 +08:00
|
|
|
|
grid = $(gridid).datagrid({
|
2015-11-13 21:33:53 +08:00
|
|
|
|
gridTitle: '用户列表',
|
2015-11-08 23:19:04 +08:00
|
|
|
|
showToolbar: true,
|
2015-11-15 00:13:49 +08:00
|
|
|
|
filterThead: false,
|
|
|
|
|
toolbarItem: 'refresh, |, del',
|
2015-11-13 21:33:53 +08:00
|
|
|
|
toolbarCustom: '<a href="/UserManager/Add" class="btn btn-green" data-icon ="plus" ' +
|
2015-11-16 23:50:00 +08:00
|
|
|
|
'data-toggle="dialog" data-id="dialog-mask" data-mask="true" data-on-close="refreshGrid">添加</a>' +
|
2015-11-15 00:13:49 +08:00
|
|
|
|
'<button class=" btn-green" onclick="editOrg()" data-icon="pencil" type="button">编辑</button>',
|
2015-11-08 23:19:04 +08:00
|
|
|
|
columns: [
|
2015-11-13 21:33:53 +08:00
|
|
|
|
{
|
|
|
|
|
name: 'Id',
|
|
|
|
|
label: 'Id',
|
|
|
|
|
attrs: { readonly: 'readonly' },
|
|
|
|
|
hide: true
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'Account',
|
|
|
|
|
label: '用户账号',
|
2015-11-15 23:00:08 +08:00
|
|
|
|
width: 142,
|
|
|
|
|
attrs: { readonly: 'readonly' }
|
2015-11-13 21:33:53 +08:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'Name',
|
2015-11-15 23:00:08 +08:00
|
|
|
|
label: '姓名/昵称',
|
|
|
|
|
width: 226
|
2015-11-13 21:33:53 +08:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'Organizations',
|
2015-11-15 23:00:08 +08:00
|
|
|
|
label: '所属机构',
|
|
|
|
|
width: 150
|
2015-11-13 21:33:53 +08:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'Status',
|
|
|
|
|
label: '状态',
|
|
|
|
|
type: 'select',
|
|
|
|
|
align: 'center',
|
2015-11-15 23:00:08 +08:00
|
|
|
|
width: 80,
|
|
|
|
|
items: [{ '0': '正常' }, { '1': '禁用' }]
|
2015-11-13 21:33:53 +08:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'Sex',
|
|
|
|
|
label: '性别',
|
|
|
|
|
type: 'select',
|
|
|
|
|
align: 'center',
|
2015-11-15 23:00:08 +08:00
|
|
|
|
width: 80,
|
2015-11-13 21:33:53 +08:00
|
|
|
|
items: [{ '0': '男' }, { '1': '女' }]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'CreateTime',
|
|
|
|
|
label: '登记日期',
|
|
|
|
|
type: 'date',
|
2015-11-15 23:00:08 +08:00
|
|
|
|
width: 180,
|
2015-11-13 21:33:53 +08:00
|
|
|
|
pattern: 'yyyy-MM-dd HH:mm:ss'
|
|
|
|
|
}
|
2015-11-08 23:19:04 +08:00
|
|
|
|
],
|
2015-11-15 23:00:08 +08:00
|
|
|
|
// data: data,
|
|
|
|
|
dataUrl: 'UserManager/Load?orgId=' + selectedId,
|
2015-11-13 21:33:53 +08:00
|
|
|
|
delUrl: 'UserManager/Delete',
|
2015-11-08 23:19:04 +08:00
|
|
|
|
delPK: "Id",
|
|
|
|
|
fullGrid: true,
|
|
|
|
|
showLinenumber: true,
|
|
|
|
|
showCheckboxcol: true,
|
2015-11-15 23:00:08 +08:00
|
|
|
|
paging: true,
|
2015-11-08 23:19:04 +08:00
|
|
|
|
filterMult: false,
|
|
|
|
|
showTfoot: true,
|
2015-11-15 23:00:08 +08:00
|
|
|
|
height: '700',
|
2015-11-08 23:19:04 +08:00
|
|
|
|
delCallback: function (delResult) {
|
|
|
|
|
if (delResult.statusCode == "200")
|
2015-11-13 21:33:53 +08:00
|
|
|
|
loadDataGrid();
|
2015-11-08 23:19:04 +08:00
|
|
|
|
else {
|
|
|
|
|
$(this).alertmsg('warn', delResult.message);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
2015-11-15 23:00:08 +08:00
|
|
|
|
|
2015-11-08 23:19:04 +08:00
|
|
|
|
function zTreeOnClick(event, treeId, treeNode) {
|
|
|
|
|
selectedId = treeNode.Id;
|
2015-11-13 21:33:53 +08:00
|
|
|
|
loadDataGrid();
|
2015-11-08 23:19:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
2015-11-13 21:33:53 +08:00
|
|
|
|
function initZtree() {
|
2015-11-08 23:19:04 +08:00
|
|
|
|
var setting = {
|
2015-11-13 21:33:53 +08:00
|
|
|
|
view: {selectedMulti: false},
|
2015-11-08 23:19:04 +08:00
|
|
|
|
data: {
|
|
|
|
|
key: {
|
|
|
|
|
name: 'Name',
|
|
|
|
|
title: 'Name'
|
|
|
|
|
},
|
|
|
|
|
simpleData: {
|
|
|
|
|
enable: true,
|
|
|
|
|
idKey: 'Id',
|
|
|
|
|
pIdKey: 'ParentId',
|
|
|
|
|
rootPId: 'null'
|
|
|
|
|
}
|
|
|
|
|
},
|
2015-11-13 21:33:53 +08:00
|
|
|
|
callback: {onClick: zTreeOnClick}
|
2015-11-08 23:19:04 +08:00
|
|
|
|
};
|
|
|
|
|
$.getJSON('OrgManager/LoadOrg', function (json) {
|
2015-11-13 21:33:53 +08:00
|
|
|
|
var zTreeObj = $.fn.zTree.init($('#@_treeId'), setting, json);
|
2015-11-08 23:19:04 +08:00
|
|
|
|
zTreeObj.expandAll(true);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//获取勾选的值
|
|
|
|
|
//column:为从0开始的列标识
|
|
|
|
|
function getSelected(column) {
|
2015-11-13 21:33:53 +08:00
|
|
|
|
var selected = $(gridid).data('selectedTrs');
|
2015-11-08 23:19:04 +08:00
|
|
|
|
if (selected == null || selected.length == 0) {
|
|
|
|
|
$(this).alertmsg('warn', '至少选择一个对象', {
|
|
|
|
|
displayMode: 'slide',
|
|
|
|
|
title: '重要提示'
|
|
|
|
|
});
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-15 00:13:49 +08:00
|
|
|
|
//todo:下面这段只能chrome有效
|
2015-11-08 23:19:04 +08:00
|
|
|
|
var records = new Array();
|
|
|
|
|
selected.each(function () {
|
|
|
|
|
records[records.length] = this.children[column].innerText;
|
|
|
|
|
});
|
|
|
|
|
|
2015-11-15 00:13:49 +08:00
|
|
|
|
return records[0];
|
2015-11-08 23:19:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//自定义的编辑按钮
|
|
|
|
|
function editOrg() {
|
|
|
|
|
var selected = getSelected(2);
|
|
|
|
|
if (selected == null) return;
|
|
|
|
|
|
2015-11-16 23:18:51 +08:00
|
|
|
|
$(this).dialog({
|
|
|
|
|
id: 'editDialog',
|
|
|
|
|
url: '/UserManager/Add?id=' + selected,
|
|
|
|
|
title: '编辑',
|
|
|
|
|
onClose:function() {
|
2015-11-16 23:50:00 +08:00
|
|
|
|
refreshGrid();
|
2015-11-16 23:18:51 +08:00
|
|
|
|
}
|
|
|
|
|
});
|
2015-11-15 00:13:49 +08:00
|
|
|
|
|
2015-11-08 23:19:04 +08:00
|
|
|
|
}
|
2015-11-16 23:50:00 +08:00
|
|
|
|
|
|
|
|
|
function refreshGrid() {
|
2015-11-19 21:49:39 +08:00
|
|
|
|
$('#@_gridId').datagrid('refresh');
|
|
|
|
|
// loadDataGrid();
|
2015-11-16 23:50:00 +08:00
|
|
|
|
}
|
2015-11-13 21:33:53 +08:00
|
|
|
|
//@@ sourceURL=userManagerIndex.js
|
2015-11-08 23:19:04 +08:00
|
|
|
|
</script>
|