2025-09-01 16:58:54 +08:00
|
|
|
<template>
|
|
|
|
|
<div class="alarm">
|
|
|
|
|
<div class="text_Cur">
|
|
|
|
|
<div v-for="item in curList" :key="item.key">
|
|
|
|
|
<div>{{ item.name }}</div>
|
|
|
|
|
<span class="mark">{{ item.value ? item.value : 0 }}</span>
|
|
|
|
|
<span class="d">{{ item.d }}</span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div id="alarm-chart"></div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2025-09-04 16:04:37 +08:00
|
|
|
import {processData} from '@/utils/dealWithData'
|
2025-09-01 16:58:54 +08:00
|
|
|
export default {
|
|
|
|
|
name: '',
|
|
|
|
|
props: {
|
2025-09-03 13:53:00 +08:00
|
|
|
total:{
|
|
|
|
|
type:Object,
|
|
|
|
|
default:()=>{}
|
|
|
|
|
},
|
2025-09-01 16:58:54 +08:00
|
|
|
deviceInfo: {
|
|
|
|
|
type: Array,
|
|
|
|
|
default: () => []
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
curList: [
|
|
|
|
|
{
|
|
|
|
|
name: '日光伏设备告警',
|
2025-09-04 11:12:20 +08:00
|
|
|
key: 'solar_num_err',
|
2025-09-01 16:58:54 +08:00
|
|
|
lineColor: '#22E4FF',
|
2025-09-03 13:53:00 +08:00
|
|
|
value: 1111,
|
2025-09-01 16:58:54 +08:00
|
|
|
d: ''
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: '日储能设备告警',
|
2025-09-04 11:12:20 +08:00
|
|
|
key: 'storage_num_err',
|
2025-09-01 16:58:54 +08:00
|
|
|
lineColor: '#0E68E4',
|
|
|
|
|
value: 0,
|
|
|
|
|
d: ''
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: '日充电设备告警',
|
2025-09-04 11:12:20 +08:00
|
|
|
key: 'charge_num_err',
|
2025-09-01 16:58:54 +08:00
|
|
|
lineColor: '#00BAAD',
|
|
|
|
|
value: 0,
|
|
|
|
|
d: ''
|
|
|
|
|
},
|
2025-09-04 11:12:20 +08:00
|
|
|
// {
|
|
|
|
|
// name: '日负荷设备告警',
|
|
|
|
|
// key: 'key4',
|
|
|
|
|
// lineColor: '#FF8D1A',
|
|
|
|
|
// value: 0,
|
|
|
|
|
// d: ''
|
|
|
|
|
// }
|
2025-09-01 16:58:54 +08:00
|
|
|
],
|
|
|
|
|
faultChart: null,
|
|
|
|
|
lineChartData: {
|
|
|
|
|
ydata: [],
|
|
|
|
|
xdata: []
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
watch: {
|
|
|
|
|
deviceInfo: {
|
|
|
|
|
handler(n) {
|
2025-09-03 13:53:00 +08:00
|
|
|
let that=this
|
2025-09-01 16:58:54 +08:00
|
|
|
this.$nextTick(() => {
|
2025-09-03 13:53:00 +08:00
|
|
|
|
2025-09-01 16:58:54 +08:00
|
|
|
this.drawLineChart()
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
// immediate: true
|
2025-09-03 13:53:00 +08:00
|
|
|
},
|
|
|
|
|
total:{
|
|
|
|
|
handler(n){
|
|
|
|
|
if(n){
|
|
|
|
|
|
|
|
|
|
let that=this
|
|
|
|
|
that.curList.forEach((item)=>{
|
|
|
|
|
item.value=that.total[item.key]
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
deep: true, // 深度监听
|
|
|
|
|
immediate: true,
|
|
|
|
|
|
2025-09-01 16:58:54 +08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
mounted() {},
|
2025-09-04 11:12:20 +08:00
|
|
|
beforeUnmount() {
|
2025-09-01 16:58:54 +08:00
|
|
|
this.faultChart = null
|
|
|
|
|
window.removeEventListener('resize', this.handleResize)
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
|
handleResize() {
|
|
|
|
|
this.faultChart.resize()
|
|
|
|
|
},
|
2025-09-04 16:04:37 +08:00
|
|
|
|
2025-09-01 16:58:54 +08:00
|
|
|
getChargeData() {
|
|
|
|
|
const arr = this.curList
|
|
|
|
|
const keyList = this.curList.map((item) => item.key)
|
2025-09-04 16:04:37 +08:00
|
|
|
const result = processData(this.deviceInfo, keyList)
|
2025-09-01 16:58:54 +08:00
|
|
|
|
|
|
|
|
this.lineChartData.xdata = result.dates
|
|
|
|
|
arr.forEach((item, index) => {
|
|
|
|
|
this.lineChartData.ydata[index] = {
|
|
|
|
|
name: item.name,
|
|
|
|
|
smooth: true,
|
|
|
|
|
type: 'bar',
|
|
|
|
|
barWidth: 5,
|
|
|
|
|
itemStyle: {
|
|
|
|
|
borderRadius: [5, 5, 0, 0],
|
|
|
|
|
color: item.lineColor
|
|
|
|
|
},
|
|
|
|
|
emphasis: {
|
|
|
|
|
focus: 'series'
|
|
|
|
|
},
|
|
|
|
|
global: false,
|
|
|
|
|
showSymbol: false,
|
|
|
|
|
data: result.values[index]
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
drawLineChart(activeKey) {
|
|
|
|
|
this.getChargeData(activeKey)
|
|
|
|
|
const chartDom = document.getElementById('alarm-chart')
|
|
|
|
|
let faultChart = this.$echarts.init(chartDom)
|
|
|
|
|
this.faultChart = faultChart
|
|
|
|
|
const option = {
|
|
|
|
|
tooltip: {
|
|
|
|
|
trigger: 'axis',
|
|
|
|
|
axisPointer: {
|
|
|
|
|
type: 'shadow'
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
legend: {
|
|
|
|
|
top: 20,
|
|
|
|
|
textStyle: {
|
|
|
|
|
color: '#fff'
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
grid: {
|
|
|
|
|
left: '3%',
|
|
|
|
|
right: '4%',
|
|
|
|
|
bottom: '5%',
|
|
|
|
|
containLabel: true
|
|
|
|
|
},
|
|
|
|
|
xAxis: {
|
|
|
|
|
type: 'category',
|
|
|
|
|
data: this.lineChartData.xdata,
|
|
|
|
|
axisLine: {
|
|
|
|
|
lineStyle: { type: 'dashed', color: '#435463' }
|
|
|
|
|
},
|
|
|
|
|
axisLabel: {
|
|
|
|
|
color: '#fff'
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
yAxis: {
|
|
|
|
|
type: 'value',
|
|
|
|
|
splitLine: {
|
|
|
|
|
lineStyle: { type: 'dashed', color: '#435463' }
|
|
|
|
|
},
|
|
|
|
|
axisLabel: {
|
2025-09-04 11:12:20 +08:00
|
|
|
interval: 4,
|
2025-09-01 16:58:54 +08:00
|
|
|
color: '#fff'
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
series: this.lineChartData.ydata
|
|
|
|
|
}
|
|
|
|
|
option && faultChart.setOption(option)
|
|
|
|
|
window.addEventListener('resize', this.handleResize)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
.alarm {
|
|
|
|
|
height: calc(100% - 45px);
|
|
|
|
|
|
|
|
|
|
#alarm-chart {
|
|
|
|
|
height: calc(100% - 45px);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.text_Cur {
|
|
|
|
|
border-bottom: 1px solid transparent;
|
|
|
|
|
border-top: 1px solid transparent;
|
|
|
|
|
border-image: linear-gradient(to right, transparent, #1d8a7b, transparent) 1;
|
|
|
|
|
padding: 0px 15px;
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
margin: 3px 0px;
|
|
|
|
|
height: 45px;
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
|
|
|
|
.mark {
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
margin-right: 2px;
|
|
|
|
|
}
|
|
|
|
|
& > div:nth-child(2),
|
|
|
|
|
& > div:nth-child(3) {
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
align-items: center;
|
|
|
|
|
}
|
|
|
|
|
& > div:last-child{
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
align-items: end;
|
|
|
|
|
}
|
|
|
|
|
background: linear-gradient(
|
|
|
|
|
90deg,
|
|
|
|
|
rgba(0, 186, 173, 0.15) 0%,
|
|
|
|
|
rgba(61, 254, 250, 0.15) 49.2%,
|
|
|
|
|
rgba(61, 254, 250, 0) 100%
|
|
|
|
|
);
|
|
|
|
|
.d {
|
|
|
|
|
margin-left: 1px;
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|