2015-11-13 21:33:53 +08:00
|
|
|
|
@{
|
|
|
|
|
string _prefix = "org";
|
|
|
|
|
var _treeId = _prefix + "Tree";
|
|
|
|
|
var _gridId = _prefix + "Grid";
|
|
|
|
|
var _treeDetail = _prefix + "Detail";
|
|
|
|
|
}
|
|
|
|
|
<div class="bjui-pageContent">
|
2015-10-28 22:49:59 +08:00
|
|
|
|
<div class="clearfix">
|
2015-11-04 23:46:21 +08:00
|
|
|
|
<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-10-28 22:49:59 +08:00
|
|
|
|
</div>
|
2015-11-03 00:22:54 +08:00
|
|
|
|
|
2015-11-13 21:33:53 +08:00
|
|
|
|
<div id="@_treeDetail" style="margin-left: 225px; width: auto;height: auto">
|
|
|
|
|
<table id="@_gridId" data-width="100%" data-height="100%" class="table table-bordered"></table>
|
2015-10-28 22:49:59 +08:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2015-10-26 21:58:12 +08:00
|
|
|
|
|
2015-10-28 22:49:59 +08:00
|
|
|
|
<script type="text/javascript">
|
2015-11-03 00:22:54 +08:00
|
|
|
|
var selectedId = 0;
|
2015-10-28 22:49:59 +08:00
|
|
|
|
$(document).ready(function () {
|
2015-11-03 00:22:54 +08:00
|
|
|
|
Init(0);
|
2015-10-28 22:49:59 +08:00
|
|
|
|
});
|
2015-11-03 00:22:54 +08:00
|
|
|
|
//加载数据到datagrid
|
2015-11-13 21:33:53 +08:00
|
|
|
|
function LoadOrg(data) {
|
2015-11-05 23:27:08 +08:00
|
|
|
|
//b-jui的datagrid需要重新处理HTML
|
2015-11-13 21:33:53 +08:00
|
|
|
|
$('#@_treeDetail').empty()
|
|
|
|
|
.append('<table id="@_gridId" data-width="100%" data-height="100%" class="table table-bordered"></table>');
|
|
|
|
|
$('#@_gridId').datagrid({
|
2015-10-30 23:14:31 +08:00
|
|
|
|
gridTitle: '机构列表显示',
|
|
|
|
|
showToolbar: true,
|
2015-11-15 00:13:49 +08:00
|
|
|
|
filterThead: false,
|
2015-11-06 00:27:08 +08:00
|
|
|
|
toolbarItem: 'refresh, |, del,edit',
|
2015-11-05 23:27:08 +08:00
|
|
|
|
toolbarCustom: '<a href="/OrgManager/AddOrg" class="btn btn-green" data-icon ="plus" ' +
|
2015-11-06 22:56:26 +08:00
|
|
|
|
'data-toggle="dialog" data-id="dialog-mask" data-mask="true">添加</a>' ,
|
2015-10-30 23:14:31 +08:00
|
|
|
|
columns: [
|
2015-11-05 23:27:08 +08:00
|
|
|
|
{
|
|
|
|
|
name: 'Id',
|
|
|
|
|
label: 'Id',
|
2015-11-06 00:27:08 +08:00
|
|
|
|
attrs: { readonly: 'readonly' },
|
2015-11-05 23:27:08 +08:00
|
|
|
|
hide: true
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'ParentId',
|
|
|
|
|
label: '上级机构ID',
|
2015-11-06 00:27:08 +08:00
|
|
|
|
attrs: { readonly: 'readonly'},
|
2015-11-05 23:27:08 +08:00
|
|
|
|
hide: true
|
|
|
|
|
},
|
2015-11-04 23:46:21 +08:00
|
|
|
|
{
|
|
|
|
|
name: 'CascadeId',
|
2015-11-06 00:27:08 +08:00
|
|
|
|
label: '唯一标识',
|
|
|
|
|
attrs: { readonly: 'readonly'}
|
2015-11-03 00:22:54 +08:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'Name',
|
|
|
|
|
label: '机构名称'
|
|
|
|
|
},
|
2015-11-04 23:46:21 +08:00
|
|
|
|
{
|
|
|
|
|
name: 'ParentName',
|
2015-11-06 00:27:08 +08:00
|
|
|
|
label: '上级机构',
|
|
|
|
|
edit: false,
|
|
|
|
|
attrs: { readonly: 'readonly' }
|
2015-11-04 23:46:21 +08:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'Status',
|
2015-11-05 23:41:06 +08:00
|
|
|
|
label: '状态',
|
|
|
|
|
type: 'select',
|
2015-11-04 23:46:21 +08:00
|
|
|
|
align: 'center',
|
2015-11-05 23:41:06 +08:00
|
|
|
|
items:[{'0':'正常'}, {'1':'禁用'}]
|
2015-11-04 23:46:21 +08:00
|
|
|
|
},
|
2015-11-03 00:22:54 +08:00
|
|
|
|
{
|
|
|
|
|
name: 'CreateTime',
|
2015-11-05 23:27:08 +08:00
|
|
|
|
label: '登记日期',
|
|
|
|
|
type: 'date',
|
|
|
|
|
pattern: 'yyyy-MM-dd HH:mm:ss'
|
2015-11-03 00:22:54 +08:00
|
|
|
|
}
|
2015-10-30 23:14:31 +08:00
|
|
|
|
],
|
|
|
|
|
data: data,
|
|
|
|
|
delUrl: 'OrgManager/DelOrg',
|
2015-11-05 23:27:08 +08:00
|
|
|
|
delPK: "Id",
|
2015-11-03 00:22:54 +08:00
|
|
|
|
editUrl: 'OrgManager/EditOrg',
|
2015-10-30 23:14:31 +08:00
|
|
|
|
editMode: 'dialog',
|
|
|
|
|
fullGrid: true,
|
|
|
|
|
showLinenumber: true,
|
|
|
|
|
showCheckboxcol: true,
|
|
|
|
|
paging: false,
|
|
|
|
|
filterMult: false,
|
2015-11-03 00:22:54 +08:00
|
|
|
|
showTfoot: true,
|
|
|
|
|
delCallback: function (delResult) {
|
2015-11-05 23:27:08 +08:00
|
|
|
|
if (delResult.statusCode == "200")
|
2015-11-03 00:22:54 +08:00
|
|
|
|
Init(selectedId);
|
|
|
|
|
else {
|
2015-11-05 23:27:08 +08:00
|
|
|
|
$(this).alertmsg('warn', delResult.message);
|
2015-11-03 00:22:54 +08:00
|
|
|
|
}
|
2015-11-06 00:27:08 +08:00
|
|
|
|
},
|
|
|
|
|
editCallback: function (delResult) {
|
|
|
|
|
if (delResult.statusCode == "200")
|
|
|
|
|
Init(selectedId);
|
|
|
|
|
else {
|
|
|
|
|
$(this).alertmsg('warn', delResult.message);
|
|
|
|
|
}
|
2015-11-03 00:22:54 +08:00
|
|
|
|
}
|
2015-10-30 23:14:31 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
2015-10-29 23:51:10 +08:00
|
|
|
|
function zTreeOnClick(event, treeId, treeNode) {
|
2015-11-03 00:22:54 +08:00
|
|
|
|
selectedId = treeNode.Id;
|
|
|
|
|
$.getJSON('OrgManager/LoadChildren', {
|
|
|
|
|
id: treeNode.Id
|
|
|
|
|
}, function (json) {
|
2015-11-13 21:33:53 +08:00
|
|
|
|
LoadOrg(json);
|
2015-10-29 23:51:10 +08:00
|
|
|
|
});
|
2015-11-03 00:22:54 +08:00
|
|
|
|
}
|
2015-11-05 23:27:08 +08:00
|
|
|
|
|
2015-11-03 00:22:54 +08:00
|
|
|
|
function Init(selectedId) {
|
|
|
|
|
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) {
|
2015-11-13 21:33:53 +08:00
|
|
|
|
var zTreeObj = $.fn.zTree.init($('#@_treeId'), setting, json);
|
2015-11-03 00:22:54 +08:00
|
|
|
|
zTreeObj.expandAll(true);
|
2015-11-05 23:27:08 +08:00
|
|
|
|
|
|
|
|
|
$.getJSON('OrgManager/LoadChildren', {
|
|
|
|
|
id: selectedId
|
|
|
|
|
}, function (data) {
|
2015-11-13 21:33:53 +08:00
|
|
|
|
LoadOrg(data);
|
2015-11-05 23:27:08 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
//TODO:设置ztree选中,不过没看到效果..
|
|
|
|
|
var selectedNod = zTreeObj.getNodesByParam('Id', selectedId, null);
|
|
|
|
|
zTreeObj.selectNode(selectedNod, false);
|
|
|
|
|
|
2015-11-03 00:22:54 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
2015-10-28 22:49:59 +08:00
|
|
|
|
//@@ sourceURL=orgIndex.js
|
2015-11-05 23:27:08 +08:00
|
|
|
|
</script>
|