username@email.com
2023-03-09 26de0696f74e183e3aadad2e9ff1918b40e5c8cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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("部门树形结构加载失败!")
        }
    });
}