2022-07-08 09:34:09 +08:00
|
|
|
<template>
|
|
|
|
|
<div class="performance-event">
|
2022-07-14 17:07:07 +08:00
|
|
|
<div class="performance-event-title"><i class="cn-icon cn-icon-a-NetworkPerformanceEvent"></i>{{$t('network.networkPerEvent')}}</div>
|
|
|
|
|
<div class="performance-event-value">
|
|
|
|
|
<div class="performance-event-pie">
|
2022-08-10 09:24:53 +08:00
|
|
|
<chart-no-data v-if="isNoData"></chart-no-data>
|
|
|
|
|
<div class="chart-drawing" id="chart1" v-else></div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="performance-event-pie-hr"></div>
|
|
|
|
|
<div class="performance-event-pie">
|
|
|
|
|
<chart-no-data v-if="isNoData2"></chart-no-data>
|
|
|
|
|
<div class="chart-drawing" id="chart2" v-else></div>
|
2022-07-14 17:07:07 +08:00
|
|
|
</div>
|
2022-07-08 09:34:09 +08:00
|
|
|
</div>
|
2022-08-10 09:24:53 +08:00
|
|
|
<el-button class="pie-button" size="small">{{$t('network.dashboards')}}<i class="cn-icon cn-icon-arrow-right"></i></el-button>
|
2022-07-08 09:34:09 +08:00
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2022-07-14 17:07:07 +08:00
|
|
|
import { pieChartOption1, pieChartOption2 } from '@/views/charts2/charts/options/echartOption.js'
|
2022-07-08 09:34:09 +08:00
|
|
|
import * as echarts from 'echarts'
|
2022-07-11 16:36:11 +08:00
|
|
|
import { shallowRef } from 'vue'
|
2022-08-04 10:26:11 +08:00
|
|
|
import { get } from '@/utils/http'
|
|
|
|
|
import { api } from '@/utils/api'
|
2022-08-05 17:50:06 +08:00
|
|
|
import { getSecond } from '@/utils/date-util'
|
2022-08-10 09:24:53 +08:00
|
|
|
import ChartNoData from '@/views/charts/charts/ChartNoData'
|
2022-07-08 09:34:09 +08:00
|
|
|
export default {
|
|
|
|
|
name: 'NetworkOverviewPerformanceEvent',
|
2022-07-11 16:36:11 +08:00
|
|
|
setup () {
|
|
|
|
|
return {
|
|
|
|
|
myChart: shallowRef(null),
|
|
|
|
|
myChart2: shallowRef(null)
|
|
|
|
|
}
|
|
|
|
|
},
|
2022-08-04 10:26:11 +08:00
|
|
|
props: {
|
|
|
|
|
timeFilter: Object
|
|
|
|
|
},
|
2022-08-10 09:24:53 +08:00
|
|
|
components: {
|
|
|
|
|
ChartNoData
|
|
|
|
|
},
|
2022-07-08 09:34:09 +08:00
|
|
|
data () {
|
|
|
|
|
return {
|
2022-08-10 09:24:53 +08:00
|
|
|
timer: null,
|
|
|
|
|
isNoData: false,
|
|
|
|
|
isNoData2: false
|
2022-07-08 09:34:09 +08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
init () {
|
2022-08-04 10:26:11 +08:00
|
|
|
const params = {
|
2022-08-05 17:50:06 +08:00
|
|
|
startTime: getSecond(this.timeFilter.startTime),
|
|
|
|
|
endTime: getSecond(this.timeFilter.endTime)
|
2022-08-04 10:26:11 +08:00
|
|
|
}
|
2022-07-11 16:36:11 +08:00
|
|
|
const dom = document.getElementById('chart1')
|
2022-07-08 09:34:09 +08:00
|
|
|
const dom2 = document.getElementById('chart2')
|
2022-07-11 16:36:11 +08:00
|
|
|
if (dom) {
|
|
|
|
|
this.myChart = echarts.init(dom)
|
|
|
|
|
this.chartOption = pieChartOption1
|
2022-08-04 10:26:11 +08:00
|
|
|
get(api.netWorkOverview.eventSeverity, params).then(res => {
|
|
|
|
|
if (res.code === 200) {
|
2022-08-10 09:24:53 +08:00
|
|
|
// res.data.result.length = 0
|
|
|
|
|
if (res.data.result.length === 0) {
|
|
|
|
|
this.isNoData = true
|
|
|
|
|
return
|
|
|
|
|
}
|
2022-08-04 10:26:11 +08:00
|
|
|
res.data.result = res.data.result.map(t => {
|
|
|
|
|
return {
|
2022-08-05 17:50:06 +08:00
|
|
|
name: t.eventSeverity,
|
|
|
|
|
value: t.count
|
2022-08-04 10:26:11 +08:00
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
if (res.data.result.length <= 0) {
|
|
|
|
|
this.chartOption.legend.show = false
|
|
|
|
|
} else {
|
|
|
|
|
this.chartOption.legend.show = true
|
|
|
|
|
}
|
|
|
|
|
this.chartOption.series[0].data = res.data.result
|
|
|
|
|
this.myChart.setOption(this.chartOption)
|
|
|
|
|
}
|
|
|
|
|
})
|
2022-07-11 16:36:11 +08:00
|
|
|
}
|
|
|
|
|
if (dom2) {
|
|
|
|
|
this.myChart2 = echarts.init(dom2)
|
|
|
|
|
this.chartOption2 = pieChartOption2
|
2022-08-05 17:50:06 +08:00
|
|
|
get(api.netWorkOverview.eventType, params).then(res => {
|
2022-08-04 10:26:11 +08:00
|
|
|
if (res.code === 200) {
|
2022-08-10 09:24:53 +08:00
|
|
|
// res.data.result.length = 0
|
|
|
|
|
if (res.data.result.length === 0) {
|
|
|
|
|
this.isNoData2 = true
|
|
|
|
|
return
|
|
|
|
|
}
|
2022-08-04 10:26:11 +08:00
|
|
|
res.data.result = res.data.result.map(t => {
|
|
|
|
|
return {
|
2022-08-05 17:50:06 +08:00
|
|
|
name: t.eventType,
|
|
|
|
|
value: t.count
|
2022-08-04 10:26:11 +08:00
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
if (res.data.result.length <= 0) {
|
|
|
|
|
this.chartOption2.legend.show = false
|
|
|
|
|
} else {
|
|
|
|
|
this.chartOption2.legend.show = true
|
|
|
|
|
}
|
|
|
|
|
this.chartOption2.series[0].data = res.data.result
|
|
|
|
|
this.myChart2.setOption(this.chartOption2)
|
|
|
|
|
}
|
|
|
|
|
})
|
2022-07-11 16:36:11 +08:00
|
|
|
}
|
2022-07-14 17:15:34 +08:00
|
|
|
},
|
|
|
|
|
resize () {
|
|
|
|
|
this.myChart.resize()
|
|
|
|
|
this.myChart2.resize()
|
2022-07-08 09:34:09 +08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
mounted () {
|
2022-07-14 17:07:07 +08:00
|
|
|
this.timer = setTimeout(() => {
|
|
|
|
|
this.init()
|
|
|
|
|
}, 100)
|
2022-07-14 17:15:34 +08:00
|
|
|
window.addEventListener('resize', this.resize)
|
2022-07-14 17:07:07 +08:00
|
|
|
},
|
|
|
|
|
beforeUnmount () {
|
|
|
|
|
clearTimeout(this.timer)
|
2022-07-08 09:34:09 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|