fix: rating

This commit is contained in:
zzc
2026-06-09 16:07:02 +08:00
parent acef084df7
commit 993b5f8eef
4 changed files with 89 additions and 28 deletions

View File

@@ -6,6 +6,14 @@
</vab-query-form-left-panel>
<vab-query-form-right-panel :span="12">
<el-form :inline="true" :model="queryForm" @submit.native.prevent>
<el-form-item>
<el-select v-model="queryForm.status" clearable placeholder="请选择状态" @change="queryData">
<el-option label="审核中" :value="1" />
<el-option label="已通过" :value="2" />
<el-option label="已拒绝" :value="3" />
<el-option label="禁用" :value="4" />
</el-select>
</el-form-item>
<el-form-item>
<el-input v-model.trim="queryForm.keyword" clearable placeholder="请输入评价主题" />
</el-form-item>
@@ -17,11 +25,9 @@
</vab-query-form>
<el-table v-loading="listLoading" :data="list" :element-loading-text="elementLoadingText">
<el-table-column align="left" label="评价主题" min-width="250">
<el-table-column align="left" label="评价主题" min-width="200" width="200">
<template #default="{ row }">
<div class="topic-info-cell">
<el-image v-if="row.coverUrl" class="topic-cover" :preview-src-list="[row.coverUrl]" :src="getThumbUrl(row.coverUrl)" />
<div v-else class="topic-cover-placeholder"><i class="el-icon-picture-outline" /></div>
<div class="topic-info-cell" style="cursor: pointer" @click="handleViewItems(row)">
<div class="topic-details">
<div class="topic-title">{{ row.title }}</div>
<div v-if="row.description" class="topic-desc" :title="row.description">{{ row.description }}</div>
@@ -47,7 +53,7 @@
</template>
</el-table-column>
<el-table-column align="left" label="互动统计" min-width="180">
<el-table-column align="left" label="互动统计" width="180">
<template #default="{ row }">
<div class="stat-cell">
<div class="stat-row">
@@ -82,17 +88,19 @@
</template>
</el-table-column>
<el-table-column align="center" label="热门分数" prop="hotScore" width="100" />
<el-table-column align="left" label="热门分数" prop="hotScore" width="100" />
<el-table-column align="center" label="创建时间" prop="createdAt" width="160">
<el-table-column align="left" label="创建时间" prop="createdAt" width="160">
<template #default="{ row }">
{{ formatTime(row.createdAt) }}
</template>
</el-table-column>
<el-table-column align="center" fixed="right" label="操作" width="120">
<el-table-column align="center" label="操作" width="150">
<template #default="{ row }">
<el-button type="text" @click="handleViewItems(row)">查看评分项</el-button>
<el-button v-if="row.status !== 4" style="color: #f56c6c" type="text" @click="handleDisable(row)">禁用</el-button>
<el-button v-if="row.status === 4" style="color: #67c23a" type="text" @click="handleEnable(row)">启用</el-button>
</template>
</el-table-column>
</el-table>
@@ -113,6 +121,7 @@
<script>
import { getList } from '@/api/rating/topic'
import { reviewTopic } from '@/api/rating/topicOperate'
import { formatTime } from '@/utils'
import { getThumbUrl } from '@/utils/blessing'
import TopicEdit from './components/TopicEdit'
@@ -131,6 +140,7 @@
pageNo: 1,
pageSize: 10,
keyword: '',
status: '',
},
}
},
@@ -173,6 +183,50 @@
query: { topicId: row.id },
})
},
handleDisable(row) {
this.$confirm('确定要禁用该话题吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(async () => {
try {
const { msg } = await reviewTopic({
topicId: row.id,
userId: this.$store.state.user.userId || '',
status: 4,
type: 'topic',
})
this.$baseMessage(msg || '已禁用', 'success')
this.fetchData()
} catch (error) {
console.error(error)
}
})
.catch(() => {})
},
handleEnable(row) {
this.$confirm('确定要启用该话题吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'success',
})
.then(async () => {
try {
const { msg } = await reviewTopic({
topicId: row.id,
userId: this.$store.state.user.userId || '',
status: 2,
type: 'topic',
})
this.$baseMessage(msg || '已启用', 'success')
this.fetchData()
} catch (error) {
console.error(error)
}
})
.catch(() => {})
},
},
}
</script>

View File

@@ -32,6 +32,7 @@
saving: false,
form: {
topicId: '',
itemId: '',
userId: '',
status: '',
type: '', // topic 或 topicItem
@@ -44,8 +45,9 @@
showEdit(row, status, type) {
this.title = `审核确认 (${type === 'topic' ? '话题' : '评价项'})`
this.form = {
topicId: row.id,
userId: row.userId || '',
topicId: type === 'topic' ? row.id : row.topicId || '',
itemId: type === 'topicItem' ? row.id : '',
userId: this.$store.state.user.userId || '',
status,
type,
rejectReason: '',

View File

@@ -19,8 +19,8 @@
<template #default="{ row }">
<div v-if="row.topicItems && row.topicItems.length > 0" class="expand-content">
<h4>包含的评价项列表</h4>
<el-table border :data="row.topicItems" size="mini">
<el-table-column align="center" label="评价项" width="200">
<el-table border :data="row.topicItems" size="mini" style="width: 100%">
<el-table-column align="center" label="评价项" min-width="150">
<template #default="scope">
<div class="item-info">
<el-image v-if="scope.row.avatarUrl" class="item-avatar" :src="getThumbUrl(scope.row.avatarUrl)" />
@@ -28,13 +28,6 @@
</div>
</template>
</el-table-column>
<el-table-column align="center" label="分类" prop="category" width="100">
<template #default="{ row: item }">
<el-tag v-if="item.category" effect="plain" type="info">{{ item.category }}</el-tag>
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column align="center" label="状态" width="100">
<template #default="scope">
<el-tag v-if="scope.row.status === 1" size="mini" type="warning">审核中</el-tag>
@@ -49,7 +42,7 @@
{{ formatTime(scope.row.createdAt) }}
</template>
</el-table-column>
<el-table-column align="center" label="操作" min-width="150">
<el-table-column align="center" label="操作" width="180">
<template #default="scope">
<el-button size="mini" type="success" @click="handleReview(scope.row, 2, 'topicItem')">通过</el-button>
<el-button size="mini" type="danger" @click="handleReview(scope.row, 3, 'topicItem')">拒绝</el-button>
@@ -61,12 +54,21 @@
</template>
</el-table-column>
<el-table-column align="left" label="评价主题" min-width="250" width="200">
<el-table-column align="left" label="评价主题" width="250">
<template #default="{ row }">
<div class="topic-info-cell">
<div class="topic-details">
<div class="topic-title">{{ row.title }}</div>
<div v-if="row.description" class="topic-desc" :title="row.description">{{ row.description }}</div>
</div>
</div>
</template>
</el-table-column>
<el-table-column align="left" label="类型" width="100">
<template #default="{ row }">
<div class="topic-info-cell">
<div class="topic-details">
<div class="topic-title">{{ row.category }}</div>
</div>
</div>
</template>
@@ -88,7 +90,7 @@
</template>
</el-table-column>
<el-table-column align="center" fixed="right" label="操作" width="180">
<el-table-column align="center" label="操作" width="180">
<template #default="{ row }">
<el-button size="mini" type="success" @click="handleReview(row, 2, 'topic')">通过</el-button>
<el-button size="mini" type="danger" @click="handleReview(row, 3, 'topic')">拒绝</el-button>
@@ -176,13 +178,16 @@
}
.expand-content {
padding: 10px 40px;
padding: 15px 40px;
background-color: #fafafa;
border-radius: 4px;
width: 100%;
box-sizing: border-box;
}
.expand-content h4 {
margin: 0 0 10px 0;
margin: 0 0 15px 0;
color: #606266;
font-size: 14px;
}
.expand-empty {
padding: 20px;