var setTree = function (obj, nwidth, nheight) {
|
var html = '<div id="showdept" style="position: absolute;left: 10px;background-color:white;margin-left:5px; z-index: 99;width: ' + nwidth + ';max-height: ' + nheight + ';overflow-y: scroll; display: none; "></div>';
|
$(''+obj+'').after(html);
|
LoadDeptTree(obj);
|
$('' + obj + '').bind('focus', function () {
|
$('#showdept').show();
|
});
|
}
|
|
var LoadDeptTree = function (obj) {
|
var treeindex;
|
$.ajax({
|
type: "Post",
|
url: "/Hr_dept/GetTreeJson",
|
dataType: "json",
|
beforeSend: function () {
|
treeindex = parent.layer.load(1, '#000');
|
},
|
complete: function () {
|
parent.layer.close(treeindex);
|
},
|
success: function (result) {
|
var treedata = [result];
|
$('#showdept').treeview({
|
data: treedata, // 数据源
|
backColor: 'white', //列表树所有节点背景颜色
|
showCheckbox: false, //是否显示复选框
|
highlightSelected: false, //是否高亮选中
|
nodeIcon: 'glyphicon glyphicon-globe',
|
emptyIcon: '', //没有子节点的节点图标
|
multiSelect: true, //多选
|
levels: 2,
|
onNodeChecked: function (event, data) {
|
},
|
onNodeSelected: function (event, data) {
|
$('#showdept').hide();
|
$('' + obj + '').val(data.text);
|
$('' + obj + '').attr('deptid', data.Id);
|
}
|
});
|
},
|
error: function () {
|
alert("部门树形结构加载失败!")
|
}
|
});
|
}
|