From e140362c425568b9149ed7c725ff1710703ea00e Mon Sep 17 00:00:00 2001 From: zhujiyan <17812234322@163.com> Date: Sun, 29 Sep 2024 16:12:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B9=E6=A1=88=E6=95=B0=E6=8D=AE=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E6=8C=87=E6=A0=87=E6=94=B9=E4=B8=BA=E5=A4=9A=E9=80=89?= =?UTF-8?q?/x=E8=BD=B4=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/govern/device/planData/index.vue | 432 ++++++++++++--------- 1 file changed, 250 insertions(+), 182 deletions(-) diff --git a/src/views/govern/device/planData/index.vue b/src/views/govern/device/planData/index.vue index de33e66..d15a5f1 100644 --- a/src/views/govern/device/planData/index.vue +++ b/src/views/govern/device/planData/index.vue @@ -15,157 +15,165 @@ {{ deviceData.describe ? deviceData.describe : '/' }} -
-
-

测试项信息

-
- - - - - - {{ item.itemName }} - - - {{ item.statisticalInterval }}分钟 - - - {{ - voltageLevelList.find(vv => { - return vv.id == item.voltageLevel - })?.name - }} - - - {{ - volConTypeList.find(vv => { - return vv.id == item.volConType - })?.name - }} - - - {{ item.capacitySscmin }}MVA - - - {{ item.capacitySi }}MVA - - - {{ item.capacitySscb }}MVA - - - {{ item.capacitySt }}MVA - - - {{ item.pt && item.pt1 ? item.pt / item.pt1 : item.pt }} - - - {{ item.ct && item.ct1 ? item.ct / item.ct1 : item.ct }} - - - - {{ item.startTime }} - - - - - {{ item.endTime }} - - - - {{ item.location }} - - - - 数据绑定 - - - - - -
-
-

历史趋势

-
-
- - - - - - - - - - - - - - -
- - - - + +
+ + + - - - + + + + {{ item.itemName }} + + + {{ item.statisticalInterval }}分钟 + + + {{ + voltageLevelList.find(vv => { + return vv.id == item.voltageLevel + })?.name + }} + + + {{ + volConTypeList.find(vv => { + return vv.id == item.volConType + })?.name + }} + + + {{ item.capacitySscmin }}MVA + + + {{ item.capacitySi }}MVA + + + {{ item.capacitySscb }}MVA + + + {{ item.capacitySt }}MVA + + + {{ item.pt && item.pt1 ? item.pt / item.pt1 : item.pt }} + + + {{ item.ct && item.ct1 ? item.ct / item.ct1 : item.ct }} + + + + {{ item.startTime }} + + + + + {{ item.endTime }} + + + + {{ item.location }} + + + + 数据绑定 + + + + +
- - - - - - -
- 查询 -
-
-
-

{{ chartTitle }}

-
-
- -
+ + + +
+ + + + + + + + + + + + +
+ + + + + + +
+ + + + + +
+
+ 查询 +
+
+
+

{{ chartTitle }}

+
+
+ +
+
+
@@ -215,7 +223,7 @@ const typeOptions = [ } ] searchForm.value = { - index: '', + index: [], dataLevel: 'Primary', type: typeOptions[0].id, count: [] @@ -230,14 +238,15 @@ 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 + searchForm.value.index[0] = indexOptions.value[0].id + // searchForm.value.index = indexOptions.value[0].id }) queryStatistical(res.data.id).then(vv => { legendDictList.value = vv.data }) }) const activeName: any = ref() +const activeColName: any = ref('1') const deviceData: any = ref([]) const schemeTreeRef = ref() //历史趋势devId @@ -311,6 +320,26 @@ const refreshTree = () => { 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 +} const init = () => { //调用子组件的方法切换的时候tree的节点也变化 let list: any = [] @@ -331,15 +360,21 @@ const init = () => { 'cadetblue' ] if (historyDevId.value && legendDictList.value && legendDictList.value.selectedList) { + console.log('where') // 选择指标的时候切换legend内容和data数据 legendDictList.value?.selectedList?.map((item: any) => { - if (item.dataType == searchForm.value.index) { - list.push(item.eleEpdPqdVOS) - } + // if (item.dataType == searchForm.value.index) { + // list.push(item.eleEpdPqdVOS) + // } + searchForm.value.index.map((vv: any) => { + if (item.dataType == vv) { + list.push(item.eleEpdPqdVOS) + } + }) }) //选择的指标使用方法处理 - formatCountOptions([searchForm.value.index]) + formatCountOptions(searchForm.value.index) //查询历史趋势 historyDataList.value = [] let middleTitle = '' @@ -357,7 +392,7 @@ const init = () => { middleTitle = '' } let indexList = [] - indexList = [searchForm.value.index] + indexList = searchForm.value.index chartTitle.value = deviceData.value.itemName + '_' + middleTitle + '_' indexList.map((item: any, indexs: any) => { indexOptions.value.map((vv: any) => { @@ -376,14 +411,16 @@ const init = () => { let obj = { devId: historyDevId.value, list: lists, - dataLevel:searchForm.value.dataLevel, + dataLevel: searchForm.value.dataLevel, valueType: searchForm.value.type } getHistoryTrend(obj) .then((res: any) => { if (res.code === 'A0000') { + console.log('this') historyDataList.value = res.data + let chartsList = JSON.parse(JSON.stringify(res.data)) echartsData.value = null //icon图标替换legend图例 const iconThree = @@ -391,7 +428,7 @@ const init = () => { let xAxis: any = [], timeList: any = [], unitList: any = [] - historyDataList.value.map((item: any) => { + chartsList.map((item: any) => { timeList.push(item.time) if (unitList.indexOf(item.unit) == -1) { unitList.push(item.unit) @@ -400,9 +437,6 @@ const init = () => { xAxis = timeList.sort((a: any, b: any) => { return new Date(a).getTime() - new Date(b).getTime() }) - // xAxis.map((item:any)=>{ - - // }) echartsData.value = { options: { title: [ @@ -472,9 +506,24 @@ const init = () => { color: '#999' } } + // formatter: function (params: any) { + // var res = params[0].name + '
' + // 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 + + // ' ' + + // `
` + + // `
${params[i].value} ${params[i].unit}

` + // } + // return res + // } }, // grid: { - // left: historyDataList.value.length != 0 ? '5%' : '1%', + // left: chartsList.length != 0 ? '5%' : '1%', // right: '5%', // bottom: '10%', // top: '8%', @@ -482,7 +531,7 @@ const init = () => { // }, xAxis: [ { - type: 'time',//category + type: 'time', //category name: '\n\n\n\n\n时间', axisLabel: { color: '#A9AEB2', @@ -490,6 +539,9 @@ const init = () => { show: function (index: any, value: any) { // 检查数据中是否存在这个时间点 // return data.some(item:any => item[0] === value) + }, + formatter: { + day: '{MM}-{d}' } }, nameTextStyle: { @@ -577,16 +629,18 @@ const init = () => { } }) } - + echartsData.value.options.legend.data = [] + console.log(list, '988888888888606') list.map((item: any, index: any) => { item.map((vv: any, indexs: any) => { //处理legend - if (historyDataList.value.length != 0) { + if (chartsList.length != 0) { echartsData.value.options.legend.data.push({ name: vv.phase + '相' + vv.showName, icon: iconThree }) } + console.log(echartsData.value.options.legend.data, 'legend-legend-legend') if ( unitList.findIndex((item: any) => { return item == vv.unit @@ -609,15 +663,18 @@ const init = () => { }, itemStyle: {}, //数据 - data: historyDataList.value - .map((kk: any) => { - if (kk.statisticalName == vv.name) { - return kk.statisticalData - } else { - return '' - } - }) - .filter((kk: any) => kk !== ''), + data: filterArray( + chartsList + .map((kk: any, kks: any) => { + if (kk.statisticalName == vv.name) { + // console.log([xAxis[kks],kk.statisticalData],"========>>>>>>>"); + return Array.from(new Set([xAxis[kks], kk.statisticalData])) + } else { + return '' + } + }) + .filter((kk: any) => kk !== '') + ), //数据对应的y轴 // yAxisIndex:0, yAxisIndex: vv.yAxisIndex @@ -634,8 +691,10 @@ const init = () => { } } } + // item.data = filterArray(item.data) }) loading.value = false + console.log(echartsData.value.options.series, '++++++++++++++++++++669') } }) .catch(error => { @@ -698,6 +757,7 @@ const handleExport = async () => { } if (historyDataList.value.length != 0) { + console.log(historyDataList.value, 'historyDataList') let xAxis: any = [] let timeList: any = [] historyDataList.value.map((item: any) => { @@ -713,6 +773,7 @@ const handleExport = async () => { csv = convertToCSV([], []) chartsCsv.value = csv // 如果你想提供下载链接 + console.log(list, '745745745745') function convertToCSV(data: any, key: any) { // 添加列头 let title = '统计时间,' @@ -722,16 +783,19 @@ const handleExport = async () => { let csv = '' csv = title // 遍历数据并添加到CSV字符串中 - list[0].data.map((vv: any, indexs: any) => { + list[0]?.data.map((vv: any, indexs: any) => { let strs = '', count = null list.map((item: any, index: any) => { if (index == 0) { count = index } + // console.log( list[index].data[indexs][list[index].data[indexs]], indexs,"88888888888888"); + console.log(list[index].data[indexs],"iiiiii"); + let itemList:any=list[index].data[indexs] index == list.length - 1 - ? (strs += list[index].data[indexs]) - : (strs += list[index].data[indexs] + ',') + ? (strs += itemList[0]) + : (strs += itemList[0] + ',') }) if (count == 0 && xAxis[indexs]) { csv += `${xAxis[indexs]},` + strs + '\n' @@ -797,7 +861,7 @@ watch( () => searchForm.value.index, (val: any, oldval: any) => { if (val) { - let list = [val] + let list = val // formatCountOptions(list) // if (val == 0) { // countData.value = [] @@ -894,8 +958,7 @@ onMounted(() => { width: 95%; display: flex; justify-content: flex-start; - - // overflow-x: auto; + overflow-x: auto; // height: 45px; // padding-top: 18px; // flex-wrap: wrap; @@ -921,7 +984,7 @@ onMounted(() => { .history_chart { width: 100%; - min-height: calc(100vh - 680px) !important; + height: calc(100vh - 440px) !important; flex: 1; margin-top: 10px; } @@ -929,4 +992,9 @@ onMounted(() => { ::v-deep .el-select { width: 120px !important; } + +::v-deep .el-collapse-item__header{ + font-size: 16px !important; + font-weight: 800 !important; +}