From 61c2259cdd539c70db4a22c0a35447f539a08f2a Mon Sep 17 00:00:00 2001 From: zhangyu Date: Sun, 26 Sep 2021 12:56:50 +0800 Subject: [PATCH] =?UTF-8?q?NEZ-1029=20fix=EF=BC=9A=20topology=20bug?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/ChartDiagram/diagram.vue | 64 +++++++++---------- .../components/common/project/topologyL5.vue | 46 +++++++------ 2 files changed, 57 insertions(+), 53 deletions(-) diff --git a/nezha-fronted/src/components/common/ChartDiagram/diagram.vue b/nezha-fronted/src/components/common/ChartDiagram/diagram.vue index 1de3e3277..25b548a08 100644 --- a/nezha-fronted/src/components/common/ChartDiagram/diagram.vue +++ b/nezha-fronted/src/components/common/ChartDiagram/diagram.vue @@ -21,7 +21,7 @@
@@ -738,10 +738,9 @@ export default { // } // getTopology(this.topologyIndex).fitView(); this.oldTopologyData = JSON.stringify(getTopology(this.topologyIndex).data) - this.winResize() + this.getNodesArr() }) } - this.winResize() }) }) }, @@ -1573,42 +1572,40 @@ export default { if (res.code == 200) { this.$message({ duration: 2000, type: 'success', message: this.$t('tip.saveSuccess') }) this.uploadPicShow = false - this.dealImg(`monitor/project/topo/icon/${res.data.id}/1`).then((data, header) => { - const group = this.tools.find(tool => tool.group === this.uploadPic.unit) - if (group) { - group.children.push({ - ...imageTemp2, - data: { - ...imageTemp2.data, - text: res.data.imageName, - image: data.data, - imageId: res.data.id, - unit: this.uploadPic.unit, - rect: { - width: data.width, - height: data.height - } - } + this.$get('monitor/project/topo/icon', { id: res.data.id }).then(iconInfo => { + this.dealImg(`monitor/project/topo/icon/${res.data.id}/1`).then((data, header) => { + const group = this.tools.find(tool => tool.group === this.uploadPic.unit) + this.iconArray.push({ + ...iconInfo.data.list[0], + image: data }) - } else { - this.tools.push({ - group: this.uploadPic.unit, - children: [{ + if (group) { + group.children.push({ ...imageTemp2, data: { ...imageTemp2.data, text: res.data.imageName, - image: data.data, + image: data, imageId: res.data.id, - unit: this.uploadPic.unit, - rect: { - width: data.width, - height: data.height - } + unit: this.uploadPic.unit } - }] - }) - } + }) + } else { + this.tools.push({ + group: this.uploadPic.unit, + children: [{ + ...imageTemp2, + data: { + ...imageTemp2.data, + text: res.data.imageName, + image: data, + imageId: res.data.id, + unit: this.uploadPic.unit + } + }] + }) + } + }) }) } else { this.$message.error(res.msg) @@ -1732,6 +1729,7 @@ export default { imgArr.push({ ...item }) }) Promise.all(promiseArr).then((res2, header) => { + // console.log(res2) this.iconArray = [...res.data.list] this.iconArray.forEach((item, index) => { item.image = res2[index].data @@ -2052,7 +2050,7 @@ export default { winResize () { setTimeout(() => { - const domRect = getTopology(this.topologyIndex).divLayer.canvas.getBoundingClientRect() + const domRect = document.getElementById('topology-canvas' + this.topologyIndex).getBoundingClientRect() getTopology(this.topologyIndex).canvasPos = domRect if (this.fromOverView) { getTopology(this.topologyIndex).open(this.oldTopologyData) diff --git a/nezha-fronted/src/components/common/project/topologyL5.vue b/nezha-fronted/src/components/common/project/topologyL5.vue index e94cbeab0..3ae46332d 100644 --- a/nezha-fronted/src/components/common/project/topologyL5.vue +++ b/nezha-fronted/src/components/common/project/topologyL5.vue @@ -1138,7 +1138,7 @@ export default { onMessage (event, data, e) { // console.log('onMessage', event, data) // console.log(getTopology(this.topologyIndex)) - // this.notModuleIDArr=[]; + this.notModuleIDArr = [] // this.toolShow.attr = false // this.toolShow.topTool = false // this.$nextTick(() => { @@ -1583,23 +1583,15 @@ export default { if (res.code == 200) { this.$message({ duration: 2000, type: 'success', message: this.$t('tip.saveSuccess') }) this.uploadPicShow = false - this.dealImg(`monitor/project/topo/icon/${res.data.id}/1`).then((data, header) => { - const group = this.tools.find(tool => tool.group === this.uploadPic.unit) - if (group) { - group.children.push({ - ...imageTemp, - data: { - ...imageTemp.data, - text: res.data.imageName, - image: data, - imageId: res.data.id, - unit: this.uploadPic.unit - } + this.$get('monitor/project/topo/icon', { id: res.data.id }).then(iconInfo => { + this.dealImg(`monitor/project/topo/icon/${res.data.id}/1`).then((data, header) => { + const group = this.tools.find(tool => tool.group === this.uploadPic.unit) + this.iconArray.push({ + ...iconInfo.data.list[0], + image: data }) - } else { - this.tools.push({ - group: this.uploadPic.unit, - children: [{ + if (group) { + group.children.push({ ...imageTemp, data: { ...imageTemp.data, @@ -1608,9 +1600,23 @@ export default { imageId: res.data.id, unit: this.uploadPic.unit } - }] - }) - } + }) + } else { + this.tools.push({ + group: this.uploadPic.unit, + children: [{ + ...imageTemp, + data: { + ...imageTemp.data, + text: res.data.imageName, + image: data, + imageId: res.data.id, + unit: this.uploadPic.unit + } + }] + }) + } + }) }) } else { this.$message.error(res.msg)