| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224 |
- <template>
- <div class="activity-review admin-page">
- <el-card>
- <PageHeader title="活动审核">
-
- <div class="admin-page-actions actions-gap">
- <el-input v-model="filter.keyword" placeholder="搜索活动..." prefix-icon="el-icon-search" clearable @keyup.enter.native="handleSearch" @clear="handleSearch" class="filter-input-200mr8" />
- <el-select v-model="filter.status" placeholder="活动状态" clearable @change="handleSearch" class="filter-select-130">
- <el-option label="全部状态" value="" />
- <el-option label="待审核" value="draft" />
- <el-option label="已发布" value="published" />
- <el-option label="已结束" value="ended" />
- </el-select>
- <el-select v-model="filter.dimensionCode" placeholder="所属维度" clearable @change="handleSearch" class="filter-select-120">
- <el-option label="全部维度" value="" />
- <el-option label="身" value="body" />
- <el-option label="心" value="mind" />
- <el-option label="智" value="wisdom" />
- <el-option label="行" value="action" />
- <el-option label="富" value="wealth" />
- </el-select>
- <el-button type="primary" size="mini" @click="handleSearch">查询</el-button>
- <el-button size="mini" @click="resetSearch">重置</el-button>
- </div>
-
- </PageHeader>
- <div class="adm-table-wrap">
- <el-table :data="pendingActivities" v-loading="loading" border stripe class="wide-table" height="100%">
- <el-table-column prop="id" label="ID" width="80">
- <template slot="header">
- <span class="sort-header" @click.stop="onSortClick('id', $event)">ID<span v-if="sortIndex('id') !== null" class="sort-index" :class="sortClass('id') === 'sort-asc' ? 'sort-asc-badge' : 'sort-desc-badge'">{{ sortIndex('id') }}</span>{{ sortIcon('id') }}</span>
- </template>
- </el-table-column>
- <el-table-column prop="title" label="活动标题" min-width="200" show-overflow-tooltip>
- <template slot="header">
- <span class="sort-header" @click.stop="onSortClick('title', $event)">活动标题<span v-if="sortIndex('title') !== null" class="sort-index" :class="sortClass('title') === 'sort-asc' ? 'sort-asc-badge' : 'sort-desc-badge'">{{ sortIndex('title') }}</span>{{ sortIcon('title') }}</span>
- </template>
- </el-table-column>
- <el-table-column prop="applicant" label="申请人" width="120">
- <template slot="header">
- <span class="sort-header" @click.stop="onSortClick('applicant', $event)">申请人<span v-if="sortIndex('applicant') !== null" class="sort-index" :class="sortClass('applicant') === 'sort-asc' ? 'sort-asc-badge' : 'sort-desc-badge'">{{ sortIndex('applicant') }}</span>{{ sortIcon('applicant') }}</span>
- </template>
- </el-table-column>
- <el-table-column prop="createdAt" label="申请时间" width="180">
- <template slot="header">
- <span class="sort-header" @click.stop="onSortClick('createdAt', $event)">申请时间<span v-if="sortIndex('createdAt') !== null" class="sort-index" :class="sortClass('createdAt') === 'sort-asc' ? 'sort-asc-badge' : 'sort-desc-badge'">{{ sortIndex('createdAt') }}</span>{{ sortIcon('createdAt') }}</span>
- </template>
- <template slot-scope="{ row }">
- {{ fmtLocalTime(row.createdAt) }}
- </template>
- </el-table-column>
- <el-table-column label="状态" width="100">
- <template slot-scope="{ row }">
- <StatusTag v-if="row.status === 'draft'" type="warning" text="待审核" />
- <StatusTag v-else-if="row.status === 'published'" type="success" text="已发布" />
- <StatusTag v-else-if="row.status === 'rejected'" type="danger" text="已驳回" />
- <StatusTag v-else type="info" :text="row.status" />
- </template>
- </el-table-column>
- <el-table-column label="操作" width="200" fixed="right">
- <template slot-scope="{ row }">
- <el-button
- v-if="row.status === 'draft'"
- size="mini"
- type="success"
- @click="approve(row)"
- >通过</el-button>
- <el-button
- v-if="row.status === 'draft'"
- size="mini"
- type="danger"
- @click="reject(row)"
- >驳回</el-button>
- <span v-else class="no-op">—</span>
- </template>
- </el-table-column>
- </el-table>
- </div>
- <el-pagination
- v-if="total > 0"
- @current-change="handlePageChange"
- :current-page="page"
- :page-size="size"
- :total="total"
- layout="total, prev, pager, next"
- class="pagination-wrap"
- />
- </el-card>
- </div>
- </template>
- <script>
- import { getActivityList, reviewActivity } from '@/api/activity'
- import SortMixin from '@/mixins/SortMixin'
- import ListStateMixin from '@/mixins/ListStateMixin'
- export default {
- name: 'ActivityReview',
- mixins: [SortMixin, ListStateMixin],
- computed: {
- tableHeight() {
- return window.innerHeight - 300
- }
- },
- data() {
- return {
- sortableColumns: { id: 'ID', createdAt: '申请时间', title: '活动标题', applicant: '申请人' },
- loading: false,
- pendingActivities: [],
- filter: {
- keyword: '',
- status: '',
- dimensionCode: ''
- },
- page: 1,
- size: 20,
- total: 0
- }
- },
- created() {
- this.loadPending()
- },
- methods: {
- loadList() {
- this.loadPending()
- },
- // 后端把 java.util.Date 序列化为 UTC 偏移串(如 2026-10-25T01:00:00.000+00:00),
- // 统一转 Asia/Shanghai 本地墙钟时间展示,避免比实际时间少 8 小时
- fmtLocalTime(val) {
- if (val === null || val === undefined || val === '') return '—'
- const d = new Date(val)
- if (isNaN(d.getTime())) return String(val)
- const bj = new Date(d.getTime() + d.getTimezoneOffset() * 60000 + 8 * 3600000)
- const pad = n => (n < 10 ? '0' + n : '' + n)
- return bj.getFullYear() + '-' + pad(bj.getMonth() + 1) + '-' + pad(bj.getDate()) + ' ' +
- pad(bj.getHours()) + ':' + pad(bj.getMinutes()) + ':' + pad(bj.getSeconds())
- },
- async loadPending() {
- this.loading = true
- try {
- const params = {
- page: this.page,
- size: this.size,
- status: this.filter.status || 'draft',
- keyword: this.filter.keyword || undefined,
- dimensionCode: this.filter.dimensionCode || undefined
- }
- this.applySortToParams(params)
- const res = await getActivityList(params)
- this.pendingActivities = (res.data && res.data.records) || []
- this.total = (res.data && res.data.total) || 0
- } catch (e) {
- this.$message.error('加载待审核活动失败')
- } finally {
- this.loading = false
- }
- },
- handlePageChange(val) {
- this.page = val
- this.loadPending()
- },
- handleSearch() {
- this.page = 1
- this.loadPending()
- },
- resetSearch() {
- this.filter.keyword = ''
- this.filter.status = ''
- this.filter.dimensionCode = ''
- this.page = 1
- this.loadPending()
- },
- async approve(row) {
- if (!row) return
- try {
- await this.$prompt('请选择所属维度(必填)', '审核通过', {
- confirmButtonText: '通过',
- cancelButtonText: '取消',
- inputPlaceholder: '请输入维度编码(body/mind/wisdom/action/wealth)',
- inputValidator: (val) => {
- if (!val || !['body', 'mind', 'wisdom', 'action', 'wealth'].includes(val.trim().toLowerCase())) {
- return '请从下拉选择或输入 body/mind/wisdom/action/wealth'
- }
- return true
- }
- }).then(({ value }) => {
- return reviewActivity({ id: row.id, action: 'publish', dimensionCode: value.trim().toLowerCase() })
- })
- this.$message.success('审核通过,活动已发布')
- this.loadPending()
- } catch (e) {
- if (e !== 'cancel') this.$message.error('操作失败')
- }
- },
- async reject(row) {
- try {
- await this.$confirm('确认驳回该活动?驳回后活动将被删除', '提示', {
- confirmButtonText: '确认',
- cancelButtonText: '取消',
- type: 'warning'
- })
- await reviewActivity({ id: row.id, action: 'reject' })
- this.$message.success('已驳回并删除')
- this.loadPending()
- } catch (e) {
- // 取消或操作失败均不做处理
- }
- }
- }
- }
- </script>
- <style scoped>
- .no-op {
- color: #ccc;
- }
- /* == C 批内联清理工具类 == */
- .actions-gap { gap: 12px; }
- .filter-input-200mr8 { width: 200px; margin-right: 8px; }
- .filter-select-130 { width: 130px; }
- .filter-select-120 { width: 120px; }
- .wide-table { min-width: 900px; }
- </style>
|