diff --git a/ruoyi-ui/src/views/dataStatistics/comparison/index.vue b/ruoyi-ui/src/views/dataStatistics/comparison/index.vue index 1c21d19..ae7b684 100644 --- a/ruoyi-ui/src/views/dataStatistics/comparison/index.vue +++ b/ruoyi-ui/src/views/dataStatistics/comparison/index.vue @@ -102,7 +102,23 @@ export default { return; } const { data } = res; - this.chartData.series.data = Object.keys(data).map((key) => { + // 按照 month 正确排序 + function sortDataByMonth(data) { + // 遍历对象的每个键 + for (const key in data) { + if (data.hasOwnProperty(key)) { + // 对每个键对应的数组进行排序 + data[key].sort((a, b) => { + // 比较 month 属性 + return new Date(a.month) - new Date(b.month); + }); + } + } + return data; + } + const sortedData = sortDataByMonth(data); + + this.chartData.series.data = Object.keys(sortedData).map((key) => { return { name: this.deptList.find((item) => item.deptId === parseInt(key))?.deptName, type: "line", diff --git a/ruoyi-ui/src/views/dataStatistics/daily/index.vue b/ruoyi-ui/src/views/dataStatistics/daily/index.vue index c9e6d57..930e1cd 100644 --- a/ruoyi-ui/src/views/dataStatistics/daily/index.vue +++ b/ruoyi-ui/src/views/dataStatistics/daily/index.vue @@ -14,24 +14,32 @@
- 导出 + 导出
@@ -40,8 +48,10 @@ @@ -50,8 +60,10 @@ @@ -84,7 +96,18 @@ export default { this.day = moment().format("YYYY-MM-DD"); this.queryData(); }, + computed: { + pppList() { + return Array.from(new Set(this.tableData.map((item) => item.ppp))); + }, + }, 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]; + }, changeDate() { this.queryData(); }, @@ -94,7 +117,7 @@ export default { this.tableData = res.data.map((item) => { return { ...item, - avgDs: parseFloat(item.avgDs.toFixed(2)) + avgDs: parseFloat(item.avgDs.toFixed(2)), }; }); } @@ -152,7 +175,9 @@ export default { } } // 计算平均值, 保留两位小数 - return (childList.reduce((a, b) => a + b, 0) / childList.length).toFixed(2); + return (childList.reduce((a, b) => a + b, 0) / childList.length).toFixed( + 2 + ); }, handleExport() { exportExcel("#dailyTable", `${this.day}-数据统计`); @@ -161,6 +186,27 @@ export default { }; +