ActivityRegistrationAudit.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <template>
  2. <div>
  3. <div class="filter-bar">
  4. <el-select v-model="statusFilter" placeholder="审核状态" @change="loadData">
  5. <el-option label="全部" value="" />
  6. <el-option label="待审核" value="pending" />
  7. <el-option label="已通过" value="approved" />
  8. <el-option label="已拒绝" value="rejected" />
  9. </el-select>
  10. <el-button size="small" @click="loadData" :loading="loading">刷新</el-button>
  11. </div>
  12. <el-table :data="list" v-loading="loading" border stripe style="min-width:900px;" :max-height="tableHeight">
  13. <el-table-column prop="id" label="ID" width="60" />
  14. <el-table-column label="用户" width="120">
  15. <template slot-scope="{ row }">{{ row.nickname || row.userName || '-' }}</template>
  16. </el-table-column>
  17. <el-table-column label="活动" min-width="180" show-overflow-tooltip>
  18. <template slot-scope="{ row }">{{ row.activityTitle || row.activityName || '-' }}</template>
  19. </el-table-column>
  20. <el-table-column label="审核状态" width="100">
  21. <template slot-scope="{ row }">
  22. <el-tag :type="statusType(row.status)">{{ statusLabel(row.status) }}</el-tag>
  23. </template>
  24. </el-table-column>
  25. <el-table-column label="操作" width="180" fixed="right">
  26. <template slot-scope="{ row }">
  27. <template v-if="row.status === 'pending'">
  28. <el-button size="mini" type="success" @click="handleApprove(row)">通过</el-button>
  29. <el-button size="mini" type="danger" @click="handleReject(row)">拒绝</el-button>
  30. </template>
  31. <span v-else class="no-op">—</span>
  32. </template>
  33. </el-table-column>
  34. </el-table>
  35. </div>
  36. </template>
  37. <script>
  38. import { getActivityList } from '@/api/activity'
  39. import { approveRegistration, rejectRegistration } from '@/api/activity'
  40. export default {
  41. name: 'ActivityRegistrationAudit',
  42. computed: {
  43. tableHeight() {
  44. return window.innerHeight - 300
  45. }
  46. },
  47. data() {
  48. return {
  49. list: [], loading: false, statusFilter: 'pending'
  50. }
  51. },
  52. mounted() { this.loadData() },
  53. methods: {
  54. statusType(s) { return { pending: 'warning', approved: 'success', rejected: 'danger' }[s] || 'info' },
  55. statusLabel(s) { return { pending: '待审核', approved: '已通过', rejected: '已拒绝' }[s] || s },
  56. async loadData() {
  57. this.loading = true
  58. try {
  59. const res = await getActivityList({ withRegistrations: true, page: 1, size: 50 })
  60. var regs = []
  61. var activities = res.data && res.data.records || res.data && res.data.list || res.data || []
  62. for (var i = 0; i < activities.length; i++) {
  63. var a = activities[i]
  64. if (a.registrations) {
  65. for (var j = 0; j < a.registrations.length; j++) {
  66. var r = a.registrations[j]
  67. r.activityTitle = a.title
  68. regs.push(r)
  69. }
  70. }
  71. }
  72. this.list = this.statusFilter ? regs.filter(function(r) { return r.status === this.statusFilter }.bind(this)) : regs
  73. } catch (e) { this.$message.error('加载失败')
  74. } finally { this.loading = false }
  75. },
  76. async handleApprove(row) {
  77. try {
  78. await approveRegistration({ id: row.id })
  79. this.$message.success('已通过')
  80. this.loadData()
  81. } catch (e) { this.$message.error('操作失败') }
  82. },
  83. async handleReject(row) {
  84. try {
  85. await rejectRegistration({ id: row.id })
  86. this.$message.success('已拒绝')
  87. this.loadData()
  88. } catch (e) { this.$message.error('操作失败') }
  89. }
  90. }
  91. }
  92. </script>
  93. <style scoped>
  94. .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); }
  95. .no-op { color: #ccc; }
  96. </style>