2024-07-03 19:31:43 +08:00
|
|
|
|
<template>
|
2024-07-23 17:28:31 +08:00
|
|
|
|
<div>
|
2024-09-30 11:08:35 +08:00
|
|
|
|
<!-- 历史趋势数据 -->
|
|
|
|
|
|
<div>
|
2024-10-22 10:50:47 +08:00
|
|
|
|
<TableHeader ref="tableHeaderRef" :showSearch="false" @selectChange="selectChange">
|
|
|
|
|
|
<template v-slot:select :key="num">
|
2024-09-30 11:08:35 +08:00
|
|
|
|
<!-- <el-form :model="searchForm" class="history_select" id="history_select"> -->
|
2024-09-29 18:15:54 +08:00
|
|
|
|
<el-form-item>
|
|
|
|
|
|
<DatePicker ref="datePickerRef"></DatePicker>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item label="统计指标" label-width="80px">
|
2024-10-22 10:50:47 +08:00
|
|
|
|
<el-select multiple :multiple-limit="3" collapse-tags collapse-tags-tooltip
|
|
|
|
|
|
v-model="searchForm.index" placeholder="请选择统计指标" @change="onIndexChange($event)">
|
|
|
|
|
|
<el-option v-for="item in indexOptions" :key="item.id" :label="item.name"
|
|
|
|
|
|
:value="item.id"></el-option>
|
2024-07-23 17:28:31 +08:00
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
2024-10-22 10:50:47 +08:00
|
|
|
|
|
2024-10-22 15:55:24 +08:00
|
|
|
|
|
2024-10-23 19:41:16 +08:00
|
|
|
|
<el-form-item class="history_count" v-for="(item, index) in countData" :key="index" :label="item.name + '谐波次数'"
|
|
|
|
|
|
v-show="item.countOptions.length != 0">
|
2024-10-22 15:55:24 +08:00
|
|
|
|
<!-- v-if="item.countOptions.length != 0" -->
|
|
|
|
|
|
<el-select v-model="item.count" @change="onCountChange($event, index)"
|
2024-10-23 19:41:16 +08:00
|
|
|
|
placeholder="请选择谐波次数" style="width: 100px" >
|
2024-10-22 15:55:24 +08:00
|
|
|
|
<el-option v-for="vv in item.countOptions" :key="vv" :label="vv"
|
|
|
|
|
|
:value="vv"></el-option>
|
2024-09-29 18:15:54 +08:00
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
2024-10-22 15:55:24 +08:00
|
|
|
|
|
2024-09-30 11:08:35 +08:00
|
|
|
|
<!-- </el-form> -->
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<template #operation>
|
|
|
|
|
|
<el-button type="primary" icon="el-icon-Search" @click="init()">查询</el-button>
|
|
|
|
|
|
</template>
|
2024-09-29 18:15:54 +08:00
|
|
|
|
</TableHeader>
|
2024-07-23 17:28:31 +08:00
|
|
|
|
</div>
|
2024-09-30 11:08:35 +08:00
|
|
|
|
<div class="history_chart" :style="pageHeight" v-loading="loading">
|
2024-07-31 10:42:04 +08:00
|
|
|
|
<MyEchart ref="historyChart" :options="echartsData" />
|
2024-07-23 17:28:31 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2024-07-03 19:31:43 +08:00
|
|
|
|
</template>
|
2024-07-23 17:28:31 +08:00
|
|
|
|
<script lang="ts" setup>
|
|
|
|
|
|
import popup from './components/popup.vue'
|
|
|
|
|
|
import schemeTree from './components/schemeTree.vue'
|
|
|
|
|
|
import { mainHeight } from '@/utils/layout'
|
|
|
|
|
|
import { queryByCode, queryByid, queryCsDictTree } from '@/api/system-boot/dictTree'
|
|
|
|
|
|
import { ref, reactive, onMounted, provide, nextTick, watch } from 'vue'
|
|
|
|
|
|
import { ElMessage } from 'element-plus'
|
|
|
|
|
|
import MyEchart from '@/components/echarts/MyEchart.vue'
|
|
|
|
|
|
import { getTestRecordInfo, getHistoryTrend } from '@/api/cs-device-boot/planData'
|
|
|
|
|
|
import { useDictData } from '@/stores/dictData'
|
|
|
|
|
|
import { queryStatistical } from '@/api/system-boot/csstatisticalset'
|
|
|
|
|
|
import * as echarts from 'echarts'
|
|
|
|
|
|
import { isNonNullChain } from 'typescript'
|
|
|
|
|
|
import { position } from 'html2canvas/dist/types/css/property-descriptors/position'
|
|
|
|
|
|
import { read, writeFile, utils } from 'xlsx'
|
2024-09-25 16:31:45 +08:00
|
|
|
|
import TableStore from '@/utils/tableStore'
|
|
|
|
|
|
import Table from '@/components/table/index.vue'
|
2024-10-22 15:55:24 +08:00
|
|
|
|
import { yMethod, exportCSV } from '@/utils/echartMethod'
|
2024-09-25 16:31:45 +08:00
|
|
|
|
import TableHeader from '@/components/table/header/index.vue'
|
2024-07-23 17:28:31 +08:00
|
|
|
|
import { getTabsDataByType } from '@/api/cs-device-boot/EquipmentDelivery'
|
2024-09-25 16:31:45 +08:00
|
|
|
|
import DatePicker from '@/components/form/datePicker/index.vue'
|
2024-09-30 11:47:25 +08:00
|
|
|
|
import { color, gradeColor3 } from '@/components/echarts/color'
|
2024-07-23 17:28:31 +08:00
|
|
|
|
const dictData = useDictData()
|
|
|
|
|
|
defineOptions({
|
2024-09-25 16:31:45 +08:00
|
|
|
|
name: 'govern/device/control'
|
2024-07-03 19:31:43 +08:00
|
|
|
|
})
|
2024-07-23 17:28:31 +08:00
|
|
|
|
//电压等级
|
2024-10-22 10:50:47 +08:00
|
|
|
|
const voltageLevelList = dictData.getBasicData('Dev_Voltage_Stand')
|
2024-07-23 17:28:31 +08:00
|
|
|
|
//接线方式
|
|
|
|
|
|
const volConTypeList = dictData.getBasicData('Dev_Connect')
|
2024-10-22 10:50:47 +08:00
|
|
|
|
const num = ref(0)
|
2024-09-25 16:31:45 +08:00
|
|
|
|
|
2024-07-23 17:28:31 +08:00
|
|
|
|
//值类型
|
2024-09-30 11:08:35 +08:00
|
|
|
|
const pageHeight = ref(mainHeight(290))
|
2024-07-23 17:28:31 +08:00
|
|
|
|
const loading = ref(true)
|
|
|
|
|
|
const searchForm = ref({})
|
2024-10-22 10:50:47 +08:00
|
|
|
|
const tableHeaderRef = ref()
|
2024-07-23 17:28:31 +08:00
|
|
|
|
const typeOptions = [
|
|
|
|
|
|
{
|
|
|
|
|
|
name: '平均值',
|
|
|
|
|
|
id: 'avg'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: '最大值',
|
|
|
|
|
|
id: 'max'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: '最小值',
|
|
|
|
|
|
id: 'min'
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: 'CP95值',
|
|
|
|
|
|
id: 'cp95'
|
|
|
|
|
|
}
|
|
|
|
|
|
]
|
|
|
|
|
|
searchForm.value = {
|
|
|
|
|
|
index: [],
|
|
|
|
|
|
type: typeOptions[0].id,
|
2024-10-22 10:50:47 +08:00
|
|
|
|
count: '',
|
2024-09-25 16:31:45 +08:00
|
|
|
|
searchBeginTime: '',
|
|
|
|
|
|
searchEndTime: ''
|
2024-07-23 17:28:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
//统计指标
|
|
|
|
|
|
const indexOptions: any = ref([])
|
|
|
|
|
|
//谐波次数
|
|
|
|
|
|
const countOptions: any = ref([])
|
|
|
|
|
|
// Harmonic_Type
|
|
|
|
|
|
// portable-harmonic
|
|
|
|
|
|
const legendDictList: any = ref([])
|
|
|
|
|
|
queryByCode('portable-harmonic').then(res => {
|
|
|
|
|
|
queryCsDictTree(res.data.id).then(item => {
|
|
|
|
|
|
indexOptions.value = item.data
|
|
|
|
|
|
searchForm.value.index[0] = indexOptions.value[0].id
|
|
|
|
|
|
})
|
|
|
|
|
|
queryStatistical(res.data.id).then(vv => {
|
|
|
|
|
|
legendDictList.value = vv.data
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
const activeName: any = ref()
|
|
|
|
|
|
const deviceData: any = ref([])
|
|
|
|
|
|
//历史趋势devId
|
|
|
|
|
|
const historyDevId: any = ref('')
|
|
|
|
|
|
const chartTitle: any = ref('')
|
|
|
|
|
|
const echartsData = ref<any>(null)
|
|
|
|
|
|
//加载echarts图表
|
|
|
|
|
|
//历史趋势数据
|
|
|
|
|
|
const historyDataList: any = ref([])
|
|
|
|
|
|
const range = (start: any, end: any, step: any) => {
|
|
|
|
|
|
return Array.from({ length: (end - start) / step + 1 }, (_, i) => start + i * step)
|
|
|
|
|
|
}
|
|
|
|
|
|
//获取请求趋势数据参数
|
|
|
|
|
|
const trendRequestData = ref()
|
2024-09-25 16:31:45 +08:00
|
|
|
|
const getTrendRequest = (val: any) => {
|
2024-07-23 17:28:31 +08:00
|
|
|
|
trendRequestData.value = val
|
|
|
|
|
|
init()
|
|
|
|
|
|
}
|
|
|
|
|
|
//初始化趋势图
|
2024-09-25 16:31:45 +08:00
|
|
|
|
const headerRef = ref()
|
|
|
|
|
|
const datePickerRef = ref()
|
2024-07-23 17:28:31 +08:00
|
|
|
|
const init = async () => {
|
2024-07-31 10:42:04 +08:00
|
|
|
|
loading.value = true
|
2024-07-23 17:28:31 +08:00
|
|
|
|
// 选择指标的时候切换legend内容和data数据
|
|
|
|
|
|
let list: any = []
|
|
|
|
|
|
legendDictList.value?.selectedList?.map((item: any) => {
|
|
|
|
|
|
searchForm.value.index.map((vv: any) => {
|
|
|
|
|
|
if (item.dataType == vv) {
|
|
|
|
|
|
list.push(item.eleEpdPqdVOS)
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
//颜色数组
|
2024-09-30 11:47:25 +08:00
|
|
|
|
const colorList = color
|
2024-07-23 17:28:31 +08:00
|
|
|
|
//选择的指标使用方法处理
|
|
|
|
|
|
initSearchFormIndexAndCount(searchForm.value.index)
|
|
|
|
|
|
//查询历史趋势
|
|
|
|
|
|
historyDataList.value = []
|
2024-07-31 10:42:04 +08:00
|
|
|
|
chartTitle.value = ''
|
2024-07-23 17:28:31 +08:00
|
|
|
|
|
|
|
|
|
|
searchForm.value.index.map((item: any, indexs: any) => {
|
|
|
|
|
|
indexOptions.value.map((vv: any) => {
|
|
|
|
|
|
if (vv.id == item) {
|
|
|
|
|
|
chartTitle.value += indexs == searchForm.value.index.length - 1 ? vv.name : vv.name + '/'
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
let lists: any = []
|
|
|
|
|
|
countData.value.map((item: any, index: any) => {
|
|
|
|
|
|
lists[index] = {
|
|
|
|
|
|
statisticalId: item.index,
|
2024-10-22 10:50:47 +08:00
|
|
|
|
frequencys: [item.count]
|
2024-07-23 17:28:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
let obj = {
|
|
|
|
|
|
...trendRequestData.value,
|
|
|
|
|
|
list: lists,
|
2024-09-25 16:31:45 +08:00
|
|
|
|
valueType: searchForm.value.type,
|
2024-09-26 11:33:58 +08:00
|
|
|
|
startTime: datePickerRef.value && datePickerRef.value.timeValue[0],
|
2024-09-26 16:41:40 +08:00
|
|
|
|
endTime: datePickerRef.value && datePickerRef.value.timeValue[1]
|
2024-07-23 17:28:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (obj.devId && obj.list.length != 0) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
await getTabsDataByType(obj)
|
2024-09-25 16:31:45 +08:00
|
|
|
|
.then((res: any) => {
|
2024-07-23 17:28:31 +08:00
|
|
|
|
if (res.code == 'A0000') {
|
|
|
|
|
|
historyDataList.value = res.data
|
2024-10-15 15:31:36 +08:00
|
|
|
|
let chartsList = JSON.parse(JSON.stringify(res.data))
|
|
|
|
|
|
echartsData.value = {}
|
2024-07-23 17:28:31 +08:00
|
|
|
|
//icon图标替换legend图例
|
|
|
|
|
|
|
2024-10-15 15:31:36 +08:00
|
|
|
|
// y轴单位数组
|
2024-07-23 17:28:31 +08:00
|
|
|
|
let unitList: any = []
|
2024-10-15 15:31:36 +08:00
|
|
|
|
|
|
|
|
|
|
let groupedData = chartsList.reduce((acc, item) => {
|
2024-10-16 16:57:04 +08:00
|
|
|
|
let key = item.anotherName
|
2024-10-15 15:31:36 +08:00
|
|
|
|
if (!acc[key]) {
|
2024-10-16 16:57:04 +08:00
|
|
|
|
acc[key] = []
|
2024-07-23 17:28:31 +08:00
|
|
|
|
}
|
2024-10-16 16:57:04 +08:00
|
|
|
|
acc[key].push(item)
|
|
|
|
|
|
return acc
|
2024-10-15 15:31:36 +08:00
|
|
|
|
}, {})
|
2024-10-16 16:57:04 +08:00
|
|
|
|
let result = Object.values(groupedData)
|
2024-10-15 15:31:36 +08:00
|
|
|
|
if (chartsList.length > 0) {
|
|
|
|
|
|
unitList = result.map((item: any) => {
|
|
|
|
|
|
return item[0].unit
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-07-23 17:28:31 +08:00
|
|
|
|
echartsData.value = {
|
2024-10-15 15:31:36 +08:00
|
|
|
|
legend: {
|
|
|
|
|
|
itemWidth: 20,
|
|
|
|
|
|
itemHeight: 10,
|
|
|
|
|
|
itemGap: 15,
|
|
|
|
|
|
type: 'scroll', // 开启滚动分页
|
|
|
|
|
|
// orient: 'vertical', // 垂直排列
|
|
|
|
|
|
top: 5,
|
|
|
|
|
|
bottom: 30,
|
|
|
|
|
|
width: 400,
|
|
|
|
|
|
height: 50
|
|
|
|
|
|
},
|
|
|
|
|
|
tooltip: {
|
|
|
|
|
|
axisPointer: {
|
|
|
|
|
|
type: 'cross',
|
|
|
|
|
|
label: {
|
|
|
|
|
|
color: '#fff',
|
|
|
|
|
|
fontSize: 16
|
2024-09-30 11:47:25 +08:00
|
|
|
|
}
|
2024-10-08 20:55:17 +08:00
|
|
|
|
},
|
2024-10-15 15:31:36 +08:00
|
|
|
|
textStyle: {
|
|
|
|
|
|
color: '#fff',
|
|
|
|
|
|
fontStyle: 'normal',
|
|
|
|
|
|
opacity: 0.35,
|
|
|
|
|
|
fontSize: 14
|
2024-07-23 17:28:31 +08:00
|
|
|
|
},
|
2024-10-15 15:31:36 +08:00
|
|
|
|
backgroundColor: 'rgba(0,0,0,0.35)',
|
|
|
|
|
|
borderWidth: 0,
|
|
|
|
|
|
formatter(params) {
|
2024-10-16 16:57:04 +08:00
|
|
|
|
const xname = params[0].value[0]
|
|
|
|
|
|
let str = `${xname}<br>`
|
2024-10-15 15:31:36 +08:00
|
|
|
|
params.forEach((el, index) => {
|
2024-10-22 10:50:47 +08:00
|
|
|
|
str += `${el.marker}${el.seriesName.split('(')[0]}:${el.value[1]}${el.value[2]
|
|
|
|
|
|
}<br>`
|
2024-10-16 16:57:04 +08:00
|
|
|
|
})
|
|
|
|
|
|
return str
|
|
|
|
|
|
}
|
2024-10-15 15:31:36 +08:00
|
|
|
|
},
|
|
|
|
|
|
color: ['#FFCC00', '#009900', '#CC0000', ...color],
|
|
|
|
|
|
xAxis: {
|
|
|
|
|
|
type: 'time',
|
|
|
|
|
|
axisLabel: {
|
|
|
|
|
|
formatter: {
|
|
|
|
|
|
day: '{MM}-{dd}',
|
|
|
|
|
|
month: '{MM}',
|
|
|
|
|
|
year: '{yyyy}'
|
2024-07-23 17:28:31 +08:00
|
|
|
|
}
|
2024-10-15 15:31:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2024-10-16 16:57:04 +08:00
|
|
|
|
yAxis: [{}],
|
2024-10-22 15:55:24 +08:00
|
|
|
|
toolbox: {
|
|
|
|
|
|
featureProps: {
|
|
|
|
|
|
myTool1: {
|
|
|
|
|
|
show: true,
|
|
|
|
|
|
title: '下载csv',
|
|
|
|
|
|
|
|
|
|
|
|
icon: 'path://M588.8 551.253333V512H352v39.253333h236.373333z m0 78.933334v-39.253334H352v39.253334h236.373333z m136.533333 78.933333V334.933333l-157.866666-157.866666H273.066667A59.306667 59.306667 0 0 0 213.333333 236.373333v551.253334a59.306667 59.306667 0 0 0 59.306667 59.306666h274.773333v42.666667H853.333333v-180.48zM568.746667 234.666667l100.266666 100.693333h-81.066666a20.053333 20.053333 0 0 1-19.626667-20.053333z m-20.48 573.013333H273.066667a19.2 19.2 0 0 1-17.493334-19.626667V236.373333a19.2 19.2 0 0 1 19.626667-19.626666h256v98.133333a58.88 58.88 0 0 0 58.88 59.306667h96.426667v334.933333h-98.133334v-39.68H352v39.68h196.266667z m100.266666 23.04a37.973333 37.973333 0 0 1-32 15.786667 38.826667 38.826667 0 0 1-32.426666-15.786667 53.76 53.76 0 0 1-10.24-32.853333 42.666667 42.666667 0 0 1 42.666666-47.786667 35.84 35.84 0 0 1 37.546667 29.866667h-12.8a23.893333 23.893333 0 0 0-24.746667-19.2c-17.066667 0-29.013333 14.08-29.013333 35.84s11.52 37.546667 28.586667 37.546666a26.453333 26.453333 0 0 0 26.453333-25.6h12.8a39.253333 39.253333 0 0 1-7.253333 22.186667z m59.733334 15.786667a35.84 35.84 0 0 1-40.106667-34.56H682.666667a23.893333 23.893333 0 0 0 26.88 23.04c12.8 0 22.613333-6.4 22.613333-15.786667s-4.266667-11.52-14.506667-13.653333l-21.333333-5.12c-17.066667-4.266667-24.32-11.52-24.32-23.893334s12.8-26.453333 34.133333-26.453333a31.573333 31.573333 0 0 1 35.413334 30.293333h-13.653334a19.626667 19.626667 0 0 0-22.613333-18.773333c-12.8 0-20.48 5.12-20.48 12.8s5.12 11.093333 17.066667 13.653333l14.933333 2.986667a42.666667 42.666667 0 0 1 20.906667 8.96 23.893333 23.893333 0 0 1 7.68 17.92c-0.426667 17.066667-14.506667 28.16-37.12 28.16z m88.746666 0h-14.506666l-32.426667-92.16h14.08l19.626667 59.733333 6.4 20.053333c0-9.386667 3.413333-12.8 5.546666-20.053333l19.2-59.733333h14.08z',
|
|
|
|
|
|
onclick: (e) => {
|
|
|
|
|
|
|
|
|
|
|
|
// console.log("🚀 ~ init ~ echartsData.value:", echartsData.value.options.series.map(item => item.data))
|
|
|
|
|
|
|
|
|
|
|
|
let list = echartsData.value.options.series?.map(item => item.data)
|
|
|
|
|
|
let dataList = list[0]?.map((item, index) => {
|
|
|
|
|
|
let value = [item[0], item[1]]
|
|
|
|
|
|
list.forEach((item1: any, index1: any) => {
|
|
|
|
|
|
if (index1 > 0) {
|
|
|
|
|
|
value.push(item1 && item1[index] ? item1[index][1] : null)
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
2024-10-15 15:31:36 +08:00
|
|
|
|
|
2024-10-22 15:55:24 +08:00
|
|
|
|
|
|
|
|
|
|
return value;
|
|
|
|
|
|
});
|
|
|
|
|
|
exportCSV(echartsData.value.options.series.map(item => item.name), dataList, '历史趋势.csv')
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2024-10-15 15:31:36 +08:00
|
|
|
|
options: {
|
2024-10-16 16:57:04 +08:00
|
|
|
|
series: []
|
2024-07-23 17:28:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-10-15 15:31:36 +08:00
|
|
|
|
if (chartsList.length > 0) {
|
|
|
|
|
|
echartsData.value.yAxis = []
|
|
|
|
|
|
unitList.forEach((item: any, index: any) => {
|
|
|
|
|
|
let right = {
|
|
|
|
|
|
position: 'right',
|
2024-10-16 16:57:04 +08:00
|
|
|
|
offset: (index - 1) * 80
|
2024-07-23 17:28:31 +08:00
|
|
|
|
}
|
2024-10-15 15:31:36 +08:00
|
|
|
|
echartsData.value.yAxis.push({
|
|
|
|
|
|
name: item,
|
|
|
|
|
|
yAxisIndex: index,
|
|
|
|
|
|
splitNumber: 5,
|
|
|
|
|
|
minInterval: 1,
|
|
|
|
|
|
splitLine: {
|
2024-10-16 16:57:04 +08:00
|
|
|
|
show: false
|
2024-10-15 15:31:36 +08:00
|
|
|
|
},
|
|
|
|
|
|
...(index > 0 ? right : null)
|
|
|
|
|
|
})
|
2024-07-23 17:28:31 +08:00
|
|
|
|
})
|
|
|
|
|
|
|
2024-10-15 15:31:36 +08:00
|
|
|
|
result.forEach((item: any, index: any) => {
|
|
|
|
|
|
let yMethodList: any = []
|
|
|
|
|
|
|
2024-10-16 16:57:04 +08:00
|
|
|
|
let ABCList = Object.values(
|
|
|
|
|
|
item.reduce((acc, item) => {
|
|
|
|
|
|
let key = item.phase
|
|
|
|
|
|
if (!acc[key]) {
|
|
|
|
|
|
acc[key] = []
|
|
|
|
|
|
}
|
|
|
|
|
|
acc[key].push(item)
|
|
|
|
|
|
return acc
|
|
|
|
|
|
}, {})
|
|
|
|
|
|
)
|
|
|
|
|
|
ABCList.forEach((kk: any) => {
|
2024-10-15 15:31:36 +08:00
|
|
|
|
let seriesList: any = []
|
|
|
|
|
|
kk.forEach((cc: any) => {
|
|
|
|
|
|
if (cc.statisticalData) {
|
|
|
|
|
|
yMethodList.push(cc.statisticalData?.toFixed(2) - 0)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-10-16 16:57:04 +08:00
|
|
|
|
seriesList.push([cc.time, cc.statisticalData?.toFixed(2), cc.unit])
|
2024-07-23 17:28:31 +08:00
|
|
|
|
})
|
2024-10-15 15:31:36 +08:00
|
|
|
|
|
|
|
|
|
|
echartsData.value.options.series.push({
|
|
|
|
|
|
name: kk[0].phase + '相' + item[0].anotherName,
|
|
|
|
|
|
type: 'line',
|
|
|
|
|
|
smooth: true,
|
|
|
|
|
|
symbol: 'none',
|
|
|
|
|
|
data: seriesList,
|
|
|
|
|
|
yAxisIndex: index
|
2024-07-23 17:28:31 +08:00
|
|
|
|
})
|
|
|
|
|
|
})
|
2024-10-15 15:31:36 +08:00
|
|
|
|
let [min, max] = yMethod(yMethodList)
|
|
|
|
|
|
echartsData.value.yAxis[index].min = min
|
|
|
|
|
|
echartsData.value.yAxis[index].max = max
|
2024-07-23 17:28:31 +08:00
|
|
|
|
})
|
2024-10-15 15:31:36 +08:00
|
|
|
|
}
|
2024-07-23 17:28:31 +08:00
|
|
|
|
loading.value = false
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
.catch(error => {
|
|
|
|
|
|
loading.value = false
|
|
|
|
|
|
})
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
loading.value = false
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-09-30 11:08:35 +08:00
|
|
|
|
const selectChange = (flag: boolean) => {
|
|
|
|
|
|
if (flag) {
|
|
|
|
|
|
pageHeight.value = mainHeight(345)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
pageHeight.value = mainHeight(290)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-07-23 17:28:31 +08:00
|
|
|
|
//导出
|
|
|
|
|
|
const historyChart = ref()
|
|
|
|
|
|
// const chart: any = ref(null)
|
|
|
|
|
|
// chart.value = echarts.init(historyChart.value)
|
|
|
|
|
|
const handleExport = async () => {
|
|
|
|
|
|
const planCsv = ref('')
|
|
|
|
|
|
const chartsCsv = ref('')
|
|
|
|
|
|
|
|
|
|
|
|
if (deviceData.value.records && deviceData.value.records.length != 0) {
|
|
|
|
|
|
let csv = '',
|
2024-09-29 18:15:54 +08:00
|
|
|
|
obj: any = {}
|
2024-07-23 17:28:31 +08:00
|
|
|
|
obj = deviceData.value.records.find((item: any) => {
|
|
|
|
|
|
return item.id == activeName.value
|
|
|
|
|
|
})
|
|
|
|
|
|
if (obj) {
|
|
|
|
|
|
//测试是否与变量名长度有关系
|
|
|
|
|
|
let cell1 = deviceData.value.itemName,
|
|
|
|
|
|
cell2 = deviceData.value.describe,
|
|
|
|
|
|
cell3 = obj?.itemName,
|
|
|
|
|
|
cell4 = obj?.statisticalInterval,
|
|
|
|
|
|
cell5 = voltageLevelList.find(vv => {
|
|
|
|
|
|
return vv.id == obj.voltageLevel
|
|
|
|
|
|
})?.name,
|
|
|
|
|
|
cell6 = volConTypeList.find(vv => {
|
|
|
|
|
|
return vv.id == obj.volConType
|
|
|
|
|
|
})?.name,
|
|
|
|
|
|
cell7 = obj.capacitySscmin,
|
|
|
|
|
|
cell8 = obj.capacitySi,
|
|
|
|
|
|
cell9 = obj.capacitySscb,
|
|
|
|
|
|
cell10 = obj.capacitySt,
|
|
|
|
|
|
cell11 = obj.pt && obj.pt1 ? obj.pt / obj.pt1 + '\b' : '/',
|
|
|
|
|
|
cell12 = obj.ct && obj.ct1 ? obj.ct / obj.ct1 + '\b' : '/',
|
|
|
|
|
|
cell13 = obj.startTime ? obj.startTime : '/',
|
|
|
|
|
|
cell14 = obj.endTime ? obj.endTime : '/',
|
|
|
|
|
|
cell15 = obj.location
|
|
|
|
|
|
csv = `方案测试项信息,
|
|
|
|
|
|
方案名称, ${cell1},
|
|
|
|
|
|
方案描述, ${cell2},
|
|
|
|
|
|
测试项名称, ${cell2},
|
|
|
|
|
|
测量间隔, ${cell4 + '分钟'},
|
|
|
|
|
|
电压等级, ${cell5},
|
|
|
|
|
|
接线方式, ${cell6},
|
|
|
|
|
|
最小短路容量, ${cell7 + 'MVA'},
|
|
|
|
|
|
用户协议容量, ${cell8 + 'MVA'},
|
|
|
|
|
|
基准短路容量, ${cell9 + 'MVA'},
|
|
|
|
|
|
供电设备容量, ${cell10 + 'MVA'},
|
|
|
|
|
|
PT变比, ${cell11},
|
|
|
|
|
|
CT变比, ${cell12},
|
|
|
|
|
|
起始时间, ${cell13},
|
|
|
|
|
|
结束时间, ${cell14},
|
|
|
|
|
|
监测位置, ${cell15}\n,
|
|
|
|
|
|
`
|
|
|
|
|
|
planCsv.value = csv
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (historyDataList.value.length != 0) {
|
|
|
|
|
|
let xAxis: any = []
|
|
|
|
|
|
let timeList: any = []
|
|
|
|
|
|
historyDataList.value.map((item: any) => {
|
|
|
|
|
|
timeList.push(item.time)
|
|
|
|
|
|
})
|
|
|
|
|
|
xAxis = timeList.sort((a: any, b: any) => {
|
|
|
|
|
|
return (
|
|
|
|
|
|
a.replace('-', '').replace('-', '').replace(' ', '').replace(':', '').replace(':', '') -
|
|
|
|
|
|
0 -
|
|
|
|
|
|
(b.replace('-', '').replace('-', '').replace(' ', '').replace(':', '').replace(':', '') - 0)
|
|
|
|
|
|
)
|
|
|
|
|
|
})
|
|
|
|
|
|
xAxis = Array.from(new Set(xAxis))
|
|
|
|
|
|
// 使用这个函数转换数据为CSV格式
|
|
|
|
|
|
let csv: any = ''
|
|
|
|
|
|
const list = echartsData.value.options.series
|
|
|
|
|
|
csv = convertToCSV([], [])
|
|
|
|
|
|
chartsCsv.value = csv
|
|
|
|
|
|
// 如果你想提供下载链接
|
|
|
|
|
|
// const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' })
|
|
|
|
|
|
// const link = document.createElement('a')
|
|
|
|
|
|
// link.href = URL.createObjectURL(blob)
|
|
|
|
|
|
// link.download = '历史趋势.csv'
|
|
|
|
|
|
// link.click()
|
|
|
|
|
|
function convertToCSV(data: any, key: any) {
|
|
|
|
|
|
// 添加列头
|
|
|
|
|
|
let title = '统计时间,'
|
|
|
|
|
|
list.map((item: any, index: any) => {
|
|
|
|
|
|
index == list.length - 1 ? (title += `${item.name}\n`) : (title += `${item.name},`)
|
|
|
|
|
|
})
|
|
|
|
|
|
let csv = ''
|
|
|
|
|
|
csv = title
|
|
|
|
|
|
// 遍历数据并添加到CSV字符串中
|
|
|
|
|
|
const listLength = list.length
|
|
|
|
|
|
list[0].data.map((vv: any, indexs: any) => {
|
|
|
|
|
|
let strs = '',
|
|
|
|
|
|
count = null
|
|
|
|
|
|
list.map((item: any, index: any) => {
|
|
|
|
|
|
if (index == 0) {
|
|
|
|
|
|
count = index
|
|
|
|
|
|
}
|
|
|
|
|
|
index == list.length - 1
|
|
|
|
|
|
? (strs += list[index].data[indexs])
|
|
|
|
|
|
: (strs += list[index].data[indexs] + ',')
|
|
|
|
|
|
})
|
|
|
|
|
|
if (count == 0 && xAxis[indexs]) {
|
|
|
|
|
|
csv += `${xAxis[indexs]},` + strs + '\n'
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
return csv
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let csvs = ''
|
|
|
|
|
|
if (chartsCsv.value) {
|
|
|
|
|
|
csvs = planCsv.value + '历史趋势数据,\n\n' + chartsCsv.value
|
|
|
|
|
|
} else {
|
|
|
|
|
|
csvs = planCsv.value
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 如果你想提供下载链接
|
|
|
|
|
|
const blob = new Blob([csvs], { type: 'text/csv;charset=utf-8;' })
|
|
|
|
|
|
const link = document.createElement('a')
|
|
|
|
|
|
link.href = URL.createObjectURL(blob)
|
|
|
|
|
|
let obj = deviceData.value.records.find((item: any) => {
|
|
|
|
|
|
return item.id == activeName.value
|
|
|
|
|
|
})
|
|
|
|
|
|
const date = window.XEUtils.toDateString(new Date(), 'yyyyMMdd HHmmss').replace(' ', '_')
|
|
|
|
|
|
link.download = `${deviceData.value.itemName}_${obj?.itemName}_${date}.csv`
|
|
|
|
|
|
link.click()
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
const countData: any = ref([])
|
|
|
|
|
|
|
|
|
|
|
|
//根据选择的指标处理谐波次数
|
|
|
|
|
|
const initSearchFormIndexAndCount = (list: any) => {
|
|
|
|
|
|
if (list.length != 0) {
|
|
|
|
|
|
list.map((item: any, index: any) => {
|
|
|
|
|
|
if (!countData.value[index]) {
|
|
|
|
|
|
countData.value[index] = {
|
|
|
|
|
|
index: item,
|
|
|
|
|
|
countOptions: [],
|
2024-10-22 10:50:47 +08:00
|
|
|
|
count: '',
|
2024-07-23 17:28:31 +08:00
|
|
|
|
name: indexOptions.value.find((vv: any) => {
|
|
|
|
|
|
return vv.id == item
|
|
|
|
|
|
})?.name
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
legendDictList.value?.selectedList?.map((vv: any, vvs: any) => {
|
|
|
|
|
|
//查找相等的指标
|
|
|
|
|
|
if (item == vv.dataType) {
|
|
|
|
|
|
vv.eleEpdPqdVOS.map((kk: any, kks: any) => {
|
|
|
|
|
|
if (kk.harmStart && kk.harmEnd) {
|
|
|
|
|
|
range(0, 0, 0)
|
2024-09-18 10:53:09 +08:00
|
|
|
|
countData.value[index].countOptions = range(kk.harmStart, kk.harmEnd, 1)
|
2024-09-27 09:31:33 +08:00
|
|
|
|
//添加默认值
|
|
|
|
|
|
if (countData.value[index].count.length == 0) {
|
2024-10-22 10:50:47 +08:00
|
|
|
|
countData.value[index].count = countData.value[index].countOptions[0]
|
2024-09-27 09:31:33 +08:00
|
|
|
|
}
|
2024-07-23 17:28:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
2024-10-22 15:55:24 +08:00
|
|
|
|
|
2024-07-23 17:28:31 +08:00
|
|
|
|
})
|
2024-10-22 15:55:24 +08:00
|
|
|
|
console.log("🚀 ~ initSearchFormIndexAndCount ~ countData.value:", countData.value)
|
|
|
|
|
|
|
|
|
|
|
|
// countData.value = countData.value.filter(item => item.countOptions.length > 0);
|
2024-10-22 10:50:47 +08:00
|
|
|
|
|
2024-07-23 17:28:31 +08:00
|
|
|
|
}
|
2024-10-22 15:55:24 +08:00
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
tableHeaderRef.value.computedSearchRow()
|
|
|
|
|
|
}, 100)
|
2024-07-23 17:28:31 +08:00
|
|
|
|
}
|
2024-09-27 16:22:34 +08:00
|
|
|
|
// 判断下拉框是否存在
|
|
|
|
|
|
const onCountChange = (val: any, index: any) => {
|
2024-09-29 18:15:54 +08:00
|
|
|
|
if (val.length == 0) {
|
2024-10-22 10:50:47 +08:00
|
|
|
|
countData.value[index].count = countData.value[index].countOptions[0]
|
2024-09-29 18:15:54 +08:00
|
|
|
|
}
|
2024-09-27 16:22:34 +08:00
|
|
|
|
}
|
2024-10-16 16:57:04 +08:00
|
|
|
|
const onIndexChange = (val: any) => {
|
2024-10-22 15:55:24 +08:00
|
|
|
|
|
|
|
|
|
|
num.value += 1
|
2024-09-29 18:15:54 +08:00
|
|
|
|
if (val.length == 0) {
|
|
|
|
|
|
searchForm.value.index = [indexOptions.value[0].id]
|
|
|
|
|
|
}
|
2024-10-22 15:55:24 +08:00
|
|
|
|
|
2024-09-27 16:22:34 +08:00
|
|
|
|
}
|
2024-07-23 17:28:31 +08:00
|
|
|
|
watch(
|
|
|
|
|
|
() => searchForm.value.index,
|
|
|
|
|
|
(val: any, oldval: any) => {
|
|
|
|
|
|
if (val) {
|
2024-10-22 10:50:47 +08:00
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
initSearchFormIndexAndCount(val)
|
|
|
|
|
|
}, 100)
|
2024-07-23 17:28:31 +08:00
|
|
|
|
if (val == 0) {
|
|
|
|
|
|
countData.value = []
|
|
|
|
|
|
}
|
|
|
|
|
|
countData.value.map((item: any, key: any) => {
|
|
|
|
|
|
if (
|
|
|
|
|
|
val.findIndex((vv: any) => {
|
2024-10-22 10:50:47 +08:00
|
|
|
|
|
2024-07-23 17:28:31 +08:00
|
|
|
|
return vv == item.index
|
|
|
|
|
|
}) == -1
|
|
|
|
|
|
) {
|
|
|
|
|
|
countData.value.splice(key, 1)
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
deep: true,
|
|
|
|
|
|
immediate: true
|
|
|
|
|
|
}
|
|
|
|
|
|
)
|
|
|
|
|
|
// watch(
|
2024-10-16 16:57:04 +08:00
|
|
|
|
// () => trendRequestData.value,
|
2024-07-23 17:28:31 +08:00
|
|
|
|
// (val: any, oldval: any) => {
|
|
|
|
|
|
// if (val) {
|
|
|
|
|
|
// init()
|
|
|
|
|
|
// }
|
|
|
|
|
|
// },
|
|
|
|
|
|
// {
|
|
|
|
|
|
// deep: true,
|
|
|
|
|
|
// immediate: true
|
|
|
|
|
|
// }
|
|
|
|
|
|
// )
|
2024-10-08 20:55:17 +08:00
|
|
|
|
onMounted(() => {
|
2024-09-30 11:47:25 +08:00
|
|
|
|
datePickerRef.value.setInterval(5)
|
|
|
|
|
|
})
|
2024-07-23 17:28:31 +08:00
|
|
|
|
defineExpose({ getTrendRequest })
|
2024-07-03 19:31:43 +08:00
|
|
|
|
</script>
|
2024-07-23 17:28:31 +08:00
|
|
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
|
|
.history_header {
|
|
|
|
|
|
display: flex;
|
2024-09-29 18:15:54 +08:00
|
|
|
|
|
2024-07-23 17:28:31 +08:00
|
|
|
|
// flex-wrap: wrap;
|
|
|
|
|
|
#history_select {
|
2024-09-25 16:31:45 +08:00
|
|
|
|
width: 100%;
|
2024-07-23 17:28:31 +08:00
|
|
|
|
display: flex;
|
2024-09-25 16:31:45 +08:00
|
|
|
|
// justify-content: flex-start;
|
|
|
|
|
|
// overflow-x: auto;
|
|
|
|
|
|
height: auto;
|
|
|
|
|
|
flex-wrap: wrap;
|
2024-09-29 18:15:54 +08:00
|
|
|
|
|
2024-07-23 17:28:31 +08:00
|
|
|
|
.el-form-item {
|
2024-09-25 16:31:45 +08:00
|
|
|
|
flex: none !important;
|
|
|
|
|
|
// max-width: 380px;
|
2024-07-23 17:28:31 +08:00
|
|
|
|
}
|
2024-09-29 18:15:54 +08:00
|
|
|
|
|
2024-07-23 17:28:31 +08:00
|
|
|
|
.el-select {
|
|
|
|
|
|
margin-right: 10px;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// #history_select::-webkit-scrollbar {
|
|
|
|
|
|
// width: 0 !important;
|
|
|
|
|
|
// display: none !important;
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
.history_searchBtn {
|
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: flex-end;
|
|
|
|
|
|
margin-top: 3px;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.history_chart {
|
|
|
|
|
|
width: 100%;
|
2024-09-30 11:08:35 +08:00
|
|
|
|
|
2024-07-23 17:28:31 +08:00
|
|
|
|
// flex: 1;
|
|
|
|
|
|
margin-top: 10px;
|
|
|
|
|
|
}
|
2024-10-23 19:41:16 +08:00
|
|
|
|
.history_count{
|
|
|
|
|
|
.el-select {
|
|
|
|
|
|
min-width: 100px;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-07-23 17:28:31 +08:00
|
|
|
|
</style>
|