Files
admin-govern/src/views/govern/device/planData/index.vue

990 lines
43 KiB
Vue
Raw Normal View History

2024-06-24 14:38:42 +08:00
<template>
<div class="default-main device-manage" :style="{ height: pageHeight.height }">
2024-09-25 16:31:45 +08:00
<!-- @node-change="nodeClick" -->
<schemeTree @node-change="nodeClick" @node-click="nodeClick" @init="nodeClick" ref="schemeTreeRef"></schemeTree>
2024-06-24 14:38:42 +08:00
<div class="device-manage-right" v-if="deviceData">
2024-09-25 16:31:45 +08:00
<el-descriptions title="方案信息" :column="2" border>
2024-06-24 14:38:42 +08:00
<template #extra>
2024-09-25 16:31:45 +08:00
<el-button type="primary" icon="el-icon-Plus" @click="handleOpen(0)">新增方案</el-button>
<el-button type="primary" icon="el-icon-Download" @click="handleExport">数据导出</el-button>
2024-06-24 14:38:42 +08:00
</template>
<el-descriptions-item label="方案名称" width="60">
{{ deviceData.itemName }}
</el-descriptions-item>
<el-descriptions-item label="方案描述" width="60">
{{ deviceData.describe ? deviceData.describe : '/' }}
</el-descriptions-item>
</el-descriptions>
<el-collapse v-model="activeColName" accordion>
<el-collapse-item title="测试项信息" name="0">
<div class="monitor_info" v-if="deviceData.records && deviceData.records.length != 0">
<!-- <div class="history_title">
<p>测试项信息</p>
</div> -->
<el-tabs v-model="activeName" type="border-card" @click="handleClickTabs">
2024-09-30 16:32:16 +08:00
<el-tab-pane
v-for="(item, index) in deviceData.records"
:label="item.itemName"
:name="item.id"
:key="index"
>
<template #label>
<span class="custom-tabs-label">
<el-icon>
<TrendCharts />
</el-icon>
<span>{{ item.itemName }}</span>
</span>
</template>
<el-descriptions size="small" width="180" :column="4" border>
<el-descriptions-item label="测试项名称" width="160">
{{ item.itemName }}
</el-descriptions-item>
<el-descriptions-item label="测量间隔" width="160">
{{ item.statisticalInterval }}分钟
</el-descriptions-item>
<el-descriptions-item label="电压等级" width="160">
{{
voltageLevelList.find(vv => {
return vv.id == item.voltageLevel
})?.name
}}
</el-descriptions-item>
<el-descriptions-item label="接线方式" width="160">
{{
volConTypeList.find(vv => {
return vv.id == item.volConType
})?.name
}}
</el-descriptions-item>
<el-descriptions-item label="最小短路容量" width="160">
{{ item.capacitySscmin }}MVA
</el-descriptions-item>
<el-descriptions-item label="用户协议容量" width="160">
{{ item.capacitySi }}MVA
</el-descriptions-item>
<el-descriptions-item label="基准短路容量" width="160">
{{ item.capacitySscb }}MVA
</el-descriptions-item>
<el-descriptions-item label="供电设备容量" width="160">
{{ item.capacitySt }}MVA
</el-descriptions-item>
<el-descriptions-item label="PT变比" width="160">
{{ item.pt && item.pt1 ? item.pt / item.pt1 : item.pt }}
</el-descriptions-item>
<el-descriptions-item label="CT变比" width="160">
{{ item.ct && item.ct1 ? item.ct / item.ct1 : item.ct }}
</el-descriptions-item>
<el-descriptions-item label="起始时间" width="160">
<span style="width: 140px; overflow: hidden; display: block">
{{ item.startTime }}
</span>
</el-descriptions-item>
<el-descriptions-item label="结束时间" width="160">
<span style="width: 140px; overflow: hidden; display: block">
{{ item.endTime }}
</span>
</el-descriptions-item>
<el-descriptions-item label="监测位置" width="160">
{{ item.location }}
</el-descriptions-item>
<el-descriptions-item label="操作" width="160">
<el-button type="primary" icon="el-icon-Tools" @click="handleOpen(3)">
数据绑定
</el-button>
</el-descriptions-item>
</el-descriptions>
</el-tab-pane>
</el-tabs>
2024-07-03 19:31:29 +08:00
</div>
2024-10-09 08:49:19 +08:00
<div class="monitor_info" v-else>
<el-empty />
</div>
</el-collapse-item>
2024-10-09 08:49:19 +08:00
<el-collapse-item title="历史趋势" name="1" class="history_collapse">
<div class="history_trend">
<div class="history_header" ref="headerRef">
<!-- <el-form :model="searchForm" class="history_select" id="history_select"> -->
<TableHeader :showSearch="false" ref="tableHeaderRef" :key="searchFormIndex">
<template v-slot:select>
<el-form-item for="-" label="统计指标" label-width="80px">
<el-select
collapse-tags
collapse-tags-tooltip
v-model="searchForm.index"
placeholder="请选择统计指标"
multiple
:multiple-limit="3"
>
<el-option
v-for="item in indexOptions"
:key="item.id"
:label="item.name"
:value="item.id"
></el-option>
</el-select>
</el-form-item>
2024-10-10 19:26:09 +08:00
<el-form-item for="-" label="值类型" label-width="80px">
2024-10-09 08:49:19 +08:00
<el-select style="width: 160px !important" v-model="searchForm.dataLevel">
<el-option value="Primary" label="一次值"></el-option>
<el-option value="Secondary" label="二次值"></el-option>
</el-select>
</el-form-item>
<div v-for="(item, index) in countData" :key="index">
<el-form-item
for="-"
:label="item.name + '谐波次数'"
label-width="180px"
v-if="item.countOptions.length != 0"
>
<!-- multiple -->
<el-select
v-model="item.count"
collapse-tags
collapse-tags-tooltip
placeholder="请选择谐波次数"
style="width: 100px"
>
<el-option
v-for="vv in item.countOptions"
:key="vv"
:label="vv"
:value="vv"
></el-option>
</el-select>
</el-form-item>
</div>
<el-form-item for="-" label="统计类型" label-width="80px">
<el-select v-model="searchForm.type" placeholder="请选择值类型">
<el-option
v-for="item in typeOptions"
:key="item.id"
:label="item.name"
:value="item.id"
></el-option>
</el-select>
</el-form-item>
</template>
<template v-slot:operation>
<el-button type="primary" icon="el-icon-Search" @click="init(true)">查询</el-button>
</template>
</TableHeader>
<!-- </el-form> -->
<!-- <div class="history_searchBtn">
</div> -->
</div>
<div class="history_title">
<p>{{ chartTitle }}</p>
</div>
<div class="history_chart" v-loading="loading" ref="chartRef">
<MyEchart ref="historyChart" v-if="echartsData" :isExport="true" :options="echartsData" />
</div>
</div>
</el-collapse-item>
</el-collapse>
2024-06-24 14:38:42 +08:00
</div>
<el-empty v-else description="请选择设备" class="device-manage-right" />
<popup ref="dialogRef" @onSubmit="refreshTree" />
</div>
</template>
<script lang="ts" setup>
import popup from './components/popup.vue'
import schemeTree from './components/schemeTree.vue'
import { mainHeight } from '@/utils/layout'
2024-09-25 16:31:45 +08:00
import { queryByCode, queryCsDictTree } from '@/api/system-boot/dictTree'
2024-10-09 08:49:19 +08:00
import { ref, onMounted, watch, nextTick } from 'vue'
2024-06-24 14:38:42 +08:00
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'
2024-09-25 16:31:45 +08:00
import { TrendCharts, Plus, Platform } from '@element-plus/icons-vue'
2024-09-30 15:35:59 +08:00
import { yMethod } from '@/utils/echartMethod'
2024-10-09 08:49:19 +08:00
import TableHeader from '@/components/table/header/index.vue'
2024-06-24 14:38:42 +08:00
const dictData = useDictData()
defineOptions({
2024-09-25 16:36:53 +08:00
name: 'govern/device/planData/index'
2024-06-24 14:38:42 +08:00
})
//电压等级
const voltageLevelList = dictData.getBasicData('Dev_Voltage')
//接线方式
const volConTypeList = dictData.getBasicData('Dev_Connect')
//值类型
const pageHeight = mainHeight(20)
2024-09-26 11:20:12 +08:00
const loading = ref(false)
2024-06-24 14:38:42 +08:00
const searchForm = ref({})
const typeOptions = [
{
name: '平均值',
id: 'avg'
},
{
name: '最大值',
id: 'max'
},
{
name: '最小值',
id: 'min'
},
{
name: 'CP95值',
id: 'cp95'
}
]
searchForm.value = {
index: [],
dataLevel: 'Primary',
2024-06-27 09:39:53 +08:00
type: typeOptions[0].id,
count: []
2024-06-24 14:38:42 +08:00
}
//统计指标
const indexOptions: any = ref([])
2024-06-27 09:39:53 +08:00
//谐波次数
const countOptions: any = ref([])
2024-06-24 14:38:42 +08:00
// 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
// searchForm.value.index = indexOptions.value[0].id
2024-06-24 14:38:42 +08:00
})
queryStatistical(res.data.id).then(vv => {
legendDictList.value = vv.data
})
})
const activeName: any = ref()
const activeColName: any = ref('1')
2024-06-24 14:38:42 +08:00
const deviceData: any = ref([])
const schemeTreeRef = ref()
2024-06-27 09:39:53 +08:00
//历史趋势devId
const historyDevId: any = ref('')
2024-06-24 14:38:42 +08:00
const chartTitle: any = ref('')
2024-09-25 16:31:45 +08:00
//点击测试项切换树节点
const handleClickTabs = async () => {
historyDevId.value = activeName.value
schemeTreeRef.value.setCheckedNode(activeName.value)
2024-09-30 15:35:59 +08:00
await init(true)
2024-09-25 16:31:45 +08:00
}
2024-06-24 14:38:42 +08:00
const nodeClick = async (e: anyObj) => {
loading.value = true
deviceData.value = []
2024-06-27 09:39:53 +08:00
historyDevId.value = e.children && e.children.length != 0 ? e.children[0].id : e.id
2024-06-24 14:38:42 +08:00
let id = e.pid ? e.pid : e.id
2024-09-26 11:20:12 +08:00
2024-06-24 14:38:42 +08:00
//查询测试项信息
2024-09-25 16:31:45 +08:00
await getTestRecordInfo(id)
.then(res => {
2024-06-24 14:38:42 +08:00
deviceData.value = res.data
2024-06-27 09:39:53 +08:00
if (res.data.records.length == 1) {
activeName.value = res.data.records[0].id
} else {
res.data.records.map((item: any) => {
//多层
if (item.id == e.id) {
activeName.value = item.id
return
}
})
}
2024-06-24 14:38:42 +08:00
schemeTreeRef.value.getPlanData(deviceData.value)
2024-09-30 15:35:59 +08:00
init(true)
2024-09-25 16:31:45 +08:00
loading.value = false
})
.catch(e => {
loading.value = false
2024-06-24 14:38:42 +08:00
})
}
const dialogRef = ref()
2024-09-26 11:20:12 +08:00
const dailogForm = ref()
2024-09-25 16:31:45 +08:00
const handleOpen = (val: any) => {
2024-09-26 11:20:12 +08:00
deviceData.value.records.map((item: any) => {
if (item.id == activeName.value) {
dailogForm.value = item
}
})
dialogRef.value.details(dailogForm.value)
2024-06-24 14:38:42 +08:00
// deviceData.value.records[0].id
2024-09-25 16:31:45 +08:00
let ids = ''
//数据绑定
2024-09-25 16:31:45 +08:00
if (val == 3) {
ids = deviceData.value.records.find((item: any) => {
return item.id == activeName.value
})?.id
dialogRef.value.detailsType('table')
2024-09-25 16:31:45 +08:00
} else {
ids = ''
dialogRef.value.detailsType('')
2024-09-25 16:31:45 +08:00
}
dialogRef.value.open(val, ids)
2024-06-24 14:38:42 +08:00
}
const echartsData = ref<any>(null)
//加载echarts图表
//历史趋势数据
const historyDataList: any = ref([])
const refreshTree = () => {
schemeTreeRef.value.getTreeList()
}
2024-06-27 09:39:53 +08:00
const range = (start: any, end: any, step: any) => {
return Array.from({ length: (end - start) / step + 1 }, (_, i) => start + i * step)
}
//二维数组去除相同数据的数组
const filterArray = (array: any) => {
const newArray: any = []
array.forEach((currentValue: any) => {
let isPush = true
newArray.forEach((currentValueIn: any) => {
if (currentValueIn) {
if (currentValue[0] === currentValueIn[0] && currentValue[1] === currentValueIn[1]) {
isPush = false
}
} else {
newArray.push(currentValue)
}
})
if (isPush) {
newArray.push(currentValue)
}
})
return newArray
}
2024-09-30 15:35:59 +08:00
const init = (flag: boolean) => {
2024-09-25 16:31:45 +08:00
//调用子组件的方法切换的时候tree的节点也变化
2024-06-27 09:39:53 +08:00
let list: any = []
2024-07-04 14:22:13 +08:00
//颜色数组
const colorList = [
'#DAA521',
'#A5292A',
'aqua',
'#d81e06',
2024-07-09 09:54:15 +08:00
'#2E8B58',
2024-07-04 14:22:13 +08:00
'coral',
'#012B6A',
'brown',
'#70B601',
2024-07-09 09:54:15 +08:00
'blueviolet',
2024-07-04 14:22:13 +08:00
'#1DD0CE',
'cadetblue'
2024-07-04 14:22:13 +08:00
]
if (historyDevId.value && legendDictList.value && legendDictList.value.selectedList) {
// 选择指标的时候切换legend内容和data数据
legendDictList.value?.selectedList?.map((item: any) => {
searchForm.value.index.map((vv: any) => {
if (item.dataType == vv) {
list.push(item.eleEpdPqdVOS)
}
})
})
2024-09-25 16:31:45 +08:00
2024-07-03 19:31:29 +08:00
//选择的指标使用方法处理
formatCountOptions(searchForm.value.index)
2024-06-27 09:39:53 +08:00
//查询历史趋势
historyDataList.value = []
let middleTitle = ''
if (
deviceData.value.records &&
deviceData.value.records.length != 0 &&
deviceData.value.records.find((item: any) => {
return item.id == activeName.value
})?.itemName
) {
middleTitle = deviceData.value.records.find((item: any) => {
return item.id == activeName.value
})?.itemName
} else {
middleTitle = ''
}
let indexList = []
indexList = searchForm.value.index
2024-07-09 10:13:09 +08:00
chartTitle.value = deviceData.value.itemName + '_' + middleTitle + '_'
indexList.map((item: any, indexs: any) => {
2024-07-03 19:31:29 +08:00
indexOptions.value.map((vv: any) => {
if (vv.id == item) {
chartTitle.value += indexs == indexList.length - 1 ? vv.name : vv.name + '/'
2024-07-03 19:31:29 +08:00
}
})
})
let lists: any = []
countData.value.map((item: any, index: any) => {
lists[index] = {
statisticalId: item.index,
frequencys: item.count && item.count.length != 0 ? [item.count] : []
2024-07-03 19:31:29 +08:00
}
})
2024-06-27 09:39:53 +08:00
let obj = {
devId: historyDevId.value,
2024-07-03 19:31:29 +08:00
list: lists,
dataLevel: searchForm.value.dataLevel,
2024-07-03 19:31:29 +08:00
valueType: searchForm.value.type
2024-06-27 09:39:53 +08:00
}
2024-06-24 14:38:42 +08:00
2024-09-30 15:35:59 +08:00
if (flag) {
loading.value = true
getHistoryTrend(obj)
.then((res: any) => {
if (res.code === 'A0000') {
historyDataList.value = res.data
let chartsList = JSON.parse(JSON.stringify(res.data))
echartsData.value = null
//icon图标替换legend图例
const iconThree =
'path://M512 85.333333c235.637333 0 426.666667 191.029333 426.666667 426.666667S747.637333 938.666667 512 938.666667 85.333333 747.637333 85.333333 512 276.362667 85.333333 512 85.333333z m214.592 318.677334a32 32 0 0 0-45.248 0.064L544.736 541.066667l-81.792-89.109334a32 32 0 0 0-46.613333-0.576l-119.36 123.733334a32 32 0 1 0 46.058666 44.437333l95.754667-99.264 81.418667 88.704a32 32 0 0 0 46.24 0.96l160.213333-160.693333a32 32 0 0 0-0.064-45.248z'
2024-10-10 19:26:09 +08:00
// let xAxis: any = [] //x轴数据数组
// let timeList: any = [] //x轴数据数组
// y轴单位数组
let unitList: any = []
let allUnitArray: any = []
2024-09-30 15:35:59 +08:00
chartsList.map((item: any) => {
2024-10-10 19:26:09 +08:00
// timeList.push(item.time)
// if (unitList.indexOf(item.unit) == -1) {
// unitList.push(item.unit)
// }
allUnitArray.push({ name: item.anotherName, unit: item.unit })
2024-09-30 15:35:59 +08:00
})
2024-10-10 19:26:09 +08:00
// xAxis = new Set(
// timeList.sort((a: any, b: any) => {
// return new Date(a).getTime() - new Date(b).getTime()
// })
// )
//去除重复的unit单位数据
unitList = allUnitArray.reduce((result: any, obj: any) => {
if (!result.some((item: any) => JSON.stringify(item) === JSON.stringify(obj))) {
result.push(obj)
}
return result
}, [])
2024-10-09 08:49:19 +08:00
2024-09-30 15:35:59 +08:00
let [min, max] = [0, 0]
list.map((item: any, index: any) => {
item.map((vv: any, indexs: any) => {
;[min, max] = yMethod(
chartsList
.map((kk: any, kks: any) => {
if (kk.statisticalName == vv.name) {
return kk.statisticalData
} else {
return ''
}
})
.filter((kk: any) => kk !== '')
)
item.min = min
item.max = max
})
})
echartsData.value = {
options: {
title: [
{
left: '10%',
top: 0
// text: chartTitle.value
}
2024-09-30 15:35:59 +08:00
],
toolbox: {
feature: {
// saveAsImage: {
// title: '保存'
// }
// dataView: { readOnly: false },
// }
}
2024-09-29 18:15:54 +08:00
},
2024-09-30 15:35:59 +08:00
legend: {
//legend使用iconfont图标
data: [],
itemWidth: 20,
itemHeight: 10,
itemGap: 15,
type: 'scroll', // 开启滚动分页
// orient: 'vertical', // 垂直排列
right: '15%', // 位置调整
top: 5,
bottom: 30,
width: 400,
height: 50
},
tooltip: {
trigger: 'axis',
textStyle: {
color: '#fff',
fontStyle: 'normal',
opacity: 0.35,
2024-09-25 16:31:45 +08:00
fontSize: 14
},
2024-09-30 15:35:59 +08:00
backgroundColor: 'rgba(0,0,0,0.35)',
borderWidth: 0,
axisPointer: {
type: 'cross',
crossStyle: {
color: '#999'
2024-06-24 14:38:42 +08:00
}
2024-09-25 16:31:45 +08:00
},
2024-09-30 15:35:59 +08:00
formatter: function (params: any) {
let list = params.filter((item, index, self) => {
return index === self.findIndex(t => t.seriesName === item.seriesName)
})
var res =
'<span style="margin-right:18px;"></span>' +
list[0].value[0] +
list[0].name +
'<br/>'
for (var i = 0, l = list.length; i < l; i++) {
list[i].unit =
echartsData.value.options.yAxis[
echartsData.value.options.series[list[i].seriesIndex].yAxisIndex
]?.name
res +=
list[i].seriesName +
' ' +
`<div style="width:16px;height:16px;float:left;background:${list[i].color};border-radius:50%;margin:0 15px"></div>` +
2024-09-30 16:32:16 +08:00
`<div style='float:right;padding-left:20px;'>${
list[i].value[1] == null ? '' : list[i].value[1].toFixed(2)
} </div><br/>`
2024-10-10 19:26:09 +08:00
// ${list[i].unit}
2024-06-24 14:38:42 +08:00
}
2024-09-30 15:35:59 +08:00
return res
2024-06-24 14:38:42 +08:00
}
2024-09-30 15:35:59 +08:00
},
xAxis: {
type: 'time',
2024-09-25 16:31:45 +08:00
axisLabel: {
2024-09-30 15:35:59 +08:00
formatter: {
2024-09-30 15:37:33 +08:00
day: '{MM}-{dd}',
month: '{MM}',
2024-09-30 16:32:16 +08:00
year: '{yyyy}'
2024-09-25 16:31:45 +08:00
}
}
2024-09-30 15:35:59 +08:00
},
yAxis: [
{
type: 'value',
2024-10-10 19:26:09 +08:00
name: unitList[0].unit,
2024-09-30 15:35:59 +08:00
axisLabel: {
color: '#000',
fontSize: 14
},
axisTick: {
show: true
},
max: list[0].max,
min: list[0].min,
axisLine: {
show: true,
lineStyle: {
// color: colorList[0]
}
},
nameTextStyle: {
color: '#000',
fontSize: '14'
},
splitLine: {
show: false,
lineStyle: {
color: ['#43485E'],
width: 1,
type: 'solid'
}
},
splitNumber: 5,
minInterval: 1
}
],
series: []
2024-09-25 16:31:45 +08:00
}
2024-09-30 15:35:59 +08:00
}
echartsData.value.options.legend.data = []
2024-10-10 19:26:09 +08:00
2024-09-30 15:35:59 +08:00
list.map((item: any, index: any) => {
item.map((vv: any, indexs: any) => {
//处理legend
if (chartsList.length != 0) {
echartsData.value.options.legend.data.push({
2024-10-10 19:26:09 +08:00
name: vv.phase + '相' + vv.showName
// icon: iconThree
2024-09-30 15:35:59 +08:00
})
}
if (
unitList.findIndex((item: any) => {
2024-10-10 19:26:09 +08:00
return item.unit == vv.unit && item.name == vv.showName
2024-09-30 15:35:59 +08:00
}) != -1
) {
vv.yAxisIndex = unitList.findIndex((item: any) => {
2024-10-10 19:26:09 +08:00
return item.unit == vv.unit && item.name == vv.showName
2024-09-30 15:35:59 +08:00
})
} else {
vv.yAxisIndex = 0
}
echartsData.value.options.series.push({
2024-07-03 19:31:29 +08:00
name: vv.phase + '相' + vv.showName,
2024-09-30 15:35:59 +08:00
type: 'line',
smooth: true,
symbol: 'none',
emphasis: {
focus: 'series'
},
itemStyle: {},
//数据
data: filterArray(
chartsList
.map((kk: any, kks: any) => {
if (kk.statisticalName == vv.name) {
2024-10-09 08:49:19 +08:00
// xAxis[kks]
return [kk.time, kk.statisticalData]
2024-09-30 15:35:59 +08:00
} else {
return ''
}
})
.filter((kk: any) => kk !== '')
),
//数据对应的y轴
// yAxisIndex:0,
yAxisIndex: vv.yAxisIndex
2024-09-25 16:31:45 +08:00
})
2024-06-24 14:38:42 +08:00
})
})
2024-09-30 15:35:59 +08:00
//处理多y轴
2024-09-30 16:32:16 +08:00
// if (unitList.length != 0 && unitList.length > 1) {
2024-10-10 19:26:09 +08:00
// console.log(max, min)
echartsData.value.options.yAxis[0].yAxisIndex = 0
2024-10-09 08:49:19 +08:00
unitList.map((item: any, index: any) => {
if (index != unitList.length - 1) {
echartsData.value.options.yAxis.push({
type: 'value',
position: 'right',
offset: index * 80, // y轴位置的偏移量
2024-10-10 19:26:09 +08:00
name: unitList[index + 1].unit,
2024-10-09 08:49:19 +08:00
axisLabel: {
color: '#000',
fontSize: 14
},
axisTick: {
show: true
},
axisLine: {
show: true,
lineStyle: {
// color: colorList[index + 1]
2024-09-30 15:35:59 +08:00
}
2024-10-09 08:49:19 +08:00
},
nameTextStyle: {
color: '#000',
fontSize: '14'
},
max: list[index + 1].max,
min: list[index + 1].min,
splitLine: {
show: false,
lineStyle: {
color: ['#43485E'],
width: 1,
type: 'solid'
}
2024-10-10 19:26:09 +08:00
},
yAxisIndex: index + 1
2024-10-09 08:49:19 +08:00
})
}
})
2024-09-30 16:32:16 +08:00
// }
2024-09-30 15:35:59 +08:00
//设置数据项颜色
echartsData.value.options.series.map((item: any, index: any) => {
item.itemStyle = {
normal: {
color: colorList[index],
lineStyle: {
color: colorList[index]
}
}
}
// item.data = filterArray(item.data)
})
loading.value = false
}
})
.catch(error => {
2024-06-24 14:38:42 +08:00
loading.value = false
2024-09-30 15:35:59 +08:00
})
}
2024-06-24 14:38:42 +08:00
}
}
//导出
const historyChart = ref()
const handleExport = async () => {
const planCsv = ref('')
const chartsCsv = ref('')
if (deviceData.value.records && deviceData.value.records.length != 0) {
let csv = '',
2024-09-25 16:31:45 +08:00
obj: any = {}
obj = deviceData.value.records.find((item: any) => {
return item.id == activeName.value
})
if (obj) {
2024-07-09 09:54:15 +08:00
//测试是否与变量名长度有关系
let cell1 = deviceData.value.itemName,
cell2 = deviceData.value.describe,
cell3 = obj?.itemName,
cell4 = obj?.statisticalInterval,
cell5 = voltageLevelList.find(vv => {
return vv.id == obj.voltageLevel
2024-07-09 09:54:15 +08:00
})?.name,
cell6 = volConTypeList.find(vv => {
return vv.id == obj.volConType
2024-07-09 09:54:15 +08:00
})?.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) {
2024-06-27 09:39:53 +08:00
let xAxis: any = []
2024-07-03 19:31:29 +08:00
let timeList: any = []
2024-06-27 09:39:53 +08:00
historyDataList.value.map((item: any) => {
2024-07-03 19:31:29 +08:00
timeList.push(item.time)
})
xAxis = timeList.sort((a: any, b: any) => {
2024-09-25 16:31:45 +08:00
new Date(a).getTime() - new Date(b).getTime()
2024-06-27 09:39:53 +08:00
})
2024-10-09 08:49:19 +08:00
xAxis = Array.from(new Set(xAxis))
2024-06-27 09:39:53 +08:00
// 使用这个函数转换数据为CSV格式
2024-07-03 19:31:29 +08:00
let csv: any = ''
2024-06-27 09:39:53 +08:00
const list = echartsData.value.options.series
2024-07-03 19:31:29 +08:00
csv = convertToCSV([], [])
chartsCsv.value = csv
2024-06-27 09:39:53 +08:00
// 如果你想提供下载链接
function convertToCSV(data: any, key: any) {
// 添加列头
2024-07-03 19:31:29 +08:00
let title = '统计时间,'
2024-06-27 09:39:53 +08:00
list.map((item: any, index: any) => {
index == list.length - 1 ? (title += `${item.name}\n`) : (title += `${item.name},`)
})
let csv = ''
csv = title
// 遍历数据并添加到CSV字符串中
list[0]?.data.map((vv: any, indexs: any) => {
2024-07-03 19:31:29 +08:00
let strs = '',
count = null
list.map((item: any, index: any) => {
if (index == 0) {
count = index
}
2024-09-29 18:15:54 +08:00
let itemList: any = list[index].data[indexs]
2024-09-30 16:32:16 +08:00
if (itemList && itemList.length != 0) {
2024-09-30 16:06:38 +08:00
index == list.length - 1 ? (strs += itemList[1]) : (strs += itemList[1] + ',')
2024-09-30 16:32:16 +08:00
} else {
index == list.length - 1 ? (strs += '/') : (strs += '/,')
2024-09-30 16:06:38 +08:00
}
2024-07-03 19:31:29 +08:00
})
if (count == 0 && xAxis[indexs]) {
csv += `${xAxis[indexs]},` + strs + '\n'
2024-09-30 15:35:59 +08:00
} else {
strs += '/,'
2024-06-27 09:39:53 +08:00
}
})
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
})
2024-07-09 09:54:15 +08:00
const date = window.XEUtils.toDateString(new Date(), 'yyyyMMdd HHmmss').replace(' ', '_')
link.download = `${deviceData.value.itemName}_${obj?.itemName}_${date}.csv`
link.click()
return
2024-06-24 14:38:42 +08:00
}
2024-07-03 19:31:29 +08:00
const countData: any = ref([])
2024-06-24 14:38:42 +08:00
2024-07-03 19:31:29 +08:00
//根据选择的指标处理谐波次数
2024-09-25 16:31:45 +08:00
const formatCountOptions = (list: any) => {
2024-07-03 19:31:29 +08:00
if (list.length != 0) {
list.map((item: any, index: any) => {
if (!countData.value[index]) {
countData.value[index] = {
index: item,
countOptions: [],
count: [],
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)
countData.value[index].countOptions = range(kk.harmStart, kk.harmEnd, 1)
2024-09-25 16:31:45 +08:00
if (!countData.value[index].count || countData.value[index].count.length == 0) {
countData.value[index].count = countData.value[index].countOptions[0]
}
2024-07-03 19:31:29 +08:00
}
})
}
})
})
}
}
2024-10-09 08:49:19 +08:00
const tableHeaderRef = ref<any>()
const searchFormIndex = ref<any>()
2024-07-03 19:31:29 +08:00
watch(
() => searchForm.value.index,
2024-07-03 19:31:29 +08:00
(val: any, oldval: any) => {
if (val) {
let list = val
2024-10-09 08:49:19 +08:00
searchFormIndex.value = val
formatCountOptions(list)
countData.value.map((item: any, key: any) => {
if (
list.findIndex((vv: any) => {
return vv == item.index
}) == -1
) {
countData.value.splice(key, 1)
2024-07-04 18:15:09 +08:00
}
})
2024-09-30 15:35:59 +08:00
init(false)
2024-07-03 19:31:29 +08:00
}
},
{
deep: true,
immediate: true
}
)
onMounted(() => {
setTimeout(() => {
2024-09-30 15:35:59 +08:00
init(true)
}, 1500)
})
2024-06-24 14:38:42 +08:00
</script>
<style lang="scss" scoped>
.device-manage {
display: flex;
height: calc(100vh - 100px);
// overflow-y: auto;
&-right {
// overflow: auto;
flex: 1;
padding: 10px 10px 10px 0;
.el-descriptions__header {
height: 36px;
margin-bottom: 7px;
display: flex;
align-items: center;
}
}
.device-manage-right {
overflow: hidden;
flex: 1 !important;
height: calc(100vh - 135px);
padding: 10px 10px 10px 10px;
border: 2px solid #eeeeee;
display: flex;
flex-direction: column;
.el-descriptions__header {
height: 36px;
margin-bottom: 7px;
display: flex;
align-items: center;
}
}
}
2024-09-29 11:29:42 +08:00
2024-06-24 14:38:42 +08:00
.history_title {
width: 100%;
p {
height: 32px;
line-height: 32px;
2024-09-25 16:31:45 +08:00
font-size: 16px;
2024-06-24 14:38:42 +08:00
font-weight: bold;
font-family: Helvetica Neue, Helvetica, PingFang SC, Hiragino Sans GB, Microsoft YaHei, SimSun, sans-serif;
2024-06-24 14:38:42 +08:00
}
}
2024-07-12 16:55:10 +08:00
::v-deep .monitor_info {
2024-06-24 14:38:42 +08:00
width: 100%;
2024-07-12 16:55:10 +08:00
.el-tabs__content {
padding: 0 !important;
2024-09-25 16:31:45 +08:00
min-height: 130px !important;
2024-07-12 16:55:10 +08:00
}
}
2024-10-09 08:49:19 +08:00
.history_collapse {
height: calc(100vh - 300px);
width: 100%;
.history_trend {
width: 100%;
height: calc(100vh - 340px);
2024-06-24 14:38:42 +08:00
display: flex;
2024-10-09 08:49:19 +08:00
flex-direction: column;
.history_header {
width: 100%;
height: auto;
overflow: hidden;
}
2024-10-09 08:49:19 +08:00
.history_chart {
width: 100%;
flex: 1 !important;
margin-top: 10px;
margin: 10px 0;
2024-06-24 14:38:42 +08:00
}
}
}
::v-deep .el-select {
width: 120px !important;
}
2024-09-29 18:15:54 +08:00
::v-deep .el-collapse-item__header {
font-size: 16px !important;
font-weight: 800 !important;
}
2024-06-24 14:38:42 +08:00
</style>