2025-09-13 20:36:46 +08:00
|
|
|
<!--电位展示图表-->
|
|
|
|
|
<template>
|
|
|
|
|
<el-dialog
|
2025-12-10 15:00:12 +08:00
|
|
|
:visible.sync="show"
|
|
|
|
|
:title="pointName"
|
|
|
|
|
:close-on-click-modal="false"
|
|
|
|
|
show-close
|
|
|
|
|
destroy-on-close
|
|
|
|
|
lock-scroll
|
|
|
|
|
append-to-body
|
|
|
|
|
width="1000px"
|
|
|
|
|
class="ems-dialog"
|
|
|
|
|
:before-close="handleClosed"
|
2025-09-13 20:36:46 +08:00
|
|
|
>
|
2025-10-12 23:10:15 +08:00
|
|
|
<el-card
|
2025-12-10 15:00:12 +08:00
|
|
|
shadow="always"
|
|
|
|
|
class="common-card-container common-card-container-body-no-padding time-range-card"
|
2025-10-12 23:10:15 +08:00
|
|
|
>
|
2025-09-13 20:36:46 +08:00
|
|
|
<div slot="header" class="time-range-header">
|
|
|
|
|
<el-radio-group class="card-title" v-model="dataUnit">
|
|
|
|
|
<el-radio :label="1">分钟</el-radio>
|
|
|
|
|
<el-radio :label="2">小时</el-radio>
|
|
|
|
|
<el-radio :label="3">天</el-radio>
|
|
|
|
|
</el-radio-group>
|
2025-10-12 23:10:15 +08:00
|
|
|
<date-time-select
|
2025-12-10 15:00:12 +08:00
|
|
|
ref="dateTimeSelect"
|
|
|
|
|
:data-unit="dataUnit"
|
|
|
|
|
@initDate="(e) => (dataRange = e || [])"
|
|
|
|
|
@updateDate="updateDate"
|
2025-10-12 23:10:15 +08:00
|
|
|
/>
|
2025-09-13 20:36:46 +08:00
|
|
|
</div>
|
|
|
|
|
<div style="height: 350px" id="searchChart"></div>
|
|
|
|
|
</el-card>
|
|
|
|
|
</el-dialog>
|
|
|
|
|
</template>
|
|
|
|
|
<script>
|
|
|
|
|
import * as echarts from "echarts";
|
|
|
|
|
import resize from "@/mixins/ems/resize";
|
|
|
|
|
import DateTimeSelect from "@/views/ems/search/DateTimeSelect.vue";
|
2025-12-10 15:00:12 +08:00
|
|
|
import {getPointValueList} from "@/api/ems/search";
|
2025-09-13 20:36:46 +08:00
|
|
|
import DateRangeSelect from "@/components/Ems/DateRangeSelect/index.vue";
|
2025-12-10 15:00:12 +08:00
|
|
|
|
2025-09-13 20:36:46 +08:00
|
|
|
export default {
|
2025-12-10 15:00:12 +08:00
|
|
|
components: {DateRangeSelect, DateTimeSelect},
|
2025-09-13 20:36:46 +08:00
|
|
|
mixins: [resize],
|
|
|
|
|
props: {
|
2025-10-12 23:10:15 +08:00
|
|
|
siteId: {
|
2025-09-13 20:36:46 +08:00
|
|
|
type: String,
|
|
|
|
|
required: true,
|
2025-10-12 23:10:15 +08:00
|
|
|
},
|
2025-09-13 20:36:46 +08:00
|
|
|
},
|
|
|
|
|
computed: {
|
2025-10-12 23:10:15 +08:00
|
|
|
isDtdc() {
|
2025-10-16 16:10:29 +08:00
|
|
|
return this.deviceCategory === "BATTERY";
|
2025-09-13 20:36:46 +08:00
|
|
|
},
|
|
|
|
|
},
|
2025-10-12 23:10:15 +08:00
|
|
|
watch: {
|
2025-09-13 20:36:46 +08:00
|
|
|
show(val) {
|
2025-10-12 23:10:15 +08:00
|
|
|
if (!val) {
|
|
|
|
|
this.pointName = "";
|
2025-10-16 16:10:29 +08:00
|
|
|
this.deviceCategory = "";
|
2025-10-12 23:10:15 +08:00
|
|
|
this.deviceId = "";
|
|
|
|
|
this.dataUnit = 1;
|
|
|
|
|
this.child = "";
|
2025-09-13 20:36:46 +08:00
|
|
|
if (!this.chart) {
|
2025-10-12 23:10:15 +08:00
|
|
|
return;
|
2025-09-13 20:36:46 +08:00
|
|
|
}
|
2025-10-12 23:10:15 +08:00
|
|
|
this.hideLoading();
|
|
|
|
|
this.chart.dispose();
|
|
|
|
|
this.chart = null;
|
2025-09-13 20:36:46 +08:00
|
|
|
}
|
|
|
|
|
},
|
2025-10-12 23:10:15 +08:00
|
|
|
dataUnit: {
|
|
|
|
|
handler(newVal, oldVal) {
|
|
|
|
|
if (!this.show) return;
|
|
|
|
|
console.log("wacth到了dataUnit的变化", newVal, oldVal);
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
this.$refs.dateTimeSelect.init();
|
|
|
|
|
this.getDate();
|
|
|
|
|
});
|
2025-09-13 20:36:46 +08:00
|
|
|
},
|
2025-10-12 23:10:15 +08:00
|
|
|
},
|
2025-09-13 20:36:46 +08:00
|
|
|
},
|
2025-10-12 23:10:15 +08:00
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
show: false,
|
|
|
|
|
chart: null,
|
|
|
|
|
dataUnit: 1,
|
|
|
|
|
dataRange: [],
|
|
|
|
|
child: "", //单体电池需要数据
|
|
|
|
|
pointName: "",
|
2025-10-16 16:10:29 +08:00
|
|
|
deviceCategory: "",
|
2025-10-12 23:10:15 +08:00
|
|
|
deviceId: "",
|
|
|
|
|
};
|
2025-09-13 20:36:46 +08:00
|
|
|
},
|
2025-10-12 23:10:15 +08:00
|
|
|
methods: {
|
2025-12-10 15:00:12 +08:00
|
|
|
showChart({pointName, deviceCategory, deviceId, child = ""}) {
|
2025-09-13 20:36:46 +08:00
|
|
|
//初始化数据
|
2025-10-12 23:10:15 +08:00
|
|
|
this.pointName = pointName;
|
2025-10-16 16:10:29 +08:00
|
|
|
this.deviceCategory = deviceCategory;
|
2025-10-12 23:10:15 +08:00
|
|
|
this.deviceId = deviceId;
|
|
|
|
|
child && (this.child = child);
|
|
|
|
|
this.show = true;
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
this.$refs.dateTimeSelect.init();
|
|
|
|
|
this.initChart();
|
|
|
|
|
this.getDate();
|
|
|
|
|
});
|
2025-09-13 20:36:46 +08:00
|
|
|
},
|
|
|
|
|
initChart() {
|
2025-10-12 23:10:15 +08:00
|
|
|
this.chart = echarts.init(document.querySelector("#searchChart"));
|
2025-09-13 20:36:46 +08:00
|
|
|
},
|
2025-10-12 23:10:15 +08:00
|
|
|
showLoading() {
|
|
|
|
|
this.chart && this.chart.showLoading();
|
2025-09-13 20:36:46 +08:00
|
|
|
},
|
2025-10-12 23:10:15 +08:00
|
|
|
hideLoading() {
|
|
|
|
|
this.chart && this.chart.hideLoading();
|
2025-09-13 20:36:46 +08:00
|
|
|
},
|
2025-10-12 23:10:15 +08:00
|
|
|
getDate() {
|
|
|
|
|
this.showLoading();
|
|
|
|
|
const {
|
|
|
|
|
siteId,
|
|
|
|
|
dataUnit,
|
|
|
|
|
dataRange: [start = "", end = ""],
|
|
|
|
|
child,
|
|
|
|
|
deviceId,
|
2025-10-16 16:10:29 +08:00
|
|
|
deviceCategory,
|
2025-10-12 23:10:15 +08:00
|
|
|
pointName,
|
|
|
|
|
} = this;
|
|
|
|
|
let siteDeviceMap = {};
|
|
|
|
|
child && (siteDeviceMap[siteId] = child);
|
|
|
|
|
let startDate, endDate;
|
|
|
|
|
if (start && dataUnit === 3) {
|
|
|
|
|
// startDate= start + `${dataUnit === 2 ? ':00' : ' 00:00:00'}`
|
|
|
|
|
startDate = start + " 00:00:00";
|
|
|
|
|
} else {
|
|
|
|
|
startDate = start;
|
|
|
|
|
}
|
|
|
|
|
if (end && dataUnit === 3) {
|
|
|
|
|
// endDate= end + `${dataUnit === 2 ? ':00' : ' 00:00:00'}`
|
|
|
|
|
endDate = end + " 00:00:00";
|
|
|
|
|
} else {
|
|
|
|
|
endDate = end;
|
|
|
|
|
}
|
2025-09-13 20:36:46 +08:00
|
|
|
|
2025-10-12 23:10:15 +08:00
|
|
|
getPointValueList({
|
|
|
|
|
siteIds: [siteId],
|
|
|
|
|
deviceId,
|
|
|
|
|
dataUnit,
|
2025-10-16 16:10:29 +08:00
|
|
|
deviceCategory,
|
2025-10-12 23:10:15 +08:00
|
|
|
pointName,
|
|
|
|
|
startDate,
|
|
|
|
|
endDate,
|
|
|
|
|
siteDeviceMap,
|
|
|
|
|
})
|
2025-12-10 15:00:12 +08:00
|
|
|
.then((response) => {
|
|
|
|
|
this.setOption(response?.data || []);
|
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
this.hideLoading();
|
|
|
|
|
});
|
2025-09-13 20:36:46 +08:00
|
|
|
},
|
|
|
|
|
setOption(data) {
|
2025-10-12 23:10:15 +08:00
|
|
|
if (!this.chart) return;
|
|
|
|
|
this.chart.clear();
|
|
|
|
|
console.log("返回的数据", data);
|
2025-12-10 15:00:12 +08:00
|
|
|
if (!data || data.length <= 0) {
|
|
|
|
|
this.$message.warning("暂无数据");
|
|
|
|
|
}
|
|
|
|
|
console.log('展示的图表类型chartType', data[0].chartType)
|
|
|
|
|
|
|
|
|
|
if (data[0].chartType === 2) {
|
|
|
|
|
// 箱型图
|
|
|
|
|
this.setBoxOption(data)
|
|
|
|
|
} else {
|
|
|
|
|
//折线图
|
|
|
|
|
this.setLineOption(data)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
setLineOption(data) {
|
2025-10-12 23:10:15 +08:00
|
|
|
let dataset = [];
|
2025-12-10 15:00:12 +08:00
|
|
|
data.forEach((item, index) => {
|
|
|
|
|
item.deviceList.forEach((inner) => {
|
|
|
|
|
dataset.push({
|
|
|
|
|
name: `${
|
2025-10-12 23:10:15 +08:00
|
|
|
this.isDtdc
|
2025-12-10 15:00:12 +08:00
|
|
|
? `${inner.parentDeviceId ? inner.parentDeviceId + "-" : ""}${inner.deviceId}`
|
|
|
|
|
: `${inner.deviceId}`
|
|
|
|
|
}`,
|
|
|
|
|
type: "line",
|
|
|
|
|
markPoint: {
|
|
|
|
|
symbolSize: 30,
|
|
|
|
|
emphasis: {
|
|
|
|
|
disabled: false//打开 鼠标高亮
|
|
|
|
|
},
|
|
|
|
|
data: [//最大值、最小值
|
|
|
|
|
{
|
|
|
|
|
// type: 'max',
|
|
|
|
|
name: `最大值`,
|
|
|
|
|
coord: [inner.maxDate, inner.maxValue],
|
|
|
|
|
relativeTo: 'coordinate',
|
|
|
|
|
label: {
|
|
|
|
|
position: "top",
|
|
|
|
|
formatter: item.dataType === 2 ? ([
|
|
|
|
|
`最大值:${inner.maxValue}`,
|
|
|
|
|
// `平均值:${inner.avgValue}`,
|
|
|
|
|
`差值:${inner.diffValue}`,
|
|
|
|
|
]).join('\n') : ([
|
|
|
|
|
`最大值:${inner.maxValue}`,
|
|
|
|
|
// `平均值:${inner.avgValue}`,
|
|
|
|
|
]).join('\n'),
|
2025-10-21 15:42:00 +08:00
|
|
|
},
|
2025-12-10 15:00:12 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
// type: 'min',
|
|
|
|
|
name: `最小值`,
|
|
|
|
|
coord: [inner.minDate, inner.minValue],
|
|
|
|
|
relativeTo: 'coordinate',
|
|
|
|
|
label: {
|
|
|
|
|
position: "top",
|
|
|
|
|
formatter: item.dataType === 2 ? ([
|
|
|
|
|
`最小值:${inner.minValue}`,
|
|
|
|
|
// `平均值:${inner.avgValue}`,
|
|
|
|
|
`差值:${inner.diffValue}`,
|
|
|
|
|
]).join('\n') : ([
|
|
|
|
|
`最小值:${inner.minValue}`,
|
|
|
|
|
// `平均值:${inner.avgValue}`,
|
|
|
|
|
]).join('\n'),
|
2025-10-21 15:42:00 +08:00
|
|
|
}
|
2025-12-10 15:00:12 +08:00
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
xdata: [],
|
|
|
|
|
data: [],
|
|
|
|
|
});
|
|
|
|
|
const length = dataset.length;
|
|
|
|
|
inner.pointValueList.forEach((value) => {
|
|
|
|
|
dataset[length - 1].xdata.push(value.valueDate);
|
|
|
|
|
dataset[length - 1].data.push(value.pointValue);
|
2025-10-12 23:10:15 +08:00
|
|
|
});
|
|
|
|
|
});
|
2025-12-10 15:00:12 +08:00
|
|
|
});
|
|
|
|
|
console.log("折线图图表数据", dataset);
|
2025-09-13 20:36:46 +08:00
|
|
|
this.chart.setOption({
|
|
|
|
|
legend: {
|
|
|
|
|
// left: 'center',
|
|
|
|
|
// top: '10',
|
|
|
|
|
},
|
|
|
|
|
grid: {
|
2025-10-12 23:10:15 +08:00
|
|
|
containLabel: true,
|
2025-09-13 20:36:46 +08:00
|
|
|
},
|
|
|
|
|
tooltip: {
|
2025-10-12 23:10:15 +08:00
|
|
|
trigger: "axis",
|
|
|
|
|
axisPointer: {
|
2025-12-10 15:00:12 +08:00
|
|
|
type: 'cross',
|
2025-10-12 23:10:15 +08:00
|
|
|
},
|
2025-12-10 15:00:12 +08:00
|
|
|
// axisPointer: {
|
|
|
|
|
// // 坐标轴指示器,坐标轴触发有效
|
|
|
|
|
// type: "shadow", // 默认为直线,可选为:'line' | 'shadow'
|
|
|
|
|
// },
|
2025-09-13 20:36:46 +08:00
|
|
|
},
|
2025-10-12 23:10:15 +08:00
|
|
|
textStyle: {
|
|
|
|
|
color: "#333333",
|
2025-09-13 20:36:46 +08:00
|
|
|
},
|
2025-12-10 15:00:12 +08:00
|
|
|
xAxis: {type: "category", data: dataset?.[0]?.xdata || []},
|
2025-09-13 20:36:46 +08:00
|
|
|
yAxis: {
|
2025-10-12 23:10:15 +08:00
|
|
|
type: "value",
|
2025-09-13 20:36:46 +08:00
|
|
|
},
|
|
|
|
|
dataZoom: [
|
|
|
|
|
{
|
2025-10-12 23:10:15 +08:00
|
|
|
type: "inside",
|
2025-09-13 20:36:46 +08:00
|
|
|
start: 0,
|
2025-10-12 23:10:15 +08:00
|
|
|
end: 100,
|
2025-09-13 20:36:46 +08:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
start: 0,
|
2025-10-12 23:10:15 +08:00
|
|
|
end: 100,
|
|
|
|
|
},
|
2025-09-13 20:36:46 +08:00
|
|
|
],
|
2025-10-12 23:10:15 +08:00
|
|
|
series: dataset,
|
|
|
|
|
});
|
2025-09-13 20:36:46 +08:00
|
|
|
},
|
2025-12-10 15:00:12 +08:00
|
|
|
setBoxOption(data) {
|
|
|
|
|
let dataset = [];
|
|
|
|
|
data.forEach((item, index) => {
|
|
|
|
|
item.deviceList.forEach((inner) => {
|
|
|
|
|
dataset.push({
|
|
|
|
|
name: `${
|
|
|
|
|
this.isDtdc
|
|
|
|
|
? `${inner.parentDeviceId ? inner.parentDeviceId + "-" : ""}${inner.deviceId}`
|
|
|
|
|
: `${inner.deviceId}`
|
|
|
|
|
}`,
|
|
|
|
|
type: "boxplot",
|
|
|
|
|
// markPoint: {
|
|
|
|
|
// symbolSize: 30,
|
|
|
|
|
// emphasis: {
|
|
|
|
|
// disabled: false//打开 鼠标高亮
|
|
|
|
|
// },
|
|
|
|
|
// data: [//最大值、最小值
|
|
|
|
|
// {
|
|
|
|
|
// // type: 'max',
|
|
|
|
|
// name: `最大值`,
|
|
|
|
|
// coord: [inner.maxDate, inner.maxValue],
|
|
|
|
|
// relativeTo: 'coordinate',
|
|
|
|
|
// label: {
|
|
|
|
|
// position: "top",
|
|
|
|
|
// formatter: item.dataType === 2 ? ([
|
|
|
|
|
// `最大值:${inner.maxValue}`,
|
|
|
|
|
// // `平均值:${inner.avgValue}`,
|
|
|
|
|
// `差值:${inner.diffValue}`,
|
|
|
|
|
// ]).join('\n') : ([
|
|
|
|
|
// `最大值:${inner.maxValue}`,
|
|
|
|
|
// // `平均值:${inner.avgValue}`,
|
|
|
|
|
// ]).join('\n'),
|
|
|
|
|
// },
|
|
|
|
|
// },
|
|
|
|
|
// {
|
|
|
|
|
// // type: 'min',
|
|
|
|
|
// name: `最小值`,
|
|
|
|
|
// coord: [inner.minDate, inner.minValue],
|
|
|
|
|
// relativeTo: 'coordinate',
|
|
|
|
|
// label: {
|
|
|
|
|
// position: "top",
|
|
|
|
|
// formatter: item.dataType === 2 ? ([
|
|
|
|
|
// `最小值:${inner.minValue}`,
|
|
|
|
|
// // `平均值:${inner.avgValue}`,
|
|
|
|
|
// `差值:${inner.diffValue}`,
|
|
|
|
|
// ]).join('\n') : ([
|
|
|
|
|
// `最小值:${inner.minValue}`,
|
|
|
|
|
// // `平均值:${inner.avgValue}`,
|
|
|
|
|
// ]).join('\n'),
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// ]
|
|
|
|
|
// },
|
|
|
|
|
xdata: [],
|
|
|
|
|
data: [],
|
|
|
|
|
});
|
|
|
|
|
const length = dataset.length;
|
|
|
|
|
inner.pointValueList.forEach((value) => {
|
|
|
|
|
const {valueDate, min, q1, median, q3, max} = value
|
|
|
|
|
// const mid = (max - min) / 2, minLine = min + Math.abs(median / 2),
|
|
|
|
|
// maxLine = max - Math.abs(median / 2)
|
|
|
|
|
dataset[length - 1].xdata.push(valueDate);
|
|
|
|
|
dataset[length - 1].data.push([min, q1, median, q3, max]);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
console.log("箱型图图表数据", dataset);
|
|
|
|
|
this.chart.setOption({
|
|
|
|
|
legend: {
|
|
|
|
|
// left: 'center',
|
|
|
|
|
// top: '10',
|
|
|
|
|
},
|
|
|
|
|
grid: {
|
|
|
|
|
containLabel: true,
|
|
|
|
|
},
|
|
|
|
|
tooltip: {
|
|
|
|
|
trigger: 'item',
|
|
|
|
|
formatter: function (params) {
|
|
|
|
|
let data = params.data;
|
|
|
|
|
let result = params.marker + params.name + ' ' + params.seriesName + '<br/>';
|
|
|
|
|
result += '最小值: ' + data[1] + '<br/>';
|
|
|
|
|
result += '平均值: ' + data[3] + '<br/>';
|
|
|
|
|
result += '最大值: ' + data[5];
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
// trigger: "axis",
|
|
|
|
|
// axisPointer: {
|
|
|
|
|
// type: 'cross',
|
|
|
|
|
// },
|
|
|
|
|
// axisPointer: {
|
|
|
|
|
// // 坐标轴指示器,坐标轴触发有效
|
|
|
|
|
// type: "shadow", // 默认为直线,可选为:'line' | 'shadow'
|
|
|
|
|
// },
|
|
|
|
|
},
|
|
|
|
|
textStyle: {
|
|
|
|
|
color: "#333333",
|
|
|
|
|
},
|
|
|
|
|
xAxis: {type: "category", data: dataset?.[0]?.xdata || []},
|
|
|
|
|
yAxis: {
|
|
|
|
|
type: "value",
|
|
|
|
|
},
|
|
|
|
|
dataZoom: [
|
|
|
|
|
{
|
|
|
|
|
type: "inside",
|
|
|
|
|
start: 0,
|
|
|
|
|
end: 100,
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
start: 0,
|
|
|
|
|
end: 100,
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
series: dataset,
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
2025-10-12 23:10:15 +08:00
|
|
|
updateDate(val) {
|
|
|
|
|
this.dataRange = val || [];
|
|
|
|
|
this.getDate();
|
2025-09-13 20:36:46 +08:00
|
|
|
},
|
2025-10-16 16:10:29 +08:00
|
|
|
handleClosed(done) {
|
2025-09-13 20:36:46 +08:00
|
|
|
if (!this.chart) {
|
|
|
|
|
return done();
|
|
|
|
|
}
|
|
|
|
|
this.chart.dispose();
|
|
|
|
|
this.chart = null;
|
|
|
|
|
done();
|
|
|
|
|
},
|
2025-10-12 23:10:15 +08:00
|
|
|
},
|
|
|
|
|
};
|
2025-09-13 20:36:46 +08:00
|
|
|
</script>
|
|
|
|
|
<style scoped lang="scss">
|
|
|
|
|
::v-deep {
|
2025-10-12 23:10:15 +08:00
|
|
|
.card-title .el-radio {
|
2025-09-13 20:36:46 +08:00
|
|
|
line-height: 40px;
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-10-12 23:10:15 +08:00
|
|
|
</style>
|