//图层管理
|
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;
|
}
|
});
|
|
});
|
}
|