This commit is contained in:
zzc
2026-06-01 06:35:41 +08:00
parent 9928bc3329
commit 5df4664b16
7 changed files with 434 additions and 1 deletions

41
src/api/rating/topic.js Normal file
View File

@@ -0,0 +1,41 @@
import request from '@/utils/request'
export function getList(data) {
return request({
url: 'management/api/rating/topic/list',
method: 'get',
params: data,
})
}
export function doAdd(data) {
return request({
url: 'management/api/rating/topic',
method: 'post',
data,
})
}
export function doEdit(id, data) {
return request({
url: `/management/api/rating/topic/${id}`,
method: 'put',
data,
})
}
export function doDelete(data) {
return request({
url: `/management/api/rating/topic`,
method: 'delete',
data,
})
}
export function toggleEnable(id, isEnabled) {
return request({
url: `/management/api/rating/topic/enable/${id}`,
method: 'patch',
data: { isEnabled },
})
}

View File

@@ -0,0 +1,41 @@
import request from '@/utils/request'
export function getList(data) {
return request({
url: 'management/api/rating/topicItem/list',
method: 'get',
params: data,
})
}
export function doAdd(data) {
return request({
url: 'management/api/rating/topicItem',
method: 'post',
data,
})
}
export function doEdit(id, data) {
return request({
url: `/management/api/rating/topicItem/${id}`,
method: 'put',
data,
})
}
export function doDelete(data) {
return request({
url: `/management/api/rating/topicItem`,
method: 'delete',
data,
})
}
export function toggleEnable(id, isEnabled) {
return request({
url: `/management/api/rating/topicItem/enable/${id}`,
method: 'patch',
data: { isEnabled },
})
}

View File

@@ -31,6 +31,7 @@ export function doDelete(data) {
data, data,
}) })
} }
export function toggleEnable(id, isEnabled) { export function toggleEnable(id, isEnabled) {
return request({ return request({
url: `/management/api/ability/rule/enable/${id}`, url: `/management/api/ability/rule/enable/${id}`,

View File

@@ -48,6 +48,27 @@ export const asyncRoutes = [
}, },
], ],
}, },
{
path: '/rating',
component: Layout,
redirect: 'noRedirect',
name: 'RatingMini',
meta: { title: '夯拉评分', icon: 'gift', permissions: ['admin'] },
children: [
{
path: 'topic',
name: 'RatingTopicIndex',
component: () => import('@/views/rating/topic/index'),
meta: { title: '评分话题' },
},
{
path: 'topic-item',
name: 'RatingTopicItemIndex',
component: () => import('@/views/rating/topicItem/index'),
meta: { title: '评分项' },
},
],
},
{ {
path: '/spring', path: '/spring',
component: Layout, component: Layout,

View File

@@ -22,5 +22,9 @@ export function getSceneName(scene) {
export const getThumbUrl = (url, w = 200, h = 200) => { export const getThumbUrl = (url, w = 200, h = 200) => {
if (!url) return '' if (!url) return ''
if (url.startsWith('http')) {
return `${url}?imageView2/1/w/${w}/h/${h}/q/80` return `${url}?imageView2/1/w/${w}/h/${h}/q/80`
} else {
return `https://file.lihailezzc.com/${url}?imageView2/1/w/${w}/h/${h}/q/80`
}
} }

View File

@@ -0,0 +1,144 @@
<template>
<div class="rating-topic-container">
<vab-query-form>
<vab-query-form-right-panel :span="24">
<el-form :inline="true" :model="queryForm" @submit.native.prevent>
<el-form-item>
<el-input v-model.trim="queryForm.keyword" clearable placeholder="请输入评价主题" />
</el-form-item>
<el-form-item>
<el-button icon="el-icon-search" type="primary" @click="queryData">查询</el-button>
</el-form-item>
</el-form>
</vab-query-form-right-panel>
</vab-query-form>
<el-table v-loading="listLoading" :data="list" :element-loading-text="elementLoadingText">
<el-table-column align="center" label="封面" width="100">
<template #default="{ row }">
<el-image
v-if="row.coverUrl"
:preview-src-list="[row.coverUrl]"
:src="getThumbUrl(row.coverUrl)"
style="width: 50px; height: 50px; border-radius: 4px"
/>
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column align="center" label="评价主题" min-width="150" prop="title" show-overflow-tooltip />
<el-table-column align="center" label="描述" min-width="200" prop="description" show-overflow-tooltip />
<el-table-column align="center" label="状态" width="100">
<template #default="{ row }">
<el-tag v-if="row.status === 1" type="warning">审核中</el-tag>
<el-tag v-else-if="row.status === 2" type="success">已审通过</el-tag>
<el-tag v-else-if="row.status === 3" type="danger">已拒绝</el-tag>
<el-tag v-else-if="row.status === 4" type="info">禁用</el-tag>
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column align="center" label="允许评论" width="100">
<template #default="{ row }">
<el-tag v-if="row.allowComment === 1 || row.allowComment === true" type="success"></el-tag>
<el-tag v-else type="danger"></el-tag>
</template>
</el-table-column>
<el-table-column align="center" label="参与人数" prop="participantCount" width="100" />
<el-table-column align="center" label="评价人数" prop="scoreCount" width="100" />
<el-table-column align="center" label="评论人数" prop="commentCount" width="100" />
<el-table-column align="center" label="浏览数" prop="viewCount" width="100" />
<el-table-column align="center" label="热门分数" prop="hotScore" width="100" />
<el-table-column align="center" 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">
<template #default="{ row }">
<el-button type="text" @click="handleViewItems(row)">查看评分项</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination
background
:current-page="queryForm.pageNo"
:layout="layout"
:page-size="queryForm.pageSize"
:total="total"
@current-change="handleCurrentChange"
@size-change="handleSizeChange"
/>
</div>
</template>
<script>
import { getList } from '@/api/rating/topic'
import { formatTime } from '@/utils'
import { getThumbUrl } from '@/utils/blessing'
export default {
name: 'RatingTopicIndex',
data() {
return {
list: [],
listLoading: true,
layout: 'total, sizes, prev, pager, next, jumper',
total: 0,
elementLoadingText: '正在加载...',
queryForm: {
pageNo: 1,
pageSize: 10,
keyword: '',
},
}
},
created() {
this.fetchData()
},
methods: {
formatTime,
getThumbUrl,
handleSizeChange(val) {
this.queryForm.pageSize = val
this.fetchData()
},
handleCurrentChange(val) {
this.queryForm.pageNo = val
this.fetchData()
},
queryData() {
this.queryForm.pageNo = 1
this.fetchData()
},
async fetchData() {
this.listLoading = true
try {
const { data } = await getList(this.queryForm)
this.list = data.list
this.total = data.totalCount
} catch (error) {
console.error(error)
} finally {
this.listLoading = false
}
},
handleViewItems(row) {
this.$router.push({
path: '/rating/topic-item',
query: { topicId: row.id },
})
},
},
}
</script>
<style scoped>
.rating-topic-container {
padding: 20px;
}
</style>

View File

@@ -0,0 +1,181 @@
<template>
<div class="rating-topic-item-container">
<vab-query-form>
<vab-query-form-left-panel :span="12">
<el-form :inline="true" :model="queryForm" @submit.native.prevent>
<el-form-item>
<el-select v-model="queryForm.topicId" clearable filterable placeholder="请选择评价主题" @change="handleTopicChange">
<el-option v-for="item in topicList" :key="item.id" :label="item.title" :value="item.id" />
</el-select>
</el-form-item>
</el-form>
</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-input v-model.trim="queryForm.keyword" clearable placeholder="请输入评价项名称" />
</el-form-item>
<el-form-item>
<el-button icon="el-icon-search" type="primary" @click="queryData">查询</el-button>
</el-form-item>
</el-form>
</vab-query-form-right-panel>
</vab-query-form>
<el-alert
v-if="!queryForm.topicId"
show-icon
style="margin-bottom: 20px"
title="请先在左侧选择一个评价主题,或从主题列表点击跳转过来"
type="warning"
/>
<el-table v-loading="listLoading" :data="list" :element-loading-text="elementLoadingText">
<el-table-column align="center" label="头像" width="100">
<template #default="{ row }">
<el-image
v-if="row.avatarUrl"
:preview-src-list="[row.avatarUrl]"
:src="getThumbUrl(row.avatarUrl)"
style="width: 50px; height: 50px; border-radius: 50%"
/>
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column align="center" label="评价项名称" min-width="150" prop="name" show-overflow-tooltip />
<el-table-column align="center" label="描述" min-width="200" prop="description" show-overflow-tooltip />
<el-table-column align="center" label="状态" width="100">
<template #default="{ row }">
<el-tag v-if="row.status === 1" type="warning">审核中</el-tag>
<el-tag v-else-if="row.status === 2" type="success">已审通过</el-tag>
<el-tag v-else-if="row.status === 3" type="danger">已拒绝</el-tag>
<el-tag v-else-if="row.status === 4" type="info">禁用</el-tag>
<span v-else>-</span>
</template>
</el-table-column>
<el-table-column align="center" label="排序" prop="sortOrder" width="80" />
<el-table-column align="center" label="分数" prop="score" width="80" />
<el-table-column align="center" label="总分数" prop="scoreTotal" width="100" />
<el-table-column align="center" label="评价人数" prop="scoreCount" width="100" />
<el-table-column align="center" label="平均分" prop="scoreAvg" width="100" />
<el-table-column align="center" label="浏览数" prop="viewCount" width="80" />
<el-table-column align="center" label="评论数" prop="commentCount" width="80" />
<el-table-column align="center" label="打分人数" prop="ratingCount" width="100" />
<el-table-column align="center" label="排名分" prop="rankScore" width="100" />
<el-table-column align="center" label="热门分" prop="hotScore" width="100" />
<el-table-column align="center" label="创建时间" prop="createdAt" width="160">
<template #default="{ row }">
{{ formatTime(row.createdAt) }}
</template>
</el-table-column>
</el-table>
<el-pagination
background
:current-page="queryForm.pageNo"
:layout="layout"
:page-size="queryForm.pageSize"
:total="total"
@current-change="handleCurrentChange"
@size-change="handleSizeChange"
/>
</div>
</template>
<script>
import { getList } from '@/api/rating/topicItem'
import { getList as getTopicList } from '@/api/rating/topic'
import { formatTime } from '@/utils'
import { getThumbUrl } from '@/utils/blessing'
export default {
name: 'RatingTopicItemIndex',
data() {
return {
list: [],
topicList: [],
listLoading: false,
layout: 'total, sizes, prev, pager, next, jumper',
total: 0,
elementLoadingText: '正在加载...',
queryForm: {
pageNo: 1,
pageSize: 10,
keyword: '',
topicId: '',
},
}
},
watch: {
'$route.query.topicId': {
handler(newVal) {
if (newVal && newVal !== this.queryForm.topicId) {
this.queryForm.topicId = newVal
this.fetchData()
}
},
immediate: true,
},
},
created() {
this.initData()
},
methods: {
formatTime,
getThumbUrl,
async initData() {
// 先获取下拉列表的主题数据暂时取100条
try {
const { data } = await getTopicList({ pageNo: 1, pageSize: 100 })
this.topicList = data.list || []
} catch (error) {
console.error(error)
}
},
handleTopicChange() {
this.queryForm.pageNo = 1
this.fetchData()
},
handleSizeChange(val) {
this.queryForm.pageSize = val
this.fetchData()
},
handleCurrentChange(val) {
this.queryForm.pageNo = val
this.fetchData()
},
queryData() {
this.queryForm.pageNo = 1
this.fetchData()
},
async fetchData() {
if (!this.queryForm.topicId) {
this.list = []
this.total = 0
return
}
this.listLoading = true
try {
const { data } = await getList(this.queryForm)
this.list = data.list
this.total = data.totalCount
} catch (error) {
console.error(error)
} finally {
this.listLoading = false
}
},
},
}
</script>
<style scoped>
.rating-topic-item-container {
padding: 20px;
}
</style>