From f17c76ce685522441bb5c04fe25bb54838b2eb06 Mon Sep 17 00:00:00 2001
From: zzw <228544128@qq.com>
Date: 星期五, 02 十月 2026 18:45:15 +0800
Subject: [PATCH] fix: load only active report data

---
 emergency-repair-web/src/views/report/ReportPage.vue |   27 +++++++++++++++++++--------
 1 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/emergency-repair-web/src/views/report/ReportPage.vue b/emergency-repair-web/src/views/report/ReportPage.vue
index 1baad25..4f1e476 100644
--- a/emergency-repair-web/src/views/report/ReportPage.vue
+++ b/emergency-repair-web/src/views/report/ReportPage.vue
@@ -42,7 +42,7 @@
     type: { type: String, required: true }
   },
   data() {
-    return { stats: {}, rows: [], chart: null }
+    return { stats: {}, rows: [], chart: null, loadSeq: 0 }
   },
   computed: {
     title() {
@@ -107,14 +107,25 @@
   },
   methods: {
     load() {
-      const requests = {
-        overview: api.get('/reports/overview').then(res => { this.stats = res.data || {}; this.rows = this.stats.chart || [] }),
-        'top-equipment': api.get('/reports/top-equipment').then(res => { this.rows = res.data || []; this.stats = {} }),
-        'by-team': api.get('/reports/by-team').then(res => { this.rows = res.data || []; this.stats = {} }),
-        contractors: api.get('/reports/contractors').then(res => { this.rows = res.data || []; this.stats = {} }),
-        trend: api.get('/reports/yearly-trend').then(res => { this.rows = res.data || []; this.stats = {} })
+      const loaders = {
+        overview: () => api.get('/reports/overview').then(res => ({
+          stats: res.data || {},
+          rows: (res.data && res.data.chart) || []
+        })),
+        'top-equipment': () => api.get('/reports/top-equipment').then(res => ({ stats: {}, rows: res.data || [] })),
+        'by-team': () => api.get('/reports/by-team').then(res => ({ stats: {}, rows: res.data || [] })),
+        contractors: () => api.get('/reports/contractors').then(res => ({ stats: {}, rows: res.data || [] })),
+        trend: () => api.get('/reports/yearly-trend').then(res => ({ stats: {}, rows: res.data || [] }))
       }
-      ;(requests[this.type] || Promise.resolve()).then(() => this.$nextTick(this.renderChart))
+      const seq = ++this.loadSeq
+      const loader = loaders[this.type]
+      const request = loader ? loader() : Promise.resolve({ stats: {}, rows: [] })
+      request.then(result => {
+        if (seq !== this.loadSeq) return
+        this.stats = result.stats
+        this.rows = result.rows
+        this.$nextTick(this.renderChart)
+      }).catch(() => {})
     },
     renderChart() {
       if (!this.$refs.chart) return

--
Gitblit v1.9.1