2025-07-17 17:47:18 +08:00
|
|
|
<template>
|
|
|
|
|
<el-dialog
|
|
|
|
|
:visible.sync="dialogTableVisible"
|
|
|
|
|
:close-on-click-modal="false"
|
|
|
|
|
show-close
|
|
|
|
|
destroy-on-close
|
|
|
|
|
lock-scroll
|
|
|
|
|
append-to-body
|
|
|
|
|
width="700px"
|
2025-09-22 17:57:30 +08:00
|
|
|
class="ems-dialog chart-detail-dialog"
|
2025-07-17 17:47:18 +08:00
|
|
|
:before-close="handleColsed"
|
|
|
|
|
>
|
2025-10-12 23:10:15 +08:00
|
|
|
<el-card
|
|
|
|
|
shadow="always"
|
|
|
|
|
class="common-card-container time-range-card"
|
|
|
|
|
style="margin-top: 20px"
|
|
|
|
|
>
|
2025-09-22 17:57:30 +08:00
|
|
|
<div slot="header" class="time-range-header">
|
2025-10-12 23:10:15 +08:00
|
|
|
<span class="card-title"></span>
|
|
|
|
|
<date-range-select ref="dateRangeSelect" @updateDate="updateDate" />
|
2025-09-22 17:57:30 +08:00
|
|
|
</div>
|
|
|
|
|
<div class="card-main" v-loading="loading">
|
2025-10-12 23:10:15 +08:00
|
|
|
<div id="lineChart" style="height: 310px"></div>
|
2025-09-22 17:57:30 +08:00
|
|
|
</div>
|
|
|
|
|
</el-card>
|
2025-07-17 17:47:18 +08:00
|
|
|
</el-dialog>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2025-08-15 09:50:30 +08:00
|
|
|
import * as echarts from "echarts";
|
|
|
|
|
import resize from "@/mixins/ems/resize";
|
|
|
|
|
import { getSingleBatteryData } from "@/api/ems/dzjk";
|
2025-09-22 17:57:30 +08:00
|
|
|
import DateRangeSelect from "@/components/Ems/DateRangeSelect/index.vue";
|
2025-07-17 17:47:18 +08:00
|
|
|
export default {
|
2025-10-12 23:10:15 +08:00
|
|
|
components: { DateRangeSelect },
|
2025-07-17 17:47:18 +08:00
|
|
|
mixins: [resize],
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
loading: false,
|
2025-08-15 09:50:30 +08:00
|
|
|
siteId: "",
|
|
|
|
|
deviceId: "",
|
|
|
|
|
clusterDeviceId: "",
|
|
|
|
|
dataType: "", //展示的数据类型 空值展示所有数据
|
|
|
|
|
pickerOptions: {
|
2025-07-17 17:47:18 +08:00
|
|
|
disabledDate(time) {
|
|
|
|
|
return time.getTime() > Date.now();
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
dialogTableVisible: false,
|
|
|
|
|
dateRange: [],
|
2025-08-15 09:50:30 +08:00
|
|
|
};
|
2025-07-17 17:47:18 +08:00
|
|
|
},
|
|
|
|
|
methods: {
|
2025-09-22 17:57:30 +08:00
|
|
|
// 更新时间范围 重置图表
|
2025-10-12 23:10:15 +08:00
|
|
|
updateDate(data) {
|
|
|
|
|
this.dateRange = data || [];
|
|
|
|
|
this.getData();
|
2025-08-15 09:50:30 +08:00
|
|
|
},
|
|
|
|
|
handleColsed(done) {
|
2025-07-17 17:47:18 +08:00
|
|
|
if (!this.chart) {
|
2025-08-15 09:50:30 +08:00
|
|
|
return done();
|
2025-07-17 17:47:18 +08:00
|
|
|
}
|
2025-08-15 09:50:30 +08:00
|
|
|
this.chart.dispose();
|
|
|
|
|
this.chart = null;
|
|
|
|
|
done();
|
2025-07-17 17:47:18 +08:00
|
|
|
},
|
2025-08-15 09:50:30 +08:00
|
|
|
getData() {
|
|
|
|
|
if (this.loading) return;
|
2025-07-17 17:47:18 +08:00
|
|
|
this.loading = true;
|
2025-08-15 09:50:30 +08:00
|
|
|
this.chart.showLoading();
|
|
|
|
|
const {
|
|
|
|
|
siteId,
|
|
|
|
|
deviceId,
|
|
|
|
|
clusterDeviceId,
|
|
|
|
|
dateRange: [startDate = "", endDate = ""],
|
|
|
|
|
} = this;
|
|
|
|
|
getSingleBatteryData({
|
|
|
|
|
siteId,
|
|
|
|
|
deviceId,
|
|
|
|
|
clusterDeviceId,
|
|
|
|
|
startDate,
|
|
|
|
|
endDate,
|
2025-07-17 17:47:18 +08:00
|
|
|
})
|
2025-08-15 09:50:30 +08:00
|
|
|
.then((response) => {
|
|
|
|
|
this.setOption(response?.data || []);
|
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
this.loading = false;
|
|
|
|
|
this.chart.hideLoading();
|
|
|
|
|
});
|
2025-07-17 17:47:18 +08:00
|
|
|
},
|
2025-08-15 09:50:30 +08:00
|
|
|
initChart({ siteId, clusterDeviceId, deviceId }, dataType) {
|
|
|
|
|
this.siteId = siteId;
|
|
|
|
|
this.clusterDeviceId = clusterDeviceId;
|
|
|
|
|
this.deviceId = deviceId;
|
|
|
|
|
this.dataType = dataType;
|
|
|
|
|
this.dialogTableVisible = true;
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
!this.chart &&
|
|
|
|
|
(this.chart = echarts.init(document.querySelector("#lineChart")));
|
2025-10-12 23:10:15 +08:00
|
|
|
this.$refs.dateRangeSelect.init();
|
2025-08-15 09:50:30 +08:00
|
|
|
});
|
2025-07-17 17:47:18 +08:00
|
|
|
},
|
|
|
|
|
setOption(data) {
|
2025-07-18 19:15:05 +08:00
|
|
|
const obj = {
|
2025-08-15 09:50:30 +08:00
|
|
|
voltage: "电压",
|
|
|
|
|
temperature: "温度",
|
|
|
|
|
soc: "SOC",
|
|
|
|
|
soh: "SOH",
|
|
|
|
|
};
|
|
|
|
|
let source,
|
|
|
|
|
series,
|
|
|
|
|
{ dataType } = this;
|
|
|
|
|
if (dataType) {
|
|
|
|
|
source = [["日期", obj[dataType]]];
|
|
|
|
|
data.forEach((item) => {
|
|
|
|
|
source.push([item.dataTimestamp, item[dataType]]);
|
|
|
|
|
});
|
|
|
|
|
series = [
|
2025-07-18 19:15:05 +08:00
|
|
|
{
|
2025-08-15 09:50:30 +08:00
|
|
|
name: obj[dataType],
|
|
|
|
|
type: "line",
|
2025-07-18 19:15:05 +08:00
|
|
|
},
|
2025-08-15 09:50:30 +08:00
|
|
|
];
|
|
|
|
|
} else {
|
|
|
|
|
source = [["日期", "电压", "温度", "SOC", "SOH"]];
|
|
|
|
|
data.forEach((item) => {
|
|
|
|
|
source.push([
|
|
|
|
|
item.dataTimestamp,
|
|
|
|
|
item.voltage,
|
|
|
|
|
item.temperature,
|
|
|
|
|
item.soc,
|
|
|
|
|
item.soh,
|
|
|
|
|
]);
|
|
|
|
|
});
|
|
|
|
|
series = [
|
2025-07-18 19:15:05 +08:00
|
|
|
{
|
2025-08-15 09:50:30 +08:00
|
|
|
name: "电压",
|
|
|
|
|
type: "line",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "温度",
|
|
|
|
|
type: "line",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "SOC",
|
|
|
|
|
type: "line",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "SOH",
|
|
|
|
|
type: "line",
|
|
|
|
|
},
|
|
|
|
|
];
|
2025-07-18 19:15:05 +08:00
|
|
|
}
|
2025-08-15 09:50:30 +08:00
|
|
|
this.chart &&
|
|
|
|
|
this.chart.setOption({
|
|
|
|
|
color: ["#FFBD00", "#3C81FF", "#05AEA3", "#F86F70"],
|
|
|
|
|
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,
|
|
|
|
|
});
|
|
|
|
|
},
|
2025-07-17 17:47:18 +08:00
|
|
|
},
|
2025-08-15 09:50:30 +08:00
|
|
|
mounted() {},
|
|
|
|
|
};
|
2025-07-17 17:47:18 +08:00
|
|
|
</script>
|
2025-09-22 17:57:30 +08:00
|
|
|
<style lang="scss" scoped>
|
2025-10-12 23:10:15 +08:00
|
|
|
.chart-detail-dialog {
|
|
|
|
|
::v-deep {
|
|
|
|
|
.el-dialog__body {
|
|
|
|
|
padding-top: 0;
|
2025-09-22 17:57:30 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|