历史趋势修改
This commit is contained in:
@@ -225,71 +225,11 @@ const resizeObserver = new ResizeObserver(entries => {
|
||||
}, 100)
|
||||
}
|
||||
})
|
||||
const ExportChart: any = ref(null)
|
||||
const handleExport = (arr: any) => {
|
||||
// 使用ECharts的getOption方法获取当前图表的配置
|
||||
const option = ExportOptions.value
|
||||
const seriesData = option?.series
|
||||
const xAxisList = option?.xAxis[0].data
|
||||
if (seriesData && seriesData.length != 0) {
|
||||
// 转换为CSV格式
|
||||
let csvContent = '时间,'
|
||||
const legendData = ExportOptions.value.legend.data
|
||||
legendData.map((item: any, index: any) => {
|
||||
index != legendData.length - 1 ? (csvContent += item.name + ',') : (csvContent += item.name + '\n')
|
||||
})
|
||||
let cellValue = ''
|
||||
let list = []
|
||||
legendData.map((item: any, index: any) => {
|
||||
list.push('${seriesData[' + index + '].data[indexs]}')
|
||||
})
|
||||
console.log(seriesData[0].data.length)
|
||||
|
||||
seriesData.forEach((item: any, index: any) => {
|
||||
item.data.map((vv: any, indexs: any) => {
|
||||
cellValue += `${xAxisList[indexs]},`
|
||||
|
||||
// csvContent += `${item.name},${xAxisList[index]},${vv}\n`
|
||||
// legendData.map((kk: any, indexss: any) => {
|
||||
|
||||
// indexs == legendData.length - 1 ? (cellValue += `${vv}\n`) : (cellValue += `${vv},`)
|
||||
cellValue += `${seriesData[0].data[indexs]},${seriesData[1].data[indexs]},${seriesData[2].data[indexs]}s\n`
|
||||
// })
|
||||
// cellValue +=list.join(',')+'\n'
|
||||
})
|
||||
// csvContent += cellValue + `${xAxisList[index]}` + '\n'
|
||||
})
|
||||
let arrs = []
|
||||
arrs = JSON.parse(JSON.stringify(new Set(cellValue.split('s'))))
|
||||
console.log(arrs, '0000000000')
|
||||
Array.from(arrs).map((item:any)=>{
|
||||
cellValue +=item+'\n'.replace('s','')
|
||||
})
|
||||
console.log(cellValue, '去重后的数据')
|
||||
return
|
||||
csvContent += cellValue
|
||||
// return
|
||||
// 创建Blob对象,并使用a标签下载
|
||||
const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' })
|
||||
const link = document.createElement('a')
|
||||
if (link.download !== undefined) {
|
||||
// 支持下载属性
|
||||
const url = URL.createObjectURL(blob)
|
||||
link.setAttribute('href', url)
|
||||
link.setAttribute('download', '历史趋势.csv')
|
||||
link.style.visibility = 'hidden'
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
document.body.removeChild(link)
|
||||
}
|
||||
}
|
||||
}
|
||||
onMounted(() => {
|
||||
initChart()
|
||||
ExportChart.value = echarts.init(chartRef.value)
|
||||
resizeObserver.observe(chartRef.value!)
|
||||
})
|
||||
defineExpose({ initChart, handleExport })
|
||||
defineExpose({ initChart })
|
||||
onBeforeUnmount(() => {
|
||||
resizeObserver.unobserve(chartRef.value!)
|
||||
chart?.dispose()
|
||||
|
||||
@@ -98,7 +98,7 @@ const tableData = ref([])
|
||||
defineOptions({
|
||||
name: 'govern/tourist/index'
|
||||
})
|
||||
const treeIds: any = ref(['-1'])
|
||||
const treeIds: any = ref([])
|
||||
//树节点选择变化的时候处理树节点选中数据
|
||||
const checkChange = async (data: any) => {
|
||||
if (data.checked) {
|
||||
@@ -602,15 +602,18 @@ const details = (val: any) => {
|
||||
}
|
||||
//修改测试项回显
|
||||
if (activeFormIndex.value == 3) {
|
||||
form1.value = val.records[0]
|
||||
if(val.records[0]&& val.records.length != 0 ){
|
||||
form1.value = JSON.parse(JSON.stringify(val.records[0]))
|
||||
}else{
|
||||
initForm()
|
||||
}
|
||||
}
|
||||
if (activeFormIndex.value != 1 && activeFormIndex.value != 3) {
|
||||
initForm()
|
||||
}
|
||||
}
|
||||
//0 新增方案 1 修改方案 2 新增测试项 3 修改测试项 4 设备信息
|
||||
const open = (val: any, id: any) => {
|
||||
console.log(id, '8888888')
|
||||
const open = async (val: any, id: any) => {
|
||||
activeFormIndex.value = val
|
||||
title.value = val == 0 ? '新增方案' : val == 1 ? '修改方案' : val == 2 ? '新增测试项' : '修改测试项'
|
||||
dialogVisible.value = true
|
||||
@@ -632,7 +635,8 @@ const open = (val: any, id: any) => {
|
||||
//查绑定测试项列表
|
||||
getSelectedTable(id)
|
||||
//查新增列表
|
||||
tableStore.index()
|
||||
await tableStore.index()
|
||||
activeName.value = 0
|
||||
}
|
||||
}
|
||||
|
||||
@@ -642,25 +646,37 @@ const tableData = ref([])
|
||||
defineOptions({
|
||||
name: 'govern/tourist/index'
|
||||
})
|
||||
const treeIds: any = ref(['-1'])
|
||||
const treeIds: any = ref([])
|
||||
const pids: any = ref([])
|
||||
//树节点选择变化的时候处理树节点选中数据
|
||||
const checkChange = async (data: any) => {
|
||||
if (defaultCheckedKeys.value.length == 0) {
|
||||
treeIds.value[0] = '-1'
|
||||
}
|
||||
if (data.checked) {
|
||||
defaultCheckedKeys.value.push(data.data.id)
|
||||
data.data.children?.map((item: any) => {
|
||||
treeIds.value = []
|
||||
pids.value = []
|
||||
// if (data.checked) {
|
||||
// defaultCheckedKeys.value.push(data.data.id)
|
||||
// data.data.children?.map((item: any) => {
|
||||
// treeIds.value.push(item.id)
|
||||
// pids.value.push(item.pid)
|
||||
// })
|
||||
// } else {
|
||||
// defaultCheckedKeys.value.splice(defaultCheckedKeys.value.indexOf(data.data.id), 1)
|
||||
// data.data.children?.map((item: any) => {
|
||||
// treeIds.value.splice(defaultCheckedKeys.value.indexOf(item.id), 1)
|
||||
// })
|
||||
// }
|
||||
if (data.data && data.data.length != 0) {
|
||||
data.data?.map((item: any) => {
|
||||
if (item.pid) {
|
||||
treeIds.value.push(item.id)
|
||||
pids.value.push(item.pid)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
defaultCheckedKeys.value.splice(defaultCheckedKeys.value.indexOf(data.data.id), 1)
|
||||
data.data.children?.map((item: any) => {
|
||||
treeIds.value.splice(defaultCheckedKeys.value.indexOf(item.id), 1)
|
||||
})
|
||||
treeIds.value = []
|
||||
pids.value.push = []
|
||||
}
|
||||
treeIds.value = [...new Set(treeIds.value)]
|
||||
treeIds.value[0] = '-1'
|
||||
pids.value = [...new Set(pids.value)]
|
||||
await tableStore.index()
|
||||
}
|
||||
const deviceInfoTreeRef = ref()
|
||||
@@ -672,7 +688,6 @@ const getSelectedTable = async (id: any) => {
|
||||
//新增传0已绑定传1
|
||||
await getDeviceList({ id: id, isTrueFlag: 1, pageNum: 1, pageSize: 1000 }).then(res => {
|
||||
tableData.value = res.data.records
|
||||
activeName.value = tableData.value.length == 0 ? 0 : 2
|
||||
})
|
||||
}
|
||||
//新增设备列表
|
||||
@@ -695,9 +710,11 @@ const tableStore = new TableStore({
|
||||
//新增传0已绑定传1
|
||||
tableStore.table.params.isTrueFlag = 0
|
||||
tableStore.table.params.treeIds = treeIds.value
|
||||
tableStore.table.params.pids = pids.value
|
||||
}
|
||||
})
|
||||
tableStore.table.params.treeIds = ['-1']
|
||||
tableStore.table.params.treeIds = []
|
||||
tableStore.table.params.pids = []
|
||||
provide('tableStore', tableStore)
|
||||
const tableRef = ref()
|
||||
//删除设备
|
||||
@@ -756,6 +773,7 @@ const handleDelete = (row: any) => {
|
||||
delDevice({ id: selectId.value, list: list }).then(res => {
|
||||
if (res.code == 'A0000') {
|
||||
ElMessage.success('移除成功')
|
||||
activeName.value = tableData.value.length == 0 ? 0 : 2
|
||||
getSelectedTable(selectId.value)
|
||||
}
|
||||
})
|
||||
@@ -801,6 +819,7 @@ const submit = () => {
|
||||
}
|
||||
addPlan(subForm).then(res => {
|
||||
ElMessage.success('新增方案成功')
|
||||
initForm()
|
||||
emit('onSubmit')
|
||||
close()
|
||||
})
|
||||
@@ -840,6 +859,7 @@ const submit = () => {
|
||||
})
|
||||
addRecord(subForm).then(res => {
|
||||
ElMessage.success('新增测试项成功')
|
||||
initForm()
|
||||
emit('onSubmit')
|
||||
close()
|
||||
})
|
||||
@@ -848,20 +868,19 @@ const submit = () => {
|
||||
}
|
||||
//修改测试项
|
||||
if (activeFormIndex.value == 3) {
|
||||
console.log(66666, ruleFormRef2.value.validate)
|
||||
ruleFormRef2.value.validate((valid: any) => {
|
||||
console.log(valid, '------')
|
||||
if (valid) {
|
||||
// const subForm = {
|
||||
// id: planId.value,
|
||||
// ...form1.value
|
||||
// }
|
||||
let subForm = form1.value
|
||||
let subForm = JSON.parse(JSON.stringify(form1.value))
|
||||
subForm.list = tableData.value.map(item => {
|
||||
return item.id
|
||||
})
|
||||
updateRecord(subForm).then(res => {
|
||||
ElMessage.success('修改测试项成功')
|
||||
initForm()
|
||||
emit('onSubmit')
|
||||
close()
|
||||
})
|
||||
|
||||
@@ -236,7 +236,6 @@ watch(
|
||||
(val, oldVal) => {
|
||||
if (val && dialogRef.value) {
|
||||
const obj = JSON.parse(JSON.stringify(val))
|
||||
console.log(obj,"88888888888");
|
||||
obj.records = [
|
||||
val.records.find(item => {
|
||||
return item.id == monitorId.value
|
||||
|
||||
@@ -89,9 +89,16 @@
|
||||
<p>历史趋势</p>
|
||||
</div>
|
||||
<div class="history_header">
|
||||
<el-form :model="searchForm" class="history_select">
|
||||
<el-form :model="searchForm" class="history_select" label-width="auto">
|
||||
<el-form-item label="统计指标">
|
||||
<el-select @change="init" v-model="searchForm.index" placeholder="请选择统计指标">
|
||||
<el-select
|
||||
multiple
|
||||
:multiple-limit="3"
|
||||
collapse-tags
|
||||
collapse-tags-tooltip
|
||||
v-model="searchForm.index"
|
||||
placeholder="请选择统计指标"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in indexOptions"
|
||||
:key="item.id"
|
||||
@@ -100,24 +107,20 @@
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="谐波次数" v-if="countOptions.length != 0">
|
||||
<el-select
|
||||
@change="init"
|
||||
v-model="searchForm.count"
|
||||
multiple
|
||||
:multiple-limit="3"
|
||||
placeholder="请选择谐波次数"
|
||||
>
|
||||
<div v-for="(item, index) in countData" :key="index">
|
||||
<el-form-item :label="item.name + '谐波次数'" v-if="item.countOptions.length != 0">
|
||||
<el-select v-model="item.count" multiple placeholder="请选择谐波次数">
|
||||
<el-option
|
||||
v-for="item in countOptions"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
v-for="vv in item.countOptions"
|
||||
:key="vv"
|
||||
:label="vv"
|
||||
:value="vv"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</div>
|
||||
<el-form-item label="值类型">
|
||||
<el-select @change="init" v-model="searchForm.type" placeholder="请选择值类型">
|
||||
<el-select v-model="searchForm.type" placeholder="请选择值类型">
|
||||
<el-option
|
||||
v-for="item in typeOptions"
|
||||
:key="item.id"
|
||||
@@ -128,7 +131,7 @@
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div class="history_searchBtn">
|
||||
<!-- <el-button type="primary" icon="el-icon-Search" @click="handleSearch">查询</el-button> -->
|
||||
<el-button type="primary" size="small" icon="el-icon-Search" @click="init()">查询</el-button>
|
||||
<el-button
|
||||
v-if="historyDataList.length != 0"
|
||||
type="primary"
|
||||
@@ -140,16 +143,12 @@
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="title">
|
||||
10KV 母线_监测点 相电压有效值
|
||||
</div> -->
|
||||
<div class="history_chart" v-loading="loading" v-show="echartsData">
|
||||
<MyEchart ref="historyChart" :isExport="true" :options="echartsData" />
|
||||
</div>
|
||||
</div>
|
||||
<el-empty v-else description="请选择设备" class="device-manage-right" />
|
||||
<popup ref="dialogRef" @onSubmit="refreshTree" />
|
||||
<!-- <device ref="deviceRef"></device> -->
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -158,14 +157,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 } from 'vue'
|
||||
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 device from './components/device.vue'
|
||||
import { queryStatistical } from '@/api/system-boot/csstatisticalset'
|
||||
import * as echarts from 'echarts'
|
||||
import { isNonNullChain } from 'typescript'
|
||||
const dictData = useDictData()
|
||||
defineOptions({
|
||||
name: 'govern/device/manage'
|
||||
@@ -174,9 +173,7 @@ defineOptions({
|
||||
const voltageLevelList = dictData.getBasicData('Dev_Voltage')
|
||||
//接线方式
|
||||
const volConTypeList = dictData.getBasicData('Dev_Connect')
|
||||
|
||||
//值类型
|
||||
|
||||
const pageHeight = mainHeight(20)
|
||||
const loading = ref(true)
|
||||
const searchForm = ref({})
|
||||
@@ -199,7 +196,7 @@ const typeOptions = [
|
||||
}
|
||||
]
|
||||
searchForm.value = {
|
||||
index: '',
|
||||
index: [],
|
||||
type: typeOptions[0].id,
|
||||
count: []
|
||||
}
|
||||
@@ -213,7 +210,7 @@ const legendDictList: any = ref([])
|
||||
queryByCode('portable-harmonic').then(res => {
|
||||
queryCsDictTree(res.data.id).then(item => {
|
||||
indexOptions.value = item.data
|
||||
searchForm.value.index = indexOptions.value[0].id
|
||||
searchForm.value.index[0] = indexOptions.value[0].id
|
||||
})
|
||||
queryStatistical(res.data.id).then(vv => {
|
||||
legendDictList.value = vv.data
|
||||
@@ -230,7 +227,6 @@ const nodeClick = async (e: anyObj) => {
|
||||
deviceData.value = []
|
||||
historyDevId.value = e.children && e.children.length != 0 ? e.children[0].id : e.id
|
||||
let id = e.pid ? e.pid : e.id
|
||||
console.log(id, e, '单个点击')
|
||||
//查询测试项信息
|
||||
try {
|
||||
await getTestRecordInfo(id).then(res => {
|
||||
@@ -241,15 +237,12 @@ const nodeClick = async (e: anyObj) => {
|
||||
} else {
|
||||
res.data.records.map((item: any) => {
|
||||
//多层
|
||||
console.log(item.id, e.id, '88888888888888888888')
|
||||
if (item.id == e.id) {
|
||||
activeName.value = item.id
|
||||
return
|
||||
console.log('着调了', activeName.value, item.id)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
schemeTreeRef.value.getPlanData(deviceData.value)
|
||||
})
|
||||
} catch (error) {
|
||||
@@ -280,27 +273,16 @@ const init = async () => {
|
||||
// 选择指标的时候切换legend内容和data数据
|
||||
let list: any = []
|
||||
legendDictList.value?.selectedList?.map((item: any) => {
|
||||
if (item.dataType == searchForm.value.index) {
|
||||
searchForm.value.index.map((vv: any) => {
|
||||
if (item.dataType == vv) {
|
||||
list.push(item.eleEpdPqdVOS)
|
||||
countOptions.value = []
|
||||
item.eleEpdPqdVOS.map((vv: any) => {
|
||||
if (vv.harmStart && vv.harmEnd) {
|
||||
let list = []
|
||||
range(0, 0, 0)
|
||||
list = range(vv.harmStart, vv.harmEnd, 2)
|
||||
list.map((item: any) => {
|
||||
countOptions.value.push({
|
||||
id: item,
|
||||
name: item
|
||||
})
|
||||
})
|
||||
} else {
|
||||
countOptions.value = []
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
if (historyDevId.value) {
|
||||
//选择的指标使用方法处理
|
||||
initSearchFormIndexAndCount(searchForm.value.index)
|
||||
//查询历史趋势
|
||||
historyDataList.value = []
|
||||
loading.value = true
|
||||
@@ -318,31 +300,35 @@ const init = async () => {
|
||||
} else {
|
||||
middleTitle = ''
|
||||
}
|
||||
chartTitle.value =
|
||||
deviceData.value.itemName +
|
||||
' ' +
|
||||
middleTitle +
|
||||
' ' +
|
||||
indexOptions.value.find(item => {
|
||||
return item.id == searchForm.value.index
|
||||
})?.name
|
||||
chartTitle.value = deviceData.value.itemName + ' ' + middleTitle + ' '
|
||||
// +
|
||||
// indexOptions.value.find(item => {
|
||||
// return item.id == searchForm.value.index[0]
|
||||
// })?.name
|
||||
|
||||
searchForm.value.index.map((item: any) => {
|
||||
indexOptions.value.map((vv: any) => {
|
||||
if (vv.id == item) {
|
||||
chartTitle.value += ' ' + vv.name
|
||||
}
|
||||
})
|
||||
})
|
||||
let lists: any = []
|
||||
countData.value.map((item: any, index: any) => {
|
||||
lists[index] = {
|
||||
statisticalId: item.index,
|
||||
frequencys: item.count
|
||||
}
|
||||
})
|
||||
let obj = {
|
||||
devId: historyDevId.value,
|
||||
statisticalId: searchForm.value.index,
|
||||
valueType: searchForm.value.type,
|
||||
frequency: ''
|
||||
}
|
||||
if (countOptions.value.length != 0 && searchForm.value.count.length != 0) {
|
||||
obj.frequency = JSON.parse(JSON.stringify(searchForm.value.count.join(',')))
|
||||
} else {
|
||||
searchForm.value.count = []
|
||||
delete obj.frequency
|
||||
list: lists,
|
||||
valueType: searchForm.value.type
|
||||
}
|
||||
try {
|
||||
await getHistoryTrend(obj)
|
||||
.then(res => {
|
||||
if (res.code == 'A0000') {
|
||||
console.log(res, '趋势图')
|
||||
historyDataList.value = res.data
|
||||
echartsData.value = null
|
||||
//icon图标替换legend图例
|
||||
@@ -351,12 +337,26 @@ const init = async () => {
|
||||
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[] = []
|
||||
let xAxis: any = [],
|
||||
timeList: any = []
|
||||
let unit = ''
|
||||
historyDataList.value.map((item: any) => {
|
||||
xAxis.push(item.time)
|
||||
timeList.push(item.time)
|
||||
unit = 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: [
|
||||
@@ -371,62 +371,6 @@ const init = async () => {
|
||||
// title: '保存'
|
||||
// },
|
||||
// dataView: { readOnly: false },
|
||||
// myTool1: {
|
||||
// show: true,
|
||||
// title: '下载数据',
|
||||
// icon: 'path://M18 20.288L21.288 17l-.688-.688l-2.1 2.1v-4.887h-1v4.887l-2.1-2.1l-.688.688zM14.5 23.5v-1h7v1zm-10-4v-17H13L18.5 8v3.14h-1V8.5h-5v-5h-7v15h6.615v1zm1-1v-15z',
|
||||
// onclick: function () {
|
||||
// setTimeout(() => {
|
||||
// // 使用这个函数转换数据为CSV格式
|
||||
// let csv = ''
|
||||
// const list = echartsData.value.options.series
|
||||
// list.map((item: any, key: any) => {
|
||||
// csv = convertToCSV(item.data, key)
|
||||
// })
|
||||
// // 如果你想提供下载链接
|
||||
// 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) {
|
||||
// console.log(data, key, '0000000')
|
||||
// // 添加列头
|
||||
// let title = '时间,'
|
||||
// list.map((item: any, index: any) => {
|
||||
// // title+=item.name+','
|
||||
// index == list.length - 1
|
||||
// ? (title += `${item.name}\n`)
|
||||
// : (title += `${item.name},`)
|
||||
// })
|
||||
// console.log(title, '99999999999')
|
||||
// let csv = ''
|
||||
// // csv += 'x,y\n'
|
||||
// csv = title
|
||||
// // 遍历数据并添加到CSV字符串中
|
||||
// let arr = []
|
||||
// arr[key] = data
|
||||
// console.log(list[0].data.length, '77777777777')
|
||||
// list[0].data.map((vv:any,indexs:any)=>{
|
||||
// if (list.length==3) {
|
||||
// csv += `${xAxis[indexs]},${list[0].data[indexs]},${list[1].data[indexs]},${list[2].data[indexs]}\n`
|
||||
// }
|
||||
// })
|
||||
// // list[key].data.map((item: any, index: any) => {
|
||||
// // if (key == 0) {
|
||||
// // csv += `${xAxis[index]},${item},\n`
|
||||
// // }
|
||||
// // if (key == list.length - 1) {
|
||||
// // csv += `${item}\n`
|
||||
// // }
|
||||
// // if (key != 0 && key != list.length - 1) {
|
||||
// // csv += `${item},`
|
||||
// // }
|
||||
// // })
|
||||
// return csv
|
||||
// }
|
||||
// }, 10)
|
||||
// }
|
||||
// }
|
||||
}
|
||||
},
|
||||
@@ -439,11 +383,14 @@ const init = async () => {
|
||||
legend: {
|
||||
//legend使用iconfont图标
|
||||
data: [],
|
||||
top: 5,
|
||||
right: 80,
|
||||
itemWidth: 20,
|
||||
itemHeight: 10,
|
||||
itemGap: 15
|
||||
itemGap: 15,
|
||||
type: 'scroll', // 开启滚动分页
|
||||
// orient: 'vertical', // 垂直排列
|
||||
right: 10, // 位置调整
|
||||
width: 300,
|
||||
height: 50
|
||||
},
|
||||
grid: {
|
||||
left: '1%',
|
||||
@@ -458,9 +405,13 @@ const init = async () => {
|
||||
name: '时间',
|
||||
axisLabel: {
|
||||
color: '#A9AEB2',
|
||||
fontSize: 12
|
||||
fontSize: 12,
|
||||
show: function (index: any, value: any) {
|
||||
// 检查数据中是否存在这个时间点
|
||||
// return data.some(item:any => item[0] === value)
|
||||
}
|
||||
},
|
||||
data: xAxis,
|
||||
data: Array.from(new Set(xAxis)),
|
||||
axisLine: {
|
||||
lineStyle: {
|
||||
color: '#43485E'
|
||||
@@ -504,18 +455,18 @@ const init = async () => {
|
||||
}
|
||||
//颜色数组
|
||||
const colorList = ['#DAA521', '#2E8B58', '#A5292A', '#d81e06']
|
||||
list.map((item, index) => {
|
||||
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.showName,
|
||||
name: vv.phase + '相' + vv.showName,
|
||||
icon: iconThree
|
||||
})
|
||||
}
|
||||
//series数据
|
||||
echartsData.value.options.series.push({
|
||||
name: vv.showName,
|
||||
name: vv.phase + '相' + vv.showName,
|
||||
type: 'line',
|
||||
smooth: true,
|
||||
symbol: 'none',
|
||||
@@ -532,7 +483,7 @@ const init = async () => {
|
||||
},
|
||||
data: historyDataList.value
|
||||
.map((kk: any) => {
|
||||
if (kk.statisticalName === vv.name) {
|
||||
if (kk.statisticalName == vv.name) {
|
||||
return kk.statisticalData
|
||||
} else {
|
||||
return ''
|
||||
@@ -553,11 +504,6 @@ const init = async () => {
|
||||
}
|
||||
}
|
||||
}
|
||||
//搜素
|
||||
const handleSearch = () => {
|
||||
console.log(searchForm.value, '搜索')
|
||||
init()
|
||||
}
|
||||
//导出
|
||||
const historyChart = ref()
|
||||
// const chart: any = ref(null)
|
||||
@@ -565,15 +511,22 @@ const historyChart = ref()
|
||||
const handleExport = () => {
|
||||
setTimeout(() => {
|
||||
let xAxis: any = []
|
||||
let timeList: any = []
|
||||
historyDataList.value.map((item: any) => {
|
||||
xAxis.push(item.time)
|
||||
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 = ''
|
||||
let csv: any = ''
|
||||
const list = echartsData.value.options.series
|
||||
list.map((item: any, key: any) => {
|
||||
csv = convertToCSV(item.data, key)
|
||||
})
|
||||
csv = convertToCSV([], [])
|
||||
// 如果你想提供下载链接
|
||||
const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' })
|
||||
const link = document.createElement('a')
|
||||
@@ -581,50 +534,100 @@ const handleExport = () => {
|
||||
link.download = '历史趋势.csv'
|
||||
link.click()
|
||||
function convertToCSV(data: any, key: any) {
|
||||
console.log(data, key, '0000000')
|
||||
// 添加列头
|
||||
let title = '时间,'
|
||||
let title = '统计时间,'
|
||||
list.map((item: any, index: any) => {
|
||||
// title+=item.name+','
|
||||
index == list.length - 1 ? (title += `${item.name}\n`) : (title += `${item.name},`)
|
||||
})
|
||||
let csv = ''
|
||||
// csv += 'x,y\n'
|
||||
csv = title
|
||||
// 遍历数据并添加到CSV字符串中
|
||||
let arr = []
|
||||
arr[key] = data
|
||||
let str = ''
|
||||
list.map((item: any, index: any) => {
|
||||
// str += '${list[' + index + '].data[indexs]},'
|
||||
str += `${list[index].data['indexs']}`
|
||||
})
|
||||
console.log(str, 'strstrstrstrstrsr')
|
||||
const listLength = list.length
|
||||
list[0].data.map((vv: any, indexs: any) => {
|
||||
switch (listLength) {
|
||||
case 1:
|
||||
csv += `${xAxis[indexs]},${list[0].data[indexs]}\n`
|
||||
break
|
||||
case 2:
|
||||
csv += `${xAxis[indexs]},${list[0].data[indexs]},${list[1].data[indexs]}\n`
|
||||
break
|
||||
case 3:
|
||||
csv += `${xAxis[indexs]},${list[0].data[indexs]},${list[1].data[indexs]},${list[2].data[indexs]}\n`
|
||||
break
|
||||
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'
|
||||
}
|
||||
|
||||
// if (list.length == 3) {
|
||||
// // ${list[0].data[indexs]},${list[1].data[indexs]},${list[2].data[indexs]}
|
||||
// csv +=`${list[0].data[indexs]},${list[1].data[indexs]},${list[2].data[indexs]}`
|
||||
// }
|
||||
})
|
||||
return csv
|
||||
}
|
||||
}, 10)
|
||||
// historyChart.value.handleExport(historyDataList.value)
|
||||
}
|
||||
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: [],
|
||||
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, 2)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
watch(
|
||||
() => searchForm.value.index,
|
||||
(val: any, oldval: any) => {
|
||||
// countData.value = []
|
||||
if (val) {
|
||||
initSearchFormIndexAndCount(val)
|
||||
if (val == 0) {
|
||||
countData.value = []
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
deep: true,
|
||||
immediate: true
|
||||
}
|
||||
)
|
||||
watch(
|
||||
() => countData.value,
|
||||
(val: any, oldval: any) => {
|
||||
if (val) {
|
||||
if (val.length != searchForm.value.index.length) {
|
||||
val.map((item: any, index: any) => {
|
||||
searchForm.value.index.map((vv: any) => {
|
||||
if (item.index != vv) {
|
||||
val.splice(index, 1)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
deep: true,
|
||||
immediate: true
|
||||
}
|
||||
)
|
||||
onMounted(() => {})
|
||||
</script>
|
||||
|
||||
@@ -682,12 +685,12 @@ onMounted(() => {})
|
||||
|
||||
.history_header {
|
||||
display: flex;
|
||||
|
||||
flex-wrap: wrap;
|
||||
.history_select {
|
||||
width: 65%;
|
||||
width: 90%;
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
|
||||
flex-wrap: wrap;
|
||||
.el-select {
|
||||
margin-right: 10px;
|
||||
}
|
||||
@@ -702,7 +705,7 @@ onMounted(() => {})
|
||||
|
||||
.history_chart {
|
||||
width: 100%;
|
||||
min-height: calc(100vh - 600px) !important;
|
||||
min-height: calc(100vh - 680px) !important;
|
||||
flex: 1;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user