fix: 拓扑多个omc节点时异常问题

This commit is contained in:
TsMask
2024-01-05 15:31:41 +08:00
parent 25db9e9398
commit 081a45f845

View File

@@ -63,16 +63,16 @@ function fnGetList(refresh: boolean = false) {
Array.isArray(res.data) && Array.isArray(res.data) &&
res.data.length > 0 res.data.length > 0
) { ) {
let rootNode = 'OMC'; // 根网管
let rootNodeInfo = { neName: undefined };
const nodes = []; const nodes = [];
const edges = []; const edges = [];
for (const item of res.data) { for (const item of res.data) {
item.serverState = {}; item.serverState = {};
// 节点
const nodeIndex = nodes.findIndex(v => v.id === item.neName); const nodeIndex = nodes.findIndex(v => v.id === item.neName);
if (nodeIndex === -1) { if (nodeIndex === -1) {
// 根网管
if (item.neType === 'OMC') { if (item.neType === 'OMC') {
rootNode = item.neName;
nodes.push({ nodes.push({
id: item.neName, id: item.neName,
label: item.neName, label: item.neName,
@@ -95,6 +95,7 @@ function fnGetList(refresh: boolean = false) {
height: 60, height: 60,
}, },
}); });
!rootNodeInfo.neName && (rootNodeInfo = item);
} else { } else {
nodes.push({ nodes.push({
id: item.neName, id: item.neName,
@@ -111,16 +112,22 @@ function fnGetList(refresh: boolean = false) {
}); });
} }
} }
// 边
if (item.neType !== 'OMC') { if (item.neType !== 'OMC') {
const edgeIndex = edges.findIndex(v => v.source === item.neName); const edgeIndex = edges.findIndex(v => v.source === item.neName);
if (edgeIndex === -1) { if (edgeIndex === -1) {
edges.push({ edges.push({
source: item.neName, source: item.neName,
target: rootNode, target: rootNodeInfo.neName,
label: `${item.neType}-${rootNode}`, label: `${item.neName}-${rootNodeInfo.neName}`,
}); });
} }
} else {
edges.push({
source: item.neName,
target: rootNodeInfo.neName,
label: `${item.neName}-${rootNodeInfo.neName}`,
});
} }
} }
graphG6Data.nodes = nodes; graphG6Data.nodes = nodes;