mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-04-05 17:38:01 +08:00
176 lines
5.6 KiB
Plaintext
176 lines
5.6 KiB
Plaintext
<div class="bjui-pageContent">
|
||
<div class="clearfix">
|
||
<div style="float: left; width: 220px; overflow: auto;" class="table table-bordered">
|
||
<ul id="orgTree" class="ztree"></ul>
|
||
</div>
|
||
|
||
<div id="ztree-detail" style="margin-left: 225px; width: auto;height: auto">
|
||
<table id="mainGrid" data-width="100%" data-height="100%" class="table table-bordered"></table>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<script type="text/javascript">
|
||
var selectedId = 0;
|
||
$(document).ready(function () {
|
||
Init(0);
|
||
});
|
||
//加载数据到datagrid
|
||
function loadDataGrid(data) {
|
||
//b-jui的datagrid需要重新处理HTML
|
||
$('#ztree-detail').empty()
|
||
.append('<table id="mainGrid" data-width="100%" data-height="100%" class="table table-bordered"></table>');
|
||
$('#mainGrid').datagrid({
|
||
gridTitle: '机构列表显示',
|
||
showToolbar: true,
|
||
toolbarItem: 'refresh, |, del,edit',
|
||
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>',
|
||
columns: [
|
||
{
|
||
name: 'Id',
|
||
label: 'Id',
|
||
attrs: { readonly: 'readonly' },
|
||
hide: true
|
||
},
|
||
{
|
||
name: 'ParentId',
|
||
label: '上级机构ID',
|
||
attrs: { readonly: 'readonly'},
|
||
hide: true
|
||
},
|
||
{
|
||
name: 'CascadeId',
|
||
label: '唯一标识',
|
||
attrs: { readonly: 'readonly'}
|
||
},
|
||
{
|
||
name: 'Name',
|
||
label: '机构名称'
|
||
},
|
||
{
|
||
name: 'ParentName',
|
||
label: '上级机构',
|
||
edit: false,
|
||
attrs: { readonly: 'readonly' }
|
||
},
|
||
{
|
||
name: 'Status',
|
||
label: '状态',
|
||
type: 'select',
|
||
align: 'center',
|
||
items:[{'0':'正常'}, {'1':'禁用'}]
|
||
},
|
||
{
|
||
name: 'CreateTime',
|
||
label: '登记日期',
|
||
type: 'date',
|
||
pattern: 'yyyy-MM-dd HH:mm:ss'
|
||
}
|
||
],
|
||
data: data,
|
||
delUrl: 'OrgManager/DelOrg',
|
||
delPK: "Id",
|
||
editUrl: 'OrgManager/EditOrg',
|
||
editMode: 'dialog',
|
||
fullGrid: true,
|
||
showLinenumber: true,
|
||
showCheckboxcol: true,
|
||
paging: false,
|
||
filterMult: false,
|
||
showTfoot: true,
|
||
delCallback: function (delResult) {
|
||
if (delResult.statusCode == "200")
|
||
Init(selectedId);
|
||
else {
|
||
$(this).alertmsg('warn', delResult.message);
|
||
}
|
||
},
|
||
editCallback: function (delResult) {
|
||
if (delResult.statusCode == "200")
|
||
Init(selectedId);
|
||
else {
|
||
$(this).alertmsg('warn', delResult.message);
|
||
}
|
||
}
|
||
});
|
||
}
|
||
function zTreeOnClick(event, treeId, treeNode) {
|
||
selectedId = treeNode.Id;
|
||
$.getJSON('OrgManager/LoadChildren', {
|
||
id: treeNode.Id
|
||
}, function (json) {
|
||
loadDataGrid(json);
|
||
});
|
||
}
|
||
|
||
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);
|
||
|
||
$.getJSON('OrgManager/LoadChildren', {
|
||
id: selectedId
|
||
}, function (data) {
|
||
loadDataGrid(data);
|
||
});
|
||
|
||
//TODO:设置ztree选中,不过没看到效果..
|
||
var selectedNod = zTreeObj.getNodesByParam('Id', selectedId, null);
|
||
zTreeObj.selectNode(selectedNod, false);
|
||
|
||
});
|
||
}
|
||
|
||
//获取勾选的值
|
||
//column:为从0开始的列标识
|
||
function getSelected(column) {
|
||
var selected = $('#mainGrid').data('selectedTrs');
|
||
if (selected == null || selected.length == 0) {
|
||
$(this).alertmsg('warn', '至少选择一个对象', {
|
||
displayMode: 'slide',
|
||
title: '重要提示'
|
||
});
|
||
return null;
|
||
}
|
||
|
||
var records = new Array();
|
||
selected.each(function () {
|
||
records[records.length] = this.children[column].innerText;
|
||
});
|
||
|
||
return records;
|
||
}
|
||
|
||
|
||
|
||
//自定义的编辑按钮
|
||
function editOrg() {
|
||
var selected = getSelected(2);
|
||
if (selected == null) return;
|
||
|
||
}
|
||
//@@ sourceURL=orgIndex.js
|
||
</script>
|