设备监控问题修改
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
<template>
|
||||
<div class="default-main device-manage" :style="{ height: pageHeight.height }">
|
||||
<!-- @node-change="nodeClick" -->
|
||||
<schemeTree @node-click="nodeClick" @init="nodeClick" ref="schemeTreeRef"></schemeTree>
|
||||
<!-- @node-change="nodeClick" -->
|
||||
<schemeTree @node-change="nodeClick" @node-click="nodeClick" @init="nodeClick" ref="schemeTreeRef"></schemeTree>
|
||||
<div class="device-manage-right" v-if="deviceData">
|
||||
<el-descriptions size="small" title="方案信息" class="mb10" :column="2" border>
|
||||
<el-descriptions title="方案信息" :column="2" border>
|
||||
<template #extra>
|
||||
<el-button type="primary" icon="el-icon-Plus" @click="handleOpen(0, '')">新增方案</el-button>
|
||||
<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>
|
||||
</template>
|
||||
<el-descriptions-item label="方案名称" width="60">
|
||||
@@ -19,7 +19,7 @@
|
||||
<div class="history_title">
|
||||
<p>测试项信息</p>
|
||||
</div>
|
||||
<el-tabs v-model="activeName" type="border-card" @click="init()">
|
||||
<el-tabs v-model="activeName" type="border-card" @click="handleClickTabs">
|
||||
<el-tab-pane
|
||||
v-for="(item, index) in deviceData.records"
|
||||
:label="item.itemName"
|
||||
@@ -32,7 +32,7 @@
|
||||
<span>{{ item.itemName }}</span>
|
||||
</span>
|
||||
</template>
|
||||
<el-descriptions size="small" class="mb10" width="180" :column="4" border>
|
||||
<el-descriptions size="small" width="180" :column="4" border>
|
||||
<el-descriptions-item label="测试项名称" width="160">
|
||||
{{ item.itemName }}
|
||||
</el-descriptions-item>
|
||||
@@ -84,14 +84,11 @@
|
||||
<el-descriptions-item label="监测位置" width="160">
|
||||
{{ item.location }}
|
||||
</el-descriptions-item>
|
||||
<!-- <el-descriptions-item label="操作" width="160"> -->
|
||||
<!-- <el-button type="primary" icon="el-icon-EditPen" @click="handleOpen(3)">
|
||||
修改
|
||||
</el-button> -->
|
||||
<!-- <el-button type="primary" icon="el-icon-InfoFilled" @click="openDevice">
|
||||
<el-descriptions-item label="操作" width="160">
|
||||
<el-button type="primary" icon="el-icon-Tools" @click="handleOpen(3)">
|
||||
数据绑定
|
||||
</el-button> -->
|
||||
<!-- </el-descriptions-item> -->
|
||||
</el-button>
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
@@ -155,8 +152,11 @@
|
||||
<el-button type="primary" icon="el-icon-Search" @click="init()">查询</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="history_title">
|
||||
<p>{{ chartTitle }}</p>
|
||||
</div>
|
||||
<div class="history_chart" v-loading="loading">
|
||||
<MyEchart ref="historyChart" v-show="echartsData" :isExport="true" :options="echartsData" />
|
||||
<MyEchart ref="historyChart" v-if="echartsData" :isExport="true" :options="echartsData" />
|
||||
</div>
|
||||
</div>
|
||||
<el-empty v-else description="请选择设备" class="device-manage-right" />
|
||||
@@ -168,14 +168,14 @@
|
||||
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 { queryByCode, queryCsDictTree } from '@/api/system-boot/dictTree'
|
||||
import { ref, onMounted, 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 { TrendCharts, Plus } from '@element-plus/icons-vue'
|
||||
import { TrendCharts, Plus, Platform } from '@element-plus/icons-vue'
|
||||
const dictData = useDictData()
|
||||
defineOptions({
|
||||
name: 'govern/device/manage'
|
||||
@@ -226,7 +226,6 @@ queryByCode('portable-harmonic').then(res => {
|
||||
})
|
||||
queryStatistical(res.data.id).then(vv => {
|
||||
legendDictList.value = vv.data
|
||||
console.log(legendDictList.value, '2362636236636366263636', vv)
|
||||
})
|
||||
})
|
||||
const activeName: any = ref()
|
||||
@@ -235,16 +234,21 @@ const schemeTreeRef = ref()
|
||||
//历史趋势devId
|
||||
const historyDevId: any = ref('')
|
||||
const chartTitle: any = ref('')
|
||||
//点击测试项切换树节点
|
||||
const handleClickTabs = async () => {
|
||||
historyDevId.value = activeName.value
|
||||
schemeTreeRef.value.setCheckedNode(activeName.value)
|
||||
await init()
|
||||
}
|
||||
const nodeClick = async (e: anyObj) => {
|
||||
loading.value = true
|
||||
deviceData.value = []
|
||||
historyDevId.value = e.children && e.children.length != 0 ? e.children[0].id : e.id
|
||||
let id = e.pid ? e.pid : e.id
|
||||
//查询测试项信息
|
||||
try {
|
||||
getTestRecordInfo(id).then(res => {
|
||||
await getTestRecordInfo(id)
|
||||
.then(res => {
|
||||
deviceData.value = res.data
|
||||
loading.value = false
|
||||
if (res.data.records.length == 1) {
|
||||
activeName.value = res.data.records[0].id
|
||||
} else {
|
||||
@@ -257,16 +261,25 @@ const nodeClick = async (e: anyObj) => {
|
||||
})
|
||||
}
|
||||
schemeTreeRef.value.getPlanData(deviceData.value)
|
||||
init()
|
||||
loading.value = false
|
||||
})
|
||||
.catch(e => {
|
||||
loading.value = false
|
||||
})
|
||||
} catch (error) {
|
||||
loading.value = false
|
||||
}
|
||||
await init()
|
||||
}
|
||||
const dialogRef = ref()
|
||||
const handleOpen = (val: any, id: any) => {
|
||||
const handleOpen = (val: any) => {
|
||||
// deviceData.value.records[0].id
|
||||
dialogRef.value.open(val, '')
|
||||
let ids = ''
|
||||
if (val == 3) {
|
||||
ids = deviceData.value.records.find((item: any) => {
|
||||
return item.id == activeName.value
|
||||
})?.id
|
||||
} else {
|
||||
ids = ''
|
||||
}
|
||||
dialogRef.value.open(val, ids)
|
||||
}
|
||||
const echartsData = ref<any>(null)
|
||||
//加载echarts图表
|
||||
@@ -278,8 +291,11 @@ const refreshTree = () => {
|
||||
const range = (start: any, end: any, step: any) => {
|
||||
return Array.from({ length: (end - start) / step + 1 }, (_, i) => start + i * step)
|
||||
}
|
||||
const init = () => {
|
||||
const init = async () => {
|
||||
//调用子组件的方法切换的时候tree的节点也变化
|
||||
console.log(activeName.value, '000000')
|
||||
let list: any = []
|
||||
loading.value = true
|
||||
//颜色数组
|
||||
const colorList = [
|
||||
'#DAA521',
|
||||
@@ -296,18 +312,18 @@ const init = () => {
|
||||
'cadetblue'
|
||||
]
|
||||
if (historyDevId.value && legendDictList.value && legendDictList.value.selectedList) {
|
||||
loading.value = true
|
||||
// 选择指标的时候切换legend内容和data数据
|
||||
legendDictList.value?.selectedList?.map((item: any) => {
|
||||
if (item.dataType == searchForm.value.index) {
|
||||
list.push(item.eleEpdPqdVOS)
|
||||
}
|
||||
})
|
||||
console.log(legendDictList.value, '2362636236636366263636')
|
||||
|
||||
//选择的指标使用方法处理
|
||||
initSearchFormIndexAndCount([searchForm.value.index])
|
||||
await formatCountOptions([searchForm.value.index])
|
||||
//查询历史趋势
|
||||
historyDataList.value = []
|
||||
loading.value = true
|
||||
let middleTitle = ''
|
||||
if (
|
||||
deviceData.value.records &&
|
||||
@@ -334,7 +350,6 @@ const init = () => {
|
||||
})
|
||||
let lists: any = []
|
||||
countData.value.map((item: any, index: any) => {
|
||||
console.log(item.count, '878888888')
|
||||
lists[index] = {
|
||||
statisticalId: item.index,
|
||||
frequencys: item.count && item.count.length != 0 ? [item.count] : []
|
||||
@@ -345,278 +360,262 @@ const init = () => {
|
||||
list: lists,
|
||||
valueType: searchForm.value.type
|
||||
}
|
||||
try {
|
||||
getHistoryTrend(obj)
|
||||
.then((res: any) => {
|
||||
if (res.code == 'A0000') {
|
||||
historyDataList.value = 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'
|
||||
const iconDanger =
|
||||
'path://M1001.661867 796.544c48.896 84.906667 7.68 157.013333-87.552 157.013333H110.781867c-97.834667 0-139.050667-69.504-90.112-157.013333l401.664-666.88c48.896-87.552 128.725333-87.552 177.664 0l401.664 666.88zM479.165867 296.533333v341.333334a32 32 0 1 0 64 0v-341.333334a32 32 0 1 0-64 0z m0 469.333334v42.666666a32 32 0 1 0 64 0v-42.666666a32 32 0 1 0-64 0z'
|
||||
|
||||
let xAxis: any = [],
|
||||
timeList: any = [],
|
||||
unitList: any = []
|
||||
historyDataList.value.map((item: any) => {
|
||||
timeList.push(item.time)
|
||||
if (unitList.indexOf(item.unit) == -1) {
|
||||
unitList.push(item.unit)
|
||||
}
|
||||
})
|
||||
xAxis = timeList.sort((a: any, b: any) => {
|
||||
return (
|
||||
a.replace('-', '').replace('-', '').replace(' ', '').replace(':', '').replace(':', '') -
|
||||
0 -
|
||||
(b
|
||||
.replace('-', '')
|
||||
.replace('-', '')
|
||||
.replace(' ', '')
|
||||
.replace(':', '')
|
||||
.replace(':', '') -
|
||||
0)
|
||||
)
|
||||
})
|
||||
echartsData.value = {
|
||||
options: {
|
||||
title: [
|
||||
{
|
||||
left: '10%',
|
||||
top: 0,
|
||||
text: chartTitle.value
|
||||
}
|
||||
],
|
||||
toolbox: {
|
||||
feature: {
|
||||
// saveAsImage: {
|
||||
// title: '保存'
|
||||
// },
|
||||
// dataView: { readOnly: false },
|
||||
// }
|
||||
}
|
||||
},
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
axisPointer: {
|
||||
type: 'shadow'
|
||||
},
|
||||
formatter: function (params: any) {
|
||||
var res = params[0].name + '<br/>'
|
||||
for (var i = 0, l = params.length; i < l; i++) {
|
||||
params[i].unit =
|
||||
echartsData.value.options.yAxis[
|
||||
echartsData.value.options.series[params[i].seriesIndex].yAxisIndex
|
||||
]?.name
|
||||
res +=
|
||||
params[i].seriesName +
|
||||
' ' +
|
||||
`<div style="width:16px;height:16px;float:left;background:${params[i].color};border-radius:50%;margin:0 5px;margin:0 15px"></div>` +
|
||||
`<div style='float:right;min-width:120px;padding-left:20px;'>${params[i].value} ${params[i].unit}</div><br/>`
|
||||
}
|
||||
return res
|
||||
}
|
||||
},
|
||||
legend: {
|
||||
//legend使用iconfont图标
|
||||
data: [],
|
||||
itemWidth: 20,
|
||||
itemHeight: 10,
|
||||
itemGap: 15,
|
||||
type: 'scroll', // 开启滚动分页
|
||||
// orient: 'vertical', // 垂直排列
|
||||
right: '13%', // 位置调整
|
||||
top: 0,
|
||||
bottom: 20,
|
||||
width: 400,
|
||||
height: 50
|
||||
},
|
||||
grid: {
|
||||
left: '3%',
|
||||
right: '3%',
|
||||
bottom: '10%',
|
||||
top: '8%',
|
||||
containLabel: true
|
||||
},
|
||||
xAxis: [
|
||||
{
|
||||
type: 'category',
|
||||
name: '\n\n\n\n\n时间',
|
||||
axisLabel: {
|
||||
color: '#A9AEB2',
|
||||
fontSize: 12,
|
||||
show: function (index: any, value: any) {
|
||||
// 检查数据中是否存在这个时间点
|
||||
// return data.some(item:any => item[0] === value)
|
||||
}
|
||||
},
|
||||
nameTextStyle: {
|
||||
right: 0
|
||||
},
|
||||
data: Array.from(new Set(xAxis)),
|
||||
axisLine: {
|
||||
lineStyle: {
|
||||
color: '#43485E'
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
yAxis: [
|
||||
{
|
||||
type: 'value',
|
||||
name: unitList[0],
|
||||
axisLabel: {
|
||||
color: '#000',
|
||||
fontSize: 14
|
||||
},
|
||||
axisTick: {
|
||||
show: true
|
||||
},
|
||||
axisLine: {
|
||||
show: true,
|
||||
lineStyle: {
|
||||
color: colorList[0]
|
||||
}
|
||||
},
|
||||
nameTextStyle: {
|
||||
color: '#000',
|
||||
fontSize: '14'
|
||||
},
|
||||
splitLine: {
|
||||
show: false,
|
||||
lineStyle: {
|
||||
color: ['#43485E'],
|
||||
width: 1,
|
||||
type: 'solid'
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
series: []
|
||||
}
|
||||
getHistoryTrend(obj)
|
||||
.then((res: any) => {
|
||||
if (res.code == 'A0000') {
|
||||
historyDataList.value = 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'
|
||||
let xAxis: any = [],
|
||||
timeList: any = [],
|
||||
unitList: any = []
|
||||
historyDataList.value.map((item: any) => {
|
||||
timeList.push(item.time)
|
||||
if (unitList.indexOf(item.unit) == -1) {
|
||||
unitList.push(item.unit)
|
||||
}
|
||||
//处理多y轴
|
||||
if (unitList.length != 0 && unitList.length > 1) {
|
||||
// echartsData.value.options.yAxis[0].yAxisIndex = 0
|
||||
unitList.map((item: any, index: any) => {
|
||||
if (index != unitList.length - 1) {
|
||||
echartsData.value.options.yAxis.push({
|
||||
type: 'value',
|
||||
position: 'right',
|
||||
offset: index * 80, // y轴位置的偏移量
|
||||
name: unitList[index + 1],
|
||||
axisLabel: {
|
||||
color: '#000',
|
||||
fontSize: 14
|
||||
},
|
||||
axisTick: {
|
||||
show: true
|
||||
},
|
||||
axisLine: {
|
||||
show: true,
|
||||
lineStyle: {
|
||||
color: colorList[index + 1]
|
||||
}
|
||||
},
|
||||
nameTextStyle: {
|
||||
color: '#000',
|
||||
fontSize: '14'
|
||||
},
|
||||
splitLine: {
|
||||
show: false,
|
||||
lineStyle: {
|
||||
color: ['#43485E'],
|
||||
width: 1,
|
||||
type: 'solid'
|
||||
}
|
||||
})
|
||||
xAxis = timeList.sort((a: any, b: any) => {
|
||||
return new Date(a).getTime() - new Date(b).getTime()
|
||||
})
|
||||
// xAxis.map((item:any)=>{
|
||||
// item=item.replace(" ","\n")
|
||||
// })
|
||||
echartsData.value = {
|
||||
options: {
|
||||
title: [
|
||||
{
|
||||
left: '10%',
|
||||
top: 0
|
||||
// text: chartTitle.value
|
||||
}
|
||||
],
|
||||
toolbox: {
|
||||
feature: {
|
||||
// saveAsImage: {
|
||||
// title: '保存'
|
||||
// },
|
||||
// dataView: { readOnly: false },
|
||||
// }
|
||||
}
|
||||
},
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
axisPointer: {
|
||||
type: 'shadow'
|
||||
},
|
||||
formatter: function (params: any) {
|
||||
var res = params[0].name + '<br/>'
|
||||
for (var i = 0, l = params.length; i < l; i++) {
|
||||
params[i].unit =
|
||||
echartsData.value.options.yAxis[
|
||||
echartsData.value.options.series[params[i].seriesIndex].yAxisIndex
|
||||
]?.name
|
||||
res +=
|
||||
params[i].seriesName +
|
||||
' ' +
|
||||
`<div style="width:16px;height:16px;float:left;background:${params[i].color};border-radius:50%;margin:0 5px;margin:0 15px"></div>` +
|
||||
`<div style='float:right;min-width:120px;padding-left:20px;'>${params[i].value} ${params[i].unit}</div><br/>`
|
||||
}
|
||||
return res
|
||||
}
|
||||
},
|
||||
legend: {
|
||||
//legend使用iconfont图标
|
||||
data: [],
|
||||
itemWidth: 20,
|
||||
itemHeight: 10,
|
||||
itemGap: 15,
|
||||
type: 'scroll', // 开启滚动分页
|
||||
// orient: 'vertical', // 垂直排列
|
||||
right: '3%', // 位置调整
|
||||
top: 0,
|
||||
bottom: 20,
|
||||
width: 400,
|
||||
height: 50
|
||||
},
|
||||
grid: {
|
||||
left: '5%',
|
||||
right: '5%',
|
||||
bottom: '10%',
|
||||
top: '8%',
|
||||
containLabel: true
|
||||
},
|
||||
xAxis: [
|
||||
{
|
||||
type: 'category',
|
||||
name: '\n\n\n\n\n时间',
|
||||
axisLabel: {
|
||||
color: '#A9AEB2',
|
||||
fontSize: 12,
|
||||
show: function (index: any, value: any) {
|
||||
// 检查数据中是否存在这个时间点
|
||||
// return data.some(item:any => item[0] === value)
|
||||
}
|
||||
// yAxisIndex: index + 1
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
list.map((item: any, index: any) => {
|
||||
item.map((vv: any, indexs: any) => {
|
||||
//处理legend
|
||||
if (historyDataList.value.length != 0) {
|
||||
echartsData.value.options.legend.data.push({
|
||||
name: vv.phase + '相' + vv.showName,
|
||||
icon: iconThree
|
||||
})
|
||||
}
|
||||
if (
|
||||
unitList.findIndex((item: any) => {
|
||||
return item == vv.unit
|
||||
}) != -1
|
||||
) {
|
||||
vv.yAxisIndex = unitList.findIndex((item: any) => {
|
||||
return item == vv.unit
|
||||
})
|
||||
} else {
|
||||
vv.yAxisIndex = 0
|
||||
}
|
||||
|
||||
//series数据
|
||||
echartsData.value.options.series.push({
|
||||
name: vv.phase + '相' + vv.showName,
|
||||
type: 'line',
|
||||
smooth: true,
|
||||
symbol: 'none',
|
||||
emphasis: {
|
||||
focus: 'series'
|
||||
},
|
||||
itemStyle: {},
|
||||
//数据
|
||||
data: historyDataList.value
|
||||
.map((kk: any) => {
|
||||
if (kk.statisticalName == vv.name) {
|
||||
return kk.statisticalData
|
||||
} else {
|
||||
return ''
|
||||
}
|
||||
})
|
||||
.filter((kk: any) => kk !== ''),
|
||||
//数据对应的y轴
|
||||
// yAxisIndex:0,
|
||||
yAxisIndex: vv.yAxisIndex
|
||||
})
|
||||
})
|
||||
})
|
||||
//设置数据项颜色
|
||||
echartsData.value.options.series.map((item: any, index: any) => {
|
||||
item.itemStyle = {
|
||||
normal: {
|
||||
color: colorList[index],
|
||||
lineStyle: {
|
||||
color: colorList[index]
|
||||
nameTextStyle: {
|
||||
right: 0
|
||||
},
|
||||
data: Array.from(new Set(xAxis)),
|
||||
axisLine: {
|
||||
lineStyle: {
|
||||
color: '#43485E'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
loading.value = false
|
||||
],
|
||||
yAxis: [
|
||||
{
|
||||
type: 'value',
|
||||
name: unitList[0],
|
||||
axisLabel: {
|
||||
color: '#000',
|
||||
fontSize: 14
|
||||
},
|
||||
axisTick: {
|
||||
show: true
|
||||
},
|
||||
axisLine: {
|
||||
show: true,
|
||||
lineStyle: {
|
||||
// color: colorList[0]
|
||||
}
|
||||
},
|
||||
nameTextStyle: {
|
||||
color: '#000',
|
||||
fontSize: '14'
|
||||
},
|
||||
splitLine: {
|
||||
show: false,
|
||||
lineStyle: {
|
||||
color: ['#43485E'],
|
||||
width: 1,
|
||||
type: 'solid'
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
series: []
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
//处理多y轴
|
||||
if (unitList.length != 0 && unitList.length > 1) {
|
||||
// echartsData.value.options.yAxis[0].yAxisIndex = 0
|
||||
unitList.map((item: any, index: any) => {
|
||||
if (index != unitList.length - 1) {
|
||||
echartsData.value.options.yAxis.push({
|
||||
type: 'value',
|
||||
position: 'right',
|
||||
offset: index * 80, // y轴位置的偏移量
|
||||
name: unitList[index + 1],
|
||||
axisLabel: {
|
||||
color: '#000',
|
||||
fontSize: 14
|
||||
},
|
||||
axisTick: {
|
||||
show: true
|
||||
},
|
||||
axisLine: {
|
||||
show: true,
|
||||
lineStyle: {
|
||||
color: colorList[index + 1]
|
||||
}
|
||||
},
|
||||
nameTextStyle: {
|
||||
color: '#000',
|
||||
fontSize: '14'
|
||||
},
|
||||
splitLine: {
|
||||
show: false,
|
||||
lineStyle: {
|
||||
color: ['#43485E'],
|
||||
width: 1,
|
||||
type: 'solid'
|
||||
}
|
||||
}
|
||||
// yAxisIndex: index + 1
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
list.map((item: any, index: any) => {
|
||||
item.map((vv: any, indexs: any) => {
|
||||
//处理legend
|
||||
if (historyDataList.value.length != 0) {
|
||||
echartsData.value.options.legend.data.push({
|
||||
name: vv.phase + '相' + vv.showName,
|
||||
icon: iconThree
|
||||
})
|
||||
}
|
||||
if (
|
||||
unitList.findIndex((item: any) => {
|
||||
return item == vv.unit
|
||||
}) != -1
|
||||
) {
|
||||
vv.yAxisIndex = unitList.findIndex((item: any) => {
|
||||
return item == vv.unit
|
||||
})
|
||||
} else {
|
||||
vv.yAxisIndex = 0
|
||||
}
|
||||
//series数据
|
||||
echartsData.value.options.series.push({
|
||||
name: vv.phase + '相' + vv.showName,
|
||||
type: 'line',
|
||||
smooth: true,
|
||||
symbol: 'none',
|
||||
emphasis: {
|
||||
focus: 'series'
|
||||
},
|
||||
itemStyle: {},
|
||||
//数据
|
||||
data: historyDataList.value
|
||||
.map((kk: any) => {
|
||||
if (kk.statisticalName == vv.name) {
|
||||
return kk.statisticalData
|
||||
} else {
|
||||
return ''
|
||||
}
|
||||
})
|
||||
.filter((kk: any) => kk !== ''),
|
||||
//数据对应的y轴
|
||||
// yAxisIndex:0,
|
||||
yAxisIndex: vv.yAxisIndex
|
||||
})
|
||||
})
|
||||
})
|
||||
//设置数据项颜色
|
||||
echartsData.value.options.series.map((item: any, index: any) => {
|
||||
item.itemStyle = {
|
||||
normal: {
|
||||
color: colorList[index],
|
||||
lineStyle: {
|
||||
color: colorList[index]
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
loading.value = false
|
||||
})
|
||||
} catch (error) {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
loading.value = false
|
||||
})
|
||||
}
|
||||
}
|
||||
//导出
|
||||
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 = '',
|
||||
obj = {}
|
||||
obj: any = {}
|
||||
obj = deviceData.value.records.find((item: any) => {
|
||||
return item.id == activeName.value
|
||||
})
|
||||
@@ -669,11 +668,7 @@ const handleExport = async () => {
|
||||
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)
|
||||
)
|
||||
new Date(a).getTime() - new Date(b).getTime()
|
||||
})
|
||||
xAxis = Array.from(new Set(xAxis))
|
||||
// 使用这个函数转换数据为CSV格式
|
||||
@@ -682,11 +677,6 @@ const handleExport = async () => {
|
||||
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 = '统计时间,'
|
||||
@@ -737,7 +727,7 @@ const handleExport = async () => {
|
||||
const countData: any = ref([])
|
||||
|
||||
//根据选择的指标处理谐波次数
|
||||
const initSearchFormIndexAndCount = (list: any) => {
|
||||
const formatCountOptions = (list: any) => {
|
||||
if (list.length != 0) {
|
||||
list.map((item: any, index: any) => {
|
||||
if (!countData.value[index]) {
|
||||
@@ -757,13 +747,14 @@ const initSearchFormIndexAndCount = (list: any) => {
|
||||
if (kk.harmStart && kk.harmEnd) {
|
||||
range(0, 0, 0)
|
||||
countData.value[index].countOptions = range(kk.harmStart, kk.harmEnd, 1)
|
||||
countData.value[index].count = countData.value[index].countOptions[0]
|
||||
if (!countData.value[index].count || countData.value[index].count.length == 0) {
|
||||
countData.value[index].count = countData.value[index].countOptions[0]
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
console.log(countData.value, '66666666', legendDictList.value)
|
||||
}
|
||||
}
|
||||
watch(
|
||||
@@ -771,7 +762,7 @@ watch(
|
||||
(val: any, oldval: any) => {
|
||||
if (val) {
|
||||
let list = [val]
|
||||
// initSearchFormIndexAndCount(list)
|
||||
// formatCountOptions(list)
|
||||
// if (val == 0) {
|
||||
// countData.value = []
|
||||
// }
|
||||
@@ -798,8 +789,6 @@ onMounted(() => {
|
||||
init()
|
||||
loading.value = false
|
||||
}, 1500)
|
||||
|
||||
// initSearchFormIndexAndCount([searchForm.value.index])
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -844,7 +833,7 @@ onMounted(() => {
|
||||
p {
|
||||
height: 32px;
|
||||
line-height: 32px;
|
||||
font-size: 14px;
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
font-family: Helvetica Neue, Helvetica, PingFang SC, Hiragino Sans GB, Microsoft YaHei, SimSun, sans-serif;
|
||||
}
|
||||
@@ -855,7 +844,7 @@ onMounted(() => {
|
||||
|
||||
.el-tabs__content {
|
||||
padding: 0 !important;
|
||||
max-height: 130px !important;
|
||||
min-height: 130px !important;
|
||||
}
|
||||
}
|
||||
.history_header {
|
||||
@@ -884,7 +873,7 @@ onMounted(() => {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
margin-top: 3px;
|
||||
// margin-top: 3px;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user