| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- <template>
- <div>
- <div class="filter-bar">
- <el-select v-model="statusFilter" placeholder="审核状态" @change="loadData">
- <el-option label="全部" value="" />
- <el-option label="待审核" value="pending" />
- <el-option label="已通过" value="approved" />
- <el-option label="已拒绝" value="rejected" />
- </el-select>
- <el-button size="small" @click="loadData" :loading="loading">刷新</el-button>
- </div>
- <el-table :data="list" v-loading="loading" border stripe style="min-width:900px;" :max-height="tableHeight">
- <el-table-column prop="id" label="ID" width="60" />
- <el-table-column label="用户" width="120">
- <template slot-scope="{ row }">{{ row.nickname || row.userName || '-' }}</template>
- </el-table-column>
- <el-table-column label="活动" min-width="180" show-overflow-tooltip>
- <template slot-scope="{ row }">{{ row.activityTitle || row.activityName || '-' }}</template>
- </el-table-column>
- <el-table-column label="审核状态" width="100">
- <template slot-scope="{ row }">
- <el-tag :type="statusType(row.status)">{{ statusLabel(row.status) }}</el-tag>
- </template>
- </el-table-column>
- <el-table-column label="操作" width="180" fixed="right">
- <template slot-scope="{ row }">
- <template v-if="row.status === 'pending'">
- <el-button size="mini" type="success" @click="handleApprove(row)">通过</el-button>
- <el-button size="mini" type="danger" @click="handleReject(row)">拒绝</el-button>
- </template>
- <span v-else class="no-op">—</span>
- </template>
- </el-table-column>
- </el-table>
- </div>
- </template>
- <script>
- import { getActivityList } from '@/api/activity'
- import { approveRegistration, rejectRegistration } from '@/api/activity'
- export default {
- name: 'ActivityRegistrationAudit',
- computed: {
- tableHeight() {
- return window.innerHeight - 300
- }
- },
- data() {
- return {
- list: [], loading: false, statusFilter: 'pending'
- }
- },
- mounted() { this.loadData() },
- methods: {
- statusType(s) { return { pending: 'warning', approved: 'success', rejected: 'danger' }[s] || 'info' },
- statusLabel(s) { return { pending: '待审核', approved: '已通过', rejected: '已拒绝' }[s] || s },
- async loadData() {
- this.loading = true
- try {
- const res = await getActivityList({ withRegistrations: true, page: 1, size: 50 })
- var regs = []
- var activities = res.data && res.data.records || res.data && res.data.list || res.data || []
- for (var i = 0; i < activities.length; i++) {
- var a = activities[i]
- if (a.registrations) {
- for (var j = 0; j < a.registrations.length; j++) {
- var r = a.registrations[j]
- r.activityTitle = a.title
- regs.push(r)
- }
- }
- }
- this.list = this.statusFilter ? regs.filter(function(r) { return r.status === this.statusFilter }.bind(this)) : regs
- } catch (e) { this.$message.error('加载失败')
- } finally { this.loading = false }
- },
- async handleApprove(row) {
- try {
- await approveRegistration({ id: row.id })
- this.$message.success('已通过')
- this.loadData()
- } catch (e) { this.$message.error('操作失败') }
- },
- async handleReject(row) {
- try {
- await rejectRegistration({ id: row.id })
- this.$message.success('已拒绝')
- this.loadData()
- } catch (e) { this.$message.error('操作失败') }
- }
- }
- }
- </script>
- <style scoped>
- .filter-bar { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; padding: 12px; background: #fff; border-radius: 4px; box-shadow: 0 2px 4px rgba(0,0,0,0.08); }
- .no-op { color: #ccc; }
- </style>
|