feat: 蜂窝图popover弹窗宽度动态适应优化
This commit is contained in:
@@ -49,7 +49,7 @@
|
|||||||
trigger="hover"
|
trigger="hover"
|
||||||
popper-class="link-block__popper"
|
popper-class="link-block__popper"
|
||||||
v-for="(item, index) in linkData"
|
v-for="(item, index) in linkData"
|
||||||
:width="285"
|
:width="item.popverWidth"
|
||||||
:key="index"
|
:key="index"
|
||||||
>
|
>
|
||||||
<template #reference>
|
<template #reference>
|
||||||
@@ -100,7 +100,7 @@
|
|||||||
trigger="hover"
|
trigger="hover"
|
||||||
popper-class="link-block__popper"
|
popper-class="link-block__popper"
|
||||||
v-for="(item, index) in nextHopData"
|
v-for="(item, index) in nextHopData"
|
||||||
:width="285"
|
:width="item.popverWidth"
|
||||||
:key="index"
|
:key="index"
|
||||||
>
|
>
|
||||||
<template #reference>
|
<template #reference>
|
||||||
@@ -258,19 +258,11 @@ export default {
|
|||||||
s.color = colors[i]
|
s.color = colors[i]
|
||||||
s.egressUsage = this.computeUsage(s.egressBytes, s.egressBandwidth)
|
s.egressUsage = this.computeUsage(s.egressBytes, s.egressBandwidth)
|
||||||
s.ingressUsage = this.computeUsage(s.ingressBytes, s.ingressBandwidth)
|
s.ingressUsage = this.computeUsage(s.ingressBytes, s.ingressBandwidth)
|
||||||
/*const ingressLink = linkInfo.find(l => l.linkId === s.linkId && l.direction === 'ingress')
|
s.popverWidth = this.computePopoverWidth(s.egressUsage, s.ingressUsage)
|
||||||
const egressLink = linkInfo.find(l => l.linkId === s.linkId && l.direction === 'egress')
|
|
||||||
if (ingressLink && egressLink) {
|
|
||||||
// 上行使用情况计算
|
|
||||||
const egressUsage = this.computeUsage(s.egressBytes, egressLink.bandwidth)
|
|
||||||
// 下行使用情况计算
|
|
||||||
const ingressUsage = this.computeUsage(s.ingressBytes, ingressLink.bandwidth)
|
|
||||||
s.egressUsage = egressUsage
|
|
||||||
s.ingressUsage = ingressUsage
|
|
||||||
}*/
|
|
||||||
})
|
})
|
||||||
this.linkData = sorted
|
this.linkData = sorted
|
||||||
|
|
||||||
|
// 下一跳数据处理
|
||||||
const nextHopSorted = nextHopData.sort((a, b) => b.totalBitsRate - a.totalBitsRate)
|
const nextHopSorted = nextHopData.sort((a, b) => b.totalBitsRate - a.totalBitsRate)
|
||||||
|
|
||||||
nextHopSorted.forEach((s, i) => {
|
nextHopSorted.forEach((s, i) => {
|
||||||
@@ -278,6 +270,7 @@ export default {
|
|||||||
|
|
||||||
let sum = 0
|
let sum = 0
|
||||||
linkInfo.forEach((item) => {
|
linkInfo.forEach((item) => {
|
||||||
|
// todo 此处需注意,不明确接口返回的方向字段名是拼音还是汉字,后期可能会变动缓存中的nextHop
|
||||||
if (s.linkDirection === item.nextHop) {
|
if (s.linkDirection === item.nextHop) {
|
||||||
sum += item.bandwidth
|
sum += item.bandwidth
|
||||||
}
|
}
|
||||||
@@ -289,6 +282,7 @@ export default {
|
|||||||
const ingressUsage = this.computeUsage(s.ingressBytes, sum)
|
const ingressUsage = this.computeUsage(s.ingressBytes, sum)
|
||||||
s.egressUsage = egressUsage
|
s.egressUsage = egressUsage
|
||||||
s.ingressUsage = ingressUsage
|
s.ingressUsage = ingressUsage
|
||||||
|
s.popverWidth = this.computePopoverWidth(egressUsage, ingressUsage)
|
||||||
})
|
})
|
||||||
|
|
||||||
this.nextHopData = nextHopSorted
|
this.nextHopData = nextHopSorted
|
||||||
@@ -312,6 +306,25 @@ export default {
|
|||||||
}
|
}
|
||||||
return usage
|
return usage
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* 计算popover弹窗的宽度
|
||||||
|
* 最小宽度为252px,百分比每大一位,popover弹窗宽度增加7px
|
||||||
|
*/
|
||||||
|
computePopoverWidth (egress, ingress) {
|
||||||
|
let width = 252
|
||||||
|
let length = 0
|
||||||
|
|
||||||
|
// 将上下行乘100保留2位转换,即10.00为5位,100.00为6位,popover弹窗宽度就增加7px
|
||||||
|
// 最小宽度为252px,最少位数为上下行相加为8位
|
||||||
|
const egressUsage = (egress * 100).toFixed(2)
|
||||||
|
const ingressUsage = (ingress * 100).toFixed(2)
|
||||||
|
length = egressUsage.length + ingressUsage.length
|
||||||
|
|
||||||
|
if (length > 8) {
|
||||||
|
width = 252 + (length - 8) * 7
|
||||||
|
}
|
||||||
|
return width
|
||||||
|
},
|
||||||
drillLinkId (item) {
|
drillLinkId (item) {
|
||||||
const queryCondition = `common_egress_link_id = ${item.egressLinkId} AND common_ingress_link_id = ${item.ingressLinkId}`
|
const queryCondition = `common_egress_link_id = ${item.egressLinkId} AND common_ingress_link_id = ${item.ingressLinkId}`
|
||||||
this.jumpAndCache(this.$route.path, {
|
this.jumpAndCache(this.$route.path, {
|
||||||
|
|||||||
Reference in New Issue
Block a user