功能:完善评论测试与优惠券最优选择

This commit is contained in:
xiaowang
2026-05-16 14:28:42 +08:00
parent 1f05e0ab44
commit 4563dd2538
31 changed files with 1130 additions and 581 deletions
@@ -0,0 +1,116 @@
<template>
<div class="comments-page">
<header class="page-head">
<div>
<h2>评论管理</h2>
<p>查看作品评论与回复,删除不合规内容。</p>
</div>
<a-input-search v-model:value="keyword" class="search" allow-clear placeholder="搜索评论内容" @search="loadComments" />
</header>
<a-table
:columns="columns"
:data-source="comments"
:loading="loading"
:pagination="{ pageSize: 10 }"
row-key="id"
>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'commentContent'">
<div class="comment-cell">
<strong>{{ record.commentContent }}</strong>
<span v-if="record.parentCommentContent">回复:{{ record.parentCommentContent }}</span>
</div>
</template>
<template v-else-if="column.key === 'action'">
<a-popconfirm title="确认删除这条评论?" ok-text="删除" cancel-text="取消" @confirm="deleteComment(record.id)">
<a-button danger type="link">删除</a-button>
</a-popconfirm>
</template>
</template>
</a-table>
</div>
</template>
<script setup lang="ts">
import { onMounted, ref } from 'vue'
import { message } from 'ant-design-vue'
import { adminCommentApi, type AdminCommentVO } from '@/api/admin'
import type { IdType } from '@/utils/id'
const loading = ref(false)
const keyword = ref('')
const comments = ref<AdminCommentVO[]>([])
const columns = [
{ title: '评论内容', dataIndex: 'commentContent', key: 'commentContent' },
{ title: '用户', dataIndex: 'userNickname', key: 'userNickname', width: 140 },
{ title: '作品', dataIndex: 'productTitle', key: 'productTitle', width: 180 },
{ title: '门店', dataIndex: 'shopName', key: 'shopName', width: 160 },
{ title: '时间', dataIndex: 'createTime', key: 'createTime', width: 180 },
{ title: '操作', key: 'action', width: 100 }
]
const loadComments = async () => {
loading.value = true
try {
comments.value = await adminCommentApi.listComments({ keyword: keyword.value || undefined })
} catch (error: any) {
message.error(error?.message || '评论加载失败')
} finally {
loading.value = false
}
}
const deleteComment = async (id: IdType) => {
await adminCommentApi.deleteComment(id)
message.success('评论已删除')
await loadComments()
}
onMounted(loadComments)
</script>
<style scoped>
.comments-page {
display: grid;
gap: 18px;
}
.page-head {
display: flex;
justify-content: space-between;
gap: 16px;
align-items: flex-start;
}
.page-head h2 {
margin: 0;
font-size: 22px;
color: #20232a;
}
.page-head p {
margin: 6px 0 0;
color: #687385;
}
.search {
width: min(360px, 100%);
}
.comment-cell {
display: grid;
gap: 6px;
}
.comment-cell strong {
color: #20232a;
font-weight: 600;
}
.comment-cell span {
color: #7b8494;
font-size: 12px;
}
</style>