From b5b16a26de0d84d7b5fb69b584377bdc3582e3ab Mon Sep 17 00:00:00 2001 From: wlzboy <66905212@qq.com> Date: 星期日, 21 九月 2025 20:43:08 +0800 Subject: [PATCH] feat: 更新评价功能 --- ruoyi-ui/src/views/evaluation/statistics/index.vue | 89 +++++++++++++++++++++++++++++++++----------- 1 files changed, 67 insertions(+), 22 deletions(-) diff --git a/ruoyi-ui/src/views/evaluation/statistics/index.vue b/ruoyi-ui/src/views/evaluation/statistics/index.vue index 68b46d4..29820c5 100644 --- a/ruoyi-ui/src/views/evaluation/statistics/index.vue +++ b/ruoyi-ui/src/views/evaluation/statistics/index.vue @@ -185,7 +185,7 @@ </template> <script> -import { listCustomerEvaluation, getCustomerEvaluation } from "@/api/evaluation"; +import { listCustomerEvaluation, getCustomerEvaluation, getEvaluationStatistics } from "@/api/evaluation"; import * as echarts from 'echarts'; export default { @@ -227,7 +227,11 @@ averageScore: 0, goodRate: 0, vehicleCount: 0 - } + }, + // 鍥捐〃瀹炰緥 + scoreChart: null, + trendChart: null, + dimensionChart: null }; }, created() { @@ -251,13 +255,26 @@ }, /** 鑾峰彇缁熻鏁版嵁 */ getStatistics() { - // 杩欓噷搴旇璋冪敤缁熻鎺ュ彛锛屾殏鏃朵娇鐢ㄦā鎷熸暟鎹� - this.statisticsData = { - totalEvaluations: 156, - averageScore: 4.2, - goodRate: 85.6, - vehicleCount: 23 - }; + getEvaluationStatistics(this.addDateRange(this.queryParams, this.dateRange)).then(response => { + const data = response.data; + this.statisticsData = { + totalEvaluations: data.totalEvaluations || 0, + averageScore: data.averageScore || 0, + goodRate: data.goodRate || 0, + vehicleCount: data.vehicleCount || 0 + }; + + // 鏇存柊鍥捐〃鏁版嵁 + this.updateCharts(data); + }).catch(() => { + // 濡傛灉鎺ュ彛璋冪敤澶辫触锛屼娇鐢ㄩ粯璁ゆ暟鎹� + this.statisticsData = { + totalEvaluations: 0, + averageScore: 0, + goodRate: 0, + vehicleCount: 0 + }; + }); }, /** 鍒濆鍖栧浘琛� */ initCharts() { @@ -265,9 +282,22 @@ this.initTrendChart(); this.initDimensionChart(); }, + /** 鏇存柊鍥捐〃鏁版嵁 */ + updateCharts(data) { + this.updateScoreChart(data.scoreDistribution); + this.updateTrendChart(data.monthlyTrend); + this.updateDimensionChart(data.dimensionScores); + }, /** 鍒濆鍖栬瘎鍒嗗垎甯冨浘琛� */ initScoreChart() { - const chart = echarts.init(this.$refs.scoreChart); + this.scoreChart = echarts.init(this.$refs.scoreChart); + this.updateScoreChart([0, 0, 0, 0, 0]); + }, + /** 鏇存柊璇勫垎鍒嗗竷鍥捐〃 */ + updateScoreChart(scoreDistribution) { + if (!this.scoreChart) { + this.scoreChart = echarts.init(this.$refs.scoreChart); + } const option = { title: { text: '璇勫垎鍒嗗竷', @@ -282,11 +312,11 @@ type: 'pie', radius: '50%', data: [ - { value: 35, name: '5鏄�' }, - { value: 28, name: '4鏄�' }, - { value: 20, name: '3鏄�' }, - { value: 12, name: '2鏄�' }, - { value: 5, name: '1鏄�' } + { value: scoreDistribution[4] || 0, name: '5鏄�' }, + { value: scoreDistribution[3] || 0, name: '4鏄�' }, + { value: scoreDistribution[2] || 0, name: '3鏄�' }, + { value: scoreDistribution[1] || 0, name: '2鏄�' }, + { value: scoreDistribution[0] || 0, name: '1鏄�' } ], emphasis: { itemStyle: { @@ -298,11 +328,18 @@ } ] }; - chart.setOption(option); + this.scoreChart.setOption(option); }, /** 鍒濆鍖栬秼鍔垮浘琛� */ initTrendChart() { - const chart = echarts.init(this.$refs.trendChart); + this.trendChart = echarts.init(this.$refs.trendChart); + this.updateTrendChart([0, 0, 0, 0, 0, 0]); + }, + /** 鏇存柊瓒嬪娍鍥捐〃 */ + updateTrendChart(monthlyTrend) { + if (!this.trendChart) { + this.trendChart = echarts.init(this.$refs.trendChart); + } const option = { title: { text: '鏈堝害璇勪环瓒嬪娍', @@ -322,16 +359,23 @@ { name: '璇勪环鏁伴噺', type: 'line', - data: [12, 19, 23, 18, 25, 28], + data: monthlyTrend || [0, 0, 0, 0, 0, 0], smooth: true } ] }; - chart.setOption(option); + this.trendChart.setOption(option); }, /** 鍒濆鍖栫淮搴︾粺璁″浘琛� */ initDimensionChart() { - const chart = echarts.init(this.$refs.dimensionChart); + this.dimensionChart = echarts.init(this.$refs.dimensionChart); + this.updateDimensionChart([0, 0, 0, 0, 0]); + }, + /** 鏇存柊缁村害缁熻鍥捐〃 */ + updateDimensionChart(dimensionScores) { + if (!this.dimensionChart) { + this.dimensionChart = echarts.init(this.$refs.dimensionChart); + } const option = { title: { text: '鍚勭淮搴﹁瘎鍒嗙粺璁�', @@ -355,14 +399,14 @@ { name: '骞冲潎璇勫垎', type: 'bar', - data: [4.5, 4.2, 4.3, 4.4, 4.1], + data: dimensionScores || [0, 0, 0, 0, 0], itemStyle: { color: '#409EFF' } } ] }; - chart.setOption(option); + this.dimensionChart.setOption(option); }, // 鍙栨秷鎸夐挳 cancel() { @@ -390,6 +434,7 @@ handleQuery() { this.queryParams.pageNum = 1; this.getList(); + this.getStatistics(); }, /** 閲嶇疆鎸夐挳鎿嶄綔 */ resetQuery() { -- Gitblit v1.9.1