ansel0926
2022-05-16 cee67c9f4623f287ce96901763963d50cdc24736
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
//图层管理
var layerMenu = [];
var layerPage = undefined;
//添加数据节点
function addTreeNode(data, oid) {
    if (oid == undefined) {
        layerMenu.push(data);
    } else {
        var node = getNodeById(oid, layerMenu);
        if (node != null) {
            if (node.children == null || node.children == undefined) {
                node.children = [];
            }
            node.children.push(data);
        } else {
            layerMenu.push(data);
        }
    }
    // if (layerPage != undefined) {
    //     layerPage.refreshTree();
    // }
}
//删除数据节点
function delNodeById(id, data) {
    var ret = false;
    for (let i in data) {
        if (data[i].id == id) {
            data.splice(i, 1);
            return true;
        } else {
            if (data[i].children != undefined && data[i].children.length > 0) {
                ret = delNodeById(id, data[i].children);
            }
        }
        if (ret) {
            return ret;
        }
    }
    return ret;
}
//寻找数据节点
function getNodeById(id, data) {
    if (typeof (data) == 'undefined') {
        data = layerMenu;
    }
    var ret = null;
    for (let i in data) {
        if (data[i].id == id) {
            return data[i];
        } else {
            if (data[i].children != undefined && data[i].children.length > 0) {
                var temp = getNodeById(id, data[i].children);
                if (temp != null) {
                    ret = temp;
                }
            }
        }
        if (ret != null) {
            break;
        }
    }
    return ret;
}
function getRootById(id, data) {
    if (typeof (data) == 'undefined') {
        data = layerMenu;
    }
    var ret = null;
    for (let i in data) {
        if (data[i].id == id) {
            ret = data[i];
        }
    }
    return ret;
}
function getParentByChildrenId(id, data){
    if (typeof (data) == 'undefined') {
        data = layerMenu;
    }
    var ret = null;
    for (let i in data) {
        var isFind = false;
        if (data[i].children != undefined && data[i].children.length > 0) {
            for (var j = 0; j < data[i].children.length; j++){
                if (data[i].children[j].id == id){
                    isFind = true;
                    break;
                }
            }
        }
        if (isFind){
            return data[i];
        }else{
            if (data[i].children != undefined && data[i].children.length > 0) {
                var temp = getParentByChildrenId(id, data[i].children);
                if (temp != null) {
                    ret = temp;
                }
            }
        }
        if (ret != null) {
            break;
        }
    }
    return ret;
}
 
$.ajaxSettings.async = false;
$.getJSON('../../assets/config/layerMenu.json', data => {
    for (let i in data) {
        addTreeNode(data[i]);
    }
});
 
function layerAnalysis() {
    layui.use(['element', 'layer', 'form', 'upload', 'tree', 'util'], function () {
        var layer = layui.layer;
        layer.config({
            extend: 'myskin/style.css' //同样需要先加载新皮肤
        });
        layer.closeAll();
        layer.open({
            type: 2,
            title: '<i class="iconfont icon-tuceng i-item" style="font-size: 18px; color: white;"></i>  ' + "图层控制",
            maxmin: true,
            skin: 'layer-ext-myskin',
            shade: 0,
            maxmin: false,
            scrollbar: true,
            shadeClose: true, //点击遮罩关闭层
            area: ['300px', '600px'],
            resize: false,
            content: 'project/layerAnalysis.html',
            offset: [layerPageStyle.offsetX, layerPageStyle.offsetY],
            success: function (layero, index) {
                layerPage = window[layero.find('iframe')[0]['name']];
                // layerPage.init();
            },
            end: function () {
                layerPage = undefined;
            }
        });
 
    });
}