2015-10-28 22:49:59 +08:00
|
|
|
|
<div class="bjui-pageContent">
|
|
|
|
|
<div class="clearfix">
|
2015-11-04 23:46:21 +08:00
|
|
|
|
<div style="float: left; width: 220px; overflow: auto;" class="table table-bordered">
|
2015-10-28 22:49:59 +08:00
|
|
|
|
<ul id="orgTree" class="ztree"></ul>
|
|
|
|
|
</div>
|
2015-11-03 00:22:54 +08:00
|
|
|
|
|
2015-11-04 23:46:21 +08:00
|
|
|
|
<div id="ztree-detail" style="margin-left: 225px; width: auto;height: auto">
|
2015-11-05 23:27:08 +08:00
|
|
|
|
<table id="mainGrid" 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-10-30 23:14:31 +08:00
|
|
|
|
function loadDataGrid(data) {
|
2015-11-05 23:27:08 +08:00
|
|
|
|
//b-jui的datagrid需要重新处理HTML
|
|
|
|
|
$('#ztree-detail').empty()
|
|
|
|
|
.append('<table id="mainGrid" data-width="100%" data-height="100%" class="table table-bordered"></table>');
|
|
|
|
|
$('#mainGrid').datagrid({
|
2015-10-30 23:14:31 +08:00
|
|
|
|
gridTitle: '机构列表显示',
|
|
|
|
|
showToolbar: true,
|
2015-11-05 23:27:08 +08:00
|
|
|
|
toolbarItem: 'refresh, |, del',
|
|
|
|
|
toolbarCustom: '<a href="/OrgManager/AddOrg" class="btn btn-green" data-icon ="plus" ' +
|
|
|
|
|
'data-toggle="dialog" data-id="dialog-mask" data-mask="true">添加</a>' +
|
|
|
|
|
'<button class=" btn-green" onclick="editOrg()" data-icon="pencil" type="button">编辑</button>',
|
2015-10-30 23:14:31 +08:00
|
|
|
|
columns: [
|
2015-11-05 23:27:08 +08:00
|
|
|
|
{
|
|
|
|
|
name: 'Id',
|
|
|
|
|
label: 'Id',
|
|
|
|
|
hide: true
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'ParentId',
|
|
|
|
|
label: '上级机构ID',
|
|
|
|
|
hide: true
|
|
|
|
|
},
|
2015-11-04 23:46:21 +08:00
|
|
|
|
{
|
|
|
|
|
name: 'CascadeId',
|
2015-11-05 23:27:08 +08:00
|
|
|
|
label: '唯一标识'
|
2015-11-03 00:22:54 +08:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'Name',
|
|
|
|
|
label: '机构名称'
|
|
|
|
|
},
|
2015-11-04 23:46:21 +08:00
|
|
|
|
{
|
|
|
|
|
name: 'ParentName',
|
2015-11-05 23:27:08 +08:00
|
|
|
|
label: '上级机构'
|
2015-11-04 23:46:21 +08:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'Status',
|
|
|
|
|
label: '禁用',
|
|
|
|
|
type: 'boolean',
|
|
|
|
|
align: 'center',
|
|
|
|
|
render: function (value) {
|
|
|
|
|
return (value && String(value) == 'true') ?
|
|
|
|
|
'<span style="color:red;">是</span>' : '否'
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
},
|
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,
|
2015-11-03 00:22:54 +08:00
|
|
|
|
addUrl: 'OrgManager/AddOrg',
|
2015-10-30 23:14:31 +08:00
|
|
|
|
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-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-10-30 23:14:31 +08:00
|
|
|
|
loadDataGrid(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) {
|
|
|
|
|
var zTreeObj = $.fn.zTree.init($('#orgTree'), setting, json);
|
|
|
|
|
zTreeObj.expandAll(true);
|
2015-11-05 23:27:08 +08:00
|
|
|
|
|
|
|
|
|
$.getJSON('OrgManager/LoadChildren', {
|
|
|
|
|
id: selectedId
|
|
|
|
|
}, function (data) {
|
|
|
|
|
loadDataGrid(data);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
//TODO:设置ztree选中,不过没看到效果..
|
|
|
|
|
var selectedNod = zTreeObj.getNodesByParam('Id', selectedId, null);
|
|
|
|
|
zTreeObj.selectNode(selectedNod, false);
|
|
|
|
|
|
2015-11-03 00:22:54 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
2015-11-05 23:27:08 +08:00
|
|
|
|
|
|
|
|
|
//获取勾选的值
|
|
|
|
|
//column:为从0开始的列标识
|
|
|
|
|
function getSelected(column) {
|
|
|
|
|
var selected = $('#mainGrid').data('selectedTrs');
|
|
|
|
|
if (selected == null || selected.length == 0) {
|
2015-11-03 00:22:54 +08:00
|
|
|
|
$(this).alertmsg('warn', '至少选择一个对象', {
|
|
|
|
|
displayMode: 'slide',
|
|
|
|
|
title: '重要提示'
|
|
|
|
|
});
|
2015-11-05 23:27:08 +08:00
|
|
|
|
return null;
|
2015-11-03 00:22:54 +08:00
|
|
|
|
}
|
2015-11-05 23:27:08 +08:00
|
|
|
|
|
|
|
|
|
var records = new Array();
|
|
|
|
|
selected.each(function () {
|
|
|
|
|
records[records.length] = this.children[column].innerText;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return records;
|
2015-10-29 23:51:10 +08:00
|
|
|
|
}
|
2015-11-04 23:46:21 +08:00
|
|
|
|
|
2015-11-05 23:27:08 +08:00
|
|
|
|
|
|
|
|
|
|
2015-11-04 23:46:21 +08:00
|
|
|
|
//自定义的编辑按钮
|
|
|
|
|
function editOrg() {
|
2015-11-05 23:27:08 +08:00
|
|
|
|
var selected = getSelected(2);
|
2015-11-04 23:46:21 +08:00
|
|
|
|
if (selected == null) return;
|
|
|
|
|
|
|
|
|
|
}
|
2015-10-28 22:49:59 +08:00
|
|
|
|
//@@ sourceURL=orgIndex.js
|
2015-11-05 23:27:08 +08:00
|
|
|
|
</script>
|