Commit 0811da45 authored by ibuler's avatar ibuler

[Update] 更新树形结构

parent 14de7d22
...@@ -63,53 +63,38 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges { ...@@ -63,53 +63,38 @@ export class ElementAssetTreeComponent implements OnInit, OnChanges {
draw() { draw() {
const nodes = {}; const nodes = {};
const assets = {}; const assets = {};
this.Data.forEach((v, i) => { this.Data.forEach(node => {
if (!nodes[v['id']]) { if (!nodes[node['id']]) {
nodes[v['id']] = true; nodes[node['id']] = true;
this.nodes.push({ this.nodes.push({
'id': v['id'], 'id': node['id'],
'key': v['key'], 'key': node['key'],
'name': v['name'], 'name': node['name'],
'value': v['value'], 'value': node['value'],
'pId': v['parent'], 'pId': node['parent'],
'assets_amount': v['assets_amount'], 'assets_amount': node['assets_amount'],
'isParent': true, 'isParent': true,
'open': v['key'] === '0' 'open': node['key'] === '0'
}); });
} }
v['assets_granted'].forEach((vv, ii) => { node['assets_granted'].forEach(asset => {
vv['nodes'].forEach((vvv, iii) => { if (!assets[asset['id']]) {
if (!nodes[vvv['id']]) {
this.nodes.push({ this.nodes.push({
'id': vvv['id'], 'id': asset['id'],
'key': vvv['key'], 'name': asset['hostname'],
'name': vvv['value'], 'value': asset['hostname'],
'value': vvv['value'], 'system_users_granted': asset['system_users_granted'],
'pId': vvv['parent'], 'platform': asset['platform'],
'assets_amount': vvv['assets_amount'], 'comment': asset['comment'],
'isParent': true,
'open': vvv['key'] === '0'
});
nodes[vvv['id']] = true;
}
if (!assets[vv['id'] + '@' + vvv['id']]) {
this.nodes.push({
'id': vv['id'],
'name': vv['hostname'],
'value': vv['hostname'],
'system_users_granted': vv['system_users_granted'],
'platform': vv['platform'],
'comment': vv['comment'],
'isParent': false, 'isParent': false,
'pId': vvv['id'], 'pId': node['id'],
'iconSkin': vv['platform'].toLowerCase() 'iconSkin': asset['platform'].toLowerCase()
}); });
assets[vv['id'] + '@' + vvv['id']] = true; assets[asset['id'] + '@' + node['id']] = true;
} }
}); });
}); });
});
this.nodes.sort(function(node1, node2) { this.nodes.sort(function(node1, node2) {
if (node1.isParent && !node2.isParent) { if (node1.isParent && !node2.isParent) {
return -1; return -1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment