1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
<template>
  <div class="dashboard">
    <el-row :gutter="20" class="stats-row">
      <el-col :span="6">
        <div class="stat-card">
          <div class="icon-container blue">
            <el-icon><Trophy /></el-icon>
          </div>
          <div class="stat-number">{{ stats.activeActivities }}</div>
          <div class="stat-title">当前比赛</div>
        </div>
      </el-col>
      <el-col :span="6">
        <div class="stat-card">
          <div class="icon-container green">
            <el-icon><UserFilled /></el-icon>
          </div>
          <div class="stat-number">{{ stats.totalPlayers }}</div>
          <div class="stat-title">参赛总人数</div>
        </div>
      </el-col>
      <el-col :span="6">
        <div class="stat-card">
          <div class="icon-container yellow">
            <el-icon><Clock /></el-icon>
          </div>
          <div class="stat-number">{{ stats.pendingReviews }}</div>
          <div class="stat-title">报名待审核</div>
        </div>
      </el-col>
      <el-col :span="6">
        <div class="stat-card">
          <div class="icon-container red">
            <el-icon><User /></el-icon>
          </div>
          <div class="stat-number">{{ stats.totalJudges }}</div>
          <div class="stat-title">评委总数</div>
        </div>
      </el-col>
    </el-row>
 
    <div class="table-card">
      <div class="table-header">
        <h3 class="table-title">最近比赛</h3>
        <el-button type="primary" @click="$router.push('/activity')">查看全部</el-button>
      </div>
      <el-table :data="recentActivities" class="recent-table">
        <el-table-column prop="name" label="比赛名称" width="180" />
        <el-table-column prop="playerCount" label="报名人数" width="120" />
        <el-table-column prop="startTime" label="开始时间" width="180" />
        <el-table-column prop="endTime" label="结束时间" width="180" />
        <el-table-column prop="status" label="状态" width="100">
          <template #default="{ row }">
            <span :class="getStatusClass(row.status)">{{ row.status }}</span>
          </template>
        </el-table-column>
        <el-table-column label="操作">
          <template #default="scope">
            <a class="action-link" @click="viewActivity(scope.row)">查看</a>
            <a class="action-link" @click="manageActivity(scope.row)">管理</a>
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>
 
<script setup lang="ts">
import { ref, onMounted } from 'vue'
import { useRouter } from 'vue-router'
import { ElMessage } from 'element-plus'
import { Trophy, UserFilled, Clock, User } from '@element-plus/icons-vue'
import { getDashboardStats } from '@/api/dashboard'
import { getActivities } from '@/api/activity'
 
const router = useRouter()
 
// 统计数据
const stats = ref({
  activeActivities: 0,
  totalPlayers: 0,
  pendingReviews: 0,
  totalJudges: 0
})
 
// 最近活动数据
const recentActivities = ref([])
 
// 加载统计数据
const loadStats = async () => {
  try {
    const data = await getDashboardStats()
    stats.value = data
  } catch (error) {
    console.error('加载统计数据失败:', error)
    ElMessage.error('加载统计数据失败')
  }
}
 
// 加载最近活动
const loadRecentActivities = async () => {
  try {
    const data = await getActivities(0, 5) // 获取前5条活动
    recentActivities.value = data.content.map(activity => ({
      id: activity.id,
      name: activity.name,
      playerCount: activity.playerCount || 0,
      startTime: activity.matchTime || activity.createTime,
      endTime: activity.endTime || '待定',
      status: activity.stateName || '未知'
    }))
  } catch (error) {
    console.error('加载最近活动失败:', error)
    ElMessage.error('加载最近活动失败')
  }
}
 
// 页面加载时获取数据
onMounted(() => {
  loadStats()
  loadRecentActivities()
})
 
// 查看比赛
const viewActivity = (activity: any) => {
  router.push(`/activity/${activity.id}`)
}
 
// 管理比赛
const manageActivity = (activity: any) => {
  router.push('/activity')
}
 
// 获取状态样式类
const getStatusClass = (status: string) => {
  const statusMap: Record<string, string> = {
    '已发布': 'status-published',
    '进行中': 'status-published',
    '未发布': 'status-unpublished',
    '报名中': 'status-unpublished',
    '关闭': 'status-closed',
    '已结束': 'status-closed',
    '待开始': 'status-unpublished'
  }
  return statusMap[status] || 'status-unpublished'
}
</script>
 
<style scoped>
/* 页面整体样式 */
.dashboard {
  padding: 24px;
  background-color: #FFFFFF;
  min-height: 100vh;
}
 
/* 统计卡片行 */
.stats-row {
  margin-bottom: 20px;
}
 
/* 统计卡片样式 */
.stat-card {
  background: #FFFFFF;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  border: none;
  padding: 24px;
  height: 120px;
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}
 
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}
 
/* 图标容器 */
.icon-container {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: 24px;
  left: 24px;
}
 
.icon-container.blue {
  background-color: #E0E7FF;
  color: #6366F1;
}
 
.icon-container.green {
  background-color: #D1FAE5;
  color: #10B981;
}
 
.icon-container.yellow {
  background-color: #FEF3C7;
  color: #F59E0B;
}
 
.icon-container.red {
  background-color: #FECACA;
  color: #EF4444;
}
 
/* 统计数字 */
.stat-number {
  font-size: 32px;
  font-weight: 700;
  color: #1F2937;
  position: absolute;
  top: 24px;
  right: 24px;
  line-height: 1;
}
 
/* 统计标题 */
.stat-title {
  font-size: 14px;
  font-weight: 500;
  color: #6B7280;
  position: absolute;
  bottom: 24px;
  left: 24px;
}
 
/* 表格卡片 */
.table-card {
  background: #FFFFFF;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  border: none;
  padding: 24px;
  margin-top: 20px;
}
 
/* 表格头部 */
.table-header {
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
 
.table-title {
  font-size: 18px;
  font-weight: 600;
  color: #1F2937;
  margin: 0;
}
 
/* 表格样式 */
.recent-table {
  width: 100%;
}
 
:deep(.el-table__header) {
  background-color: #F9FAFB;
}
 
:deep(.el-table__header th) {
  background-color: #F9FAFB !important;
  color: #374151;
  font-size: 14px;
  font-weight: 500;
  height: 48px;
  border-bottom: 1px solid #E5E7EB;
}
 
:deep(.el-table__row) {
  height: 56px;
}
 
:deep(.el-table__row:nth-child(even)) {
  background-color: #F9FAFB;
}
 
:deep(.el-table__row:nth-child(odd)) {
  background-color: #FFFFFF;
}
 
:deep(.el-table td) {
  color: #1F2937;
  font-size: 14px;
  font-weight: 400;
  border-bottom: 1px solid #F3F4F6;
}
 
/* 状态标签样式 */
.status-published {
  color: #67C23A;
  background-color: #F0F9FF;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
}
 
.status-unpublished {
  color: #E6A23C;
  background-color: #FDF6EC;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
}
 
.status-closed {
  color: #F56C6C;
  background-color: #FEF0F0;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
}
 
/* 操作链接样式 */
.action-link {
  color: #409EFF;
  cursor: pointer;
  font-size: 14px;
  margin: 0 8px;
  text-decoration: none;
}
 
.action-link:hover {
  color: #66B1FF;
  text-decoration: underline;
}
 
.action-link:first-child {
  margin-left: 0;
}
 
/* 响应式设计 */
@media (max-width: 768px) {
  .dashboard {
    padding: 16px;
  }
  
  .stat-card {
    margin-bottom: 16px;
  }
}
</style>