//二级数组
var tree = [];
data.forEach(function(item) {
var level1 = tree.find(function(node) {
return node.fathno === item.fathno;
});
console.log(level1);
if (!level1) {
level1 = {
fathno: item.fathno,
fathna: item.fathna,
children: []
};
console.log(level1);
tree.push(level1);
}
var level2 = {
na: item.na,
no: item.no
};
level1.children.push(level2);
});
console.log(tree);
var map = {},//二维数组
dest = [];
for (var i = 0; i < departList.length; i++) {
var ai = departList[i];
if (!map[ai.fathna]) {
dest.push({
fathno: ai.fathno,
fathna: ai.fathna,
data: [ai]
});
map[ai.fathno] = ai;
map[ai.fathna] = ai;
} else {
for (var j = 0; j < dest.length; j++) {
var dj = dest[j];
if (dj.fathna == ai.fathna) {
dj.data.push(ai);
break;
}
}
}
}
console.log(dest)
const result = this.list1.map(item => {//三维数组
const ip = item.wk_ip;
const acc = item.wk_dbacc;
const pass = item.wk_dbpass;
return {
label: ip,
value:'1',
children: [{
label: acc,
value:'2',
children: [{
label: pass,
value:'3'
}]
}]
};
});