Files
emsfront/src/views/ems/dzjk/tjbb/glqx/index.vue

141 lines
3.5 KiB
Vue
Raw Normal View History

<template>
2025-07-10 21:14:35 +08:00
<div v-loading="loading">
<div class="select-container">
<el-form :inline="true">
<el-form-item label="时间选择">
<el-date-picker
v-model="dateRange"
type="daterange"
range-separator="至"
start-placeholder="开始时间"
:picker-options="pickerOptions"
:default-value="defaultDateRange"
end-placeholder="结束时间">
</el-date-picker>
</el-form-item>
<el-form-item>
2025-06-24 22:48:33 +08:00
<el-button type="primary" @click="onSearch" native-type="button">搜索</el-button>
</el-form-item>
<el-form-item>
<el-button @click="onReset" native-type="button">重置</el-button>
</el-form-item>
</el-form>
</div>
<div style="margin:30px 0;">
<div id="glqxEchart" style="height:360px;"></div>
</div>
</div>
</template>
<script>
import * as echarts from 'echarts'
import resize from "@/mixins/ems/resize";
2025-07-09 23:52:19 +08:00
import getQuerySiteId from "@/mixins/ems/getQuerySiteId";
import {getPcsNameList, getPowerData} from "@/api/ems/dzjk";
import {formatDate} from "@/filters/ems";
export default {
name:'DzjkTjbbGlqx',
2025-07-09 23:52:19 +08:00
mixins: [resize,getQuerySiteId],
data() {
return {
pickerOptions:{
disabledDate(time) {
return time.getTime() > Date.now();
},
},
defaultDateRange:[],//默认展示的时间
dateRange:[],
loading:false,
}
},
methods: {
// 搜索
onSearch(){
this.getData()
},
// 重置
onReset(){
this.dateRange=[]
this.getData()
},
getData(){
2025-09-14 23:33:53 +08:00
const {siteId}=this;
2025-07-09 23:52:19 +08:00
const [start='',end='']=(this.dateRange || [])
//接口调用完成之后 设置图表、结束loading
2025-07-09 23:52:19 +08:00
this.loading=true;
2025-09-14 23:33:53 +08:00
getPowerData({siteId,startDate:formatDate(start),endDate:formatDate(end)}).then(response => {
2025-07-09 23:52:19 +08:00
this.setOption(response?.data || [])
}).finally(()=>{this.loading=false;})
},
2025-07-09 23:52:19 +08:00
setOption(data) {
2025-09-14 23:33:53 +08:00
const source = [['日期','电网功率','负载功率','储能功率','光伏功率']]
data.forEach(item=>{
source.push([item.statisDate,item.gridPower,item.loadPower,item.storagePower,item.pvPower])
2025-07-09 23:52:19 +08:00
})
this.chart.setOption({
2025-08-13 14:51:26 +08:00
grid: {
containLabel: true
},
legend: {
left: 'center',
2025-08-13 14:51:26 +08:00
bottom: '15',
},
tooltip: {
trigger: 'axis',
axisPointer: { // 坐标轴指示器,坐标轴触发有效
type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
}
},
textStyle:{
color:"#333333",
},
xAxis: {
2025-07-09 23:52:19 +08:00
type: 'category',
},
yAxis: {
type: 'value',
},
2025-07-09 23:52:19 +08:00
dataset:{source},
series: [
{
2025-09-14 23:33:53 +08:00
type: 'scatter',
},
{
type: 'scatter',
},
{
type: 'scatter',
},
{
type: 'scatter',
}
2025-07-09 23:52:19 +08:00
]
},true)
},
initChart() {
this.chart = echarts.init(document.querySelector('#glqxEchart'));
2025-07-09 23:52:19 +08:00
},
init(){
this.loading = true
this.initChart()
2025-09-14 23:33:53 +08:00
this.getData()
}
},
mounted(){
const now = new Date();
const lastMonth = new Date(now.getFullYear(), now.getMonth() - 1, 1);
this.defaultDateRange = [lastMonth, now];
},
beforeDestroy() {
if (!this.chart) {
return
}
this.chart.dispose()
this.chart = null
},
}
</script>