From 5033c539dec961fc689e47a0051196b9aab854c1 Mon Sep 17 00:00:00 2001 From: songlh Date: Thu, 6 Jun 2024 14:05:32 +0800 Subject: [PATCH] fix: ci topo expand error --- .../views/ci/modules/ciDetailRelation.vue | 2 +- .../ci/modules/ciDetailRelationTopo/index.vue | 60 ++++++++++--------- 2 files changed, 32 insertions(+), 30 deletions(-) diff --git a/cmdb-ui/src/modules/cmdb/views/ci/modules/ciDetailRelation.vue b/cmdb-ui/src/modules/cmdb/views/ci/modules/ciDetailRelation.vue index e164dd1..e78fe55 100644 --- a/cmdb-ui/src/modules/cmdb/views/ci/modules/ciDetailRelation.vue +++ b/cmdb-ui/src/modules/cmdb/views/ci/modules/ciDetailRelation.vue @@ -269,7 +269,7 @@ export default { return { nodes, edges } }, exsited_ci() { - const _exsited_ci = [this.typeId] + const _exsited_ci = [this.ciId] this.parentCITypes.forEach((parent) => { if (this.firstCIs[parent.name]) { this.firstCIs[parent.name].forEach((parentCi) => { diff --git a/cmdb-ui/src/modules/cmdb/views/ci/modules/ciDetailRelationTopo/index.vue b/cmdb-ui/src/modules/cmdb/views/ci/modules/ciDetailRelationTopo/index.vue index 77d5cc2..b89c573 100644 --- a/cmdb-ui/src/modules/cmdb/views/ci/modules/ciDetailRelationTopo/index.vue +++ b/cmdb-ui/src/modules/cmdb/views/ci/modules/ciDetailRelationTopo/index.vue @@ -100,35 +100,37 @@ export default { const r = res.result[i] if (!this.exsited_ci.includes(r._id)) { const _findCiType = ci_types_list.find((item) => item.id === r._type) - const { attributes } = await getCITypeAttributesById(_findCiType.id) - const unique_id = _findCiType.show_id || _findCiType.unique_id - const _findUnique = attributes.find((attr) => attr.id === unique_id) - const unique_name = _findUnique?.name - const unique_alias = _findUnique?.alias || _findUnique?.name || '' - newNodes.push({ - id: `${r._id}`, - Class: Node, - title: r.ci_type_alias || r.ci_type, - name: r.ci_type, - side: side, - unique_alias, - unique_name, - unique_value: r[unique_name], - children: [], - icon: _findCiType?.icon || '', - endpoints: [ - { - id: 'left', - orientation: [-1, 0], - pos: [0, 0.5], - }, - { - id: 'right', - orientation: [1, 0], - pos: [0, 0.5], - }, - ], - }) + if (_findCiType) { + const { attributes } = await getCITypeAttributesById(_findCiType.id) + const unique_id = _findCiType.show_id || _findCiType.unique_id + const _findUnique = attributes.find((attr) => attr.id === unique_id) + const unique_name = _findUnique?.name + const unique_alias = _findUnique?.alias || _findUnique?.name || '' + newNodes.push({ + id: `${r._id}`, + Class: Node, + title: r.ci_type_alias || r.ci_type, + name: r.ci_type, + side: side, + unique_alias, + unique_name, + unique_value: r[unique_name], + children: [], + icon: _findCiType?.icon || '', + endpoints: [ + { + id: 'left', + orientation: [-1, 0], + pos: [0, 0.5], + }, + { + id: 'right', + orientation: [1, 0], + pos: [0, 0.5], + }, + ], + }) + } } newEdges.push({ id: `${r._id}`,