lrj
22 小时以前 dc643ba44fd2a426263015491268a0f0d6b4671d
web/src/views/player/index.vue
@@ -1,7 +1,7 @@
<template>
  <div class="player-page">
    <div class="page-card">
      <h3 class="card-title">比赛报名</h3>
      <h3 class="card-title">报名审核</h3>
      
      <!-- 搜索和操作栏 -->
      <div class="toolbar">
@@ -26,13 +26,10 @@
          <el-option 
            v-for="activity in activityOptions" 
            :key="activity.id" 
            :label="getActivityDisplayName(activity)"
            :label="activity.name"
            :value="activity.id"
          >
            <span>{{ getCompetitionName(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
@@ -41,15 +38,20 @@
          style="width: 150px"
          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>
        <el-button type="warning" @click="debugAPI">
          调试API
        </el-button>
        <span style="margin-left: 10px; color: #666; font-size: 12px;">
          活动选项数量: {{ activityOptions.length }}
        </span>
      </div>
      <!-- 学员列表 -->
@@ -70,27 +72,12 @@
            <el-tag :type="getStateType(row.state)">{{ getStateText(row.state) }}</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="操作" width="200" fixed="right">
        <el-table-column label="操作" width="120" 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 type="primary" size="small" @click="handleViewDetail(row)">
                详情
              </el-button>
            </div>
          </template>
@@ -149,7 +136,7 @@
    activityName: '2024年创新创业大赛',
    phone: '13800138001',
    applyTime: '2024-01-05 14:30:00',
    state: 1 // 1-待审核, 2-进行中, 3-已结束
    state: 0 // 0-未审核
  },
  {
    id: 2,
@@ -158,7 +145,7 @@
    activityName: '书法比赛',
    phone: '13900139002',
    applyTime: '2024-01-16 10:30:00',
    state: 2
    state: 1 // 1-审核通过
  },
  {
    id: 3,
@@ -167,16 +154,25 @@
    activityName: '绘画比赛',
    phone: '13900139003',
    applyTime: '2024-01-17 14:20:00',
    state: 1
    state: 2 // 2-审核驳回
  },
  {
    id: 4,
    name: '赵六',
    avatar: '',
    activityName: '音乐比赛',
    phone: '13900139004',
    applyTime: '2024-01-18 09:15:00',
    state: 0 // 0-未审核
  }
])
// 获取状态标签类型
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 +181,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 +195,16 @@
  loadData()
}
// 审核通过
const handleApprove = async (row: any) => {
  try {
    await ElMessageBox.confirm(`确定审核通过学员"${row.name}"的报名申请吗?`, '提示', {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'success'
    })
    ElMessage.success('审核通过成功')
    row.state = 2
  } catch {
    // 用户取消
  }
}
// 审核拒绝
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`)
}
// 查看详情(跳转到评分页面)
@@ -252,29 +229,93 @@
}
// 获取比赛名称(如果是阶段,返回父比赛名称;如果是比赛,返回自己的名称)
const getCompetitionName = (activity: any) => {
const getActivityName = (activity: any) => {
  if (activity.pid > 0 && activity.parent) {
    return activity.parent.name
  }
  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 {
    console.log('=== 开始加载活动选项 ===')
    console.log('调用getAllActivities API...')
    const activities = await getAllActivities()
    // 只显示状态为1(进行中)的比赛及其阶段
    activityOptions.value = (activities || []).filter(activity => activity.state === 1)
  } catch (e: any) {
    console.error('加载活动选项失败:', e)
    console.log('API返回的原始数据:', activities)
    console.log('数据类型:', typeof activities)
    console.log('是否为数组:', Array.isArray(activities))
    if (activities && Array.isArray(activities)) {
      console.log('活动数量:', activities.length)
      activities.forEach((activity, index) => {
        console.log(`活动${index + 1}:`, {
          id: activity.id,
          name: activity.name,
          state: activity.state,
          pid: activity.pid
        })
      })
      // 过滤出正在进行的比赛(不是阶段)
      const filtered = activities.filter(activity =>
        activity.state === 1 && (activity.pid === 0 || activity.pid === "0")
      )
      console.log('过滤条件: state === 1 && (pid === 0 || pid === "0")')
      console.log('过滤后的活动:', filtered)
      activityOptions.value = filtered
      console.log('设置到activityOptions.value:', activityOptions.value)
      console.log('activityOptions.value.length:', activityOptions.value.length)
      // 强制触发响应式更新
      setTimeout(() => {
        console.log('延迟检查activityOptions.value:', activityOptions.value)
        console.log('延迟检查activityOptions.value.length:', activityOptions.value.length)
      }, 100)
    } else {
      console.error('API返回的数据格式不正确:', activities)
    }
  } catch (error) {
    console.error('=== 加载活动选项失败 ===')
    console.error('错误详情:', error)
    console.error('错误消息:', error.message)
    console.error('错误堆栈:', error.stack)
    ElMessage.error('加载活动选项失败: ' + error.message)
  }
}
// 调试API函数
const debugAPI = async () => {
  console.log('=== 开始API调试 ===')
  // 检查认证状态
  const token = localStorage.getItem('auth_token')
  const userInfo = localStorage.getItem('user_info')
  console.log('认证状态检查:')
  console.log('Token:', token ? '已存在' : '不存在')
  console.log('Token内容:', token)
  console.log('用户信息:', userInfo ? '已存在' : '不存在')
  console.log('用户信息内容:', userInfo)
  if (!token) {
    ElMessage.error('未找到认证token,请先登录')
    return
  }
  // 测试API调用
  try {
    console.log('开始测试getAllActivities API...')
    const activities = await getAllActivities()
    console.log('API调用成功,返回数据:', activities)
    ElMessage.success(`API调用成功,获取到${activities?.length || 0}个活动`)
  } catch (error) {
    console.error('API调用失败:', error)
    ElMessage.error('API调用失败: ' + error.message)
  }
}
@@ -285,6 +326,7 @@
    const list = await PlayerApi.getApplications(
      searchForm.name || '', 
      searchForm.activityId || null, 
      searchForm.state !== '' ? parseInt(searchForm.state) : null,
      pagination.page, 
      pagination.size
    )
@@ -306,8 +348,17 @@
}
onMounted(() => {
  loadActivityOptions()
  loadData()
  console.log('=== Player页面onMounted被调用 ===')
  console.log('当前时间:', new Date().toLocaleTimeString())
  console.log('activityOptions初始值:', activityOptions.value)
  console.log('直接加载活动选项进行测试...')
  // 立即调用API测试
  loadActivityOptions().catch(error => {
    console.error('loadActivityOptions调用失败:', error)
  })
  // loadData() // 暂时注释掉,专注于活动选项加载
})
</script>
@@ -331,8 +382,11 @@
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
  }
  
  .pagination {
    margin-top: 20px;
    display: flex;