diff --git a/nezha-fronted/src/components/common/ChartDiagram/diagram.vue b/nezha-fronted/src/components/common/ChartDiagram/diagram.vue index 53194265a..f063fe4e7 100644 --- a/nezha-fronted/src/components/common/ChartDiagram/diagram.vue +++ b/nezha-fronted/src/components/common/ChartDiagram/diagram.vue @@ -825,6 +825,8 @@ export default { getTopology(this.topologyIndex).on('scale', this.topoScale) // 缩放· getTopology(this.topologyIndex).on('translatePens', () => {}) // 移动画笔结束· getTopology(this.topologyIndex).on('translatingPens', () => {}) // 移动画笔进行中· + getTopology(this.topologyIndex).on('enter', this.penEnter) // 移入画笔· + getTopology(this.topologyIndex).on('leave', this.penLeave) // 移出画笔· getTopology(this.topologyIndex).on('add', this.appPen) // 添加新画笔· getTopology(this.topologyIndex).on('click', this.topoClick) // click画笔· getTopology(this.topologyIndex).store.options.autoAnchor = true diff --git a/nezha-fronted/src/components/common/project/topologyL5.vue b/nezha-fronted/src/components/common/project/topologyL5.vue index 60cf6865d..f2b34654e 100644 --- a/nezha-fronted/src/components/common/project/topologyL5.vue +++ b/nezha-fronted/src/components/common/project/topologyL5.vue @@ -830,6 +830,8 @@ export default { getTopology(this.topologyIndex).on('scale', this.topoScale) // 缩放· getTopology(this.topologyIndex).on('translatePens', () => {}) // 移动画笔结束· getTopology(this.topologyIndex).on('translatingPens', () => {}) // 移动画笔进行中· + getTopology(this.topologyIndex).on('enter', this.penEnter) // 移入画笔· + getTopology(this.topologyIndex).on('leave', this.penLeave) // 移出画笔· getTopology(this.topologyIndex).on('add', this.appPen) // 添加新画笔· getTopology(this.topologyIndex).on('click', this.topoClick) // click画笔· getTopology(this.topologyIndex).store.options.autoAnchor = true diff --git a/nezha-fronted/src/components/common/project/topologyMixin.js b/nezha-fronted/src/components/common/project/topologyMixin.js index c43640be7..b30001a92 100644 --- a/nezha-fronted/src/components/common/project/topologyMixin.js +++ b/nezha-fronted/src/components/common/project/topologyMixin.js @@ -178,6 +178,7 @@ export default { }, topoClick (pointAndPen) { this.showNodeTools('') + this.tooltipPosition.show = false if (!pointAndPen.pen) { this.props = { node: null, @@ -191,6 +192,53 @@ export default { } } }, + penEnter (pen) { + if (this.timer3) { + clearTimeout(this.timer3) + this.timer3 = null + } + this.chartData = { ...pen.data, ...this.chartGetData.find(item => item.id === pen.id) } + this.tooltipPosition.show = false + const timer = setTimeout(() => { + this.tooltipPosition.show = true + let ePosition = window.ePosition + let boxWidth = document.getElementsByClassName('page')[0].offsetWidth + let boxHeight = document.getElementsByClassName('page')[0].offsetHeight + this.tooltipPosition.left = ePosition.layerX + 20 + this.tooltipPosition.top = ePosition.layerY + this.$nextTick(() => { + if (this.$refs.topoTooltip) { + if ((boxWidth / 2) > ePosition.layerX) { + this.tooltipPosition.left = ePosition.layerX + 20 + } else { + this.tooltipPosition.left = ePosition.layerX - 20 - this.$refs.topoTooltip.offsetWidth + } + if (boxHeight > (ePosition.layerY + this.$refs.topoTooltip.offsetHeight)) { + this.tooltipPosition.top = ePosition.layerY + } else { + this.tooltipPosition.top = ePosition.layerY - this.$refs.topoTooltip.offsetHeight + } + } + ePosition = null + boxWidth = null + boxHeight = null + }) + clearTimeout(timer) + }, 100) + }, + penLeave (pen) { + if (!this.timer3) { + this.timer3 = setTimeout(() => { + this.tooltipPosition.show = false + this.timer3 = null + }, 50) + } else { + this.timer3 = setTimeout(() => { + this.tooltipPosition.show = false + this.timer3 = null + }, 50) + } + }, toCenter () { if (getTopology(this.topologyIndex)) { getTopology(this.topologyIndex).resize()