From 1dbc0cb5282feee72421f827040a103daf3a76a3 Mon Sep 17 00:00:00 2001 From: yinq Date: Tue, 5 Nov 2024 17:17:57 +0800 Subject: [PATCH] =?UTF-8?q?change=20-=20=E6=95=B4=E7=82=B9=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E3=80=81=E8=83=BD=E6=BA=90=E9=A2=84=E8=A7=88=E6=8A=A5?= =?UTF-8?q?=E8=A1=A8=E6=B7=BB=E5=8A=A0=E5=8F=91=E7=94=B5=E9=87=8F=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/request.js | 2 +- .../ems/record/recordDnbInstant/index.vue | 4 +- src/views/ems/report/energyPreview/index.vue | 132 +++++++++++------- src/views/ems/report/reportPointDnb/index.vue | 22 ++- 4 files changed, 103 insertions(+), 57 deletions(-) diff --git a/src/utils/request.js b/src/utils/request.js index a94a448..dd715cb 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -18,7 +18,7 @@ const service = axios.create({ // axios中请求配置有baseURL选项,表示请求URL公共部分 baseURL: process.env.VUE_APP_BASE_API, // 超时 - timeout: 10000 + timeout: 60000 }) // request拦截器 diff --git a/src/views/ems/record/recordDnbInstant/index.vue b/src/views/ems/record/recordDnbInstant/index.vue index ccea72b..6bf0e41 100644 --- a/src/views/ems/record/recordDnbInstant/index.vue +++ b/src/views/ems/record/recordDnbInstant/index.vue @@ -142,8 +142,8 @@ - - + + diff --git a/src/views/ems/report/energyPreview/index.vue b/src/views/ems/report/energyPreview/index.vue index db11599..d3cb576 100644 --- a/src/views/ems/report/energyPreview/index.vue +++ b/src/views/ems/report/energyPreview/index.vue @@ -103,12 +103,24 @@ >导出 + + 展开/折叠 + + + @@ -178,6 +196,10 @@ export default { multiple: true, // 显示搜索条件 showSearch: true, + // 重新渲染表格状态 + refreshTable: true, + // 是否展开,默认全部展开 + isExpandAll: false, // 表格数据 dataList: null, // 时间List @@ -437,60 +459,71 @@ export default { myChart.setOption(option) energyPreviewReportList(this.queryParams).then((response) => { - this.dataList = this.handleTree(response.data,'objId') - this.loading = false + this.dataList = this.handleTree(response.data, 'objId'); + this.loading = false const data = response.data || [] if (data.length === 0) return this.totalConsumption = data.reduce((sum, item) => { return sum + parseFloat(item.expendSum || 0); }, 0); + if (parseFloat(data[0].expendSum) > 0){ + const keys = Object.keys(data[0]) + const filteredKeys = keys.filter(item => item.includes('dateData|')); - const keys = Object.keys(data[0]) - const filteredKeys = keys.filter(key => key && !['unitName', 'state', 'expendSum', 'type'].includes(key)) + const yData = filteredKeys.map(key => { + return data.reduce((sum, item) => sum + parseFloat(item[key] || 0), 0).toFixed(2) + }) - const yData = filteredKeys.map(key => { - return data.reduce((sum, item) => sum + parseFloat(item[key] || 0), 0).toFixed(2) - }) + const timeData = filteredKeys.map(key => key.split('dateData|')[1] + ':00:00') - const timeData = filteredKeys.map(key => key.split('expend')[1] + ':00:00') - const sortedData = timeData.map((time, index) => ({ - name: time, - value: parseFloat(yData[index]), - time: new Date(time).getTime() - })).sort((a, b) => a.time - b.time) + const sortedData = timeData.map((time, index) => ({ + name: time, + value: parseFloat(yData[index]), + time: new Date(time).getTime() + })).sort((a, b) => b.time - a.time); - const xAxisData = sortedData.map(item => item.name.split(':')[0]) - const seriesData = sortedData.map(item => item.value) + console.log(sortedData) - myChart.setOption({ - dataZoom: [{ - show: true, - type: 'slider', - bottom: '3%', - xAxisIndex: 0, - height: 12, - start: 0, - brushSelect: false, - end: (1 / (seriesData.length / 20)) * 100, - textStyle: { - fontSize: 0, - color: 'rgba(0,0,0,0)' - } - }], - xAxis: [{ - data: xAxisData - }], - series: [{ - data: seriesData - }, { - data: seriesData - }] - }) + const xAxisData = sortedData.map(item => item.name.split(':')[0]) + const seriesData = sortedData.map(item => item.value) + myChart.setOption({ + dataZoom: [{ + show: true, + type: 'slider', + bottom: '3%', + xAxisIndex: 0, + height: 12, + start: 0, + brushSelect: false, + end: (1 / (seriesData.length / 20)) * 100, + textStyle: { + fontSize: 0, + color: 'rgba(0,0,0,0)' + } + }], + xAxis: [{ + data: xAxisData + }], + series: [{ + data: seriesData + }, { + data: seriesData + }] + }) + } }) }, + /** 展开/折叠操作 */ + toggleExpandAll() { + this.refreshTable = false + this.isExpandAll = !this.isExpandAll + this.$nextTick(() => { + this.refreshTable = true + }) + }, /** 查询用户列表 */ getList(dateList) { this.loading = true @@ -512,20 +545,21 @@ export default { title: '耗量合计(' + this.measurementUnit + ')', align: 'center', rowspan: 2 + }, + { + field: 'powerExpendSum', + title: '发电量合计(' + this.measurementUnit + ')', + align: 'center', + rowspan: 2 } ) for (let i in columns) { this.timeList.push({ title: columns[i], align: 'center', - colspan: 1, - field: 'expend' + columns[i].substring(0, 13) - }) - this.energyList.push({ + colspan: 2, field: 'expend' + columns[i].substring(0, 13), - title: '耗量(' + this.measurementUnit + ')', - align: 'center', - rowspan: 1 + powerField: 'powerExpend' + columns[i].substring(0, 13), }) } }, diff --git a/src/views/ems/report/reportPointDnb/index.vue b/src/views/ems/report/reportPointDnb/index.vue index 30d3776..fec79a5 100644 --- a/src/views/ems/report/reportPointDnb/index.vue +++ b/src/views/ems/report/reportPointDnb/index.vue @@ -121,6 +121,9 @@ + + + -