lrj
4 天以前 4fa9591629721797386fc11836e3a9deb69cd58c
web/src/views/player/index.vue
@@ -17,7 +17,26 @@
          </template>
        </el-input>
        <el-select
          v-model="searchForm.status"
          v-model="searchForm.activityId"
          placeholder="选择比赛"
          style="width: 300px"
          clearable
          filterable
        >
          <el-option
            v-for="activity in activityOptions"
            :key="activity.id"
            :label="getActivityDisplayName(activity)"
            :value="activity.id"
          >
            <span>{{ getCompetitionName(activity) }}</span>
            <span v-if="activity.pid > 0" style="color: #409eff; margin-left: 8px;">
              {{ activity.name }}
            </span>
          </el-option>
        </el-select>
        <el-select
          v-model="searchForm.state"
          placeholder="选择状态"
          style="width: 150px"
          clearable
@@ -46,16 +65,16 @@
        <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="status" label="状态" width="100" align="center">
        <el-table-column prop="state" label="状态" width="100" align="center">
          <template #default="{ row }">
            <el-tag :type="getStatusType(row.status)">{{ getStatusText(row.status) }}</el-tag>
            <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.status === 1"
                v-if="row.state === 1"
                type="success" 
                size="small" 
                @click="handleApprove(row)"
@@ -63,7 +82,7 @@
                审核通过
              </el-button>
              <el-button 
                v-if="row.status === 1"
                v-if="row.state === 1"
                type="danger" 
                size="small" 
                @click="handleReject(row)"
@@ -99,14 +118,19 @@
import { useRouter } from 'vue-router'
import { ElMessage, ElMessageBox } from 'element-plus'
import { PlayerApi } from '@/api/player'
import { getAllActivities } from '@/api/activity'
const loading = ref(false)
const router = useRouter()
// 活动选项
const activityOptions = ref([])
// 搜索表单
const searchForm = reactive({
  name: '',
  status: ''
  activityId: '',
  state: ''
})
// 分页信息
@@ -125,48 +149,48 @@
    activityName: '2024年创新创业大赛',
    phone: '13800138001',
    applyTime: '2024-01-05 14:30:00',
    status: 1 // 1-待审核, 2-进行中, 3-已结束
    state: 1 // 1-待审核, 2-进行中, 3-已结束
  },
  {
    id: 2,
    name: '李四',
    avatar: '',
    activityName: '技能竞赛初赛',
    phone: '13800138002',
    applyTime: '2024-01-06 09:15:00',
    status: 2
    activityName: '书法比赛',
    phone: '13900139002',
    applyTime: '2024-01-16 10:30:00',
    state: 2
  },
  {
    id: 3,
    name: '王五',
    avatar: '',
    activityName: '设计大赛决赛',
    phone: '13800138003',
    applyTime: '2024-01-07 16:45:00',
    status: 1
    activityName: '绘画比赛',
    phone: '13900139003',
    applyTime: '2024-01-17 14:20:00',
    state: 1
  }
])
// 获取状态标签类型
const getStatusType = (status: number | null | undefined) => {
const getStateType = (state: number | null | undefined) => {
  const typeMap: Record<number, string> = {
    0: 'warning',   // 待审核
    1: 'success',   // 进行中
    2: 'danger',    // 未通过
    3: 'info'       // 已结束
  }
  return status != null ? (typeMap[status] || 'info') : 'info'
  return state != null ? (typeMap[state] || 'info') : 'info'
}
// 获取状态文本
const getStatusText = (status: number | null | undefined) => {
const getStateText = (state: number | null | undefined) => {
  const textMap: Record<number, string> = {
    0: '待审核',
    1: '进行中',
    2: '未通过',
    3: '已结束'
  }
  return status != null ? (textMap[status] || '未知') : '未知'
  return state != null ? (textMap[state] || '未知') : '未知'
}
// 搜索
@@ -185,26 +209,25 @@
    })
    
    ElMessage.success('审核通过成功')
    row.status = 2
    row.state = 2
  } catch {
    // 用户取消
  }
}
// 审核拒绝
const handleReject = async (row: any) => {
  try {
    await ElMessageBox.confirm(`确定拒绝学员"${row.name}"的报名申请吗?`, '提示', {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
      type: 'warning'
    })
    ElMessage.success('审核拒绝成功')
    // 这里可以设置为删除状态或其他状态
  } catch {
    // 用户取消
  }
const handleReject = (row: any) => {
  ElMessageBox.confirm('确认拒绝该申请?', '提示', {
    confirmButtonText: '确定',
    cancelButtonText: '取消',
    type: 'warning'
  }).then(() => {
    // 这里应该调用API更新状态
    row.state = 3 // 更新为已结束
    ElMessage.success('已拒绝')
  }).catch(() => {
    ElMessage.info('已取消')
  })
}
// 查看详情(跳转到评分页面)
@@ -228,11 +251,43 @@
  loadData()
}
// 获取比赛名称(如果是阶段,返回父比赛名称;如果是比赛,返回自己的名称)
const getCompetitionName = (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 {
    const activities = await getAllActivities()
    // 只显示状态为1(进行中)的比赛及其阶段
    activityOptions.value = (activities || []).filter(activity => activity.state === 1)
  } catch (e: any) {
    console.error('加载活动选项失败:', e)
  }
}
// 加载数据
const loadData = async () => {
  loading.value = true
  try {
    const list = await PlayerApi.getApplications(searchForm.name || '', pagination.page, pagination.size)
    const list = await PlayerApi.getApplications(
      searchForm.name || '',
      searchForm.activityId || null,
      pagination.page,
      pagination.size
    )
    tableData.value = (list || []).map((item: any) => ({
      id: item.id,
      name: item.playerName,
@@ -240,7 +295,7 @@
      activityName: item.activityName,
      phone: item.phone,
      applyTime: item.applyTime,
      status: item.state
      state: item.state
    }))
    pagination.total = tableData.value.length
  } catch (e: any) {
@@ -251,6 +306,7 @@
}
onMounted(() => {
  loadActivityOptions()
  loadData()
})
</script>