Files
emsfront/src/views/ems/dzjk/home/index.vue

842 lines
26 KiB
Vue
Raw Normal View History

2025-06-18 01:01:17 +08:00
<template>
2026-02-13 21:46:12 +08:00
<div>
2025-08-14 17:59:58 +08:00
<el-row style="background: #fff" class="row-container" :gutter="15">
2026-01-22 17:27:03 +08:00
<el-col :xs="24" :sm="24" :lg="5">
<!-- 站点信息-->
2025-08-14 17:59:58 +08:00
<el-card
2026-01-13 16:38:21 +08:00
shadow="always"
class="common-card-container common-card-container-body-no-padding"
2025-08-14 17:59:58 +08:00
>
2025-06-18 01:01:17 +08:00
<div slot="header">
2025-09-08 18:01:48 +08:00
<span class="card-title">站点信息</span>
2026-01-13 16:38:21 +08:00
<div class="alarm-msg" v-if="tableData.length > 0" @click="toAlarm">
2026-01-22 17:27:03 +08:00
<i class="el-icon-message-solid"></i> 设备告警
2026-01-13 16:38:21 +08:00
</div>
2025-08-06 17:34:35 +08:00
</div>
2025-08-14 17:59:58 +08:00
<div
2026-01-22 17:27:03 +08:00
style="box-sizing: border-box; height: 218px; padding: 20px 15px"
2025-08-14 17:59:58 +08:00
>
2026-01-22 17:27:03 +08:00
<!-- 地址运行时间-->
<div class="site-info site-info-address">
<div class="title">
<i class="el-icon-location"></i>
</div>
2026-02-13 21:46:12 +08:00
<div class="value">
<i v-if="isBaseInfoLoading" class="el-icon-loading"></i>
<span v-else>{{ info.siteAddress || '-' }}</span>
</div>
2026-01-22 17:27:03 +08:00
</div>
<div class="site-info">
<div class="title">
<i class="el-icon-date"></i>
</div>
2026-02-13 21:46:12 +08:00
<div class="value">
<i v-if="isBaseInfoLoading" class="el-icon-loading"></i>
<span v-else>{{ info.runningTime || '-' }}</span>
</div>
2026-01-22 17:27:03 +08:00
</div>
<!-- 装机功率容量 -->
<el-row :gutter="10" style="margin-top:20px;">
<el-col
:span="12"
class="sjgl-col power-col"
2025-08-14 17:59:58 +08:00
>
2026-01-22 17:27:03 +08:00
<div class="sjgl-wrapper">
2026-04-01 14:27:35 +08:00
<div class="sjgl-title">装机功率(MWh)</div>
2026-01-22 17:27:03 +08:00
<div class="sjgl-value">
2026-02-13 21:46:12 +08:00
<i v-if="isBaseInfoLoading" class="el-icon-loading"></i>
<span v-else>{{ info.installPower | formatNumber }}</span>
2026-01-22 17:27:03 +08:00
</div>
</div>
</el-col>
2025-08-14 17:59:58 +08:00
<el-col
2026-01-13 16:38:21 +08:00
:span="12"
2026-01-22 17:27:03 +08:00
class="sjgl-col power-col"
2025-08-14 17:59:58 +08:00
>
2026-01-22 17:27:03 +08:00
<div class="sjgl-wrapper">
2026-04-01 14:27:35 +08:00
<div class="sjgl-title">装机容量(MWh)</div>
2026-01-22 17:27:03 +08:00
<div class="sjgl-value">
2026-02-13 21:46:12 +08:00
<i v-if="isBaseInfoLoading" class="el-icon-loading"></i>
<span v-else>{{ info.installCapacity | formatNumber }}</span>
2026-01-22 17:27:03 +08:00
</div>
2025-08-14 17:59:58 +08:00
</div>
2025-06-18 01:01:17 +08:00
</el-col>
</el-row>
</div>
</el-card>
</el-col>
2026-01-22 17:27:03 +08:00
<!-- 总累计运行数据-->
<el-col :xs="24" :sm="24" :lg="19">
2026-01-13 16:38:21 +08:00
<el-card
shadow="always"
class="common-card-container common-card-container-body-no-padding"
>
<div slot="header">
2026-01-22 17:27:03 +08:00
<span class="card-title">总累计运行数据</span>
<div class="total-count">
2026-02-16 13:41:41 +08:00
<span class="title pointer-field" @click="handleTotalRevenueClick">总收入</span>
<span
class="value pointer-field"
:class="{ 'field-disabled': !hasPointId(totalRevenueDisplayItem) }"
@click="handleTotalRevenueClick"
>
2026-02-13 21:46:12 +08:00
<i v-if="isRunningInfoLoading" class="el-icon-loading"></i>
<span v-else>{{ totalRevenueDisplayValue | formatNumber }}</span>
</span>
2026-01-22 17:27:03 +08:00
<span class="unit"></span>
</div>
2026-01-13 16:38:21 +08:00
</div>
<div
2026-01-22 17:27:03 +08:00
style="box-sizing: border-box; height: 218px; padding: 20px 15px"
2026-01-13 16:38:21 +08:00
>
2026-01-22 17:27:03 +08:00
<el-row :gutter="10">
2026-01-13 16:38:21 +08:00
<el-col
2026-01-22 17:27:03 +08:00
:span="6"
2026-02-13 21:46:12 +08:00
v-for="(item, index) in runningDataCards"
2026-01-22 17:27:03 +08:00
:key="index + 'sjglData'"
class="sjgl-col"
2026-01-13 16:38:21 +08:00
>
2026-02-16 13:41:41 +08:00
<div
class="sjgl-wrapper pointer-field"
:class="{ 'field-disabled': !hasPointId(item.raw) }"
@click="handleRunningFieldClick(item)"
>
2026-01-22 17:27:03 +08:00
<div class="sjgl-title">{{ item.title }}</div>
<div class="sjgl-value" :style="{color:item.color}">
2026-02-13 21:46:12 +08:00
<i v-if="item.loading" class="el-icon-loading"></i>
<span v-else>{{ item.value | formatNumber }}</span>
2026-01-22 17:27:03 +08:00
</div>
2026-01-13 16:38:21 +08:00
</div>
</el-col>
</el-row>
</div>
</el-card>
2025-06-18 01:01:17 +08:00
</el-col>
2026-01-22 17:27:03 +08:00
<el-col :xs="24" :sm="24" :lg="12">
2026-02-15 16:24:29 +08:00
<week-chart ref="weekChart" :display-data="runningDisplayData"/>
2025-08-06 17:34:35 +08:00
</el-col>
2026-01-22 17:27:03 +08:00
<el-col :xs="24" :sm="24" :lg="12">
2026-02-15 16:24:29 +08:00
<active-chart ref="activeChart" :display-data="runningDisplayData"/>
2025-08-06 17:34:35 +08:00
</el-col>
</el-row>
2026-02-16 13:41:41 +08:00
<el-dialog
:visible.sync="curveDialogVisible"
:title="curveDialogTitle"
width="1000px"
append-to-body
class="ems-dialog"
:close-on-click-modal="false"
destroy-on-close
@opened="handleCurveDialogOpened"
@closed="handleCurveDialogClosed"
>
<div class="curve-tools">
<el-date-picker
v-model="curveCustomRange"
type="datetimerange"
value-format="yyyy-MM-dd HH:mm:ss"
range-separator="至"
start-placeholder="开始时间"
end-placeholder="结束时间"
style="width: 440px"
/>
<el-button type="primary" size="mini" :loading="curveLoading" @click="loadCurveData">查询</el-button>
</div>
<div v-loading="curveLoading" ref="curveChartRef" style="height: 380px;"></div>
</el-dialog>
2025-06-18 01:01:17 +08:00
</div>
</template>
<script>
2026-02-16 13:41:41 +08:00
import * as echarts from "echarts";
2026-01-13 16:38:21 +08:00
import {getSingleSiteBaseInfo} from "@/api/ems/zddt";
import {getAmmeterData, getDzjkHomeTotalView, getProjectDisplayData} from "@/api/ems/dzjk";
2026-02-16 13:41:41 +08:00
import {getPointConfigCurve} from "@/api/ems/site";
2025-08-06 17:34:35 +08:00
import WeekChart from "./WeekChart.vue";
import ActiveChart from "./ActiveChart.vue";
2025-08-11 17:34:39 +08:00
import AlarmTable from "./AlarmTable.vue";
2025-08-14 17:59:58 +08:00
import ClInfo from "./ClInfo.vue";
import getQuerySiteId from "@/mixins/ems/getQuerySiteId";
2025-09-25 17:30:16 +08:00
import intervalUpdate from "@/mixins/ems/intervalUpdate";
2026-01-13 16:38:21 +08:00
2025-06-18 01:01:17 +08:00
export default {
2025-08-14 17:59:58 +08:00
name: "DzjkSbjkHome",
2026-01-13 16:38:21 +08:00
components: {WeekChart, ActiveChart, AlarmTable, ClInfo},
2025-09-27 17:44:03 +08:00
mixins: [getQuerySiteId, intervalUpdate],
2025-06-18 01:01:17 +08:00
data() {
return {
2025-08-14 17:59:58 +08:00
loading: false,
2026-02-13 21:46:12 +08:00
baseInfoLoading: false,
runningInfoLoading: false,
2026-02-15 16:24:29 +08:00
runningUpdateSpinning: false,
runningUpdateTimer: null,
2026-02-16 13:41:41 +08:00
curveDialogVisible: false,
curveDialogTitle: "点位曲线",
curveChart: null,
curveLoading: false,
curveCustomRange: [],
curveQuery: {
siteId: "",
pointId: "",
pointType: "data",
rangeType: "custom",
startTime: "",
endTime: "",
},
2026-02-13 21:46:12 +08:00
fallbackSjglData: [
2025-08-14 17:59:58 +08:00
{
title: "今日充电量kWh",
2025-08-14 17:59:58 +08:00
attr: "dayChargedCap",
2026-01-22 17:27:03 +08:00
color: '#4472c4'
2025-08-14 17:59:58 +08:00
},
{
title: "今日放电量kWh",
2025-08-14 17:59:58 +08:00
attr: "dayDisChargedCap",
2026-01-22 17:27:03 +08:00
color: '#70ad47'
},
{
title: "总充电量kWh",
attr: "totalChargedCap",
color: '#4472c4'
},
{
title: "今日实时收入(元)",
attr: "dayRevenue",
color: '#f67438'
2025-08-14 17:59:58 +08:00
},
2026-01-13 16:38:21 +08:00
{
title: "昨日充电量kWh",
2026-01-23 14:18:22 +08:00
attr: "yesterdayChargedCap",
2026-01-22 17:27:03 +08:00
color: '#4472c4'
2026-01-13 16:38:21 +08:00
},
{
title: "昨日放电量kWh",
2026-01-23 14:18:22 +08:00
attr: "yesterdayDisChargedCap",
2026-01-22 17:27:03 +08:00
color: '#70ad47'
2025-09-25 17:58:22 +08:00
},
{
2025-09-27 17:44:03 +08:00
title: "总放电量kWh",
attr: "totalDischargedCap",
2026-01-22 17:27:03 +08:00
color: '#70ad47'
2025-08-14 17:59:58 +08:00
},
2026-01-13 16:38:21 +08:00
{
title: "昨日实时收入(元)",
2026-01-23 14:18:22 +08:00
attr: "yesterdayRevenue",
2026-01-22 17:27:03 +08:00
color: '#f67438'
2026-01-13 16:38:21 +08:00
},
2025-08-14 17:59:58 +08:00
],
info: {}, //基本信息
runningInfo: {}, //总累计运行数据+报警表格
2026-02-13 21:46:12 +08:00
runningDisplayData: [], //单站监控项目配置展示数据
ammeterDailySummary: {},
2025-08-14 17:59:58 +08:00
};
2025-08-11 17:34:39 +08:00
},
2025-08-14 17:59:58 +08:00
computed: {
2026-02-13 21:46:12 +08:00
isBaseInfoLoading() {
2026-02-15 16:24:29 +08:00
return false;
2026-02-13 21:46:12 +08:00
},
isRunningInfoLoading() {
const state = this.$data || {};
2026-02-15 16:24:29 +08:00
return !!(state.runningInfoLoading || state.runningUpdateSpinning || state.loading);
2026-02-13 21:46:12 +08:00
},
2025-08-14 17:59:58 +08:00
tableData() {
return this.runningInfo?.siteMonitorHomeAlarmVo || [];
},
2026-02-13 21:46:12 +08:00
totalRunningSectionData() {
return (this.runningDisplayData || []).filter(item => item.sectionName === "总累计运行数据");
},
totalRevenueDisplayItem() {
const sectionData = this.totalRunningSectionData || [];
const byFieldCode = sectionData.find(item => item.fieldCode === "totalRevenue");
if (byFieldCode) {
return byFieldCode;
}
return sectionData.find(item => item.fieldName === "总收入");
},
totalRevenueDisplayValue() {
return this.totalRevenueDisplayItem ? this.totalRevenueDisplayItem.fieldValue : this.runningInfo.totalRevenue;
},
runningDataCards() {
const sectionData = this.totalRunningSectionData || [];
if (sectionData.length > 0) {
const revenueFieldCode = this.totalRevenueDisplayItem ? this.totalRevenueDisplayItem.fieldCode : "";
return sectionData
.filter(item => item.fieldCode !== revenueFieldCode)
.map((item, index) => ({
title: item.fieldName,
value: this.getRunningCardValue(item),
2026-02-13 21:46:12 +08:00
color: this.getCardColor(index),
loading: this.isRunningInfoLoading,
2026-02-16 13:41:41 +08:00
raw: item,
2026-02-13 21:46:12 +08:00
}));
}
return this.fallbackSjglData.map(item => ({
title: item.title,
value: this.getRunningCardValue(item),
2026-02-13 21:46:12 +08:00
color: item.color,
loading: this.isRunningInfoLoading,
2026-02-16 13:41:41 +08:00
raw: item,
2026-02-13 21:46:12 +08:00
}));
},
},
2026-02-15 16:24:29 +08:00
beforeDestroy() {
if (this.runningUpdateTimer) {
clearTimeout(this.runningUpdateTimer);
this.runningUpdateTimer = null;
}
2026-02-16 13:41:41 +08:00
if (this.curveChart) {
this.curveChart.dispose();
this.curveChart = null;
}
2026-02-15 16:24:29 +08:00
},
2025-08-14 17:59:58 +08:00
methods: {
2026-02-16 13:41:41 +08:00
hasPointId(item) {
return !!String(item?.dataPoint || "").trim();
},
handleTotalRevenueClick() {
const item = this.totalRevenueDisplayItem;
const pointId = String(item?.dataPoint || "").trim();
if (!pointId) {
this.$message.warning("该字段未配置点位,无法查询曲线");
return;
}
this.openCurveDialog({
pointId,
title: item?.fieldName || "总收入",
});
},
handleRunningFieldClick(card) {
const item = card?.raw || {};
const pointId = String(item?.dataPoint || "").trim();
if (!pointId) {
this.$message.warning("该字段未配置点位,无法查询曲线");
return;
}
this.openCurveDialog({
pointId,
title: card?.title || item?.fieldName || item?.fieldCode || pointId,
});
},
openCurveDialog({pointId, title}) {
const range = this.getDefaultCurveRange();
this.curveCustomRange = range;
this.curveDialogTitle = `点位曲线 - ${title || pointId}`;
this.curveQuery = {
siteId: this.siteId,
pointId,
pointType: "data",
rangeType: "custom",
startTime: range[0],
endTime: range[1],
};
this.curveDialogVisible = true;
},
handleCurveDialogOpened() {
if (!this.curveChart && this.$refs.curveChartRef) {
this.curveChart = echarts.init(this.$refs.curveChartRef);
}
this.loadCurveData();
},
handleCurveDialogClosed() {
if (this.curveChart) {
this.curveChart.dispose();
this.curveChart = null;
}
this.curveLoading = false;
},
getDefaultCurveRange() {
const end = new Date();
const start = new Date(end.getTime() - 24 * 60 * 60 * 1000);
return [this.formatDateTime(start), this.formatDateTime(end)];
},
formatDateTime(date) {
const d = new Date(date);
const pad = (num) => String(num).padStart(2, "0");
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`;
},
formatCurveTime(value) {
if (value === undefined || value === null || value === "") {
return "";
}
const raw = String(value).trim();
const normalized = raw
.replace("T", " ")
.replace(/\.\d+/, "")
.replace(/Z$/, "")
.replace(/([+-]\d{2}:?\d{2})$/, "")
.trim();
const matched = normalized.match(/^(\d{4}-\d{2}-\d{2})\s+(\d{2}:\d{2})/);
if (matched) {
return `${matched[1]} ${matched[2]}`;
}
return normalized.slice(0, 16);
},
loadCurveData() {
if (!this.curveQuery.siteId || !this.curveQuery.pointId) {
this.$message.warning("点位信息不完整,无法查询曲线");
return;
}
if (!this.curveCustomRange || this.curveCustomRange.length !== 2) {
this.$message.warning("请选择查询时间范围");
return;
}
this.curveQuery.startTime = this.curveCustomRange[0];
this.curveQuery.endTime = this.curveCustomRange[1];
const query = {
siteId: this.curveQuery.siteId,
pointId: this.curveQuery.pointId,
pointType: "data",
rangeType: "custom",
startTime: this.curveQuery.startTime,
endTime: this.curveQuery.endTime,
};
this.curveLoading = true;
getPointConfigCurve(query).then((response) => {
const rows = response?.data || [];
this.renderCurveChart(rows);
}).catch(() => {
this.renderCurveChart([]);
}).finally(() => {
this.curveLoading = false;
});
},
renderCurveChart(rows = []) {
if (!this.curveChart) return;
const xData = rows.map(item => this.formatCurveTime(item.dataTime));
const yData = rows.map(item => item.pointValue);
this.curveChart.clear();
this.curveChart.setOption({
legend: {},
grid: {
containLabel: true,
},
tooltip: {
trigger: "axis",
axisPointer: {
type: "cross",
},
},
textStyle: {
color: "#333333",
},
xAxis: {
type: "category",
data: xData,
},
yAxis: {
type: "value",
},
dataZoom: [
{
type: "inside",
start: 0,
end: 100,
},
{
start: 0,
end: 100,
},
],
series: [
{
name: this.curveDialogTitle,
type: "line",
data: yData,
connectNulls: true,
},
],
});
if (!rows.length) {
this.$message.warning("当前时间范围暂无曲线数据");
}
},
2026-02-13 21:46:12 +08:00
setBaseInfoLoading(loading) {
if (Object.prototype.hasOwnProperty.call(this.$data, "baseInfoLoading")) {
this.baseInfoLoading = loading;
return;
}
this.$set(this.$data, "baseInfoLoading", loading);
},
setRunningInfoLoading(loading) {
if (Object.prototype.hasOwnProperty.call(this.$data, "runningInfoLoading")) {
this.runningInfoLoading = loading;
return;
}
this.$set(this.$data, "runningInfoLoading", loading);
},
getCardColor(index) {
const colors = ['#4472c4', '#70ad47', '#4472c4', '#f67438', '#4472c4', '#70ad47', '#70ad47', '#f67438'];
return colors[index % colors.length];
},
formatDateOnly(date) {
const value = new Date(date);
if (isNaN(value.getTime())) {
return "";
}
const pad = (num) => String(num).padStart(2, "0");
return `${value.getFullYear()}-${pad(value.getMonth() + 1)}-${pad(value.getDate())}`;
},
normalizeDateOnly(value) {
if (!value) {
return "";
}
const raw = String(value).trim();
const matched = raw.match(/\d{4}-\d{2}-\d{2}/);
if (matched) {
return matched[0];
}
return this.formatDateOnly(raw);
},
toDisplayNumber(value) {
if (value === null || value === undefined || value === "") {
return value;
}
const num = Number(value);
return Number.isNaN(num) ? value : num;
},
getAmmeterSummaryAttr(item) {
const fieldCode = String(item?.fieldCode || item?.attr || "").trim();
const fieldName = String(item?.fieldName || item?.title || "").trim();
if (["dayChargedCap", "今日充电量kWh"].includes(fieldCode) || fieldName === "今日充电量kWh") {
return "dayChargedCap";
}
if (["dayDisChargedCap", "今日放电量kWh"].includes(fieldCode) || fieldName === "今日放电量kWh") {
return "dayDisChargedCap";
}
if (["yesterdayChargedCap", "昨日充电量kWh"].includes(fieldCode) || fieldName === "昨日充电量kWh") {
return "yesterdayChargedCap";
}
if (["yesterdayDisChargedCap", "昨日放电量kWh"].includes(fieldCode) || fieldName === "昨日放电量kWh") {
return "yesterdayDisChargedCap";
}
if (["totalChargedCap", "总充电量kWh"].includes(fieldCode) || fieldName === "总充电量kWh") {
return "totalChargedCap";
}
if (["totalDischargedCap", "总放电量kWh"].includes(fieldCode) || fieldName === "总放电量kWh") {
return "totalDischargedCap";
}
return "";
},
getRunningCardValue(item) {
const summaryAttr = this.getAmmeterSummaryAttr(item);
if (summaryAttr) {
const summaryValue = this.ammeterDailySummary?.[summaryAttr];
if (summaryValue !== undefined && summaryValue !== null && summaryValue !== "") {
return summaryValue;
}
}
const rawValue = item?.fieldValue !== undefined ? item.fieldValue : this.runningInfo?.[item?.attr];
return this.toDisplayNumber(rawValue);
},
queryAllAmmeterDailyRows({ startTime = "", endTime = "", pageSize = 500, pageNum = 1, rows = [] } = {}) {
return getAmmeterData({
siteId: this.siteId,
startTime,
endTime,
pageSize,
pageNum,
}).then((response) => {
const currentRows = Array.isArray(response?.rows) ? response.rows : [];
const allRows = rows.concat(currentRows);
const total = Number(response?.total) || 0;
if (allRows.length >= total || currentRows.length < pageSize) {
return allRows;
}
return this.queryAllAmmeterDailyRows({
startTime,
endTime,
pageSize,
pageNum: pageNum + 1,
rows: allRows,
});
});
},
getAmmeterDailySummary() {
const today = new Date();
const yesterday = new Date(today);
yesterday.setDate(yesterday.getDate() - 1);
const startTime = this.formatDateOnly(yesterday);
const endTime = this.formatDateOnly(today);
return Promise.all([
this.queryAllAmmeterDailyRows({
startTime,
endTime,
pageSize: 20,
pageNum: 1,
}),
this.queryAllAmmeterDailyRows(),
]).then(([recentRows, allRows]) => {
const rowMap = recentRows.reduce((result, row) => {
const dateKey = this.normalizeDateOnly(row?.dataTime);
if (dateKey) {
result[dateKey] = row;
}
return result;
}, {});
const todayKey = this.formatDateOnly(today);
const yesterdayKey = this.formatDateOnly(yesterday);
const todayRow = rowMap[todayKey] || {};
const yesterdayRow = rowMap[yesterdayKey] || {};
const totalChargedCap = allRows.reduce((result, row) => {
return result + (Number(row?.activeTotalKwh) || 0);
}, 0);
const totalDischargedCap = allRows.reduce((result, row) => {
return result + (Number(row?.reActiveTotalKwh) || 0);
}, 0);
return {
dayChargedCap: this.toDisplayNumber(todayRow.activeTotalKwh),
dayDisChargedCap: this.toDisplayNumber(todayRow.reActiveTotalKwh),
yesterdayChargedCap: this.toDisplayNumber(yesterdayRow.activeTotalKwh),
yesterdayDisChargedCap: this.toDisplayNumber(yesterdayRow.reActiveTotalKwh),
totalChargedCap: this.toDisplayNumber(totalChargedCap),
totalDischargedCap: this.toDisplayNumber(totalDischargedCap),
};
}).catch(() => ({}));
},
2026-01-13 16:38:21 +08:00
toAlarm() {
this.$router.push({path: "/dzjk/gzgj", query: this.$route.query});
},
2025-08-14 17:59:58 +08:00
getBaseInfo() {
return getSingleSiteBaseInfo(this.siteId).then((response) => {
this.info = response?.data || {};
});
2025-08-06 23:06:12 +08:00
},
2025-08-14 17:59:58 +08:00
getRunningInfo() {
2026-02-15 16:24:29 +08:00
const hasOldData = Object.keys(this.runningInfo || {}).length > 0 || (this.runningDisplayData || []).length > 0;
if (!hasOldData) {
this.setRunningInfoLoading(true);
}
2026-02-13 21:46:12 +08:00
return Promise.all([
2026-04-01 14:27:35 +08:00
getDzjkHomeTotalView(this.siteId),
2026-02-13 21:46:12 +08:00
getProjectDisplayData(this.siteId),
this.getAmmeterDailySummary(),
]).then(([homeResponse, displayResponse, ammeterDailySummary]) => {
2026-02-15 16:24:29 +08:00
const nextRunningInfo = homeResponse?.data || {};
const nextRunningDisplayData = displayResponse?.data || [];
const changed = hasOldData && this.hasTotalRunningChanged(nextRunningInfo, nextRunningDisplayData, ammeterDailySummary || {});
2026-02-15 16:24:29 +08:00
this.runningInfo = nextRunningInfo;
this.runningDisplayData = nextRunningDisplayData;
this.ammeterDailySummary = ammeterDailySummary || {};
2026-02-15 16:24:29 +08:00
if (changed) {
this.triggerRunningUpdateSpinner();
}
2026-02-13 21:46:12 +08:00
}).finally(() => {
2026-02-15 16:24:29 +08:00
if (!hasOldData) {
this.setRunningInfoLoading(false);
}
});
},
triggerRunningUpdateSpinner() {
if (this.runningUpdateTimer) {
clearTimeout(this.runningUpdateTimer);
}
this.runningUpdateSpinning = true;
this.runningUpdateTimer = setTimeout(() => {
this.runningUpdateSpinning = false;
this.runningUpdateTimer = null;
}, 800);
},
hasTotalRunningChanged(nextRunningInfo, nextRunningDisplayData, nextAmmeterDailySummary = {}) {
const oldSnapshot = this.getTotalRunningSnapshot(this.runningInfo, this.runningDisplayData, this.ammeterDailySummary || {});
const newSnapshot = this.getTotalRunningSnapshot(nextRunningInfo, nextRunningDisplayData, nextAmmeterDailySummary);
2026-02-15 16:24:29 +08:00
return JSON.stringify(oldSnapshot) !== JSON.stringify(newSnapshot);
},
getTotalRunningSnapshot(runningInfo, runningDisplayData, ammeterDailySummary = {}) {
2026-02-15 16:24:29 +08:00
const snapshot = {};
const sectionData = (runningDisplayData || []).filter(item => item.sectionName === "总累计运行数据");
if (sectionData.length > 0) {
sectionData.forEach(item => {
const key = item.fieldCode || item.fieldName;
if (!key) return;
const summaryAttr = this.getAmmeterSummaryAttr(item);
const value = summaryAttr ? ammeterDailySummary?.[summaryAttr] : item.fieldValue;
snapshot[`cfg:${key}`] = this.normalizeRunningCompareValue(value);
2026-02-15 16:24:29 +08:00
});
return snapshot;
}
this.fallbackSjglData.forEach(item => {
const summaryAttr = this.getAmmeterSummaryAttr(item);
const value = summaryAttr
? ammeterDailySummary?.[summaryAttr]
: runningInfo?.[item.attr];
snapshot[`fallback:${item.attr}`] = this.normalizeRunningCompareValue(value);
2025-08-14 17:59:58 +08:00
});
2026-02-15 16:24:29 +08:00
snapshot["fallback:totalRevenue"] = this.normalizeRunningCompareValue(runningInfo?.totalRevenue);
return snapshot;
},
normalizeRunningCompareValue(value) {
if (value === null || value === undefined) return "";
if (typeof value === "number") return Number.isNaN(value) ? "" : value;
const text = String(value).trim();
if (text === "") return "";
const num = Number(text);
return Number.isNaN(num) ? text : num;
2025-08-06 23:06:12 +08:00
},
2025-08-14 17:59:58 +08:00
init() {
2025-08-06 23:06:12 +08:00
// 功率曲线
2025-08-14 17:59:58 +08:00
this.$refs.activeChart.init(this.siteId);
2025-08-11 17:34:39 +08:00
// 一周冲放曲线
2025-08-14 17:59:58 +08:00
this.$refs.weekChart.init(this.siteId);
2025-08-11 17:34:39 +08:00
// 静态信息 this.getBaseInfo()
// 总累计运行数据+故障告警 this.getRunningInfo()
2026-02-13 21:46:12 +08:00
Promise.all([this.getBaseInfo(), this.getRunningInfo()]);
2025-09-25 17:30:16 +08:00
// 一分钟循环一次总累计运行数据
2025-09-27 17:44:03 +08:00
this.updateInterval(this.getRunningInfo);
2025-08-14 17:59:58 +08:00
},
},
2025-08-14 17:59:58 +08:00
};
2025-06-18 01:01:17 +08:00
</script>
<style scoped lang="scss">
2026-01-22 17:27:03 +08:00
//设备告警
2026-01-13 16:38:21 +08:00
.alarm-msg {
2026-01-22 17:27:03 +08:00
background: #ff4949;
padding: 2px 5px;
font-size: 10px;
font-weight: bolder;
border-radius: 3px;
line-height: 20px;
2026-01-13 16:38:21 +08:00
cursor: pointer;
2026-01-22 17:27:03 +08:00
color: #fff;
2026-01-13 16:38:21 +08:00
position: absolute;
2026-01-22 17:27:03 +08:00
right: 10px;
2026-01-13 16:38:21 +08:00
top: 50%;
transform: translateY(-50%);
}
2026-01-22 17:27:03 +08:00
//基本信息-地址 运行️时间
.site-info {
display: flex;
font-size: 12px;
line-height: 20px;
margin-bottom: 10px;
align-items: center;
&.site-info-address {
height: 40px;
}
.title {
color: #1791ff;
font-size: 18px;
line-height: 20px;
margin-right: 7px;
}
.value {
color: #000;
font-size: 12px;
max-height: 40px;
overflow: hidden;
}
}
//总收入
.total-count {
position: absolute;
right: 10px;
top: 50%;
transform: translateY(-50%);
font-size: 12px;
font-weight: bolder;
color: #333;
line-height: 14px;
.unit {
font-style: italic;
}
.value {
font-size: 22px;
font-weight: bolder;
color: #ed2f1d;
font-style: italic;
padding: 0 5px;
}
}
2026-02-16 13:41:41 +08:00
.pointer-field {
cursor: pointer;
}
.field-disabled {
cursor: not-allowed;
opacity: 0.75;
}
.curve-tools {
margin-bottom: 10px;
display: flex;
align-items: center;
gap: 10px;
}
2025-08-14 17:59:58 +08:00
.row-container {
& > .el-col {
margin-bottom: 20px;
2025-08-11 17:34:39 +08:00
}
2025-08-14 17:59:58 +08:00
}
2025-06-18 01:01:17 +08:00
//数据概览
2026-01-22 17:27:03 +08:00
.sjgl-col {
.sjgl-wrapper {
text-align: left;
padding: 15px 20px;
background-color: #f2f7fb;
}
&.power-col {
.sjgl-wrapper {
padding: 10px;
.sjgl-value {
color: #c44444;
}
}
}
2026-01-13 16:38:21 +08:00
2026-01-22 17:27:03 +08:00
&:nth-child(4),
2025-09-27 17:44:03 +08:00
&:nth-child(2),
&:nth-child(3),
&:nth-child(4) {
2026-01-22 17:27:03 +08:00
margin-bottom: 10px;
2025-06-18 01:01:17 +08:00
}
2026-01-13 16:38:21 +08:00
2025-08-14 17:59:58 +08:00
.sjgl-title {
2026-01-22 17:27:03 +08:00
color: #717171;
2025-08-14 17:59:58 +08:00
line-height: 14px;
2026-01-22 17:27:03 +08:00
font-weight: bold;
2025-08-14 17:59:58 +08:00
}
2026-01-13 16:38:21 +08:00
2025-08-14 17:59:58 +08:00
.sjgl-value {
color: rgba(51, 51, 51, 1);
2026-01-22 17:27:03 +08:00
font-size: 22px;
2025-08-14 17:59:58 +08:00
line-height: 26px;
2026-01-22 17:27:03 +08:00
font-weight: bolder;
font-style: italic;
2025-08-14 17:59:58 +08:00
margin-top: 14px;
2026-01-22 17:27:03 +08:00
width: 100%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
2025-08-14 17:59:58 +08:00
}
}
2025-08-11 17:34:39 +08:00
</style>
<style lang="scss">
2025-08-14 17:59:58 +08:00
.home-normal-info {
font-size: 12px;
2026-01-13 16:38:21 +08:00
2025-08-14 17:59:58 +08:00
.el-descriptions-item__container {
.el-descriptions-item__label {
color: #666666;
}
2026-01-13 16:38:21 +08:00
2025-08-14 17:59:58 +08:00
.el-descriptions-item__content {
color: #333333;
}
2025-08-13 17:49:25 +08:00
}
2025-08-14 17:59:58 +08:00
}
2025-08-11 21:50:38 +08:00
</style>