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-10-28 22:49:59 +08:00
|
|
|
|
<table id="test-datagrid-array" data-width="100%" data-height="100%" class="table table-bordered"></table>
|
|
|
|
|
</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) {
|
|
|
|
|
$('#test-datagrid-array').datagrid({
|
|
|
|
|
gridTitle: '机构列表显示',
|
|
|
|
|
showToolbar: true,
|
2015-11-03 00:22:54 +08:00
|
|
|
|
toolbarItem: 'add, edit, refresh, |, del',
|
2015-11-04 23:46:21 +08:00
|
|
|
|
//toolbarCustom: '<button class=" btn-green" data-icon="plus" type="button">添加</button>' +
|
|
|
|
|
// '<button class=" btn-green" onclick="editOrg()" data-icon="pencil" type="button">编辑</button>',
|
2015-10-30 23:14:31 +08:00
|
|
|
|
columns: [
|
2015-11-03 00:22:54 +08:00
|
|
|
|
{
|
|
|
|
|
name: 'Id',
|
2015-11-04 23:46:21 +08:00
|
|
|
|
label:'Id',
|
|
|
|
|
hide: true,
|
|
|
|
|
edit:false
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'CascadeId',
|
|
|
|
|
label: '唯一标识',
|
|
|
|
|
edit:false
|
2015-11-03 00:22:54 +08:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: 'Name',
|
|
|
|
|
label: '机构名称'
|
|
|
|
|
},
|
2015-11-04 23:46:21 +08:00
|
|
|
|
{
|
|
|
|
|
name: 'ParentName',
|
|
|
|
|
label: '上级机构',
|
|
|
|
|
type: 'lookup',
|
|
|
|
|
attrs: { 'data-url': 'OrgManager/LookupParent' }
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
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',
|
|
|
|
|
label: '登记日期'
|
|
|
|
|
}
|
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-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) {
|
|
|
|
|
if (delResult.Status == true)
|
|
|
|
|
Init(selectedId);
|
|
|
|
|
else {
|
|
|
|
|
$(this).alertmsg('warn', delResult.Message);
|
|
|
|
|
}
|
|
|
|
|
}
|
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
|
|
|
|
$('#ztree-detail').empty().append('<table id="test-datagrid-array" data-width="100%" data-height="100%" class="table table-bordered"></table>');
|
|
|
|
|
loadDataGrid(json);
|
2015-10-29 23:51:10 +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);
|
|
|
|
|
if (selectedId == 0) {
|
|
|
|
|
loadDataGrid(json);
|
|
|
|
|
} else {
|
|
|
|
|
//TODO:设置ztree选中,不过没看到效果..
|
|
|
|
|
var selectedNod = zTreeObj.getNodesByParam('Id', selectedId, null);
|
|
|
|
|
zTreeObj.selectNode(selectedNod, false);
|
|
|
|
|
$.getJSON('OrgManager/LoadChildren', {
|
|
|
|
|
id: selectedId
|
|
|
|
|
}, function (data) {
|
|
|
|
|
$('#ztree-detail').empty().append('<table id="test-datagrid-array" data-width="100%" data-height="100%" class="table table-bordered"></table>');
|
|
|
|
|
loadDataGrid(data);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
function getSelected() {
|
|
|
|
|
var selected = $('#test-datagrid-array').data('selectedTrs');
|
|
|
|
|
if (selected == null) {
|
|
|
|
|
$(this).alertmsg('warn', '至少选择一个对象', {
|
|
|
|
|
displayMode: 'slide',
|
|
|
|
|
title: '重要提示'
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
return selected;
|
2015-10-29 23:51:10 +08:00
|
|
|
|
}
|
2015-11-04 23:46:21 +08:00
|
|
|
|
|
|
|
|
|
//自定义的编辑按钮
|
|
|
|
|
function editOrg() {
|
|
|
|
|
var selected = getSelected();
|
|
|
|
|
if (selected == null) return;
|
|
|
|
|
|
|
|
|
|
}
|
2015-10-28 22:49:59 +08:00
|
|
|
|
//@@ sourceURL=orgIndex.js
|
|
|
|
|
</script>
|