This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
nezha-nezha-fronted/nezha-fronted/src/components/common/mixin/beforeMeta2d.js

78 lines
2.0 KiB
JavaScript

export default {
data () {
return {
topoData: {},
querysArray: [],
meta2dType: '',
params: {},
iconArray: [],
iconArrayLoad: false
}
},
watch: {
currentProject: {
handler (n) {
this.reload()
}
},
chart: {}
},
methods: {
reload (isRefresh) {
if (this.currentProject && this.currentProject.id) {
this.$get('monitor/project/topo', { projectId: this.currentProject.id }).then(res => {
if (res.data && res.data.topo) {
this.topoData = res.data.topo || {}
if (res.data.topo.topo) {
this.topoData = res.data.topo.topo || {}
}
this.querysArray = res.data.topo.elements || []
this.params = {
timeType: res.data.topo.timeType || 5
}
} else {
this.topoData = {}
this.querysArray = []
this.params = {
timeType: 5
}
}
})
} else if (this.isChart) {
const res = {
data: this.chartInfo.param
}
if (isRefresh) {
this.$get('/visual/dashboard/chart/' + this.chartInfo.id).then(response => {
res.data = JSON.parse(response.data.param)
console.log(res.data)
this.topoInit(res)
this.chartInfo.param.topo = res.data.topo
this.$refs.diagram && this.$refs.diagram.reload()
})
} else {
this.topoInit(res)
}
}
},
topoInit (res) {
if (res.data && res.data.topo) {
this.topoData = res.data.topo || {}
if (res.data.topo.topo) {
this.topoData = res.data.topo.topo || {}
}
this.querysArray = res.data.topo.elements || []
this.params = {
timeType: res.data.topo.timeType || 5
}
} else {
this.topoData = {}
this.querysArray = []
this.params = {
timeType: 5
}
}
}
}
}