Merge branch 'develop' into single-develop

This commit is contained in:
白菜
2025-11-05 14:10:00 +08:00
59 changed files with 4535 additions and 1971 deletions

View File

@ -3,23 +3,18 @@
<div style="width:100%" v-loading="loading">
<!-- 搜索栏-->
<el-form :inline="true" class="select-container">
<el-form-item label="电表">
<el-select v-model="search.deviceId" placeholder="请选择" loading-text="正在加载数据">
<el-option :label="item.deviceName" :value="item.id" v-for="(item,index) in deviceOptions" :key="index+'dbOptions'"></el-option>
</el-select>
</el-form-item>
<!-- <el-form-item label="日报">-->
<!-- <el-select v-model="search.rb" placeholder="请选择" :loading="loading" loading-text="正在加载数据">-->
<!-- <el-option :label="item.name" :value="item.id" v-for="(item,index) in rbOptions" :key="index+'rbOptions'"></el-option>-->
<!-- </el-select>-->
<!-- </el-form-item>-->
<el-form-item label="时间选择">
<el-date-picker
v-model="search.date"
type="date"
:picker-options="pickerOptions"
:default-value="defaultDate">
</el-date-picker>
v-model="dateRange"
type="daterange"
range-separator=""
start-placeholder="开始日期"
end-placeholder="结束日期"
value-format="yyyy-MM-dd"
:clearable="false"
:picker-options="pickerOptions"
:default-value="defaultDateRange"
></el-date-picker>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="onSearch" native-type="button">搜索</el-button>
@ -40,71 +35,92 @@
prop="dataTime"
label="日期"
width="120">
<template slot-scope="scope">
<span>{{scope.row.dataTime}}{{scope.row.dataTime === '汇总' ? '' : ':00'}}</span>
</template>
</el-table-column>
</el-table-column>
<!--充电量列-->
<el-table-column label="充电量">
<el-table-column label="充电量" align="center">
<el-table-column
align="center"
prop="activePeakKwh"
label="尖">
</el-table-column>
<el-table-column
align="center"
prop="activeHighKwh"
label="峰">
</el-table-column>
<el-table-column
align="center"
prop="activeFlatKwh"
label="平">
</el-table-column>
<el-table-column
align="center"
prop="activeValleyKwh"
label="谷">
</el-table-column>
<el-table-column
align="center"
prop="activeTotalKwh"
label="总">
</el-table-column>
</el-table-column>
<!--充电量列-->
<el-table-column label="放电量">
<el-table-column label="放电量" align="center">
<el-table-column
align="center"
prop="reActivePeakKwh"
label="尖">
</el-table-column>
<el-table-column
align="center"
prop="reActiveHighKwh"
label="峰">
</el-table-column>
<el-table-column
align="center"
prop="reActiveFlatKwh"
label="平">
</el-table-column>
<el-table-column
align="center"
prop="reActiveValleyKwh"
label="谷">
</el-table-column>
<el-table-column
align="center"
prop="reActiveTotalKwh"
label="总">
</el-table-column>
</el-table-column>
<!-- 效率-->
<el-table-column label="效率(%)">
<el-table-column label="效率(%)" align="center">
<el-table-column
align="center"
prop="effect">
</el-table-column>
</el-table-column>
</el-table>
<el-pagination
v-show="tableData.length>0"
background
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="pageNum"
:page-size="pageSize"
:page-sizes="[10, 20, 30, 40]"
layout="total, sizes, prev, pager, next, jumper"
:total="totalSize"
style="margin-top:15px;text-align: center"
>
</el-pagination>
</div>
</template>
<script>
import getQuerySiteId from "@/mixins/ems/getQuerySiteId";
import { getAmmeterData, getLoadNameList} from '@/api/ems/dzjk'
import { getAmmeterData} from '@/api/ems/dzjk'
import {formatDate} from "@/filters/ems";
export default {
name:'DzjkTjbbDbbb',
@ -117,61 +133,64 @@ export default {
return time.getTime() > Date.now();
},
},
defaultDate:'',//默认展示的时间
search:{deviceId:'',date:''},
deviceOptions:[],
// rbOptions:[
// {name:'日报1',id:1},
// {name:'日报2',id:2},
// ],
tableData:[]
defaultDateRange:[],//默认展示的时间
dateRange:[],
tableData:[],
pageSize:10,//分页栏当前每个数据总数
pageNum:1,//分页栏当前页数
totalSize:0,//table表格数据总数
}
},
methods:{
// 搜索
onSearch(){
this.pageNum =1//每次搜索从1开始搜索
this.getData()
},
// 重置
onReset(){
this.search.date = ''
this.dateRange=this.defaultDateRange
this.pageNum =1//每次搜索从1开始搜索
this.getData()
},
// 分页
handleSizeChange(val) {
this.pageSize = val;
this.$nextTick(()=>{
this.getData()
})
},
handleCurrentChange(val) {
this.pageNum = val
this.$nextTick(()=>{
this.getData()
})
},
// 获取数据
getData(){
if(!this.search.deviceId) return
this.loading=true
getAmmeterData({siteId:this.siteId,deviceId:this.search.deviceId,dateTime:formatDate(this.search.date)}).then(response=>{
this.tableData=response?.data || [];
const {siteId,pageNum,pageSize} =this
const [startTime='',endTime='']=(this.dateRange || [])
getAmmeterData({siteId:siteId,startTime,endTime,pageSize,pageNum}).then(response=>{
this.tableData=response?.rows || [];
this.totalSize = response?.total || 0
}).finally(()=> {
this.loading = false
})
},
getDbList(){
return getLoadNameList(this.siteId).then(response=>{
this.deviceOptions=response?.data || [];
this.deviceOptions.length > 0 && (this.search.deviceId = this.deviceOptions[0].id);
})
},
init(){
this.loading = true
this.deviceOptions = []
this.search.deviceId=''
this.search.date=''
this.dateRange=[]
this.tableData=[]
this.getDbList().then(()=>{
if(this.search.deviceId){
this.onReset()
}else{
this.loading = false
}
})
this.totalSize=0
this.pageSize=10
this.pageNum = 1
const now = new Date().getTime();
const lastMonth = new Date(now-30 * 24 * 60 * 60 * 1000).getTime();
this.defaultDateRange = [formatDate(lastMonth), formatDate(now)];
this.dateRange=[formatDate(lastMonth), formatDate(now)];
this.getData()
},
},
mounted(){
this.defaultDate = new Date()
}
}
</script>

View File

@ -1,165 +1,191 @@
<template>
<el-card shadow="always" class="common-card-container time-range-card" style="margin-top:20px">
<el-card
shadow="always"
class="common-card-container time-range-card"
style="margin-top: 20px"
>
<div slot="header" class="time-range-header">
<span class="card-title">
<el-button-group class="ems-btns-group">
<el-button v-for="(item,index) in btnList" :key="index+'dcdqxBtns'" size="mini" :class="{'activeBtn' : activeBtn === item.id}" @click="changeDataType(item.id)">{{item.name}}</el-button>
</el-button-group>
</span>
<date-range-select ref="dateRangeSelect" @updateDate="updateDate"/>
<span class="card-title"> </span>
<date-range-select ref="dateRangeSelect" @updateDate="updateDate" />
</div>
<div class="card-main" v-loading="loading">
<div id="dcdEchart" style="height: 310px;"></div>
<el-button-group class="ems-btns-group">
<el-button
v-for="(item, index) in btnList"
:key="index + 'dcdqxBtns'"
size="mini"
:class="{ activeBtn: activeBtn === item.id }"
@click="changeDataType(item.id)"
>{{ item.name }}</el-button
>
</el-button-group>
<div id="dcdEchart" style="height: 310px"></div>
</div>
</el-card>
</template>
<script>
import * as echarts from 'echarts'
import * as echarts from "echarts";
import resize from "@/mixins/ems/resize";
import getQuerySiteId from "@/mixins/ems/getQuerySiteId";
import { getStackData, getStackNameList} from '@/api/ems/dzjk'
import {formatDate} from "@/filters/ems";
import { getStackData, getStackNameList } from "@/api/ems/dzjk";
import { formatDate } from "@/filters/ems";
import DateRangeSelect from "@/components/Ems/DateRangeSelect/index.vue";
export default {
name:'DzjkTjbbDcdqx',
components: {DateRangeSelect},
mixins: [resize,getQuerySiteId],
name: "DzjkTjbbDcdqx",
components: { DateRangeSelect },
mixins: [resize, getQuerySiteId],
data() {
return {
pickerOptions:{
pickerOptions: {
disabledDate(time) {
return time.getTime() > Date.now();
},
},
dateRange:[],
loading:false,
activeBtn:'1',
btnList:[
{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']},
dateRange: [],
loading: false,
activeBtn: "1",
btnList: [
{ 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"] },
],
}
};
},
methods: {
changeDataType(id){
if(id !== this.activeBtn){
this.activeBtn=id;
this.getData()
changeDataType(id) {
if (id !== this.activeBtn) {
this.activeBtn = id;
this.getData();
}
},
// 更新时间范围 重置图表
updateDate(data){
this.dateRange=data || []
this.getData()
updateDate(data) {
this.dateRange = data || [];
this.getData();
},
getData(){
const {siteId,activeBtn}=this;
const [start='',end='']=(this.dateRange || [])
getData() {
const { siteId, activeBtn } = this;
const [start = "", end = ""] = this.dateRange || [];
//接口调用完成之后 设置图表、结束loading
this.loading=true;
getStackData({siteId,startTime:formatDate(start),endTime:formatDate(end),dataType:activeBtn}).then(response => {
this.setOption(response?.data || [])
}).finally(()=>{this.loading=false;})
this.loading = true;
getStackData({
siteId,
startTime: formatDate(start),
endTime: formatDate(end),
dataType: activeBtn,
})
.then((response) => {
this.setOption(response?.data || []);
})
.finally(() => {
this.loading = false;
});
},
compareDate(date1,date2){
console.log('比较时间',date1,date2)
compareDate(date1, date2) {
console.log("比较时间", date1, date2);
// 年2025-09/天2025-09-15/时2025-09-15/10:00
if(date1.indexOf(':') > -1 && date2.indexOf(':') > -1){
return parseInt(date1) - parseInt(date2)
if (date1.indexOf(":") > -1 && date2.indexOf(":") > -1) {
return parseInt(date1) - parseInt(date2);
}
const [date1_Y='',date1_M='',date1_D=''] = date1.split('-')//根据空格区分[年月日,小时]
const [date2_Y='',date2_M='',date2_D=''] = date2.split('-')//根据空格区分[年月日,小时]
return (date1_Y === date2_Y && date1_M === date2_M && date1_D - date2_D) || (date1_Y === date2_Y && date1_M - date2_M) || date1_Y - date2_Y
const [date1_Y = "", date1_M = "", date1_D = ""] = date1.split("-"); //根据空格区分[年月日,小时]
const [date2_Y = "", date2_M = "", date2_D = ""] = date2.split("-"); //根据空格区分[年月日,小时]
return (
(date1_Y === date2_Y && date1_M === date2_M && date1_D - date2_D) ||
(date1_Y === date2_Y && date1_M - date2_M) ||
date1_Y - date2_Y
);
},
setOption(data) {
const ele = this.btnList.find((item)=>{return item.id === this.activeBtn})
const sourceBase = JSON.parse(JSON.stringify(ele.source))
const ele = this.btnList.find((item) => {
return item.id === this.activeBtn;
});
const sourceBase = JSON.parse(JSON.stringify(ele.source));
// sourceBase={name:'堆平均维度',id:'1',attr:['temp'],source:['有功功率']},
const source=[]
const sourceTop = ['日期']
let map={},mapArr=[]
const source = [];
const sourceTop = ["日期"];
let map = {},
mapArr = [];
// 生成所有{日期:[],日期:[]}格式的对象和所有包含所有日期的[日期1,日期2...]
data.forEach((item)=>{
item.dataList.forEach((inner)=>{
data.forEach((item) => {
item.dataList.forEach((inner) => {
// 日期格式
// 年2025-09/天2025-09-15/时2025-09-15/10:00
// 所有数据的日期格式一致
if(!map[inner.statisDate]) {
map[inner.statisDate] = []
mapArr.push(inner.statisDate)
if (!map[inner.statisDate]) {
map[inner.statisDate] = [];
mapArr.push(inner.statisDate);
}
})
})
data.forEach((item,itemIndex)=>{
const dataTimeList = item.dataList.map(i =>i.statisDate)
const noDataTime = mapArr.filter(i=>!dataTimeList.includes(i))
sourceBase.forEach((outer,outerIndex)=>{
sourceTop.push(`${item.deviceId}-${outer}`)
noDataTime.forEach(i=>map[i].push(''))
item.dataList.forEach((inner,innerIndex)=>{
map[inner.statisDate].push(inner[ele.attr[outerIndex]])
})
})
})
mapArr = mapArr.sort((a,b)=>this.compareDate(a,b))
mapArr.forEach(item=>{
source.push([item,...map[item]])
})
source.unshift(sourceTop)
console.log('map=',map)
console.log('mapArr=',mapArr)
console.log('========',source)
this.chart.setOption({
grid: {
containLabel: true
});
});
data.forEach((item, itemIndex) => {
const dataTimeList = item.dataList.map((i) => i.statisDate);
const noDataTime = mapArr.filter((i) => !dataTimeList.includes(i));
sourceBase.forEach((outer, outerIndex) => {
sourceTop.push(`${item.deviceId}-${outer}`);
noDataTime.forEach((i) => map[i].push(""));
item.dataList.forEach((inner, innerIndex) => {
map[inner.statisDate].push(inner[ele.attr[outerIndex]]);
});
});
});
mapArr = mapArr.sort((a, b) => this.compareDate(a, b));
mapArr.forEach((item) => {
source.push([item, ...map[item]]);
});
source.unshift(sourceTop);
this.chart.setOption(
{
grid: {
containLabel: true,
},
legend: {
left: "center",
bottom: "15",
},
tooltip: {
trigger: "axis",
axisPointer: {
// 坐标轴指示器,坐标轴触发有效
type: "shadow", // 默认为直线,可选为:'line' | 'shadow'
},
},
textStyle: {
color: "#333333",
},
xAxis: {
type: "category",
},
yAxis: {
type: "value",
},
dataset: { source },
series: source[0].slice(1).map((item) => {
return {
type: "line",
};
}),
},
legend: {
left: 'center',
bottom: '15',
},
tooltip: {
trigger: 'axis',
axisPointer: { // 坐标轴指示器,坐标轴触发有效
type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
}
},
textStyle:{
color:"#333333",
},
xAxis: {
type: 'category',
},
yAxis: {
type: 'value',
},
dataset: {source},
series:source[0].slice(1).map(item=>{
return {
type:ele.type || 'scatter'
}
})
},true)
true
);
},
initChart() {
this.chart = echarts.init(document.querySelector('#dcdEchart'));
this.chart = echarts.init(document.querySelector("#dcdEchart"));
},
init() {
this.$nextTick(() => {
this.initChart();
this.$refs.dateRangeSelect.init();
});
},
init(){
this.$nextTick(()=>{
this.initChart()
this.$refs.dateRangeSelect.init()
})
}
},
beforeDestroy() {
if (!this.chart) {
return
return;
}
this.chart.dispose()
this.chart = null
this.chart.dispose();
this.chart = null;
},
}
};
</script>

View File

@ -1,116 +1,151 @@
<template>
<el-card shadow="always" class="common-card-container time-range-card" style="margin-top:20px">
<el-card
shadow="always"
class="common-card-container time-range-card"
style="margin-top: 20px"
>
<div slot="header" class="time-range-header">
<span class="card-title">功率曲线</span>
<date-range-select ref="dateRangeSelect" @updateDate="updateDate"/>
<date-range-select
ref="dateRangeSelect"
@reset="resetTime"
@updateDate="updateDate"
/>
</div>
<div class="card-main" v-loading="loading">
<div id="glqxEchart" style="height: 310px;"></div>
<div id="glqxEchart" style="height: 310px"></div>
</div>
</el-card>
</template>
<script>
import * as echarts from 'echarts'
import * as echarts from "echarts";
import resize from "@/mixins/ems/resize";
import getQuerySiteId from "@/mixins/ems/getQuerySiteId";
import {getPcsNameList, getPowerData} from "@/api/ems/dzjk";
import {formatDate} from "@/filters/ems";
import { getPcsNameList, getPowerData } from "@/api/ems/dzjk";
import { formatDate } from "@/filters/ems";
import DateRangeSelect from "@/components/Ems/DateRangeSelect/index.vue";
export default {
name:'DzjkTjbbGlqx',
components: {DateRangeSelect},
mixins: [resize,getQuerySiteId],
name: "DzjkTjbbGlqx",
components: { DateRangeSelect },
mixins: [resize, getQuerySiteId],
data() {
return {
pickerOptions:{
pickerOptions: {
disabledDate(time) {
return time.getTime() > Date.now();
},
},
dateRange:[],
loading:false,
}
dateRange: [],
loading: false,
dateRangeInit: true,
};
},
methods: {
// 更新时间范围 重置图表
updateDate(data){
this.dateRange=data || []
this.getData()
updateDate(data) {
this.dateRange = data || [];
this.getData();
},
getData(){
const {siteId}=this;
const [start='',end='']=(this.dateRange || [])
resetTime() {
this.dateRangeInit = true;
},
getData() {
const { siteId } = this;
let [start = "", end = ""] = this.dateRange || [];
//接口调用完成之后 设置图表、结束loading
this.loading=true;
getPowerData({siteId,startDate:formatDate(start),endDate:formatDate(end)}).then(response => {
this.setOption(response?.data || [])
}).finally(()=>{this.loading=false;})
this.loading = true;
if (this.dateRangeInit) {
start = "";
end = "";
this.dateRangeInit = false;
}
getPowerData({
siteId,
startDate: formatDate(start),
endDate: formatDate(end),
})
.then((response) => {
this.setOption(response?.data || []);
})
.finally(() => {
this.loading = false;
});
},
setOption(data) {
const source = [['日期','电网功率','负载功率','储能功率','光伏功率']]
data.forEach(item=>{
source.push([item.statisDate,item.gridPower,item.loadPower,item.storagePower,item.pvPower])
})
this.chart.setOption({
grid: {
containLabel: true
},
legend: {
left: 'center',
bottom: '15',
},
tooltip: {
trigger: 'axis',
axisPointer: { // 坐标轴指示器,坐标轴触发有效
type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
}
},
textStyle:{
color:"#333333",
},
xAxis: {
type: 'category',
},
yAxis: {
type: 'value',
},
dataset:{source},
series: [
{
type: 'scatter',
const source = [["日期", "电网功率", "负载功率", "储能功率", "光伏功率"]];
data.forEach((item) => {
source.push([
item.statisDate,
item.gridPower,
item.loadPower,
item.storagePower,
item.pvPower,
]);
});
this.chart.setOption(
{
grid: {
containLabel: true,
},
{
type: 'scatter',
legend: {
left: "center",
bottom: "15",
},
{
type: 'scatter',
tooltip: {
trigger: "axis",
axisPointer: {
// 坐标轴指示器,坐标轴触发有效
type: "shadow", // 默认为直线,可选为:'line' | 'shadow'
},
},
{
type: 'scatter',
}
]
},true)
textStyle: {
color: "#333333",
},
xAxis: {
type: "category",
},
yAxis: {
type: "value",
},
dataset: { source },
series: [
{
type: "line",
},
{
type: "line",
},
{
type: "line",
},
{
type: "line",
},
],
},
true
);
},
initChart() {
this.chart = echarts.init(document.querySelector('#glqxEchart'));
if (this.chart) return;
this.chart = echarts.init(document.querySelector("#glqxEchart"));
},
init() {
this.$nextTick(() => {
this.dateRangeInit = true;
this.initChart();
this.$refs.dateRangeSelect.init();
});
},
init(){
this.$nextTick(()=>{
this.initChart()
this.$refs.dateRangeSelect.init()
})
}
},
beforeDestroy() {
if (!this.chart) {
return
return;
}
this.chart.dispose()
this.chart = null
this.chart.dispose();
this.chart = null;
},
}
};
</script>

View File

@ -1,167 +1,207 @@
<template>
<el-card shadow="always" class="common-card-container time-range-card" style="margin-top:20px">
<el-card
shadow="always"
class="common-card-container time-range-card"
style="margin-top: 20px"
>
<div slot="header" class="time-range-header">
<span class="card-title">
<el-button-group class="ems-btns-group">
<el-button v-for="(item,index) in btnList" :key="index+'flqxcBtns'" size="mini" :class="{'activeBtn' : activeBtn === item.id}" @click="changeDataType(item.id)">{{item.name}}</el-button>
</el-button-group>
</span>
<date-range-select ref="dateRangeSelect" @updateDate="updateDate"/>
<span class="card-title"> </span>
<date-range-select ref="dateRangeSelect" @updateDate="updateDate" />
</div>
<div class="card-main" v-loading="loading">
<div id="pcsEchart" style="height: 310px;"></div>
<el-button-group class="ems-btns-group">
<el-button
v-for="(item, index) in btnList"
:key="index + 'flqxcBtns'"
size="mini"
:class="{ activeBtn: activeBtn === item.id }"
@click="changeDataType(item.id)"
>{{ item.name }}</el-button
>
</el-button-group>
<div id="pcsEchart" style="height: 310px"></div>
</div>
</el-card>
</template>
<script>
import * as echarts from 'echarts'
import * as echarts from "echarts";
import resize from "@/mixins/ems/resize";
import getQuerySiteId from "@/mixins/ems/getQuerySiteId";
import { getPCSData, getPcsNameList} from '@/api/ems/dzjk'
import {formatDate} from "@/filters/ems";
import { getPCSData, getPcsNameList } from "@/api/ems/dzjk";
import { formatDate } from "@/filters/ems";
import DateRangeSelect from "@/components/Ems/DateRangeSelect/index.vue";
export default {
name:'DzjkTjbbPcsqx',
components: {DateRangeSelect},
mixins: [resize,getQuerySiteId],
name: "DzjkTjbbPcsqx",
components: { DateRangeSelect },
mixins: [resize, getQuerySiteId],
data() {
return {
pickerOptions:{
pickerOptions: {
disabledDate(time) {
return time.getTime() > Date.now();
},
},
dateRange:[],
loading:false,
activeBtn:'1',
btnList:[
{name:'有功功率',id:'1',attr:['activePower'],source:['有功功率']},
{name:'无功功率',id:'2',attr:['reactivePower'],source:['无功功率']},
{name:'三相电流',id:'3',attr:['uCurrent','vCurrent','wCurrent'],source:['u电流','v电流','w电流'],type:'bar'},
dateRange: [],
loading: false,
activeBtn: "1",
btnList: [
{
name: "有功功率",
id: "1",
attr: ["activePower"],
source: ["有功功率"],
},
{
name: "无功功率",
id: "2",
attr: ["reactivePower"],
source: ["无功功率"],
},
{
name: "三相电流",
id: "3",
attr: ["uCurrent", "vCurrent", "wCurrent"],
source: ["u电流", "v电流", "w电流"],
type: "bar",
},
],
}
};
},
methods: {
changeDataType(id){
if(id !== this.activeBtn){
console.log('点击了不同的菜单,更新数据')
this.activeBtn=id;
this.getData()
changeDataType(id) {
if (id !== this.activeBtn) {
console.log("点击了不同的菜单,更新数据");
this.activeBtn = id;
this.getData();
}
},
// 更新时间范围 重置图表
updateDate(data){
this.dateRange=data || []
this.getData()
updateDate(data) {
this.dateRange = data || [];
this.getData();
},
getData(){
const {siteId,activeBtn}=this;
const [start='',end='']=(this.dateRange || [])
this.loading=true;
getData() {
const { siteId, activeBtn } = this;
const [start = "", end = ""] = this.dateRange || [];
this.loading = true;
//接口调用完成之后 设置图表、结束loading
getPCSData({siteId,startTime:formatDate(start),endTime:formatDate(end),dataType:activeBtn}).then(response => {
this.setOption(response?.data || [])
}).finally(()=>{this.loading=false;})
getPCSData({
siteId,
startTime: formatDate(start),
endTime: formatDate(end),
dataType: activeBtn,
})
.then((response) => {
this.setOption(response?.data || []);
})
.finally(() => {
this.loading = false;
});
},
compareDate(date1,date2){
console.log('比较时间',date1,date2)
compareDate(date1, date2) {
console.log("比较时间", date1, date2);
// 年2025-09/天2025-09-15/时2025-09-15/10:00
if(date1.indexOf(':') > -1 && date2.indexOf(':') > -1){
return parseInt(date1) - parseInt(date2)
if (date1.indexOf(":") > -1 && date2.indexOf(":") > -1) {
return parseInt(date1) - parseInt(date2);
}
const [date1_Y='',date1_M='',date1_D=''] = date1.split('-')//根据空格区分[年月日,小时]
const [date2_Y='',date2_M='',date2_D=''] = date2.split('-')//根据空格区分[年月日,小时]
return (date1_Y === date2_Y && date1_M === date2_M && date1_D - date2_D) || (date1_Y === date2_Y && date1_M - date2_M) || date1_Y - date2_Y
const [date1_Y = "", date1_M = "", date1_D = ""] = date1.split("-"); //根据空格区分[年月日,小时]
const [date2_Y = "", date2_M = "", date2_D = ""] = date2.split("-"); //根据空格区分[年月日,小时]
return (
(date1_Y === date2_Y && date1_M === date2_M && date1_D - date2_D) ||
(date1_Y === date2_Y && date1_M - date2_M) ||
date1_Y - date2_Y
);
},
setOption(data) {
const ele = this.btnList.find((item)=>{return item.id === this.activeBtn})
const sourceBase = JSON.parse(JSON.stringify(ele.source))
const ele = this.btnList.find((item) => {
return item.id === this.activeBtn;
});
const sourceBase = JSON.parse(JSON.stringify(ele.source));
// sourceBase={name:'堆平均维度',id:'1',attr:['temp'],source:['有功功率']},
const source=[]
const sourceTop = ['日期']
let map={},mapArr=[]
const source = [];
const sourceTop = ["日期"];
let map = {},
mapArr = [];
// 生成所有{日期:[],日期:[]}格式的对象和所有包含所有日期的[日期1,日期2...]
data.forEach((item)=>{
item.dataList.forEach((inner)=>{
data.forEach((item) => {
item.dataList.forEach((inner) => {
// 日期格式
// 年2025-09/天2025-09-15/时2025-09-15/10:00
// 所有数据的日期格式一致
if(!map[inner.statisDate]) {
map[inner.statisDate] = []
mapArr.push(inner.statisDate)
if (!map[inner.statisDate]) {
map[inner.statisDate] = [];
mapArr.push(inner.statisDate);
}
})
})
data.forEach((item,itemIndex)=>{
const dataTimeList = item.dataList.map(i =>i.statisDate)
const noDataTime = mapArr.filter(i=>!dataTimeList.includes(i))
sourceBase.forEach((outer,outerIndex)=>{
sourceTop.push(`${item.deviceId}-${outer}`)
noDataTime.forEach(i=>map[i].push(''))
item.dataList.forEach((inner,innerIndex)=>{
map[inner.statisDate].push(inner[ele.attr[outerIndex]])
})
})
})
mapArr = mapArr.sort((a,b)=>this.compareDate(a,b))
mapArr.forEach(item=>{
source.push([item,...map[item]])
})
source.unshift(sourceTop)
console.log('map=',map)
console.log('mapArr=',mapArr)
console.log('========',source)
this.chart.setOption({
grid: {
containLabel: true
});
});
data.forEach((item, itemIndex) => {
const dataTimeList = item.dataList.map((i) => i.statisDate);
const noDataTime = mapArr.filter((i) => !dataTimeList.includes(i));
sourceBase.forEach((outer, outerIndex) => {
sourceTop.push(`${item.deviceId}-${outer}`);
noDataTime.forEach((i) => map[i].push(""));
item.dataList.forEach((inner, innerIndex) => {
map[inner.statisDate].push(inner[ele.attr[outerIndex]]);
});
});
});
mapArr = mapArr.sort((a, b) => this.compareDate(a, b));
mapArr.forEach((item) => {
source.push([item, ...map[item]]);
});
source.unshift(sourceTop);
this.chart.setOption(
{
grid: {
containLabel: true,
},
legend: {
left: "center",
bottom: "15",
},
tooltip: {
trigger: "axis",
axisPointer: {
// 坐标轴指示器,坐标轴触发有效
type: "shadow", // 默认为直线,可选为:'line' | 'shadow'
},
},
textStyle: {
color: "#333333",
},
xAxis: {
type: "category",
},
yAxis: {
type: "value",
},
dataset: { source },
series: source[0].slice(1).map((item) => {
return {
type: "line",
};
}),
},
legend: {
left: 'center',
bottom: '15',
},
tooltip: {
trigger: 'axis',
axisPointer: { // 坐标轴指示器,坐标轴触发有效
type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
}
},
textStyle:{
color:"#333333",
},
xAxis: {
type: 'category',
},
yAxis: {
type: 'value',
},
dataset: {source},
series:source[0].slice(1).map(item=>{
return {
type:ele.type || 'scatter'
}
})
},true)
true
);
},
initChart() {
this.chart = echarts.init(document.querySelector('#pcsEchart'));
this.chart = echarts.init(document.querySelector("#pcsEchart"));
},
init() {
this.$nextTick(() => {
this.initChart();
this.$refs.dateRangeSelect.init();
});
},
init(){
this.$nextTick(()=>{
this.initChart()
this.$refs.dateRangeSelect.init()
})
}
},
beforeDestroy() {
if (!this.chart) {
return
return;
}
this.chart.dispose()
this.chart = null
this.chart.dispose();
this.chart = null;
},
}
};
</script>