2021-03-19 18:52:19 +08:00
|
|
|
|
export function resetZIndex (e) {
|
|
|
|
|
|
let popId = e.target.getAttribute('aria-describedby')// 这里获取的属性 在包含slot='reference'
|
|
|
|
|
|
if (!popId) {
|
|
|
|
|
|
popId = e.target.parentNode.getAttribute('aria-describedby')
|
2020-03-04 20:30:25 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
const pop = document.getElementById(popId)
|
|
|
|
|
|
setTimeout(function () {
|
|
|
|
|
|
pop.style.zIndex = 999999
|
|
|
|
|
|
}, 100)
|
|
|
|
|
|
}
|
|
|
|
|
|
export function getUUID () {
|
|
|
|
|
|
function S4 () {
|
2021-05-14 16:44:54 +08:00
|
|
|
|
return (((1 + window.crypto.getRandomValues(new Uint32Array(10))[0]) * 0x10000) | 0).toString(16).substring(1)
|
2020-04-28 17:39:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
|
return (S4() + S4() + '-' + S4() + '-' + S4() + '-' + S4() + '-' + S4() + S4() + S4())
|
2020-04-28 17:39:54 +08:00
|
|
|
|
}
|
2020-09-25 11:48:54 +08:00
|
|
|
|
|
2022-07-13 15:07:13 +08:00
|
|
|
|
export const chartCache = {}
|
2020-09-25 11:48:54 +08:00
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
|
export function getChart (key) {
|
|
|
|
|
|
return chartCache[`chart${key}`]
|
2020-09-25 11:48:54 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
|
export function setChart (key, value) {
|
2021-11-29 15:43:07 +08:00
|
|
|
|
chartCache[`chart${key}`] && chartCache[`chart${key}`].dispose()
|
2021-03-19 18:52:19 +08:00
|
|
|
|
chartCache[`chart${key}`] = value
|
2020-09-25 11:48:54 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
const hexagonCache = {}
|
|
|
|
|
|
export function getHexagon (key) {
|
|
|
|
|
|
return hexagonCache[`hexagon${key}`]
|
2020-12-11 16:44:20 +08:00
|
|
|
|
}
|
2020-09-29 09:25:43 +08:00
|
|
|
|
|
2022-07-13 15:07:13 +08:00
|
|
|
|
export let topologyCache = {}
|
2021-01-04 18:33:25 +08:00
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
|
export function getTopology (key) {
|
2022-04-19 15:33:19 +08:00
|
|
|
|
// console.log(topologyCache, 'topologyCache')
|
2021-03-19 18:52:19 +08:00
|
|
|
|
return topologyCache[`topology${key}`]
|
2021-01-04 18:33:25 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
|
export function setTopology (key, value) {
|
|
|
|
|
|
topologyCache[`topology${key}`] = value
|
2021-01-04 18:33:25 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-07-13 15:07:13 +08:00
|
|
|
|
export function clearTopologyCache () {
|
|
|
|
|
|
topologyCache = {}
|
|
|
|
|
|
}
|
2022-04-19 15:33:19 +08:00
|
|
|
|
// const topologyImgList = localStorage.getItem('nz-imgList') ? JSON.parse(localStorage.getItem('nz-imgList')) : {}
|
|
|
|
|
|
|
|
|
|
|
|
export function getTopologyImg (key) {
|
2022-07-13 15:07:13 +08:00
|
|
|
|
return false
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export const topologyImg = {}
|
|
|
|
|
|
|
|
|
|
|
|
export function dealImg (url, id) {
|
|
|
|
|
|
if (url) {
|
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
|
if (topologyImg['img' + id]) {
|
|
|
|
|
|
resolve(topologyImg['img' + id])
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
vm.$axios
|
|
|
|
|
|
.get(url)
|
|
|
|
|
|
.then((res) => {
|
|
|
|
|
|
const imageInfo = {
|
|
|
|
|
|
data: ('data:image/jpeg;base64,' + res.data),
|
|
|
|
|
|
// width: res.headers.width === -1 ? 100 : (res.headers.width > 900 ? 900 : res.headers.width),
|
|
|
|
|
|
// height: res.headers.height === -1 ? 100 : (res.headers.height > 900 ? 900 : res.headers.height)
|
|
|
|
|
|
width: res.headers.width === -1 ? 100 : Number(res.headers.width),
|
|
|
|
|
|
height: res.headers.height === -1 ? 100 : Number(res.headers.height)
|
|
|
|
|
|
}
|
|
|
|
|
|
if (imageInfo.width > 900 || imageInfo.height > 900) {
|
|
|
|
|
|
if (imageInfo.height > imageInfo.width) {
|
|
|
|
|
|
imageInfo.width = imageInfo.width * 900 / imageInfo.height
|
|
|
|
|
|
imageInfo.height = 900
|
|
|
|
|
|
} else if (imageInfo.height < imageInfo.width) {
|
|
|
|
|
|
imageInfo.height = imageInfo.height * 900 / imageInfo.width
|
|
|
|
|
|
imageInfo.width = 900
|
|
|
|
|
|
} else {
|
|
|
|
|
|
imageInfo.height = 900
|
|
|
|
|
|
imageInfo.width = 900
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
topologyImg['img' + id] = imageInfo
|
|
|
|
|
|
resolve(topologyImg['img' + id])
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
} else {
|
|
|
|
|
|
return new Promise(resolve => {
|
|
|
|
|
|
resolve({})
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
2022-04-19 15:33:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export function setTopologyImg (key, img) {
|
2022-07-13 15:07:13 +08:00
|
|
|
|
// localStorage.setItem('nz-topologyImg-' + key, img)
|
2022-04-19 15:33:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
|
export function setHexagon (key, value) {
|
|
|
|
|
|
hexagonCache[`hexagon${key}`] = value
|
|
|
|
|
|
}
|
|
|
|
|
|
export function delHexagon (key) {
|
|
|
|
|
|
delete hexagonCache[`hexagon${key}`]
|
2020-12-11 16:44:20 +08:00
|
|
|
|
}
|
2021-03-19 18:52:19 +08:00
|
|
|
|
const mousePoint = { // 在echart tooltip中获取不到鼠标在窗口的位置,在火狐没有window。event 在此兼容火狐 获取鼠标在窗口位置
|
|
|
|
|
|
x: '',
|
|
|
|
|
|
y: ''
|
2020-12-11 16:44:20 +08:00
|
|
|
|
}
|
2020-09-29 09:25:43 +08:00
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
|
export function lineChartMove (e) {
|
|
|
|
|
|
const event = e || window.event
|
|
|
|
|
|
mousePoint.x = event.pageX
|
|
|
|
|
|
mousePoint.y = event.pageY
|
2020-09-29 09:25:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-03-19 18:52:19 +08:00
|
|
|
|
export function getMousePoint () {
|
2020-09-29 09:25:43 +08:00
|
|
|
|
return mousePoint
|
|
|
|
|
|
}
|