2025-06-24 19:52:11 +08:00
|
|
|
|
|
|
|
|
<template>
|
2025-07-09 00:03:52 +08:00
|
|
|
<div v-loading="loading">
|
2025-06-24 19:52:11 +08:00
|
|
|
<div class="select-container">
|
|
|
|
|
<el-form :inline="true">
|
2025-09-14 23:33:53 +08:00
|
|
|
<!-- <el-form-item label="电池堆">-->
|
|
|
|
|
<!-- <el-select v-model="pcs" placeholder="请选择" :loading="loading" loading-text="正在加载数据">-->
|
|
|
|
|
<!-- <el-option :label="item.deviceName" :value="item.id" v-for="(item,index) in pcsOptions" :key="index+'pcsListOptions'"></el-option>-->
|
|
|
|
|
<!-- </el-select>-->
|
|
|
|
|
<!-- </el-form-item>-->
|
2025-06-24 19:52:11 +08:00
|
|
|
<el-form-item label="时间选择">
|
|
|
|
|
<el-date-picker
|
|
|
|
|
v-model="dateRange"
|
2025-07-09 00:03:52 +08:00
|
|
|
type="daterange"
|
2025-06-24 19:52:11 +08:00
|
|
|
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>
|
2025-06-24 19:52:11 +08:00
|
|
|
</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;">
|
|
|
|
|
<!-- 二个选择按钮-->
|
|
|
|
|
<el-row style="">
|
|
|
|
|
<el-col :xs="24" :sm="24" :lg="24">
|
2025-06-24 22:48:33 +08:00
|
|
|
<el-button-group class="ems-btns-group">
|
2025-07-09 00:03:52 +08:00
|
|
|
<el-button v-for="(item,index) in btnList" :key="index+'dcdqxBtns'" :class="{'activeBtn' : activeBtn === item.id}" @click="changeDataType(item.id)">{{item.name}}</el-button>
|
2025-06-24 19:52:11 +08:00
|
|
|
</el-button-group>
|
|
|
|
|
</el-col>
|
|
|
|
|
</el-row>
|
|
|
|
|
<!--echart-->
|
|
|
|
|
<div id="dcdEchart" style="height:360px;"></div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import * as echarts from 'echarts'
|
|
|
|
|
import resize from "@/mixins/ems/resize";
|
2025-07-09 00:03:52 +08:00
|
|
|
import getQuerySiteId from "@/mixins/ems/getQuerySiteId";
|
2025-07-09 21:16:54 +08:00
|
|
|
import { getStackData, getStackNameList} from '@/api/ems/dzjk'
|
2025-07-09 00:03:52 +08:00
|
|
|
import {formatDate} from "@/filters/ems";
|
2025-06-24 19:52:11 +08:00
|
|
|
export default {
|
2025-07-09 00:03:52 +08:00
|
|
|
name:'DzjkTjbbDcdqx',
|
|
|
|
|
mixins: [resize,getQuerySiteId],
|
2025-06-24 19:52:11 +08:00
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
pickerOptions:{
|
|
|
|
|
disabledDate(time) {
|
|
|
|
|
return time.getTime() > Date.now();
|
|
|
|
|
},
|
|
|
|
|
},
|
2025-07-09 00:03:52 +08:00
|
|
|
defaultDateRange:[],//默认展示的时间
|
|
|
|
|
dateRange:[],
|
2025-06-24 19:52:11 +08:00
|
|
|
loading:false,
|
2025-09-14 23:33:53 +08:00
|
|
|
// pcs:'',
|
|
|
|
|
// pcsOptions: [],
|
2025-07-09 00:03:52 +08:00
|
|
|
activeBtn:'1',
|
2025-06-24 19:52:11 +08:00
|
|
|
btnList:[
|
2025-09-14 23:33:53 +08:00
|
|
|
{name:'堆平均维度',id:'1',attr:['temp'],source:['有功功率']},
|
|
|
|
|
{name:'堆电压',id:'2',attr:['voltage'],source:['堆电压']},
|
|
|
|
|
{name:'堆电流',id:'3',attr:['current'],source:['堆电流']},
|
|
|
|
|
{name:'堆soc',id:'4',attr:['soc'],source:['堆soc']},
|
2025-06-24 19:52:11 +08:00
|
|
|
],
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
changeDataType(id){
|
|
|
|
|
if(id !== this.activeBtn){
|
|
|
|
|
this.activeBtn=id;
|
2025-07-09 00:03:52 +08:00
|
|
|
this.getData()
|
2025-06-24 19:52:11 +08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
// 搜索
|
|
|
|
|
onSearch(){
|
|
|
|
|
this.getData()
|
|
|
|
|
},
|
|
|
|
|
// 重置
|
|
|
|
|
onReset(){
|
2025-07-09 00:03:52 +08:00
|
|
|
// this.pcs = this.pcsOptions.length > 0 ?this.pcsOptions[0].id : ''
|
2025-06-24 23:50:29 +08:00
|
|
|
this.dateRange=''
|
2025-06-24 19:52:11 +08:00
|
|
|
this.getData()
|
|
|
|
|
},
|
2025-09-14 23:33:53 +08:00
|
|
|
// getPcsList(){
|
|
|
|
|
// return getStackNameList(this.siteId).then(response => {
|
|
|
|
|
// const data = JSON.parse(JSON.stringify(response?.data || []))
|
|
|
|
|
// this.pcsOptions = data
|
|
|
|
|
// this.pcs = data.length>0?data[0].id:'';
|
|
|
|
|
// })
|
|
|
|
|
// },
|
2025-06-24 19:52:11 +08:00
|
|
|
getData(){
|
2025-09-14 23:33:53 +08:00
|
|
|
const {siteId,activeBtn}=this;
|
2025-07-09 00:03:52 +08:00
|
|
|
const [start='',end='']=(this.dateRange || [])
|
2025-06-24 19:52:11 +08:00
|
|
|
//接口调用完成之后 设置图表、结束loading
|
2025-07-09 23:52:19 +08:00
|
|
|
this.loading=true;
|
2025-09-14 23:33:53 +08:00
|
|
|
getStackData({siteId,startTime:formatDate(start),endTime:formatDate(end),dataType:activeBtn}).then(response => {
|
2025-07-09 00:03:52 +08:00
|
|
|
this.setOption(response?.data || [])
|
|
|
|
|
}).finally(()=>{this.loading=false;})
|
2025-06-24 19:52:11 +08:00
|
|
|
},
|
2025-07-09 00:03:52 +08:00
|
|
|
setOption(data) {
|
2025-09-14 23:33:53 +08:00
|
|
|
|
|
|
|
|
// [{
|
|
|
|
|
// "deviceId": "PCS04",
|
|
|
|
|
// "dataList": [
|
|
|
|
|
// {
|
|
|
|
|
// "statisDate": "2025-09-05",
|
|
|
|
|
// "activePower": null,
|
|
|
|
|
// "reactivePower": null,
|
|
|
|
|
// "uCurrent": 1.30,
|
|
|
|
|
// "vCurrent": 0.90,
|
|
|
|
|
// "wCurrent": 1.00,
|
|
|
|
|
// "deviceId": "PCS04"
|
|
|
|
|
// },
|
|
|
|
|
// {
|
|
|
|
|
// "statisDate": "2025-09-04",
|
|
|
|
|
// "activePower": null,
|
|
|
|
|
// "reactivePower": null,
|
|
|
|
|
// "uCurrent": 71.40,
|
|
|
|
|
// "vCurrent": 71.30,
|
|
|
|
|
// "wCurrent": 71.80,
|
|
|
|
|
// "deviceId": "PCS04"
|
|
|
|
|
// }
|
|
|
|
|
// ]
|
|
|
|
|
// }]
|
2025-07-09 00:03:52 +08:00
|
|
|
const ele = this.btnList.find((item)=>{return item.id === this.activeBtn})
|
2025-09-14 23:33:53 +08:00
|
|
|
const sourceBase = JSON.parse(JSON.stringify(ele.source))
|
|
|
|
|
const source=[]
|
|
|
|
|
const sourceTop = ['日期']
|
|
|
|
|
sourceBase.forEach((outer,outerIndex)=>{
|
|
|
|
|
data.forEach((item,itemIndex)=>{
|
|
|
|
|
sourceTop.push(`${item.deviceId}-${outer}`)
|
|
|
|
|
item.dataList.forEach((inner,innerIndex)=>{
|
|
|
|
|
if(itemIndex === 0 || innerIndex+1>source.length) {
|
|
|
|
|
source.push([inner.statisDate])
|
|
|
|
|
}
|
|
|
|
|
source[innerIndex].push(inner[ele.attr[outerIndex]])
|
|
|
|
|
})
|
2025-07-09 00:03:52 +08:00
|
|
|
})
|
|
|
|
|
})
|
2025-09-14 23:33:53 +08:00
|
|
|
source.unshift(sourceTop)
|
|
|
|
|
console.log('========',source)
|
2025-06-24 19:52:11 +08:00
|
|
|
this.chart.setOption({
|
2025-08-13 14:51:26 +08:00
|
|
|
grid: {
|
|
|
|
|
containLabel: true
|
|
|
|
|
},
|
2025-06-24 19:52:11 +08:00
|
|
|
legend: {
|
|
|
|
|
left: 'center',
|
2025-08-13 14:51:26 +08:00
|
|
|
bottom: '15',
|
2025-06-24 19:52:11 +08:00
|
|
|
},
|
|
|
|
|
tooltip: {
|
|
|
|
|
trigger: 'axis',
|
|
|
|
|
axisPointer: { // 坐标轴指示器,坐标轴触发有效
|
|
|
|
|
type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
textStyle:{
|
|
|
|
|
color:"#333333",
|
|
|
|
|
},
|
|
|
|
|
xAxis: {
|
2025-07-09 00:03:52 +08:00
|
|
|
type: 'category',
|
2025-06-24 19:52:11 +08:00
|
|
|
},
|
|
|
|
|
yAxis: {
|
|
|
|
|
type: 'value',
|
|
|
|
|
},
|
2025-07-09 00:03:52 +08:00
|
|
|
dataset: {source},
|
2025-09-14 23:33:53 +08:00
|
|
|
series:source[0].slice(1).map(item=>{
|
|
|
|
|
return {
|
|
|
|
|
type:ele.type || 'scatter'
|
|
|
|
|
}
|
|
|
|
|
})
|
2025-07-09 00:03:52 +08:00
|
|
|
},true)
|
2025-06-24 19:52:11 +08:00
|
|
|
},
|
|
|
|
|
initChart() {
|
|
|
|
|
this.chart = echarts.init(document.querySelector('#dcdEchart'));
|
2025-07-09 00:03:52 +08:00
|
|
|
},
|
|
|
|
|
init(){
|
|
|
|
|
this.loading = true
|
2025-09-14 23:33:53 +08:00
|
|
|
// this.pcs=''
|
|
|
|
|
// this.pcsOptions=[]
|
2025-07-09 00:03:52 +08:00
|
|
|
this.initChart()
|
2025-09-14 23:33:53 +08:00
|
|
|
this.onReset()
|
2025-06-24 19:52:11 +08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
mounted(){
|
2025-07-09 00:03:52 +08:00
|
|
|
const now = new Date();
|
|
|
|
|
const lastMonth = new Date(now.getFullYear(), now.getMonth() - 1, 1);
|
|
|
|
|
this.defaultDateRange = [lastMonth, now];
|
2025-06-24 19:52:11 +08:00
|
|
|
},
|
|
|
|
|
beforeDestroy() {
|
|
|
|
|
if (!this.chart) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
this.chart.dispose()
|
|
|
|
|
this.chart = null
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|