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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
var loadComplete = 0;
var setTree = function (obj, nwidth, nheight) {
    $('' + obj + '').attr("materialcode", "");
    var html = '<div id="showArticle" style="position: absolute;left: 0px;background-color:white;margin-left:0px;z-index: 99;width: ' + nwidth + ';max-height: ' + nheight + ';overflow-y: scroll;    display: none; "></div>';
    $(''+obj+'').after(html);
    LoadArticleTree(obj);
    $('' + obj + '').bind('focus', function () {
        $('#showArticle').show();
    });
    var id = $('' + obj + '').attr("id") || "";
    //隐藏物料分类弹框
    document.body.addEventListener("click", function (even) {
        if (even.target.id == id&&loadComplete == 0) {
            layer.msg('物料树加载中,请稍后再试....', { icon: 6 });
            return;
        }
 
        if (!even.target)
            return;
        
        if (even.target.id != id && even.target.tagName != 'I') {
            $("#showArticle").hide();
        }
    })
 
}
 
var LoadArticleTree = function (obj) {
    var treeindex;
    $.ajax({
        type: "POST",
        url: "/Article/GetTreeJson",
        dataType: "json",
        async: true,
        beforeSend: function () {
            //treeindex = parent.layer.load(1, '#000');
        },
        complete: function () {
            loadComplete = 1;
            //parent.layer.close(treeindex);
        },
        success: function (result) {
            var treedata = [result];
            $('#showArticle').treeview({
                data: treedata,         // 数据源
                backColor: 'white',    //列表树所有节点背景颜色
                showCheckbox: false,   //是否显示复选框
                highlightSelected: false,    //是否高亮选中
                nodeIcon: 'glyphicon glyphicon-globe',
                emptyIcon: '',    //没有子节点的节点图标
                multiSelect: true,    //多选
                onNodeChecked: function (event, data) {
                },
                onNodeSelected: function (event, data) {
                    $('#showArticle').hide();
                    $('' + obj + '').val(data.text);
                    $('' + obj + '').attr('materialcode', data.code);
                }
            });
        },
 
        error: function () {
            alert("物料树形结构加载失败!");
        }
    });
}