修改测试bug

This commit is contained in:
GGJ
2024-10-22 10:50:47 +08:00
parent 29150a3c82
commit 7d2394f75d
6 changed files with 126 additions and 65 deletions

View File

@@ -39,7 +39,8 @@ import { reactive } from 'vue'
import DatePicker from '@/components/form/datePicker/index.vue'
import { getDeviceDataTrend } from '@/api/cs-harmonic-boot/datatrend'
import MyEchart from '@/components/echarts/MyEchart.vue'
import { yMethod } from '@/utils/echartMethod'
import { yMethod, exportCSV } from '@/utils/echartMethod'
import { ITEM_RENDER_EVT } from 'element-plus/es/components/virtual-list/src/defaults'
interface Props {
detail: anyObj
@@ -121,11 +122,11 @@ const init = () => {
})
let [min, max] = yMethod(arr.map((item: any) => item.statisticalData.toFixed(2)))
echartsData.value = {
options: {
grid: {
top: '50px',
top: '60px',
left: '10px',
right: '20px',
bottom: '40px',
@@ -160,7 +161,7 @@ const init = () => {
})
},
title: {
text: props.detail.name?.split('(')[0],
text: props.detail.name?.split('(')[0],
},
tooltip: {
axisPointer: {
@@ -187,9 +188,7 @@ const init = () => {
yAxis: {
name: `单位:(${arr[0].unit == null ? ' / ' : arr[0].unit})`,
type: 'value',
axisLine: {
show: true
},
min: min,
max: max,
@@ -246,6 +245,21 @@ const init = () => {
// return value.split(' ').join('\n')
// }
// }
},
toolbox: {
featureProps: {
myTool1: {
show: true,
title: '下载csv',
icon: 'path://M733.549304 0l116.434359 116.23452-226.402521 226.40252 57.053835 57.068109 226.459617-226.445342 120.616689 120.41685V0H733.549304zM689.513507 619.855586l-57.068108 57.068109 224.232847 224.232847-122.64362 122.843458h293.676657V729.838022l-114.007751 114.207588-224.190025-224.190024zM338.197775 404.144414l57.068109-57.068109L171.033037 122.843458 293.676657 0H0v294.161978l114.022025-114.207588 224.17575 224.190024zM347.076305 624.294851L120.616689 850.754468 0 730.323343v293.676657h294.161978l-116.420084-116.23452 226.40252-226.40252-57.068109-57.068109z',
onclick: (e) => {
echartsData.value
console.log("🚀 ~ init ~ echartsData.value:", echartsData.value.options.series.map(item => item.name))
exportCSV(echartsData.value.options.series.map(item => item.name),dataList, 'aaa.csv')
// downloadCSV(dataList, 'data.csv');
}
}
}
}
}
if ((echartsData.value.legend = ['A相', 'B相', 'C相'])) {
@@ -257,6 +271,15 @@ const init = () => {
loading.value = false
})
}
const dataList = [
{ x: 'A', y: 10 },
{ x: 'B', y: 20 },
{ x: 'C', y: 30 }
// ... 其他数据点
];
defineExpose({ open })
</script>
<style lang="scss">

View File

@@ -2,41 +2,30 @@
<div>
<!-- 历史趋势数据 -->
<div>
<TableHeader :showSearch="false" @selectChange="selectChange">
<template v-slot:select>
<TableHeader ref="tableHeaderRef" :showSearch="false" @selectChange="selectChange">
<template v-slot:select :key="num">
<!-- <el-form :model="searchForm" class="history_select" id="history_select"> -->
<el-form-item>
<DatePicker ref="datePickerRef"></DatePicker>
</el-form-item>
<el-form-item label="统计指标" label-width="80px">
<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>
<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>
</el-select>
</el-form-item>
<div v-for="(item, index) in countData" :key="index">
<el-form-item
v-for="(item, index) in countData" :key="index"
:label="item.name + '谐波次数'"
v-if="item.countOptions.length != 0"
label-width="180px"
>
<!-- v-if="item.countOptions.length != 0" -->
<el-select
v-model="item.count"
multiple
collapse-tags
collapse-tags-tooltip
@change="onCountChange($event, index)"
placeholder="请选择谐波次数"
>
@@ -48,7 +37,7 @@
></el-option>
</el-select>
</el-form-item>
</div>
<!-- </el-form> -->
</template>
<template #operation>
@@ -88,14 +77,16 @@ defineOptions({
name: 'govern/device/control'
})
//电压等级
const voltageLevelList = dictData.getBasicData('Dev_Voltage')
const voltageLevelList = dictData.getBasicData('Dev_Voltage_Stand')
//接线方式
const volConTypeList = dictData.getBasicData('Dev_Connect')
const num = ref(0)
//值类型
const pageHeight = ref(mainHeight(290))
const loading = ref(true)
const searchForm = ref({})
const tableHeaderRef = ref()
const typeOptions = [
{
name: '平均值',
@@ -117,7 +108,7 @@ const typeOptions = [
searchForm.value = {
index: [],
type: typeOptions[0].id,
count: [],
count: '',
searchBeginTime: '',
searchEndTime: ''
}
@@ -189,7 +180,7 @@ const init = async () => {
countData.value.map((item: any, index: any) => {
lists[index] = {
statisticalId: item.index,
frequencys: item.count
frequencys: [item.count]
}
})
let obj = {
@@ -260,9 +251,8 @@ const init = async () => {
const xname = params[0].value[0]
let str = `${xname}<br>`
params.forEach((el, index) => {
str += `${el.marker}${el.seriesName.split('(')[0]}${el.value[1]}${
el.value[2]
}<br>`
str += `${el.marker}${el.seriesName.split('(')[0]}${el.value[1]}${el.value[2]
}<br>`
})
return str
}
@@ -497,7 +487,7 @@ const initSearchFormIndexAndCount = (list: any) => {
countData.value[index] = {
index: item,
countOptions: [],
count: [],
count: '',
name: indexOptions.value.find((vv: any) => {
return vv.id == item
})?.name
@@ -512,37 +502,48 @@ const initSearchFormIndexAndCount = (list: any) => {
countData.value[index].countOptions = range(kk.harmStart, kk.harmEnd, 1)
//添加默认值
if (countData.value[index].count.length == 0) {
countData.value[index].count = [countData.value[index].countOptions[0]]
countData.value[index].count = countData.value[index].countOptions[0]
}
}
})
}
})
})
countData.value = countData.value.filter(item => item.countOptions.length > 0);
}
}
// 判断下拉框是否存在
const onCountChange = (val: any, index: any) => {
if (val.length == 0) {
countData.value[index].count = [countData.value[index].countOptions[0]]
countData.value[index].count = countData.value[index].countOptions[0]
}
}
const onIndexChange = (val: any) => {
num.value +=1
if (val.length == 0) {
searchForm.value.index = [indexOptions.value[0].id]
}
setTimeout(() => {
tableHeaderRef.value.computedSearchRow()
},500)
}
watch(
() => searchForm.value.index,
(val: any, oldval: any) => {
if (val) {
initSearchFormIndexAndCount(val)
setTimeout(() => {
initSearchFormIndexAndCount(val)
}, 100)
if (val == 0) {
countData.value = []
}
countData.value.map((item: any, key: any) => {
if (
val.findIndex((vv: any) => {
return vv == item.index
}) == -1
) {

View File

@@ -240,7 +240,7 @@ defineOptions({
const config = useConfig()
color[0] = config.layout.elementUiPrimary[0]
//电压等级
const voltageLevelList = dictData.getBasicData('Dev_Voltage')
const voltageLevelList = dictData.getBasicData('Dev_Voltage_Stand')
//接线方式
const volConTypeList = dictData.getBasicData('Dev_Connect')
//值类型