web/src/views/player/index.vue
@@ -1,114 +1,103 @@
<template>
  <div class="player-page">
    <div class="page-card">
      <h3 class="card-title">比赛报名</h3>
      <!-- 搜索和操作栏 -->
      <div class="toolbar">
    <!-- 页面标题区域 -->
    <div class="page-header">
      <div class="title-section">
        <h1 class="page-title">报名审核</h1>
        <p class="page-subtitle">管理参赛选手的报名申请,审核参赛资格和信息</p>
      </div>
    </div>
    <!-- 搜索工具栏 -->
    <div class="search-toolbar">
      <div class="search-form">
        <el-input
          v-model="searchForm.name"
          placeholder="请输入学员名称"
          style="width: 200px"
          style="width: 180px"
          clearable
          @keyup.enter="handleSearch"
        >
          <template #prefix>
            <el-icon><Search /></el-icon>
          </template>
        </el-input>
          @clear="handleClear"
        />
        <el-select
          v-model="searchForm.activityId"
          placeholder="选择比赛"
          style="width: 300px"
          style="width: 200px"
          clearable
          filterable
        >
          <el-option 
            v-for="activity in activityOptions" 
            :key="activity.id" 
            :label="getActivityDisplayName(activity)"
            :label="activity.name"
            :value="activity.id"
          >
            <span>{{ getActivityName(activity) }}</span>
            <span v-if="activity.pid > 0" style="color: #409eff; margin-left: 8px;">
              {{ activity.name }}
            </span>
            {{ activity.name }}
          </el-option>
        </el-select>
        <el-select
          v-model="searchForm.state"
          placeholder="选择状态"
          style="width: 150px"
          style="width: 120px"
          clearable
        >
          <el-option label="未审核" value="0" />
          <el-option label="进行中" value="1" />
          <el-option label="已驳回" value="2" />
          <el-option label="已结束" value="3" />
          <el-option label="待审核" value="0" />
          <el-option label="通过" value="1" />
          <el-option label="驳回" value="2" />
        </el-select>
        <el-button type="primary" @click="handleSearch">
          <el-icon><Search /></el-icon>
          搜索
          查询
        </el-button>
      </div>
    </div>
      <!-- 学员列表 -->
      <el-table :data="tableData" style="width: 100%" v-loading="loading">
        <el-table-column label="头像" width="80" align="center">
          <template #default="{ row }">
            <el-avatar :src="row.avatar" :size="40">
              <el-icon><User /></el-icon>
            </el-avatar>
          </template>
        </el-table-column>
        <el-table-column prop="name" label="学员名称" min-width="120" />
        <el-table-column prop="activityName" label="报名项目" min-width="200" />
        <el-table-column prop="phone" label="联系电话" width="140" />
        <el-table-column prop="applyTime" label="申请时间" width="180" />
        <el-table-column prop="state" label="状态" width="100" align="center">
          <template #default="{ row }">
            <el-tag :type="getStateType(row.state)">{{ getStateText(row.state) }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="操作" width="200" fixed="right">
          <template #default="{ row }">
            <div class="table-actions">
              <el-button
                v-if="row.state === 1"
                type="success"
                size="small"
                @click="handleApprove(row)"
              >
                审核通过
              </el-button>
              <el-button
                v-if="row.state === 1"
                type="danger"
                size="small"
                @click="handleReject(row)"
              >
                审核拒绝
              </el-button>
              <el-button type="primary" size="small" @click="handleView(row)">
                评分详情
              </el-button>
            </div>
          </template>
        </el-table-column>
      </el-table>
    <!-- 学员列表 -->
    <el-table :data="tableData" style="width: 100%" v-loading="loading">
      <el-table-column label="头像" width="80" align="center">
        <template #default="{ row }">
          <el-avatar :src="row.avatar" :size="40">
            <el-icon><User /></el-icon>
          </el-avatar>
        </template>
      </el-table-column>
      <el-table-column label="学员名称" min-width="120">
        <template #default="{ row }">
          {{ row.name }}
        </template>
      </el-table-column>
      <el-table-column prop="projectName" label="项目名称" min-width="150" />
      <el-table-column prop="activityName" label="比赛名称" min-width="200" />
      <el-table-column prop="phone" label="联系电话" width="140" />
      <el-table-column prop="applyTime" label="申请时间" width="180" />
      <el-table-column prop="state" label="状态" width="100" align="center">
        <template #default="{ row }">
          <el-tag :type="getStateType(row.state)">{{ getStateText(row.state) }}</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="操作" width="80" align="center">
        <template #default="{ row }">
          <el-button
            text
            :icon="View"
            @click="handleViewDetail(row)"
            class="action-btn view-btn"
            title="查看详情"
          />
        </template>
      </el-table-column>
    </el-table>
      <!-- 分页 -->
      <div class="pagination">
        <el-pagination
          v-model:current-page="pagination.page"
          v-model:page-size="pagination.size"
          :page-sizes="[10, 20, 50, 100]"
          :total="pagination.total"
          layout="total, sizes, prev, pager, next, jumper"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
        />
      </div>
    <!-- 分页 -->
    <div class="pagination">
      <el-pagination
        v-model:current-page="pagination.page"
        v-model:page-size="pagination.size"
        :page-sizes="[10, 20, 50, 100]"
        :total="pagination.total"
        layout="total, sizes, prev, pager, next, jumper"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      />
    </div>
  </div>
</template>
@@ -117,6 +106,7 @@
import { reactive, ref, onMounted } from 'vue'
import { useRouter } from 'vue-router'
import { ElMessage, ElMessageBox } from 'element-plus'
import { Search, User, View } from '@element-plus/icons-vue'
import { PlayerApi } from '@/api/player'
import { getAllActivities } from '@/api/activity'
@@ -141,42 +131,14 @@
})
// 表格数据
const tableData = ref([
  {
    id: 1,
    name: '张三',
    avatar: '',
    activityName: '2024年创新创业大赛',
    phone: '13800138001',
    applyTime: '2024-01-05 14:30:00',
    state: 1 // 1-待审核, 2-进行中, 3-已结束
  },
  {
    id: 2,
    name: '李四',
    avatar: '',
    activityName: '书法比赛',
    phone: '13900139002',
    applyTime: '2024-01-16 10:30:00',
    state: 2
  },
  {
    id: 3,
    name: '王五',
    avatar: '',
    activityName: '绘画比赛',
    phone: '13900139003',
    applyTime: '2024-01-17 14:20:00',
    state: 1
  }
])
const tableData = ref([])
// 获取状态标签类型
const getStateType = (state: number | null | undefined) => {
  const typeMap: Record<number, string> = {
    0: 'warning',   // 待审核
    1: 'success',   // 进行中
    2: 'danger',    // 未通过
    0: 'warning',   // 未审核
    1: 'success',   // 审核通过
    2: 'danger',    // 审核驳回
    3: 'info'       // 已结束
  }
  return state != null ? (typeMap[state] || 'info') : 'info'
@@ -185,9 +147,9 @@
// 获取状态文本
const getStateText = (state: number | null | undefined) => {
  const textMap: Record<number, string> = {
    0: '待审核',
    1: '进行中',
    2: '未通过',
    0: '未审核',
    1: '审核通过',
    2: '审核驳回',
    3: '已结束'
  }
  return state != null ? (textMap[state] || '未知') : '未知'
@@ -199,35 +161,20 @@
  loadData()
}
// 审核通过
const handleApprove = async (row: any) => {
  try {
    await ElMessageBox.confirm(`确定审核通过学员"${row.name}"的报名申请吗?`, '提示', {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'success'
    })
    ElMessage.success('审核通过成功')
    row.state = 2
  } catch {
    // 用户取消
  }
const handleClear = () => {
  searchForm.name = ''
  pagination.page = 1
  loadData()
}
// 审核拒绝
const handleReject = (row: any) => {
  ElMessageBox.confirm('确认拒绝该申请?', '提示', {
    confirmButtonText: '确定',
    cancelButtonText: '取消',
    type: 'warning'
  }).then(() => {
    // 这里应该调用API更新状态
    row.state = 3 // 更新为已结束
    ElMessage.success('已拒绝')
  }).catch(() => {
    ElMessage.info('已取消')
  })
// 查看详情(跳转到详情页面,只读模式)
const handleViewDetail = (row: any) => {
  if (!row.id) {
    ElMessage.error('无法获取报名记录ID')
    return
  }
  // 跳转到详情页面(只读模式)
  router.push(`/player/${row.id}/detail`)
}
// 查看详情(跳转到评分页面)
@@ -259,45 +206,49 @@
  return activity.name
}
// 获取活动显示名称(用于搜索和选中时显示)
const getActivityDisplayName = (activity: any) => {
  if (activity.pid > 0 && activity.parent) {
    return `${activity.parent.name} - ${activity.name}`
  }
  return activity.name
}
// 加载活动选项
const loadActivityOptions = async () => {
  try {
    const activities = await getAllActivities()
    // 只显示状态为1(进行中)的比赛及其阶段
    activityOptions.value = (activities || []).filter(activity => activity.state === 1)
  } catch (e: any) {
    console.error('加载活动选项失败:', e)
    if (activities && Array.isArray(activities)) {
      // 过滤出正在进行的比赛(不是阶段)
      const filtered = activities.filter(activity =>
        activity.state === 1 && (activity.pid === 0 || activity.pid === "0")
      )
      activityOptions.value = filtered
    }
  } catch (error) {
    ElMessage.error('加载活动选项失败')
  }
}
// 加载数据
const loadData = async () => {
  loading.value = true
  try {
    const list = await PlayerApi.getApplications(
    const response = await PlayerApi.getApplications(
      searchForm.name || '', 
      searchForm.activityId || null, 
      searchForm.state !== '' ? parseInt(searchForm.state) : null,
      pagination.page, 
      pagination.size
    )
    tableData.value = (list || []).map((item: any) => ({
    const list = response.content || []
    tableData.value = list.map((item: any) => ({
      id: item.id,
      name: item.playerName,
      projectName: item.projectName,
      avatar: '',
      activityName: item.activityName,
      phone: item.phone,
      applyTime: item.applyTime,
      state: item.state
    }))
    pagination.total = tableData.value.length
    pagination.total = response.totalElements || 0
  } catch (e: any) {
    ElMessage.error(String(e?.message || e))
  } finally {
@@ -313,30 +264,95 @@
<style lang="scss" scoped>
.player-page {
  .card-title {
    margin-bottom: 20px;
    color: #303133;
    font-size: 16px;
    font-weight: 500;
  }
  .toolbar {
    display: flex;
  padding: 20px;
}
/* 页面标题区域 */
.page-header {
  margin-bottom: 24px;
}
.title-section {
  text-align: left;
}
.page-title {
  font-size: 24px;
  font-weight: 600;
  color: #1f2937;
  margin: 0 0 8px 0;
}
.page-subtitle {
  font-size: 14px;
  color: #6b7280;
  margin: 0;
  line-height: 1.5;
}
/* 搜索工具栏 */
.search-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 20px;
}
.search-form {
  display: flex;
  gap: 12px;
  align-items: center;
}
.search-area {
  display: flex;
  align-items: center;
  gap: 12px;
}
.action-area {
  display: flex;
  align-items: center;
  gap: 12px;
}
/* 操作按钮样式 */
.action-btn {
  padding: 8px !important;
  margin: 0 6px;
  border-radius: 6px;
  transition: all 0.2s ease;
}
.view-btn {
  color: #3b82f6 !important;
}
.view-btn:hover {
  background-color: rgba(59, 130, 246, 0.1) !important;
  transform: scale(1.2);
}
.pagination {
  margin-top: 20px;
  display: flex;
  justify-content: center;
}
/* 响应式适配 */
@media (max-width: 768px) {
  .search-toolbar {
    flex-direction: column;
    gap: 12px;
    margin-bottom: 20px;
    align-items: center;
    align-items: stretch;
  }
  
  .table-actions {
    display: flex;
    gap: 8px;
  .search-area {
    justify-content: center;
    flex-wrap: wrap;
  }
  
  .pagination {
    margin-top: 20px;
    display: flex;
    justify-content: flex-end;
  .action-area {
    justify-content: center;
  }
}
</style>