ActivityReview.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <template>
  2. <div class="activity-review admin-page">
  3. <el-card>
  4. <div class="admin-page-header">
  5. <span class="admin-page-title">活动审核</span>
  6. <div class="admin-page-actions" style="gap:12px;">
  7. <el-input v-model="filter.keyword" placeholder="搜索活动..." prefix-icon="el-icon-search" clearable @keyup.enter.native="handleSearch" @clear="handleSearch" style="width:200px;margin-right:8px;" />
  8. <el-select v-model="filter.status" placeholder="活动状态" clearable @change="handleSearch" style="width:130px;">
  9. <el-option label="全部状态" value="" />
  10. <el-option label="待审核" value="draft" />
  11. <el-option label="已发布" value="published" />
  12. <el-option label="已结束" value="ended" />
  13. </el-select>
  14. <el-select v-model="filter.dimensionCode" placeholder="所属维度" clearable @change="handleSearch" style="width:120px;">
  15. <el-option label="全部维度" value="" />
  16. <el-option label="身" value="body" />
  17. <el-option label="心" value="mind" />
  18. <el-option label="智" value="wisdom" />
  19. <el-option label="行" value="action" />
  20. <el-option label="富" value="wealth" />
  21. </el-select>
  22. <el-button type="primary" size="mini" @click="handleSearch">查询</el-button>
  23. <el-button size="mini" @click="resetSearch">重置</el-button>
  24. </div>
  25. </div>
  26. <el-table :data="pendingActivities" v-loading="loading" border stripe style="min-width:900px;" :max-height="tableHeight">
  27. <el-table-column prop="id" label="ID" width="80" />
  28. <el-table-column prop="title" label="活动标题" min-width="200" show-overflow-tooltip />
  29. <el-table-column prop="applicant" label="申请人" width="120" />
  30. <el-table-column prop="createdAt" label="申请时间" width="180" />
  31. <el-table-column label="状态" width="100">
  32. <template slot-scope="{ row }">
  33. <el-tag v-if="row.status === 'draft'" type="warning">待审核</el-tag>
  34. <el-tag v-else-if="row.status === 'published'" type="success">已发布</el-tag>
  35. <el-tag v-else-if="row.status === 'rejected'" type="danger">已驳回</el-tag>
  36. <el-tag v-else type="info">{{ row.status }}</el-tag>
  37. </template>
  38. </el-table-column>
  39. <el-table-column label="操作" width="200" fixed="right">
  40. <template slot-scope="{ row }">
  41. <el-button
  42. v-if="row.status === 'draft'"
  43. size="mini"
  44. type="success"
  45. @click="approve(row)"
  46. >通过</el-button>
  47. <el-button
  48. v-if="row.status === 'draft'"
  49. size="mini"
  50. type="danger"
  51. @click="reject(row)"
  52. >驳回</el-button>
  53. <span v-else class="no-op">—</span>
  54. </template>
  55. </el-table-column>
  56. </el-table>
  57. <el-pagination
  58. v-if="total > 0"
  59. @current-change="handlePageChange"
  60. :current-page="page"
  61. :page-size="size"
  62. :total="total"
  63. layout="total, prev, pager, next"
  64. class="pagination-wrap"
  65. />
  66. </el-card>
  67. </div>
  68. </template>
  69. <script>
  70. import { getActivityList, reviewActivity } from '@/api/activity'
  71. export default {
  72. name: 'ActivityReview',
  73. computed: {
  74. tableHeight() {
  75. return window.innerHeight - 300
  76. }
  77. },
  78. data() {
  79. return {
  80. loading: false,
  81. pendingActivities: [],
  82. filter: {
  83. keyword: '',
  84. status: '',
  85. dimensionCode: ''
  86. },
  87. page: 1,
  88. size: 20,
  89. total: 0
  90. }
  91. },
  92. created() {
  93. this.loadPending()
  94. },
  95. methods: {
  96. async loadPending() {
  97. this.loading = true
  98. try {
  99. const params = {
  100. page: this.page,
  101. size: this.size,
  102. status: this.filter.status || 'draft',
  103. keyword: this.filter.keyword || undefined,
  104. dimensionCode: this.filter.dimensionCode || undefined
  105. }
  106. const res = await getActivityList(params)
  107. this.pendingActivities = (res.data && res.data.records) || []
  108. this.total = (res.data && res.data.total) || 0
  109. } catch (e) {
  110. this.$message.error('加载待审核活动失败')
  111. } finally {
  112. this.loading = false
  113. }
  114. },
  115. handlePageChange(val) {
  116. this.page = val
  117. this.loadPending()
  118. },
  119. handleSearch() {
  120. this.page = 1
  121. this.loadPending()
  122. },
  123. resetSearch() {
  124. this.filter.keyword = ''
  125. this.filter.status = ''
  126. this.filter.dimensionCode = ''
  127. this.page = 1
  128. this.loadPending()
  129. },
  130. async approve(row) {
  131. try {
  132. await reviewActivity({ id: row.id, action: 'publish' })
  133. this.$message.success('审核通过,活动已发布')
  134. this.loadPending()
  135. } catch (e) {
  136. this.$message.error('操作失败')
  137. }
  138. },
  139. async reject(row) {
  140. try {
  141. await this.$confirm('确认驳回该活动?驳回后活动将被删除', '提示', {
  142. confirmButtonText: '确认',
  143. cancelButtonText: '取消',
  144. type: 'warning'
  145. })
  146. await reviewActivity({ id: row.id, action: 'reject' })
  147. this.$message.success('已驳回并删除')
  148. this.loadPending()
  149. } catch (e) {
  150. // 取消或操作失败均不做处理
  151. }
  152. }
  153. }
  154. }
  155. </script>
  156. <style scoped>
  157. .no-op {
  158. color: #ccc;
  159. }
  160. </style>