fix: ci topo expand error

This commit is contained in:
songlh 2024-06-06 14:05:32 +08:00
parent 104d163db8
commit 5033c539de
2 changed files with 32 additions and 30 deletions

View File

@ -269,7 +269,7 @@ export default {
return { nodes, edges } return { nodes, edges }
}, },
exsited_ci() { exsited_ci() {
const _exsited_ci = [this.typeId] const _exsited_ci = [this.ciId]
this.parentCITypes.forEach((parent) => { this.parentCITypes.forEach((parent) => {
if (this.firstCIs[parent.name]) { if (this.firstCIs[parent.name]) {
this.firstCIs[parent.name].forEach((parentCi) => { this.firstCIs[parent.name].forEach((parentCi) => {

View File

@ -100,35 +100,37 @@ export default {
const r = res.result[i] const r = res.result[i]
if (!this.exsited_ci.includes(r._id)) { if (!this.exsited_ci.includes(r._id)) {
const _findCiType = ci_types_list.find((item) => item.id === r._type) const _findCiType = ci_types_list.find((item) => item.id === r._type)
const { attributes } = await getCITypeAttributesById(_findCiType.id) if (_findCiType) {
const unique_id = _findCiType.show_id || _findCiType.unique_id const { attributes } = await getCITypeAttributesById(_findCiType.id)
const _findUnique = attributes.find((attr) => attr.id === unique_id) const unique_id = _findCiType.show_id || _findCiType.unique_id
const unique_name = _findUnique?.name const _findUnique = attributes.find((attr) => attr.id === unique_id)
const unique_alias = _findUnique?.alias || _findUnique?.name || '' const unique_name = _findUnique?.name
newNodes.push({ const unique_alias = _findUnique?.alias || _findUnique?.name || ''
id: `${r._id}`, newNodes.push({
Class: Node, id: `${r._id}`,
title: r.ci_type_alias || r.ci_type, Class: Node,
name: r.ci_type, title: r.ci_type_alias || r.ci_type,
side: side, name: r.ci_type,
unique_alias, side: side,
unique_name, unique_alias,
unique_value: r[unique_name], unique_name,
children: [], unique_value: r[unique_name],
icon: _findCiType?.icon || '', children: [],
endpoints: [ icon: _findCiType?.icon || '',
{ endpoints: [
id: 'left', {
orientation: [-1, 0], id: 'left',
pos: [0, 0.5], orientation: [-1, 0],
}, pos: [0, 0.5],
{ },
id: 'right', {
orientation: [1, 0], id: 'right',
pos: [0, 0.5], orientation: [1, 0],
}, pos: [0, 0.5],
], },
}) ],
})
}
} }
newEdges.push({ newEdges.push({
id: `${r._id}`, id: `${r._id}`,