From fc3c2bd71c7e0515e9e0a164086e33092cd3c724 Mon Sep 17 00:00:00 2001 From: LokerL Date: Fri, 8 Nov 2024 11:15:05 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20=E4=BC=98=E5=8C=96=E5=B9=B4?= =?UTF-8?q?=E5=BA=A6=E6=95=B0=E6=8D=AE=E6=9F=A5=E8=AF=A2=EF=BC=8C=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=B8=AF=E5=8F=A3=E5=92=8C=E4=BC=81=E4=B8=9A=E5=B1=82?= =?UTF-8?q?=E7=BA=A7=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mybatis/oil/ThDeviceReportMonthMapper.xml | 11 +- .../views/dataStatistics/yearData/index.vue | 126 ++++++++++++++++-- 2 files changed, 118 insertions(+), 19 deletions(-) diff --git a/RuoYi-Vue-Oracle/src/main/resources/mybatis/oil/ThDeviceReportMonthMapper.xml b/RuoYi-Vue-Oracle/src/main/resources/mybatis/oil/ThDeviceReportMonthMapper.xml index 6fcf0f6..d4ecd3e 100644 --- a/RuoYi-Vue-Oracle/src/main/resources/mybatis/oil/ThDeviceReportMonthMapper.xml +++ b/RuoYi-Vue-Oracle/src/main/resources/mybatis/oil/ThDeviceReportMonthMapper.xml @@ -48,15 +48,16 @@ - - + + + + + + + + + - + -
+
@@ -102,6 +134,9 @@ export default { tableHeight() { return window.innerHeight - 300; }, + pppList() { + return Array.from(new Set(this.tableData.map((item) => item.ppp))); + }, }, mounted() { // 获取当前年份 2024 @@ -109,6 +144,68 @@ export default { this.queryDebounce = debounce(this.query, 100); }, methods: { + tableRowClassName({ row, rowIndex }) { + const classNames = ["default-row", "success-row", "error-row", "warning-row", "info-row"]; + const index = this.pppList.findIndex((item) => item === row.ppp); + if (index === -1) return "info-row"; + return index > classNames.length - 1 ? classNames[index % classNames.length] : classNames[index]; + }, + getChildCount(row, key, childKey) { + const childSet = new Set(); + for (let i = 0; i < this.tableData.length; i++) { + if (row[key] === this.tableData[i][key]) { + childSet.add(this.tableData[i][childKey]); + } + } + return childSet.size; + }, + calculateChildAvg(row, key) { + const childList = []; + for (let i = 0; i < this.tableData.length; i++) { + if (row[key] === this.tableData[i][key]) { + childList.push(this.tableData[i].avgValue); + } + } + // 计算平均值, 保留两位小数 + return (childList.reduce((a, b) => a + b, 0) / childList.length).toFixed( + 2 + ); + }, + objectSpanMethod({ row, column, rowIndex, columnIndex }) { + const calculateRowSpan = (key) => { + const value = row[key]; + let rowSpan = 1; + if (rowIndex === 0) { + while ( + this.tableData[rowIndex + rowSpan] && + this.tableData[rowIndex + rowSpan][key] === value + ) { + rowSpan++; + } + return { rowspan: rowSpan, colspan: 1 }; + } else { + if (this.tableData[rowIndex - 1][key] === value) { + return { rowspan: 0, colspan: 0 }; + } else { + while ( + this.tableData[rowIndex + rowSpan] && + this.tableData[rowIndex + rowSpan][key] === value + ) { + rowSpan++; + } + return { rowspan: rowSpan, colspan: 1 }; + } + } + }; + + if (columnIndex === 0) { + return calculateRowSpan("ppp"); + } else if (columnIndex === 1) { + return calculateRowSpan("pp"); + } else if (columnIndex === 2) { + return calculateRowSpan("p"); + } + }, handleYearChange() { this.queryDebounce(); }, @@ -130,16 +227,16 @@ export default { } this.loading = true; - getDeviceReportYearList({ + getDeviceReportYearListAll({ deptId: this.dept.deptId, year: this.year, - pageNum: this.pageNum, - pageSize: this.pageSize, + // pageNum: this.pageNum, + // pageSize: this.pageSize, }) .then((res) => { if (res.code === 200) { - this.tableData = res.rows; - this.total = res.total; + this.tableData = res.data; + // this.total = res.total; } }) .finally(() => { @@ -161,10 +258,11 @@ export default { dataToExcel({ data: [ [fileName], - ["归属港区", "归属企业", "设备编码", "年份", "平均值"], + ["归属港口", "归属港区", "归属企业", "设备编码", "年份", "平均值"], ...data.map((row) => [ - row.gangqu, - row.deptName, + row.ppp, + row.pp, + row.p, row.sn, row.year, row.avgValue,