<template>
|
<div class="player-page">
|
<div class="page-card">
|
<h3 class="card-title">比赛报名</h3>
|
|
<!-- 搜索和操作栏 -->
|
<div class="toolbar">
|
<el-input
|
v-model="searchForm.name"
|
placeholder="请输入学员名称"
|
style="width: 200px"
|
clearable
|
@keyup.enter="handleSearch"
|
>
|
<template #prefix>
|
<el-icon><Search /></el-icon>
|
</template>
|
</el-input>
|
<el-select
|
v-model="searchForm.status"
|
placeholder="选择状态"
|
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-select>
|
<el-button type="primary" @click="handleSearch">
|
<el-icon><Search /></el-icon>
|
搜索
|
</el-button>
|
</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="status" label="状态" width="100" align="center">
|
<template #default="{ row }">
|
<el-tag :type="getStatusType(row.status)">{{ getStatusText(row.status) }}</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"
|
type="success"
|
size="small"
|
@click="handleApprove(row)"
|
>
|
审核通过
|
</el-button>
|
<el-button
|
v-if="row.status === 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>
|
|
<!-- 分页 -->
|
<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>
|
</div>
|
</template>
|
|
<script setup lang="ts">
|
import { reactive, ref, onMounted } from 'vue'
|
import { useRouter } from 'vue-router'
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
import { PlayerApi } from '@/api/player'
|
|
const loading = ref(false)
|
const router = useRouter()
|
|
// 搜索表单
|
const searchForm = reactive({
|
name: '',
|
status: ''
|
})
|
|
// 分页信息
|
const pagination = reactive({
|
page: 1,
|
size: 10,
|
total: 0
|
})
|
|
// 表格数据
|
const tableData = ref([
|
{
|
id: 1,
|
name: '张三',
|
avatar: '',
|
activityName: '2024年创新创业大赛',
|
phone: '13800138001',
|
applyTime: '2024-01-05 14:30:00',
|
status: 1 // 1-待审核, 2-进行中, 3-已结束
|
},
|
{
|
id: 2,
|
name: '李四',
|
avatar: '',
|
activityName: '技能竞赛初赛',
|
phone: '13800138002',
|
applyTime: '2024-01-06 09:15:00',
|
status: 2
|
},
|
{
|
id: 3,
|
name: '王五',
|
avatar: '',
|
activityName: '设计大赛决赛',
|
phone: '13800138003',
|
applyTime: '2024-01-07 16:45:00',
|
status: 1
|
}
|
])
|
|
// 获取状态标签类型
|
const getStatusType = (status: number | null | undefined) => {
|
const typeMap: Record<number, string> = {
|
0: 'warning', // 待审核
|
1: 'success', // 进行中
|
2: 'danger', // 未通过
|
3: 'info' // 已结束
|
}
|
return status != null ? (typeMap[status] || 'info') : 'info'
|
}
|
|
// 获取状态文本
|
const getStatusText = (status: number | null | undefined) => {
|
const textMap: Record<number, string> = {
|
0: '待审核',
|
1: '进行中',
|
2: '未通过',
|
3: '已结束'
|
}
|
return status != null ? (textMap[status] || '未知') : '未知'
|
}
|
|
// 搜索
|
const handleSearch = () => {
|
pagination.page = 1
|
loadData()
|
}
|
|
// 审核通过
|
const handleApprove = async (row: any) => {
|
try {
|
await ElMessageBox.confirm(`确定审核通过学员"${row.name}"的报名申请吗?`, '提示', {
|
confirmButtonText: '确定',
|
cancelButtonText: '取消',
|
type: 'success'
|
})
|
|
ElMessage.success('审核通过成功')
|
row.status = 2
|
} catch {
|
// 用户取消
|
}
|
}
|
|
// 审核拒绝
|
const handleReject = async (row: any) => {
|
try {
|
await ElMessageBox.confirm(`确定拒绝学员"${row.name}"的报名申请吗?`, '提示', {
|
confirmButtonText: '确定',
|
cancelButtonText: '取消',
|
type: 'warning'
|
})
|
|
ElMessage.success('审核拒绝成功')
|
// 这里可以设置为删除状态或其他状态
|
} catch {
|
// 用户取消
|
}
|
}
|
|
// 查看详情(跳转到评分页面)
|
const handleView = (row: any) => {
|
if (!row.id) {
|
ElMessage.error('无法获取报名记录ID')
|
return
|
}
|
router.push(`/activity-player/${row.id}/rating`)
|
}
|
|
// 分页大小改变
|
const handleSizeChange = (size: number) => {
|
pagination.size = size
|
loadData()
|
}
|
|
// 当前页改变
|
const handleCurrentChange = (page: number) => {
|
pagination.page = page
|
loadData()
|
}
|
|
// 加载数据
|
const loadData = async () => {
|
loading.value = true
|
try {
|
const list = await PlayerApi.getApplications(searchForm.name || '', pagination.page, pagination.size)
|
tableData.value = (list || []).map((item: any) => ({
|
id: item.id,
|
name: item.playerName,
|
avatar: '',
|
activityName: item.activityName,
|
phone: item.phone,
|
applyTime: item.applyTime,
|
status: item.state
|
}))
|
pagination.total = tableData.value.length
|
} catch (e: any) {
|
ElMessage.error(String(e?.message || e))
|
} finally {
|
loading.value = false
|
}
|
}
|
|
onMounted(() => {
|
loadData()
|
})
|
</script>
|
|
<style lang="scss" scoped>
|
.player-page {
|
.card-title {
|
margin-bottom: 20px;
|
color: #303133;
|
font-size: 16px;
|
font-weight: 500;
|
}
|
|
.toolbar {
|
display: flex;
|
gap: 12px;
|
margin-bottom: 20px;
|
align-items: center;
|
}
|
|
.table-actions {
|
display: flex;
|
gap: 8px;
|
flex-wrap: wrap;
|
}
|
|
.pagination {
|
margin-top: 20px;
|
display: flex;
|
justify-content: flex-end;
|
}
|
}
|
</style>
|