Compare commits
27 Commits
6f99958275
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
254d2601bf | ||
|
|
28fff91b57 | ||
|
|
8da9a7e8cc | ||
|
|
c60ea798fd | ||
|
|
f2389e73aa | ||
|
|
fe7613c6df | ||
|
|
7d62377380 | ||
|
|
93da905e1d | ||
|
|
1361bf34f8 | ||
|
|
a34ed84a29 | ||
|
|
a263e8a7e0 | ||
|
|
bb819d07a1 | ||
|
|
0ef2b697a3 | ||
|
|
97f2e6a17c | ||
|
|
9e59ae710a | ||
|
|
5f9a5aeae7 | ||
|
|
a260b98725 | ||
|
|
4fb04c2be8 | ||
|
|
2d84ee213c | ||
|
|
e032412adf | ||
|
|
d44f88b124 | ||
|
|
790a2658d5 | ||
|
|
993b5f8eef | ||
|
|
acef084df7 | ||
|
|
b5a246f11b | ||
|
|
ffbd355393 | ||
|
|
0dc2c2f0c3 |
114
src/api/rating/pk.js
Normal file
114
src/api/rating/pk.js
Normal file
@@ -0,0 +1,114 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
/**
|
||||
* 获取PK赛列表
|
||||
* @param {pageNo: number, pageSize: number, topicId?: string, itemId?: string} data
|
||||
*/
|
||||
export function getList(data) {
|
||||
return request({
|
||||
url: 'management/api/rating/pk/list',
|
||||
method: 'get',
|
||||
params: data,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取PK赛参与人
|
||||
* @param { pkId: string, chooseItemId: string, pageNo: number, pageSize: number } data
|
||||
*/
|
||||
export function getParticipantList(data) {
|
||||
return request({
|
||||
url: 'management/api/rating/pk/participants',
|
||||
method: 'get',
|
||||
params: data,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* pk 投票
|
||||
* @param { pkId: string, itemId: string, userId?: string, count?: number } data
|
||||
*/
|
||||
export function vote(data) {
|
||||
return request({
|
||||
url: 'management/api/rating/pk/vote',
|
||||
method: 'post',
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成PK赛
|
||||
* @param {topicId: string, leftItemId: string, rightItemId: string} data
|
||||
*/
|
||||
export function generate(data) {
|
||||
return request({
|
||||
url: 'management/api/rating/pk/generate',
|
||||
method: 'post',
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取PK赛评论列表
|
||||
* @param { pageNo: number, pageSize: number, pkId: string, status?: number, rootCommentId?: string, orderBy?: string } data
|
||||
*/
|
||||
export function getCommentList(data) {
|
||||
return request({
|
||||
url: 'management/api/rating/pk/comment/list',
|
||||
method: 'get',
|
||||
params: data,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* PK赛 评论/回复
|
||||
* @param { userId: string, pkId: string, content: string, parentCommentId?: string, replyToCommentId?: string } data
|
||||
* @param { parentCommentId: string } data 评论回复必传
|
||||
* @param { replyToCommentId: string } data 回复必传
|
||||
*/
|
||||
export function comment(data) {
|
||||
return request({
|
||||
url: 'management/api/rating/pk/comment',
|
||||
method: 'post',
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* PK赛 评论 点赞
|
||||
* @param { userId: string, commentId: string } data
|
||||
*/
|
||||
export function like(data) {
|
||||
return request({
|
||||
url: 'management/api/rating/pk/comment/like',
|
||||
method: 'post',
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* PK赛 评论 禁用/启用
|
||||
* @param { id: string, enable: boolean } data
|
||||
*/
|
||||
export function toggleEnable(data) {
|
||||
return request({
|
||||
url: 'management/api/rating/pk/comment/toggle',
|
||||
method: 'post',
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改评论状态
|
||||
* @param {*} { id, enable: boolean }
|
||||
* @param { enable: boolean } data 是否启用
|
||||
* @param { id: string } data 评论id
|
||||
* @returns
|
||||
*/
|
||||
export function commentStatus(data) {
|
||||
return request({
|
||||
url: 'management/api/rating/pk/comment/toggle',
|
||||
method: 'post',
|
||||
data,
|
||||
})
|
||||
}
|
||||
@@ -8,6 +8,19 @@ export function getList(data) {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取待审核话题列表
|
||||
* @param {pageNo: number, pageSize: number} data
|
||||
* @returns
|
||||
*/
|
||||
export function getPendingList(data) {
|
||||
return request({
|
||||
url: 'management/api/rating/topic/pending/list',
|
||||
method: 'get',
|
||||
params: data,
|
||||
})
|
||||
}
|
||||
|
||||
export function getAllList(data) {
|
||||
return request({
|
||||
url: 'management/api/rating/topic/list/all',
|
||||
@@ -16,6 +29,12 @@ export function getAllList(data) {
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加话题
|
||||
* @param {title: string, categoryId: string, participants: object[]} data
|
||||
* @param {name: string, avatar: string} data.participants 话题 items
|
||||
* @returns
|
||||
*/
|
||||
export function doAdd(data) {
|
||||
return request({
|
||||
url: 'management/api/rating/topic',
|
||||
@@ -47,3 +66,17 @@ export function toggleEnable(id, isEnabled) {
|
||||
data: { isEnabled },
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 置顶话题置顶状态
|
||||
* @param {id: string} id 话题 id
|
||||
* @param {isPinned: boolean} 是否置顶话题
|
||||
* @returns
|
||||
*/
|
||||
export function pinnedTopic(id, isPinned) {
|
||||
return request({
|
||||
url: `/management/api/rating/topic/pinned/${id}`,
|
||||
method: 'patch',
|
||||
data: { isPinned },
|
||||
})
|
||||
}
|
||||
|
||||
67
src/api/rating/topicCategory.js
Normal file
67
src/api/rating/topicCategory.js
Normal file
@@ -0,0 +1,67 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
/**
|
||||
* 获取话题分类列表
|
||||
* @param {*} data
|
||||
* @returns
|
||||
*/
|
||||
export function getList(data) {
|
||||
return request({
|
||||
url: 'management/api/rating/topic_category/list',
|
||||
method: 'get',
|
||||
params: data,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换话题分类状态
|
||||
* @param {*} id
|
||||
* @param {*} enable
|
||||
* @returns
|
||||
*/
|
||||
export function toggleEnable(id, enable) {
|
||||
return request({
|
||||
url: `/management/api/rating/topic_category/toggle/${id}`,
|
||||
method: 'patch',
|
||||
data: { enable },
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 移动话题分类
|
||||
* @param {*} id
|
||||
* @param {*} to
|
||||
* @returns
|
||||
*/
|
||||
export function moveTo(id, to) {
|
||||
return request({
|
||||
url: `/management/api/rating/topic_category/move_to/${id}`,
|
||||
method: 'patch',
|
||||
data: { to },
|
||||
})
|
||||
}
|
||||
/**
|
||||
* 编辑话题分类
|
||||
* @param {*} id
|
||||
* @returns
|
||||
*/
|
||||
export function doEdit(id, data) {
|
||||
return request({
|
||||
url: `/management/api/rating/topic_category/${id}`,
|
||||
method: 'put',
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建话题分类
|
||||
* @param {title: string} data
|
||||
* @returns
|
||||
*/
|
||||
export function doAdd(data) {
|
||||
return request({
|
||||
url: '/management/api/rating/topic_category',
|
||||
method: 'post',
|
||||
data,
|
||||
})
|
||||
}
|
||||
@@ -47,3 +47,27 @@ export function toggleEnable(id, isEnabled) {
|
||||
data: { isEnabled },
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 评分项审核列表
|
||||
*/
|
||||
export function getPendingList(data) {
|
||||
return request({
|
||||
url: 'management/api/rating/topicItem/pending/list',
|
||||
method: 'get',
|
||||
params: data,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 给某个分数段投票
|
||||
* @param {topicId: string, itemId: string, score: number, count: number} data
|
||||
* @returns
|
||||
*/
|
||||
export function ItemScorevote(data) {
|
||||
return request({
|
||||
url: 'management/api/rating/topicItem/vote/robot',
|
||||
method: 'post',
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ export function scoreRecordList(data) {
|
||||
|
||||
/**
|
||||
* 评论记录
|
||||
* @param {*} { pageNo, pageSize, userId?, topicId?, itemId?, trueUser? }
|
||||
* @param {*} { pageNo, pageSize, userId?, topicId?, itemId?, trueUser?, rootCommentId? }
|
||||
* @returns
|
||||
*/
|
||||
export function userCommentList(data) {
|
||||
@@ -42,7 +42,9 @@ export function userCommentList(data) {
|
||||
|
||||
/**
|
||||
* 评论
|
||||
* @param {*} { topicId, itemId, comment, userId }
|
||||
* @param {*} { topicId, itemId, comment, userId,parentCommentId, replyToCommentId, }
|
||||
* @param { parentCommentId: string } data 评论回复必传
|
||||
* @param { replyToCommentId: string } data 回复必传
|
||||
* @returns
|
||||
*/
|
||||
export function comment(data) {
|
||||
@@ -52,3 +54,60 @@ export function comment(data) {
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改评论状态
|
||||
* @param {*} { id, enable: boolean }
|
||||
* @param { enable: boolean } data 是否启用
|
||||
* @param { id: string } data 评论id
|
||||
* @returns
|
||||
*/
|
||||
export function commentStatus(data) {
|
||||
return request({
|
||||
url: 'management/api/rating/topicItemOperate/comment/toggle',
|
||||
method: 'post',
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 评论点赞
|
||||
* @param {*} { commentId, userId }
|
||||
* @returns
|
||||
*/
|
||||
export function commentLike(data) {
|
||||
return request({
|
||||
url: 'management/api/rating/topicItemOperate/comment/like',
|
||||
method: 'post',
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 审核话题
|
||||
* @param { topicId, itemmId, userId, status, type, rejectReason?, auditRemark? }
|
||||
* @param {*} status 2: 通过, 3: 拒绝 4: 禁用
|
||||
* @param {*} type topic topicItem
|
||||
* @param {*} rejectReason 拒绝原因
|
||||
* @param {*} auditRemark 审核备注
|
||||
* @returns
|
||||
*/
|
||||
export function reviewTopic(data) {
|
||||
return request({
|
||||
url: 'management/api/rating/topicItemOperate/audit',
|
||||
method: 'post',
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 审核日志列表
|
||||
* @param { pageNo, pageSize, topicId?, itemId?, userId? }
|
||||
*/
|
||||
export function getReviewLogList(data) {
|
||||
return request({
|
||||
url: 'management/api/rating/topicItemOperate/pending/history',
|
||||
method: 'get',
|
||||
params: data,
|
||||
})
|
||||
}
|
||||
|
||||
67
src/api/rating/topicRecommend.js
Normal file
67
src/api/rating/topicRecommend.js
Normal file
@@ -0,0 +1,67 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
/**
|
||||
* 获取话题推荐列表
|
||||
* @param {*} data
|
||||
* @returns
|
||||
*/
|
||||
export function getList(data) {
|
||||
return request({
|
||||
url: 'management/api/rating/topic_recommend/list',
|
||||
method: 'get',
|
||||
params: data,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加话题推荐
|
||||
* @param {{ topicId: string }} data
|
||||
* @returns
|
||||
*/
|
||||
export function doAdd(data) {
|
||||
return request({
|
||||
url: 'management/api/rating/topic_recommend',
|
||||
method: 'post',
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换话题推荐状态
|
||||
* @param {*} id
|
||||
* @param {*} enable
|
||||
* @returns
|
||||
*/
|
||||
export function toggleEnable(id, enable) {
|
||||
return request({
|
||||
url: `/management/api/rating/topic_recommend/toggle/${id}`,
|
||||
method: 'patch',
|
||||
data: { enable },
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 移动话题推荐
|
||||
* @param {*} id
|
||||
* @param {*} to
|
||||
* @returns
|
||||
*/
|
||||
export function moveTo(id, to) {
|
||||
return request({
|
||||
url: `/management/api/rating/topic_recommend/move_to/${id}`,
|
||||
method: 'patch',
|
||||
data: { to },
|
||||
})
|
||||
}
|
||||
/**
|
||||
* 编辑话题推荐
|
||||
* @param {*} id
|
||||
* @returns
|
||||
*/
|
||||
export function doEdit(id, data) {
|
||||
return request({
|
||||
url: `/management/api/rating/topic_recommend/${id}`,
|
||||
method: 'put',
|
||||
data,
|
||||
})
|
||||
}
|
||||
@@ -9,7 +9,7 @@ export function getList(data) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取机器人列表(基础信息) {appId, pageNo, pageSize, topicId, itemId}
|
||||
* 获取机器人列表(基础信息) {appId, pageNo, pageSize, topicId, itemId, commentId?, pkId?}
|
||||
* @param {*} data
|
||||
* @returns
|
||||
*/
|
||||
@@ -21,10 +21,10 @@ export function getListBase(data) {
|
||||
})
|
||||
}
|
||||
|
||||
export function generate(appId) {
|
||||
export function generate(appId, count) {
|
||||
return request({
|
||||
url: 'management/api/system/robot',
|
||||
method: 'post',
|
||||
data: { appId },
|
||||
data: { appId, count },
|
||||
})
|
||||
}
|
||||
|
||||
108
src/components/UserInfo/index.vue
Normal file
108
src/components/UserInfo/index.vue
Normal file
@@ -0,0 +1,108 @@
|
||||
<template>
|
||||
<div class="user-info-component">
|
||||
<div v-if="user" class="user-info-cell" :class="{ 'is-clickable': !user.isRobot }" @click="handleUserClick">
|
||||
<el-image v-if="user.avatar" class="user-avatar" :preview-src-list="[user.avatar]" :src="getThumbUrl(user.avatar)" @click.stop />
|
||||
<div v-else class="user-avatar-placeholder"><i class="el-icon-user" /></div>
|
||||
<div class="user-details">
|
||||
<div class="user-nickname" :class="{ 'hover-link': !user.isRobot }">
|
||||
{{ user.nickname || '未知用户' }}
|
||||
<el-tag v-if="user.isRobot" size="mini" style="margin-left: 4px" type="info">机器人</el-tag>
|
||||
<el-tag v-else size="mini" style="margin-left: 4px" type="success">真人</el-tag>
|
||||
</div>
|
||||
<div class="user-id">{{ user.id }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="user-details">
|
||||
<div class="user-id">{{ userId }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getThumbUrl } from '@/utils/blessing'
|
||||
|
||||
export default {
|
||||
name: 'UserInfo',
|
||||
props: {
|
||||
user: {
|
||||
type: Object,
|
||||
default: () => null,
|
||||
},
|
||||
userId: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
getThumbUrl,
|
||||
handleUserClick() {
|
||||
if (this.user && !this.user.isRobot) {
|
||||
// 跳转到用户页面
|
||||
this.$router.push({
|
||||
path: '/spring/user/user',
|
||||
query: { userId: this.user.id },
|
||||
})
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.user-info-component {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.user-info-cell {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.is-clickable {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.is-clickable:hover .hover-link {
|
||||
color: #409eff;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.user-avatar,
|
||||
.user-avatar-placeholder {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border-radius: 50%;
|
||||
margin-right: 12px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.user-avatar-placeholder {
|
||||
background-color: #f0f2f5;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #909399;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.user-details {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.user-nickname {
|
||||
font-weight: bold;
|
||||
color: #303133;
|
||||
margin-bottom: 4px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
transition: color 0.2s;
|
||||
}
|
||||
|
||||
.user-id {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
}
|
||||
</style>
|
||||
@@ -57,27 +57,111 @@ export const asyncRoutes = [
|
||||
children: [
|
||||
{
|
||||
path: 'topic',
|
||||
name: 'RatingTopicIndex',
|
||||
component: () => import('@/views/rating/topic/index'),
|
||||
meta: { title: '评分话题' },
|
||||
component: EmptyLayout,
|
||||
alwaysShow: true,
|
||||
redirect: 'noRedirect',
|
||||
name: 'TopicIndex',
|
||||
meta: {
|
||||
title: '评分话题',
|
||||
icon: 'clover',
|
||||
permissions: ['admin'],
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: 'recommend',
|
||||
name: 'RatingTopicRecommendIndex',
|
||||
component: () => import('@/views/rating/topicRecommend/index'),
|
||||
meta: { title: '话题推荐' },
|
||||
},
|
||||
{
|
||||
path: 'category',
|
||||
name: 'RatingTopicCategoryIndex',
|
||||
component: () => import('@/views/rating/topicCategory/index'),
|
||||
meta: { title: '评分话题分类' },
|
||||
},
|
||||
{
|
||||
path: 'list',
|
||||
name: 'RatingTopicIndex',
|
||||
component: () => import('@/views/rating/topic/index'),
|
||||
meta: { title: '评分话题' },
|
||||
},
|
||||
{
|
||||
path: 'item',
|
||||
name: 'RatingTopicItemIndex',
|
||||
component: () => import('@/views/rating/topicItem/index'),
|
||||
meta: { title: '评分项' },
|
||||
},
|
||||
{
|
||||
path: 'record',
|
||||
name: 'RatingTopicRecordIndex',
|
||||
component: () => import('@/views/rating/topicScoreRecord/index'),
|
||||
meta: { title: '用户评分记录' },
|
||||
},
|
||||
{
|
||||
path: 'comment',
|
||||
name: 'RatingTopicCommentIndex',
|
||||
component: () => import('@/views/rating/topicCommentRecord/index'),
|
||||
meta: { title: '用户评论记录' },
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: 'topic-item',
|
||||
name: 'RatingTopicItemIndex',
|
||||
component: () => import('@/views/rating/topicItem/index'),
|
||||
meta: { title: '评分项' },
|
||||
path: 'pk',
|
||||
component: EmptyLayout,
|
||||
alwaysShow: true,
|
||||
redirect: 'noRedirect',
|
||||
name: 'PkIndex',
|
||||
meta: {
|
||||
title: 'PK赛',
|
||||
icon: 'clover',
|
||||
permissions: ['admin'],
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: 'list',
|
||||
name: 'List',
|
||||
component: () => import('@/views/rating/pk/list/index'),
|
||||
meta: { title: 'PK赛列表', icon: 'setting' },
|
||||
},
|
||||
{
|
||||
path: 'pkComment',
|
||||
name: 'PkComment',
|
||||
component: () => import('@/views/rating/pk/comment/index'),
|
||||
meta: { title: 'pK赛评论', icon: 'setting' },
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
path: 'topic-record',
|
||||
name: 'RatingTopicRecordIndex',
|
||||
component: () => import('@/views/rating/topicScoreRecord/index'),
|
||||
meta: { title: '用户评分记录' },
|
||||
},
|
||||
{
|
||||
path: 'topic-comment',
|
||||
name: 'RatingTopicCommentIndex',
|
||||
component: () => import('@/views/rating/topicCommentRecord/index'),
|
||||
meta: { title: '用户评论记录' },
|
||||
path: '审核',
|
||||
component: EmptyLayout,
|
||||
alwaysShow: true,
|
||||
redirect: 'noRedirect',
|
||||
name: 'AuditIndex',
|
||||
meta: {
|
||||
title: '审核',
|
||||
icon: 'clover',
|
||||
permissions: ['admin'],
|
||||
},
|
||||
children: [
|
||||
{
|
||||
path: 'topic-review',
|
||||
name: 'RatingTopicReviewIndex',
|
||||
component: () => import('@/views/rating/topicReview/index'),
|
||||
meta: { title: '话题审核' },
|
||||
},
|
||||
{
|
||||
path: 'item-review',
|
||||
name: 'RatingTopicItemReviewIndex',
|
||||
component: () => import('@/views/rating/topicItemReview/index'),
|
||||
meta: { title: '评分项审核' },
|
||||
},
|
||||
{
|
||||
path: 'item-review-log',
|
||||
name: 'RatingTopicItemReviewLogIndex',
|
||||
component: () => import('@/views/rating/topicItemReviewLog/index'),
|
||||
meta: { title: '审核日志' },
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -27,6 +27,7 @@ export const eventTypeMap = {
|
||||
|
||||
export const appMap = {
|
||||
'69665538a49b8ae3be50fe5d': '新春祝福',
|
||||
'6a0d7dbe4c5de50f2ba66475': '夯拉评',
|
||||
}
|
||||
|
||||
export const userMap = {
|
||||
|
||||
176
src/views/rating/pk/comment/components/CommentReplyList.vue
Normal file
176
src/views/rating/pk/comment/components/CommentReplyList.vue
Normal file
@@ -0,0 +1,176 @@
|
||||
<template>
|
||||
<el-dialog :title="title" :visible.sync="dialogVisible" width="900px" @close="close">
|
||||
<el-table v-loading="listLoading" :data="list" :element-loading-text="elementLoadingText">
|
||||
<el-table-column align="center" fixed="left" label="操作" width="120">
|
||||
<template #default="{ row }">
|
||||
<el-button type="text" @click="handleLike(row)">点赞</el-button>
|
||||
<el-button type="text" @click="handleReply(row)">回复</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column align="left" label="回复内容" min-width="250">
|
||||
<template #default="{ row }">
|
||||
<div class="comment-content-cell">
|
||||
<div v-if="row.replyToUser" class="reply-target">回复 @{{ row.replyToUser.nickname || '未知用户' }}:</div>
|
||||
<div class="content-text">{{ row.content }}</div>
|
||||
<div class="comment-meta">
|
||||
<span class="meta-item">
|
||||
<i class="el-icon-thumb" />
|
||||
{{ row.likeCount || 0 }}
|
||||
</span>
|
||||
<el-tag v-if="row.status === 2" size="mini" style="margin-left: 8px" type="success">已展示</el-tag>
|
||||
<el-tag v-else size="mini" style="margin-left: 8px" type="info">隐藏/待审</el-tag>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column align="left" label="用户信息" min-width="180">
|
||||
<template #default="{ row }">
|
||||
<user-info :user="row.user" :user-id="row.userId" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column align="center" label="状态切换" width="80">
|
||||
<template #default="{ row }">
|
||||
<el-switch v-model="row.status" :active-value="2" :inactive-value="4" @change="handleToggleStatus(row)" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<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"
|
||||
/>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getCommentList, commentStatus } from '@/api/rating/pk'
|
||||
import { formatTime } from '@/utils'
|
||||
import { getThumbUrl } from '@/utils/blessing'
|
||||
import UserInfo from '@/components/UserInfo'
|
||||
|
||||
export default {
|
||||
name: 'CommentReplyList',
|
||||
components: { UserInfo },
|
||||
data() {
|
||||
return {
|
||||
title: '回复列表',
|
||||
dialogVisible: false,
|
||||
list: [],
|
||||
listLoading: false,
|
||||
layout: 'total, prev, pager, next',
|
||||
total: 0,
|
||||
elementLoadingText: '正在加载...',
|
||||
queryForm: {
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
rootCommentId: '',
|
||||
},
|
||||
parentRow: null,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
formatTime,
|
||||
getThumbUrl,
|
||||
show(row) {
|
||||
this.parentRow = row
|
||||
this.title = `回复列表`
|
||||
this.dialogVisible = true
|
||||
this.queryForm.rootCommentId = row.id
|
||||
this.queryForm.pageNo = 1
|
||||
this.fetchData()
|
||||
},
|
||||
close() {
|
||||
this.dialogVisible = false
|
||||
this.list = []
|
||||
},
|
||||
handleSizeChange(val) {
|
||||
this.queryForm.pageSize = val
|
||||
this.fetchData()
|
||||
},
|
||||
handleCurrentChange(val) {
|
||||
this.queryForm.pageNo = val
|
||||
this.fetchData()
|
||||
},
|
||||
async fetchData() {
|
||||
this.listLoading = true
|
||||
try {
|
||||
const { data } = await getCommentList(this.queryForm)
|
||||
this.list = data.list || []
|
||||
this.total = data.totalCount || 0
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
this.listLoading = false
|
||||
}
|
||||
},
|
||||
handleLike(row) {
|
||||
this.$emit('like', row)
|
||||
},
|
||||
handleReply(row) {
|
||||
// 传递当前行作为被回复对象,同时传递根评论ID
|
||||
this.$emit('reply', row, this.queryForm.rootCommentId)
|
||||
},
|
||||
async handleToggleStatus(row) {
|
||||
try {
|
||||
const enable = row.status === 2
|
||||
const { msg } = await commentStatus({ id: row.id, enable })
|
||||
this.$baseMessage(msg || '状态切换成功', 'success')
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
row.status = row.status === 2 ? 4 : 2
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.comment-content-cell {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.reply-target {
|
||||
font-size: 12px;
|
||||
color: #409eff;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.content-text {
|
||||
font-size: 14px;
|
||||
color: #303133;
|
||||
margin-bottom: 8px;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.comment-meta {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.meta-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-right: 12px;
|
||||
}
|
||||
|
||||
.meta-item i {
|
||||
margin-right: 4px;
|
||||
}
|
||||
</style>
|
||||
194
src/views/rating/pk/comment/components/PkCommentEdit.vue
Normal file
194
src/views/rating/pk/comment/components/PkCommentEdit.vue
Normal file
@@ -0,0 +1,194 @@
|
||||
<template>
|
||||
<el-dialog :title="title" :visible.sync="dialogFormVisible" width="600px" @close="close">
|
||||
<el-form ref="form" label-width="100px" :model="form" :rules="rules">
|
||||
<el-form-item label="参与机器人" prop="userId">
|
||||
<el-select v-model="form.userId" v-loadmore="loadMoreRobots" filterable placeholder="请选择参与评论的机器人" style="width: 100%">
|
||||
<el-option v-for="item in robotList" :key="item.id" :label="item.nickname || item.id" :value="item.id">
|
||||
<div style="display: flex; align-items: center">
|
||||
<el-image
|
||||
v-if="item.avatar"
|
||||
:src="getThumbUrl(item.avatar)"
|
||||
style="width: 24px; height: 24px; border-radius: 50%; margin-right: 10px"
|
||||
/>
|
||||
<span>{{ item.nickname || '未知用户' }}</span>
|
||||
</div>
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item v-if="!isReply" label="PK赛" prop="pkId">
|
||||
<el-select v-model="form.pkId" v-loadmore="loadMorePks" filterable placeholder="请选择PK赛" style="width: 100%">
|
||||
<el-option v-for="item in pkList" :key="item.id" :label="getPkLabel(item)" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="评论内容" prop="content">
|
||||
<el-input v-model="form.content" maxlength="500" :placeholder="contentPlaceholder" :rows="4" show-word-limit type="textarea" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="close">取 消</el-button>
|
||||
<el-button :loading="saving" type="primary" @click="save">确 定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getListBase as getRobotList } from '@/api/system/robot'
|
||||
import { getList as getPkList, comment } from '@/api/rating/pk'
|
||||
import { getThumbUrl } from '@/utils/blessing'
|
||||
|
||||
export default {
|
||||
name: 'PkCommentEdit',
|
||||
directives: {
|
||||
loadmore: {
|
||||
bind(el, binding) {
|
||||
setTimeout(() => {
|
||||
const SELECTWRAP_DOM = el.querySelector('.el-select-dropdown .el-select-dropdown__wrap')
|
||||
if (SELECTWRAP_DOM) {
|
||||
SELECTWRAP_DOM.addEventListener('scroll', function () {
|
||||
const condition = this.scrollHeight - this.scrollTop <= this.clientHeight + 2
|
||||
if (condition) {
|
||||
binding.value()
|
||||
}
|
||||
})
|
||||
}
|
||||
}, 0)
|
||||
},
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
title: '立即评论',
|
||||
dialogFormVisible: false,
|
||||
saving: false,
|
||||
isReply: false,
|
||||
contentPlaceholder: '请输入您的评论文字',
|
||||
form: {
|
||||
userId: '',
|
||||
pkId: '',
|
||||
content: '',
|
||||
parentCommentId: '',
|
||||
replyToCommentId: '',
|
||||
},
|
||||
rules: {
|
||||
userId: [{ required: true, trigger: 'change', message: '请选择机器人' }],
|
||||
pkId: [{ required: true, trigger: 'change', message: '请选择PK赛' }],
|
||||
content: [{ required: true, trigger: 'blur', message: '请输入评论内容' }],
|
||||
},
|
||||
|
||||
// 机器人列表
|
||||
robotList: [],
|
||||
robotQuery: { pageNo: 1, pageSize: 20, appId: '6a0d7dbe4c5de50f2ba66475' },
|
||||
robotTotal: 0,
|
||||
fetchingRobots: false,
|
||||
|
||||
// PK列表
|
||||
pkList: [],
|
||||
pkQuery: { pageNo: 1, pageSize: 20 },
|
||||
pkTotal: 0,
|
||||
fetchingPks: false,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getThumbUrl,
|
||||
getPkLabel(item) {
|
||||
if (!item) return ''
|
||||
const left = item.leftItemName ? item.leftItemName : '未知'
|
||||
const right = item.rightItemName ? item.rightItemName : '未知'
|
||||
return `[${item.topicTitle ? item.topicTitle : '未知主题'}] ${left} vs ${right}`
|
||||
},
|
||||
showEdit(replyToRow = null, parentCommentId = null) {
|
||||
this.dialogFormVisible = true
|
||||
this.form = this.$options.data().form
|
||||
|
||||
if (replyToRow) {
|
||||
this.isReply = true
|
||||
this.title = '回复评论'
|
||||
this.contentPlaceholder = `回复 @${replyToRow.user ? replyToRow.user.nickname : '未知用户'}:`
|
||||
this.form.pkId = replyToRow.pkId
|
||||
this.form.parentCommentId = parentCommentId || replyToRow.id
|
||||
this.form.replyToCommentId = replyToRow.id
|
||||
} else {
|
||||
this.isReply = false
|
||||
this.title = '立即评论'
|
||||
this.contentPlaceholder = '请输入您的评论文字'
|
||||
this.pkList = []
|
||||
this.pkQuery.pageNo = 1
|
||||
this.pkTotal = 0
|
||||
this.fetchPkList()
|
||||
}
|
||||
|
||||
this.robotList = []
|
||||
this.robotQuery.pageNo = 1
|
||||
this.robotTotal = 0
|
||||
this.fetchRobotList()
|
||||
},
|
||||
close() {
|
||||
this.$refs['form'].resetFields()
|
||||
this.dialogFormVisible = false
|
||||
},
|
||||
|
||||
// -- 机器人列表加载 --
|
||||
async fetchRobotList() {
|
||||
if (this.fetchingRobots) return
|
||||
this.fetchingRobots = true
|
||||
try {
|
||||
const { data } = await getRobotList(this.robotQuery)
|
||||
this.robotList = this.robotList.concat(data.list || [])
|
||||
this.robotTotal = data.totalCount || 0
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
this.fetchingRobots = false
|
||||
}
|
||||
},
|
||||
loadMoreRobots() {
|
||||
if (this.robotList.length >= this.robotTotal || this.fetchingRobots) return
|
||||
this.robotQuery.pageNo += 1
|
||||
this.fetchRobotList()
|
||||
},
|
||||
|
||||
// -- PK 列表加载 --
|
||||
async fetchPkList() {
|
||||
if (this.fetchingPks) return
|
||||
this.fetchingPks = true
|
||||
try {
|
||||
const { data } = await getPkList(this.pkQuery)
|
||||
this.pkList = this.pkList.concat(data.list || [])
|
||||
this.pkTotal = data.totalCount || 0
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
this.fetchingPks = false
|
||||
}
|
||||
},
|
||||
loadMorePks() {
|
||||
if (this.pkList.length >= this.pkTotal || this.fetchingPks) return
|
||||
this.pkQuery.pageNo += 1
|
||||
this.fetchPkList()
|
||||
},
|
||||
|
||||
save() {
|
||||
this.$refs['form'].validate(async (valid) => {
|
||||
if (valid) {
|
||||
this.saving = true
|
||||
try {
|
||||
const { msg } = await comment(this.form)
|
||||
this.$baseMessage(msg || (this.isReply ? '回复成功' : '评论成功'), 'success')
|
||||
this.close()
|
||||
this.$emit('fetch-data')
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
this.saving = false
|
||||
}
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
134
src/views/rating/pk/comment/components/PkCommentLikeEdit.vue
Normal file
134
src/views/rating/pk/comment/components/PkCommentLikeEdit.vue
Normal file
@@ -0,0 +1,134 @@
|
||||
<template>
|
||||
<el-dialog :title="title" :visible.sync="dialogFormVisible" width="500px" @close="close">
|
||||
<el-form ref="form" label-width="80px" :model="form" :rules="rules">
|
||||
<el-form-item label="点赞用户" prop="userId">
|
||||
<el-select v-model="form.userId" v-loadmore="loadMoreRobots" filterable placeholder="请选择执行点赞的机器人" style="width: 100%">
|
||||
<el-option v-for="item in robotList" :key="item.id" :label="item.nickname || item.id" :value="item.id">
|
||||
<div style="display: flex; align-items: center">
|
||||
<el-image
|
||||
v-if="item.avatar"
|
||||
:src="getThumbUrl(item.avatar)"
|
||||
style="width: 24px; height: 24px; border-radius: 50%; margin-right: 10px"
|
||||
/>
|
||||
<span>{{ item.nickname || '未知用户' }}</span>
|
||||
</div>
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="close">取 消</el-button>
|
||||
<el-button :loading="saving" type="primary" @click="save">确 定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getListBase as getRobotList } from '@/api/system/robot'
|
||||
import { like } from '@/api/rating/pk'
|
||||
import { getThumbUrl } from '@/utils/blessing'
|
||||
|
||||
export default {
|
||||
name: 'PkCommentLikeEdit',
|
||||
directives: {
|
||||
loadmore: {
|
||||
bind(el, binding) {
|
||||
setTimeout(() => {
|
||||
const SELECTWRAP_DOM = el.querySelector('.el-select-dropdown .el-select-dropdown__wrap')
|
||||
if (SELECTWRAP_DOM) {
|
||||
SELECTWRAP_DOM.addEventListener('scroll', function () {
|
||||
const condition = this.scrollHeight - this.scrollTop <= this.clientHeight + 2
|
||||
if (condition) {
|
||||
binding.value()
|
||||
}
|
||||
})
|
||||
}
|
||||
}, 0)
|
||||
},
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
title: '选择机器人点赞',
|
||||
dialogFormVisible: false,
|
||||
saving: false,
|
||||
form: {
|
||||
commentId: '',
|
||||
userId: '',
|
||||
},
|
||||
rules: {
|
||||
userId: [{ required: true, trigger: 'change', message: '请选择执行点赞的机器人' }],
|
||||
},
|
||||
|
||||
// 机器人下拉列表状态
|
||||
robotList: [],
|
||||
robotQuery: {
|
||||
appId: '6a0d7dbe4c5de50f2ba66475',
|
||||
pageNo: 1,
|
||||
pageSize: 20,
|
||||
commentId: '',
|
||||
},
|
||||
robotTotal: 0,
|
||||
fetchingRobots: false,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getThumbUrl,
|
||||
showEdit(row) {
|
||||
this.title = '选择机器人点赞'
|
||||
this.dialogFormVisible = true
|
||||
this.form = this.$options.data().form
|
||||
this.form.commentId = row.id
|
||||
|
||||
// 重置列表并加载第一页
|
||||
this.robotList = []
|
||||
this.robotQuery.pageNo = 1
|
||||
this.robotQuery.commentId = row.id
|
||||
this.robotTotal = 0
|
||||
this.fetchRobotList()
|
||||
},
|
||||
close() {
|
||||
this.$refs['form'].resetFields()
|
||||
this.dialogFormVisible = false
|
||||
},
|
||||
async fetchRobotList() {
|
||||
if (this.fetchingRobots) return
|
||||
this.fetchingRobots = true
|
||||
try {
|
||||
const { data } = await getRobotList(this.robotQuery)
|
||||
this.robotList = this.robotList.concat(data.list || [])
|
||||
this.robotTotal = data.totalCount || 0
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
this.fetchingRobots = false
|
||||
}
|
||||
},
|
||||
loadMoreRobots() {
|
||||
if (this.robotList.length >= this.robotTotal || this.fetchingRobots) return
|
||||
this.robotQuery.pageNo += 1
|
||||
this.fetchRobotList()
|
||||
},
|
||||
save() {
|
||||
this.$refs['form'].validate(async (valid) => {
|
||||
if (valid) {
|
||||
this.saving = true
|
||||
try {
|
||||
const { msg } = await like(this.form)
|
||||
this.$baseMessage(msg || '点赞成功', 'success')
|
||||
this.close()
|
||||
this.$emit('fetch-data')
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
this.saving = false
|
||||
}
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
317
src/views/rating/pk/comment/index.vue
Normal file
317
src/views/rating/pk/comment/index.vue
Normal file
@@ -0,0 +1,317 @@
|
||||
<template>
|
||||
<div class="rating-pk-comment-container">
|
||||
<vab-query-form>
|
||||
<vab-query-form-left-panel :span="24">
|
||||
<el-form :inline="true" :model="queryForm" @submit.native.prevent>
|
||||
<el-form-item>
|
||||
<el-select
|
||||
v-model="queryForm.pkId"
|
||||
v-loadmore="loadMorePks"
|
||||
clearable
|
||||
filterable
|
||||
placeholder="请选择PK赛"
|
||||
style="width: 250px"
|
||||
@change="handleFilterChange"
|
||||
>
|
||||
<el-option v-for="item in pkList" :key="item.id" :label="getPkLabel(item)" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<el-select v-model="queryForm.status" clearable placeholder="评论状态" @change="handleFilterChange">
|
||||
<el-option label="待审/隐藏" :value="1" />
|
||||
<el-option label="已展示" :value="2" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item>
|
||||
<el-button icon="el-icon-search" type="primary" @click="queryData">查询</el-button>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button icon="el-icon-edit" type="success" @click="handleCommentNow">立即评论</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</vab-query-form-left-panel>
|
||||
</vab-query-form>
|
||||
|
||||
<el-table v-loading="listLoading" :data="list" :element-loading-text="elementLoadingText">
|
||||
<el-table-column align="center" fixed="left" label="操作" width="160">
|
||||
<template #default="{ row }">
|
||||
<el-button type="text" @click="handleLike(row)">点赞</el-button>
|
||||
<el-button type="text" @click="handleReply(row)">回复</el-button>
|
||||
<el-button v-if="row.replyCount > 0" type="text" @click="handleViewReplies(row)">查看回复</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column align="left" label="评论内容" min-width="250">
|
||||
<template #default="{ row }">
|
||||
<div class="comment-content-cell">
|
||||
<div class="content-text">{{ row.content }}</div>
|
||||
<div class="comment-meta">
|
||||
<span class="meta-item">
|
||||
<i class="el-icon-thumb" />
|
||||
{{ row.likeCount || 0 }}
|
||||
</span>
|
||||
<span class="meta-item">
|
||||
<i class="el-icon-chat-dot-square" />
|
||||
{{ row.replyCount || 0 }}
|
||||
</span>
|
||||
<el-tag v-if="row.status === 2" size="mini" style="margin-left: 8px" type="success">已展示</el-tag>
|
||||
<el-tag v-else size="mini" style="margin-left: 8px" type="info">隐藏/待审</el-tag>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column align="left" label="PK赛目标" min-width="250">
|
||||
<template #default="{ row }">
|
||||
<div v-if="row.leftItemName && row.rightItemName" class="target-info-cell">
|
||||
<div class="topic-title">[{{ row.topicTitle ? row.topicTitle : '未知主题' }}]</div>
|
||||
<div class="item-info">
|
||||
<span>{{ row.leftItemName ? row.leftItemName : '未知123' }}</span>
|
||||
<span style="margin: 0 8px; color: #f56c6c; font-weight: bold">VS</span>
|
||||
<span>{{ row.rightItemName ? row.rightItemName : '未知123' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else>{{ row.pkId }}</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column align="left" label="用户信息" min-width="200">
|
||||
<template #default="{ row }">
|
||||
<user-info :user="row.user" :user-id="row.userId" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column align="center" label="状态切换" width="100">
|
||||
<template #default="{ row }">
|
||||
<el-switch v-model="row.status" :active-value="2" :inactive-value="4" @change="handleToggleStatus(row)" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<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"
|
||||
/>
|
||||
|
||||
<pk-comment-edit ref="commentEdit" @fetch-data="fetchData" />
|
||||
<pk-comment-like-edit ref="likeEdit" @fetch-data="fetchData" />
|
||||
<comment-reply-list ref="replyList" @like="handleLikeFromList" @reply="handleReplyFromList" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getCommentList, commentStatus, getList as getPkList } from '@/api/rating/pk'
|
||||
import { formatTime } from '@/utils'
|
||||
import { getThumbUrl } from '@/utils/blessing'
|
||||
import UserInfo from '@/components/UserInfo'
|
||||
import PkCommentEdit from './components/PkCommentEdit'
|
||||
import PkCommentLikeEdit from './components/PkCommentLikeEdit'
|
||||
import CommentReplyList from './components/CommentReplyList'
|
||||
|
||||
export default {
|
||||
name: 'PkComment',
|
||||
components: { PkCommentEdit, PkCommentLikeEdit, CommentReplyList, UserInfo },
|
||||
directives: {
|
||||
loadmore: {
|
||||
bind(el, binding) {
|
||||
setTimeout(() => {
|
||||
const SELECTWRAP_DOM = el.querySelector('.el-select-dropdown .el-select-dropdown__wrap')
|
||||
if (SELECTWRAP_DOM) {
|
||||
SELECTWRAP_DOM.addEventListener('scroll', function () {
|
||||
const condition = this.scrollHeight - this.scrollTop <= this.clientHeight + 2
|
||||
if (condition) {
|
||||
binding.value()
|
||||
}
|
||||
})
|
||||
}
|
||||
}, 0)
|
||||
},
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
list: [],
|
||||
listLoading: true,
|
||||
layout: 'total, sizes, prev, pager, next, jumper',
|
||||
total: 0,
|
||||
elementLoadingText: '正在加载...',
|
||||
queryForm: {
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
pkId: '',
|
||||
status: '',
|
||||
},
|
||||
|
||||
// PK下拉列表状态
|
||||
pkList: [],
|
||||
pkQuery: { pageNo: 1, pageSize: 20 },
|
||||
pkTotal: 0,
|
||||
fetchingPks: false,
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.fetchPkList()
|
||||
this.fetchData()
|
||||
},
|
||||
methods: {
|
||||
formatTime,
|
||||
getThumbUrl,
|
||||
getPkLabel(item) {
|
||||
if (!item) return ''
|
||||
const left = item.leftItemName ? item.leftItemName : '未知'
|
||||
const right = item.rightItemName ? item.rightItemName : '未知'
|
||||
return `[${item.topicTitle ? item.topicTitle : '未知主题'}] ${left} vs ${right}`
|
||||
},
|
||||
|
||||
// -- PK 列表加载 --
|
||||
async fetchPkList() {
|
||||
if (this.fetchingPks) return
|
||||
this.fetchingPks = true
|
||||
try {
|
||||
const { data } = await getPkList(this.pkQuery)
|
||||
this.pkList = this.pkList.concat(data.list || [])
|
||||
this.pkTotal = data.totalCount || 0
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
this.fetchingPks = false
|
||||
}
|
||||
},
|
||||
loadMorePks() {
|
||||
if (this.pkList.length >= this.pkTotal || this.fetchingPks) return
|
||||
this.pkQuery.pageNo += 1
|
||||
this.fetchPkList()
|
||||
},
|
||||
|
||||
handleFilterChange() {
|
||||
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() {
|
||||
this.listLoading = true
|
||||
try {
|
||||
const params = { ...this.queryForm }
|
||||
if (params.pkId === '') delete params.pkId
|
||||
if (params.status === '') delete params.status
|
||||
|
||||
const { data } = await getCommentList(params)
|
||||
this.list = data.list || []
|
||||
this.total = data.totalCount || 0
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
this.listLoading = false
|
||||
}
|
||||
},
|
||||
handleCommentNow() {
|
||||
this.$refs['commentEdit'].showEdit()
|
||||
},
|
||||
handleLike(row) {
|
||||
this.$refs['likeEdit'].showEdit(row)
|
||||
},
|
||||
handleReply(row) {
|
||||
this.$refs['commentEdit'].showEdit(row)
|
||||
},
|
||||
handleViewReplies(row) {
|
||||
this.$refs['replyList'].show(row)
|
||||
},
|
||||
async handleToggleStatus(row) {
|
||||
try {
|
||||
// status: 2为启用,4为禁用
|
||||
const enable = row.status === 2
|
||||
const { msg } = await commentStatus({ id: row.id, enable })
|
||||
this.$baseMessage(msg || '状态切换成功', 'success')
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
row.status = row.status === 2 ? 4 : 2
|
||||
}
|
||||
},
|
||||
|
||||
// 子组件触发的方法
|
||||
handleReplyFromList(row, parentCommentId) {
|
||||
this.$refs['commentEdit'].showEdit(row, parentCommentId)
|
||||
},
|
||||
handleLikeFromList(row) {
|
||||
this.$refs['likeEdit'].showEdit(row)
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.rating-pk-comment-container {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.comment-content-cell {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.content-text {
|
||||
font-size: 14px;
|
||||
color: #303133;
|
||||
margin-bottom: 8px;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.comment-meta {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.meta-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-right: 12px;
|
||||
}
|
||||
|
||||
.meta-item i {
|
||||
margin-right: 4px;
|
||||
}
|
||||
|
||||
.target-info-cell {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.topic-title {
|
||||
font-size: 13px;
|
||||
color: #909399;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.item-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-weight: bold;
|
||||
color: #303133;
|
||||
}
|
||||
</style>
|
||||
210
src/views/rating/pk/list/components/PkGenerate.vue
Normal file
210
src/views/rating/pk/list/components/PkGenerate.vue
Normal file
@@ -0,0 +1,210 @@
|
||||
<template>
|
||||
<el-dialog :title="title" :visible.sync="dialogFormVisible" width="600px" @close="close">
|
||||
<el-form ref="form" label-width="100px" :model="form" :rules="rules">
|
||||
<el-form-item label="评价主题" prop="topicId">
|
||||
<el-select
|
||||
v-model="form.topicId"
|
||||
v-loadmore="loadMoreTopics"
|
||||
filterable
|
||||
placeholder="请选择评价主题"
|
||||
style="width: 100%"
|
||||
@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-item label="评价项" prop="itemIds">
|
||||
<el-select
|
||||
v-model="form.itemIds"
|
||||
v-loadmore="loadMoreItems"
|
||||
:disabled="!form.topicId"
|
||||
filterable
|
||||
multiple
|
||||
:multiple-limit="2"
|
||||
placeholder="请选择两个评价项进行PK"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option v-for="item in itemList" :key="item.id" :label="item.name" :value="item.id">
|
||||
<div style="display: flex; align-items: center">
|
||||
<el-image
|
||||
v-if="item.avatarUrl"
|
||||
:src="getThumbUrl(item.avatarUrl)"
|
||||
style="width: 24px; height: 24px; border-radius: 50%; margin-right: 10px"
|
||||
/>
|
||||
<span>{{ item.name }}</span>
|
||||
</div>
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="close">取 消</el-button>
|
||||
<el-button :loading="saving" type="primary" @click="save">确 定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getList as getTopicList } from '@/api/rating/topic'
|
||||
import { getList as getItemList } from '@/api/rating/topicItem'
|
||||
import { generate } from '@/api/rating/pk'
|
||||
import { getThumbUrl } from '@/utils/blessing'
|
||||
|
||||
export default {
|
||||
name: 'PkGenerate',
|
||||
directives: {
|
||||
loadmore: {
|
||||
bind(el, binding) {
|
||||
setTimeout(() => {
|
||||
const SELECTWRAP_DOM = el.querySelector('.el-select-dropdown .el-select-dropdown__wrap')
|
||||
if (SELECTWRAP_DOM) {
|
||||
SELECTWRAP_DOM.addEventListener('scroll', function () {
|
||||
const condition = this.scrollHeight - this.scrollTop <= this.clientHeight + 2
|
||||
if (condition) {
|
||||
binding.value()
|
||||
}
|
||||
})
|
||||
}
|
||||
}, 0)
|
||||
},
|
||||
},
|
||||
},
|
||||
data() {
|
||||
const validateItemIds = (rule, value, callback) => {
|
||||
if (!value || value.length !== 2) {
|
||||
callback(new Error('请必须选择两个评价项进行PK'))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
return {
|
||||
title: '生成PK赛',
|
||||
dialogFormVisible: false,
|
||||
saving: false,
|
||||
form: {
|
||||
topicId: '',
|
||||
itemIds: [],
|
||||
},
|
||||
rules: {
|
||||
topicId: [{ required: true, trigger: 'change', message: '请选择评价主题' }],
|
||||
itemIds: [{ required: true, trigger: 'change', validator: validateItemIds }],
|
||||
},
|
||||
topicList: [],
|
||||
topicQuery: {
|
||||
pageNo: 1,
|
||||
pageSize: 20,
|
||||
},
|
||||
topicTotal: 0,
|
||||
fetchingTopics: false,
|
||||
|
||||
itemList: [],
|
||||
itemQuery: {
|
||||
pageNo: 1,
|
||||
pageSize: 20,
|
||||
topicId: '',
|
||||
},
|
||||
itemTotal: 0,
|
||||
fetchingItems: false,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getThumbUrl,
|
||||
showEdit() {
|
||||
this.title = '生成PK赛'
|
||||
this.form = this.$options.data().form
|
||||
this.dialogFormVisible = true
|
||||
|
||||
this.topicQuery.pageNo = 1
|
||||
this.topicList = []
|
||||
this.topicTotal = 0
|
||||
this.fetchTopicList()
|
||||
},
|
||||
close() {
|
||||
this.$refs['form'].resetFields()
|
||||
this.form = this.$options.data().form
|
||||
this.itemList = []
|
||||
this.dialogFormVisible = false
|
||||
},
|
||||
// -- Topic 列表加载 --
|
||||
async fetchTopicList() {
|
||||
if (this.fetchingTopics) return
|
||||
this.fetchingTopics = true
|
||||
try {
|
||||
const { data } = await getTopicList(this.topicQuery)
|
||||
this.topicList = this.topicList.concat(data.list || [])
|
||||
this.topicTotal = data.totalCount || 0
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
this.fetchingTopics = false
|
||||
}
|
||||
},
|
||||
loadMoreTopics() {
|
||||
if (this.topicList.length >= this.topicTotal || this.fetchingTopics) return
|
||||
this.topicQuery.pageNo += 1
|
||||
this.fetchTopicList()
|
||||
},
|
||||
|
||||
// -- Item 列表加载 --
|
||||
async fetchItemList() {
|
||||
if (this.fetchingItems || !this.itemQuery.topicId) return
|
||||
this.fetchingItems = true
|
||||
try {
|
||||
const { data } = await getItemList(this.itemQuery)
|
||||
this.itemList = this.itemList.concat(data.list || [])
|
||||
this.itemTotal = data.totalCount || 0
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
this.fetchingItems = false
|
||||
}
|
||||
},
|
||||
loadMoreItems() {
|
||||
if (this.itemList.length >= this.itemTotal || this.fetchingItems) return
|
||||
this.itemQuery.pageNo += 1
|
||||
this.fetchItemList()
|
||||
},
|
||||
|
||||
handleTopicChange(val) {
|
||||
this.form.itemIds = []
|
||||
this.itemList = []
|
||||
this.itemQuery.pageNo = 1
|
||||
this.itemTotal = 0
|
||||
|
||||
if (val) {
|
||||
this.itemQuery.topicId = val
|
||||
this.fetchItemList()
|
||||
} else {
|
||||
this.itemQuery.topicId = ''
|
||||
}
|
||||
},
|
||||
|
||||
save() {
|
||||
this.$refs['form'].validate(async (valid) => {
|
||||
if (valid) {
|
||||
this.saving = true
|
||||
try {
|
||||
const payload = {
|
||||
topicId: this.form.topicId,
|
||||
leftItemId: this.form.itemIds[0],
|
||||
rightItemId: this.form.itemIds[1],
|
||||
}
|
||||
const { msg } = await generate(payload)
|
||||
this.$baseMessage(msg || '生成PK赛成功', 'success')
|
||||
this.close()
|
||||
this.$emit('fetch-data')
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
this.saving = false
|
||||
}
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
84
src/views/rating/pk/list/components/PkParticipantList.vue
Normal file
84
src/views/rating/pk/list/components/PkParticipantList.vue
Normal file
@@ -0,0 +1,84 @@
|
||||
<template>
|
||||
<el-dialog :title="title" :visible.sync="dialogVisible" width="500px" @close="close">
|
||||
<el-table v-loading="listLoading" :data="list" :element-loading-text="elementLoadingText">
|
||||
<el-table-column align="left" label="投票用户" min-width="150">
|
||||
<template #default="{ row }">
|
||||
<user-info :user="row" :user-id="row.id" />
|
||||
</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"
|
||||
/>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getParticipantList } from '@/api/rating/pk'
|
||||
import { getThumbUrl } from '@/utils/blessing'
|
||||
import UserInfo from '@/components/UserInfo'
|
||||
|
||||
export default {
|
||||
name: 'PkParticipantList',
|
||||
components: { UserInfo },
|
||||
data() {
|
||||
return {
|
||||
title: '投票用户列表',
|
||||
dialogVisible: false,
|
||||
list: [],
|
||||
listLoading: false,
|
||||
layout: 'total, prev, pager, next',
|
||||
total: 0,
|
||||
elementLoadingText: '正在加载...',
|
||||
queryForm: {
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
pkId: '',
|
||||
chooseItemId: '',
|
||||
},
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getThumbUrl,
|
||||
show(pkId, chooseItemId, titlePrefix) {
|
||||
this.title = `${titlePrefix}的投票用户`
|
||||
this.queryForm.pkId = pkId
|
||||
this.queryForm.chooseItemId = chooseItemId
|
||||
this.queryForm.pageNo = 1
|
||||
this.dialogVisible = true
|
||||
this.fetchData()
|
||||
},
|
||||
close() {
|
||||
this.dialogVisible = false
|
||||
this.list = []
|
||||
},
|
||||
handleSizeChange(val) {
|
||||
this.queryForm.pageSize = val
|
||||
this.fetchData()
|
||||
},
|
||||
handleCurrentChange(val) {
|
||||
this.queryForm.pageNo = val
|
||||
this.fetchData()
|
||||
},
|
||||
async fetchData() {
|
||||
this.listLoading = true
|
||||
try {
|
||||
const { data } = await getParticipantList(this.queryForm)
|
||||
this.list = data.list || []
|
||||
this.total = data.totalCount || 0
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
this.listLoading = false
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
168
src/views/rating/pk/list/components/PkVoteEdit.vue
Normal file
168
src/views/rating/pk/list/components/PkVoteEdit.vue
Normal file
@@ -0,0 +1,168 @@
|
||||
<template>
|
||||
<el-dialog :title="title" :visible.sync="dialogFormVisible" width="500px" @close="close">
|
||||
<el-form ref="form" label-width="80px" :model="form" :rules="rules">
|
||||
<el-form-item label="支持项">
|
||||
<span style="font-weight: bold; color: #409eff">{{ targetName }}</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="支持方式" prop="voteMode">
|
||||
<el-radio-group v-model="form.voteMode">
|
||||
<el-radio label="user">投票用户</el-radio>
|
||||
<el-radio label="count">支持个数</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item v-if="form.voteMode === 'user'" label="投票用户" prop="userId">
|
||||
<el-select v-model="form.userId" v-loadmore="loadMoreRobots" filterable placeholder="请选择投票的机器人" style="width: 100%">
|
||||
<el-option v-for="item in robotList" :key="item.id" :label="item.nickname || item.id" :value="item.id">
|
||||
<div style="display: flex; align-items: center">
|
||||
<el-image
|
||||
v-if="item.avatar"
|
||||
:src="getThumbUrl(item.avatar)"
|
||||
style="width: 24px; height: 24px; border-radius: 50%; margin-right: 10px"
|
||||
/>
|
||||
<span>{{ item.nickname || '未知用户' }}</span>
|
||||
</div>
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item v-if="form.voteMode === 'count'" label="支持个数" prop="count">
|
||||
<el-input-number v-model="form.count" controls-position="right" :max="100000" :min="1" :step="1" style="width: 100%" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="close">取 消</el-button>
|
||||
<el-button :loading="saving" type="primary" @click="save">确 定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getListBase as getRobotList } from '@/api/system/robot'
|
||||
import { vote } from '@/api/rating/pk'
|
||||
import { getThumbUrl } from '@/utils/blessing'
|
||||
|
||||
export default {
|
||||
name: 'PkVoteEdit',
|
||||
directives: {
|
||||
loadmore: {
|
||||
bind(el, binding) {
|
||||
setTimeout(() => {
|
||||
const SELECTWRAP_DOM = el.querySelector('.el-select-dropdown .el-select-dropdown__wrap')
|
||||
if (SELECTWRAP_DOM) {
|
||||
SELECTWRAP_DOM.addEventListener('scroll', function () {
|
||||
const condition = this.scrollHeight - this.scrollTop <= this.clientHeight + 2
|
||||
if (condition) {
|
||||
binding.value()
|
||||
}
|
||||
})
|
||||
}
|
||||
}, 0)
|
||||
},
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
title: '参与投票',
|
||||
dialogFormVisible: false,
|
||||
saving: false,
|
||||
targetName: '',
|
||||
form: {
|
||||
pkId: '',
|
||||
itemId: '',
|
||||
voteMode: 'user',
|
||||
userId: '',
|
||||
count: 1,
|
||||
},
|
||||
rules: {
|
||||
voteMode: [{ required: true, trigger: 'change', message: '请选择支持方式' }],
|
||||
},
|
||||
|
||||
// 机器人下拉列表状态
|
||||
robotList: [],
|
||||
robotQuery: {
|
||||
appId: '6a0d7dbe4c5de50f2ba66475',
|
||||
pageNo: 1,
|
||||
pageSize: 20,
|
||||
},
|
||||
robotTotal: 0,
|
||||
fetchingRobots: false,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getThumbUrl,
|
||||
showEdit(pkId, itemId, itemName) {
|
||||
this.dialogFormVisible = true
|
||||
this.targetName = itemName
|
||||
this.form = this.$options.data().form
|
||||
this.form.pkId = pkId
|
||||
this.form.itemId = itemId
|
||||
|
||||
// 重置列表并加载第一页
|
||||
this.robotList = []
|
||||
this.robotQuery.pageNo = 1
|
||||
this.robotTotal = 0
|
||||
this.fetchRobotList()
|
||||
},
|
||||
close() {
|
||||
this.$refs['form'].resetFields()
|
||||
this.dialogFormVisible = false
|
||||
},
|
||||
async fetchRobotList() {
|
||||
if (this.fetchingRobots) return
|
||||
this.fetchingRobots = true
|
||||
try {
|
||||
const { data } = await getRobotList(this.robotQuery)
|
||||
this.robotList = this.robotList.concat(data.list || [])
|
||||
this.robotTotal = data.totalCount || 0
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
this.fetchingRobots = false
|
||||
}
|
||||
},
|
||||
loadMoreRobots() {
|
||||
if (this.robotList.length >= this.robotTotal || this.fetchingRobots) return
|
||||
this.robotQuery.pageNo += 1
|
||||
this.fetchRobotList()
|
||||
},
|
||||
save() {
|
||||
this.$refs['form'].validate(async (valid) => {
|
||||
if (valid) {
|
||||
if (this.form.voteMode === 'user' && !this.form.userId) {
|
||||
this.$baseMessage('请选择投票的机器人', 'error')
|
||||
return false
|
||||
}
|
||||
if (this.form.voteMode === 'count' && (!this.form.count || this.form.count < 1)) {
|
||||
this.$baseMessage('请输入正确的支持个数', 'error')
|
||||
return false
|
||||
}
|
||||
this.saving = true
|
||||
try {
|
||||
const params = {
|
||||
pkId: this.form.pkId,
|
||||
itemId: this.form.itemId,
|
||||
}
|
||||
if (this.form.voteMode === 'user') {
|
||||
params.userId = this.form.userId
|
||||
} else {
|
||||
params.count = this.form.count
|
||||
}
|
||||
const { msg } = await vote(params)
|
||||
this.$baseMessage(msg || '投票成功', 'success')
|
||||
this.close()
|
||||
this.$emit('fetch-data')
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
this.saving = false
|
||||
}
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
495
src/views/rating/pk/list/index.vue
Normal file
495
src/views/rating/pk/list/index.vue
Normal file
@@ -0,0 +1,495 @@
|
||||
<template>
|
||||
<div class="rating-pk-list-container">
|
||||
<vab-query-form>
|
||||
<vab-query-form-left-panel :span="12">
|
||||
<el-button icon="el-icon-magic-stick" type="primary" @click="handleGenerate">生成PK</el-button>
|
||||
</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.topicId"
|
||||
v-loadmore="loadMoreTopics"
|
||||
clearable
|
||||
filterable
|
||||
placeholder="请选择评价主题"
|
||||
@change="handleTopicFilterChange"
|
||||
>
|
||||
<el-option v-for="item in topicList" :key="item.id" :label="item.title" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-select
|
||||
v-model="queryForm.itemId"
|
||||
v-loadmore="loadMoreItems"
|
||||
clearable
|
||||
:disabled="!queryForm.topicId"
|
||||
filterable
|
||||
placeholder="请选择评价项"
|
||||
>
|
||||
<el-option v-for="item in itemList" :key="item.id" :label="item.name" :value="item.id" />
|
||||
</el-select>
|
||||
</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="所属主题" min-width="150" width="150">
|
||||
<template #default="{ row }">
|
||||
{{ row.topicTitle ? row.topicTitle : '-' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column align="center" label="PK 双方" min-width="400" width="400">
|
||||
<template #default="{ row }">
|
||||
<div class="pk-sides">
|
||||
<div class="pk-item pk-left">
|
||||
<el-image v-if="row.leftItemName && row.leftItemAvatar" class="pk-avatar" :src="getThumbUrl(row.leftItemAvatar)" />
|
||||
<span class="pk-name">{{ row.leftItemName ? row.leftItemName : '-' }}</span>
|
||||
<div class="pk-stats">
|
||||
<span
|
||||
class="pk-vote"
|
||||
style="cursor: pointer; text-decoration: underline"
|
||||
@click="handleViewParticipants(row.id, row.leftItemId, row.leftItemName)"
|
||||
>
|
||||
{{ row.leftVoteCount || 0 }} 票
|
||||
</span>
|
||||
<span class="pk-rate">({{ calculateRate(row.leftVoteCount, row.voteCount) }})</span>
|
||||
</div>
|
||||
<div style="margin-top: 5px">
|
||||
<el-button plain size="mini" type="primary" @click="handleVote(row.id, row.leftItemId, row.leftItemName)">支持</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="pk-vs-wrapper">
|
||||
<div class="pk-vs">VS</div>
|
||||
<div class="pk-total-vote">总票数: {{ row.voteCount || 0 }}</div>
|
||||
</div>
|
||||
<div class="pk-item pk-right">
|
||||
<el-image v-if="row.rightItemName && row.rightItemAvatar" class="pk-avatar" :src="getThumbUrl(row.rightItemAvatar)" />
|
||||
<span class="pk-name">{{ row.rightItemName ? row.rightItemName : '-' }}</span>
|
||||
<div class="pk-stats">
|
||||
<span
|
||||
class="pk-vote"
|
||||
style="cursor: pointer; text-decoration: underline"
|
||||
@click="handleViewParticipants(row.id, row.rightItemId, row.rightItemName)"
|
||||
>
|
||||
{{ row.rightVoteCount || 0 }} 票
|
||||
</span>
|
||||
<span class="pk-rate">({{ calculateRate(row.rightVoteCount, row.voteCount) }})</span>
|
||||
</div>
|
||||
<div style="margin-top: 5px">
|
||||
<el-button plain size="mini" type="primary" @click="handleVote(row.id, row.rightItemId, row.rightItemName)">支持</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<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="100">
|
||||
<template #default="{ row }">
|
||||
<el-button type="text" @click="handleComment(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"
|
||||
/>
|
||||
|
||||
<pk-generate ref="generate" @fetch-data="fetchData" />
|
||||
<pk-participant-list ref="participantList" />
|
||||
<pk-vote-edit ref="voteEdit" @fetch-data="fetchData" />
|
||||
|
||||
<el-dialog title="立即评论" :visible.sync="commentDialogVisible" width="600px" @close="closeCommentDialog">
|
||||
<el-form ref="commentForm" label-width="100px" :model="commentForm" :rules="commentRules">
|
||||
<el-form-item label="参与机器人" prop="userId">
|
||||
<el-select
|
||||
v-model="commentForm.userId"
|
||||
v-loadmore="loadMoreCommentUsers"
|
||||
filterable
|
||||
placeholder="请选择参与评论的机器人"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option v-for="item in commentUserList" :key="item.id" :label="item.nickname || item.id" :value="item.id">
|
||||
<div style="display: flex; align-items: center; justify-content: space-between">
|
||||
<div style="display: flex; align-items: center; min-width: 0">
|
||||
<el-image
|
||||
v-if="item.avatar"
|
||||
:src="getThumbUrl(item.avatar)"
|
||||
style="width: 24px; height: 24px; border-radius: 50%; margin-right: 10px"
|
||||
/>
|
||||
<span>{{ item.nickname || '未知用户' }}</span>
|
||||
</div>
|
||||
<el-tag v-if="item.choose" size="mini" style="margin-left: 12px; flex-shrink: 0" type="info">
|
||||
{{ getCommentUserChooseName(item.choose) }}
|
||||
</el-tag>
|
||||
</div>
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="评论内容" prop="content">
|
||||
<el-input v-model="commentForm.content" maxlength="500" placeholder="请输入评论内容" :rows="4" show-word-limit type="textarea" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<div slot="footer">
|
||||
<el-button @click="closeCommentDialog">取消</el-button>
|
||||
<el-button :loading="commentSaving" type="primary" @click="submitComment">确定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { comment, getList } from '@/api/rating/pk'
|
||||
import { getList as getTopicList } from '@/api/rating/topic'
|
||||
import { getList as getItemList } from '@/api/rating/topicItem'
|
||||
import { getListBase as getRobotListBase } from '@/api/system/robot'
|
||||
import { formatTime } from '@/utils'
|
||||
import { getThumbUrl } from '@/utils/blessing'
|
||||
import PkGenerate from './components/PkGenerate'
|
||||
import PkParticipantList from './components/PkParticipantList'
|
||||
import PkVoteEdit from './components/PkVoteEdit'
|
||||
|
||||
export default {
|
||||
name: 'RatingPkListIndex',
|
||||
components: { PkGenerate, PkParticipantList, PkVoteEdit },
|
||||
directives: {
|
||||
loadmore: {
|
||||
bind(el, binding) {
|
||||
setTimeout(() => {
|
||||
const SELECTWRAP_DOM = el.querySelector('.el-select-dropdown .el-select-dropdown__wrap')
|
||||
if (SELECTWRAP_DOM) {
|
||||
SELECTWRAP_DOM.addEventListener('scroll', function () {
|
||||
const condition = this.scrollHeight - this.scrollTop <= this.clientHeight + 2
|
||||
if (condition) {
|
||||
binding.value()
|
||||
}
|
||||
})
|
||||
}
|
||||
}, 0)
|
||||
},
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
list: [],
|
||||
listLoading: true,
|
||||
layout: 'total, sizes, prev, pager, next, jumper',
|
||||
total: 0,
|
||||
elementLoadingText: '正在加载...',
|
||||
queryForm: {
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
topicId: '',
|
||||
itemId: '',
|
||||
},
|
||||
|
||||
topicList: [],
|
||||
topicQuery: {
|
||||
pageNo: 1,
|
||||
pageSize: 20,
|
||||
},
|
||||
topicTotal: 0,
|
||||
fetchingTopics: false,
|
||||
|
||||
itemList: [],
|
||||
itemQuery: {
|
||||
pageNo: 1,
|
||||
pageSize: 20,
|
||||
topicId: '',
|
||||
},
|
||||
itemTotal: 0,
|
||||
fetchingItems: false,
|
||||
commentDialogVisible: false,
|
||||
commentSaving: false,
|
||||
commentForm: {
|
||||
pkId: '',
|
||||
userId: '',
|
||||
content: '',
|
||||
},
|
||||
commentRules: {
|
||||
userId: [{ required: true, trigger: 'change', message: '请选择参与评论的机器人' }],
|
||||
content: [{ required: true, trigger: 'blur', message: '请输入评论内容' }],
|
||||
},
|
||||
commentUserList: [],
|
||||
commentUserQuery: {
|
||||
appId: '6a0d7dbe4c5de50f2ba66475',
|
||||
pkId: '',
|
||||
pageNo: 1,
|
||||
pageSize: 20,
|
||||
},
|
||||
commentUserTotal: 0,
|
||||
fetchingCommentUsers: false,
|
||||
currentCommentPk: null,
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.fetchData()
|
||||
this.fetchTopicList()
|
||||
},
|
||||
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 params = {
|
||||
pageNo: this.queryForm.pageNo,
|
||||
pageSize: this.queryForm.pageSize,
|
||||
}
|
||||
if (this.queryForm.topicId) params.topicId = this.queryForm.topicId
|
||||
if (this.queryForm.itemId) params.itemId = this.queryForm.itemId
|
||||
|
||||
const { data } = await getList(params)
|
||||
this.list = data.list
|
||||
this.total = data.totalCount
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
this.listLoading = false
|
||||
}
|
||||
},
|
||||
handleGenerate() {
|
||||
this.$refs['generate'].showEdit()
|
||||
},
|
||||
|
||||
// -- Topic 列表加载 --
|
||||
async fetchTopicList() {
|
||||
if (this.fetchingTopics) return
|
||||
this.fetchingTopics = true
|
||||
try {
|
||||
const { data } = await getTopicList(this.topicQuery)
|
||||
this.topicList = this.topicList.concat(data.list || [])
|
||||
this.topicTotal = data.totalCount || 0
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
this.fetchingTopics = false
|
||||
}
|
||||
},
|
||||
loadMoreTopics() {
|
||||
if (this.topicList.length >= this.topicTotal || this.fetchingTopics) return
|
||||
this.topicQuery.pageNo += 1
|
||||
this.fetchTopicList()
|
||||
},
|
||||
|
||||
// -- Item 列表加载 --
|
||||
async fetchItemList() {
|
||||
if (this.fetchingItems || !this.itemQuery.topicId) return
|
||||
this.fetchingItems = true
|
||||
try {
|
||||
const { data } = await getItemList(this.itemQuery)
|
||||
this.itemList = this.itemList.concat(data.list || [])
|
||||
this.itemTotal = data.totalCount || 0
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
this.fetchingItems = false
|
||||
}
|
||||
},
|
||||
loadMoreItems() {
|
||||
if (this.itemList.length >= this.itemTotal || this.fetchingItems) return
|
||||
this.itemQuery.pageNo += 1
|
||||
this.fetchItemList()
|
||||
},
|
||||
|
||||
handleTopicFilterChange(val) {
|
||||
this.queryForm.itemId = ''
|
||||
this.itemList = []
|
||||
this.itemQuery.pageNo = 1
|
||||
this.itemTotal = 0
|
||||
|
||||
if (val) {
|
||||
this.itemQuery.topicId = val
|
||||
this.fetchItemList()
|
||||
} else {
|
||||
this.itemQuery.topicId = ''
|
||||
}
|
||||
this.queryData()
|
||||
},
|
||||
calculateRate(count, total) {
|
||||
if (!total || total === 0) return '0%'
|
||||
const rate = ((count || 0) / total) * 100
|
||||
return `${rate.toFixed(1)}%`
|
||||
},
|
||||
handleViewParticipants(pkId, chooseItemId, itemName) {
|
||||
this.$refs['participantList'].show(pkId, chooseItemId, itemName)
|
||||
},
|
||||
handleVote(pkId, itemId, itemName) {
|
||||
this.$refs['voteEdit'].showEdit(pkId, itemId, itemName)
|
||||
},
|
||||
getCommentUserChooseName(choose) {
|
||||
if (!choose || !this.currentCommentPk) return '-'
|
||||
if (choose === this.currentCommentPk.leftItemId) {
|
||||
return this.currentCommentPk.leftItemName || '-'
|
||||
}
|
||||
if (choose === this.currentCommentPk.rightItemId) {
|
||||
return this.currentCommentPk.rightItemName || '-'
|
||||
}
|
||||
return '-'
|
||||
},
|
||||
handleComment(row) {
|
||||
this.commentDialogVisible = true
|
||||
this.currentCommentPk = row
|
||||
this.commentForm = {
|
||||
pkId: row.id,
|
||||
userId: '',
|
||||
content: '',
|
||||
}
|
||||
this.commentUserList = []
|
||||
this.commentUserTotal = 0
|
||||
this.commentUserQuery.pageNo = 1
|
||||
this.commentUserQuery.pkId = row.id
|
||||
this.fetchCommentUsers()
|
||||
},
|
||||
closeCommentDialog() {
|
||||
if (this.$refs['commentForm']) {
|
||||
this.$refs['commentForm'].resetFields()
|
||||
}
|
||||
this.commentDialogVisible = false
|
||||
this.currentCommentPk = null
|
||||
},
|
||||
async fetchCommentUsers() {
|
||||
if (this.fetchingCommentUsers || !this.commentUserQuery.pkId) return
|
||||
this.fetchingCommentUsers = true
|
||||
try {
|
||||
const { data } = await getRobotListBase(this.commentUserQuery)
|
||||
this.commentUserList = this.commentUserList.concat(data.list || [])
|
||||
this.commentUserTotal = data.totalCount || 0
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
this.fetchingCommentUsers = false
|
||||
}
|
||||
},
|
||||
loadMoreCommentUsers() {
|
||||
if (this.commentUserList.length >= this.commentUserTotal || this.fetchingCommentUsers) return
|
||||
this.commentUserQuery.pageNo += 1
|
||||
this.fetchCommentUsers()
|
||||
},
|
||||
submitComment() {
|
||||
this.$refs['commentForm'].validate(async (valid) => {
|
||||
if (!valid) return false
|
||||
this.commentSaving = true
|
||||
try {
|
||||
const { msg } = await comment(this.commentForm)
|
||||
this.$baseMessage(msg || '评论成功', 'success')
|
||||
this.closeCommentDialog()
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
this.commentSaving = false
|
||||
}
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.rating-pk-list-container {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.pk-sides {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 15px;
|
||||
}
|
||||
|
||||
.pk-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
width: 120px;
|
||||
}
|
||||
|
||||
.pk-avatar {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border-radius: 50%;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.pk-name {
|
||||
font-size: 13px;
|
||||
color: #303133;
|
||||
text-align: center;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
width: 100%;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.pk-stats {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.pk-vote {
|
||||
color: #409eff;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.pk-rate {
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.pk-vs-wrapper {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-width: 80px;
|
||||
}
|
||||
|
||||
.pk-vs {
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
color: #f56c6c;
|
||||
font-style: italic;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.pk-total-vote {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
background-color: #f4f4f5;
|
||||
padding: 2px 6px;
|
||||
border-radius: 10px;
|
||||
}
|
||||
</style>
|
||||
234
src/views/rating/topic/components/TopicEdit.vue
Normal file
234
src/views/rating/topic/components/TopicEdit.vue
Normal file
@@ -0,0 +1,234 @@
|
||||
<template>
|
||||
<el-dialog :title="title" :visible.sync="dialogFormVisible" width="700px" @close="close">
|
||||
<el-form ref="form" label-width="100px" :model="form" :rules="rules">
|
||||
<el-form-item label="话题标题" prop="title">
|
||||
<el-input v-model="form.title" placeholder="请输入话题标题" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="话题分类" prop="categoryId">
|
||||
<el-select
|
||||
v-model="form.categoryId"
|
||||
v-loadmore="loadMoreCategories"
|
||||
filterable
|
||||
placeholder="请选择话题分类"
|
||||
:popper-append-to-body="false"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option v-for="item in categoryList" :key="item.id" :label="item.title" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="评价项" required>
|
||||
<div class="participants-container">
|
||||
<div v-for="(item, index) in form.participants" :key="index" class="participant-item">
|
||||
<div class="participant-avatar">
|
||||
<single-upload v-model="item.avatar" style="width: 60px; height: 60px" :upload-url="uploadUrl" />
|
||||
</div>
|
||||
<div class="participant-name">
|
||||
<el-input v-model="item.name" placeholder="请输入评价项名称" />
|
||||
</div>
|
||||
<div class="participant-action">
|
||||
<el-button circle icon="el-icon-delete" type="danger" @click="removeParticipant(index)" />
|
||||
</div>
|
||||
</div>
|
||||
<el-button icon="el-icon-plus" plain style="width: 100%; margin-top: 10px" @click="addParticipant">添加评价项</el-button>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="close">取 消</el-button>
|
||||
<el-button :loading="saving" type="primary" @click="save">确 定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { doAdd } from '@/api/rating/topic'
|
||||
import { getList as getCategoryList } from '@/api/rating/topicCategory'
|
||||
import SingleUpload from '@/components/SingleUpload'
|
||||
|
||||
export default {
|
||||
name: 'TopicEdit',
|
||||
components: { SingleUpload },
|
||||
directives: {
|
||||
loadmore: {
|
||||
bind(el, binding) {
|
||||
setTimeout(() => {
|
||||
const SELECTWRAP_DOM = el.querySelector('.el-select-dropdown .el-select-dropdown__wrap')
|
||||
if (SELECTWRAP_DOM) {
|
||||
SELECTWRAP_DOM.addEventListener('scroll', function () {
|
||||
const condition = this.scrollHeight - this.scrollTop <= this.clientHeight + 2
|
||||
if (condition) {
|
||||
binding.value()
|
||||
}
|
||||
})
|
||||
}
|
||||
}, 0)
|
||||
},
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
title: '创建话题',
|
||||
dialogFormVisible: false,
|
||||
saving: false,
|
||||
form: {
|
||||
title: '',
|
||||
categoryId: '',
|
||||
participants: [{ name: '', avatar: '' }],
|
||||
},
|
||||
rules: {
|
||||
title: [{ required: true, trigger: 'blur', message: '请输入话题标题' }],
|
||||
categoryId: [{ required: true, trigger: 'change', message: '请选择话题分类' }],
|
||||
},
|
||||
categoryList: [],
|
||||
categoryTotal: 0,
|
||||
categoryQuery: {
|
||||
pageNo: 1,
|
||||
pageSize: 20,
|
||||
},
|
||||
fetchingCategories: false,
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
uploadUrl() {
|
||||
return `${process.env.VUE_APP_API_BASE_URL}/management/api/common/upload`
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
showEdit() {
|
||||
this.title = '创建话题'
|
||||
this.form = this.$options.data().form
|
||||
this.dialogFormVisible = true
|
||||
this.fetchCategoryList(true)
|
||||
},
|
||||
close() {
|
||||
this.$refs['form'].resetFields()
|
||||
this.form = this.$options.data().form
|
||||
this.dialogFormVisible = false
|
||||
this.saving = false
|
||||
},
|
||||
async fetchCategoryList(refresh = false) {
|
||||
if (refresh) {
|
||||
this.categoryQuery.pageNo = 1
|
||||
this.categoryList = []
|
||||
}
|
||||
this.fetchingCategories = true
|
||||
try {
|
||||
const { data } = await getCategoryList(this.categoryQuery)
|
||||
if (refresh) {
|
||||
this.categoryList = data.list || []
|
||||
} else {
|
||||
this.categoryList = this.categoryList.concat(data.list || [])
|
||||
}
|
||||
this.categoryTotal = data.totalCount || 0
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
this.fetchingCategories = false
|
||||
}
|
||||
},
|
||||
loadMoreCategories() {
|
||||
if (this.categoryList.length >= this.categoryTotal || this.fetchingCategories) {
|
||||
return
|
||||
}
|
||||
this.categoryQuery.pageNo += 1
|
||||
this.fetchCategoryList()
|
||||
},
|
||||
addParticipant() {
|
||||
this.form.participants.push({ name: '', avatar: '' })
|
||||
},
|
||||
removeParticipant(index) {
|
||||
this.form.participants.splice(index, 1)
|
||||
},
|
||||
save() {
|
||||
this.$refs['form'].validate(async (valid) => {
|
||||
if (valid) {
|
||||
// 验证 participants
|
||||
if (this.form.participants.length === 0) {
|
||||
this.$message.error('请至少添加一个评价项')
|
||||
return
|
||||
}
|
||||
for (let i = 0; i < this.form.participants.length; i++) {
|
||||
const p = this.form.participants[i]
|
||||
if (!p.name) {
|
||||
this.$message.error(`第 ${i + 1} 个评价项名称不能为空`)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// 处理提交数据:去掉 avatar 的域名前缀
|
||||
const submitData = {
|
||||
...this.form,
|
||||
participants: this.form.participants.map((p) => {
|
||||
let avatar = p.avatar || ''
|
||||
if (avatar.startsWith('https://file.lihailezzc.com/')) {
|
||||
avatar = avatar.replace('https://file.lihailezzc.com/', '')
|
||||
}
|
||||
return {
|
||||
...p,
|
||||
avatar,
|
||||
}
|
||||
}),
|
||||
}
|
||||
|
||||
this.saving = true
|
||||
try {
|
||||
const { msg } = await doAdd(submitData)
|
||||
this.$baseMessage(msg || '创建成功', 'success')
|
||||
this.$emit('fetch-data')
|
||||
this.close()
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
this.saving = false
|
||||
}
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.participants-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
}
|
||||
.participant-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background-color: #f5f7fa;
|
||||
padding: 10px;
|
||||
border-radius: 4px;
|
||||
gap: 15px;
|
||||
height: 80px; /* 固定高度确保内容居中对齐 */
|
||||
}
|
||||
.participant-avatar {
|
||||
flex-shrink: 0;
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
overflow: hidden;
|
||||
border-radius: 4px;
|
||||
}
|
||||
/* 深度覆盖 SingleUpload 的默认宽高 */
|
||||
::v-deep .participant-avatar .single-upload .uploader-icon,
|
||||
::v-deep .participant-avatar .single-upload .avatar {
|
||||
width: 60px !important;
|
||||
height: 60px !important;
|
||||
line-height: 60px !important;
|
||||
}
|
||||
.participant-name {
|
||||
flex-grow: 1;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.participant-action {
|
||||
flex-shrink: 0;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
</style>
|
||||
@@ -1,8 +1,41 @@
|
||||
<template>
|
||||
<div class="rating-topic-container">
|
||||
<el-alert
|
||||
v-if="!queryForm.categoryId"
|
||||
:closable="false"
|
||||
show-icon
|
||||
style="margin-bottom: 20px"
|
||||
title="选择类别后可以置顶话题"
|
||||
type="info"
|
||||
/>
|
||||
|
||||
<vab-query-form>
|
||||
<vab-query-form-right-panel :span="24">
|
||||
<vab-query-form-left-panel>
|
||||
<el-button icon="el-icon-plus" type="primary" @click="handleAdd">创建话题</el-button>
|
||||
</vab-query-form-left-panel>
|
||||
<vab-query-form-left-panel>
|
||||
<el-form :inline="true" :model="queryForm" @submit.native.prevent>
|
||||
<el-form-item>
|
||||
<el-select
|
||||
v-model="queryForm.categoryId"
|
||||
v-loadmore="loadMoreCategories"
|
||||
clearable
|
||||
filterable
|
||||
placeholder="请选择分类"
|
||||
style="width: 200px"
|
||||
@change="queryData"
|
||||
>
|
||||
<el-option v-for="item in categoryList" :key="item.id" :label="item.title" :value="item.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<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>
|
||||
@@ -10,15 +43,13 @@
|
||||
<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-left-panel>
|
||||
</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>
|
||||
@@ -37,14 +68,14 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column align="center" label="允许评论" width="100">
|
||||
<el-table-column align="left" label="用户信息" min-width="200" width="300">
|
||||
<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>
|
||||
<user-info v-if="row.user" :user="row.user" :user-id="row.userId" />
|
||||
<span v-else>系统创建</span>
|
||||
</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">
|
||||
@@ -79,17 +110,25 @@
|
||||
</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="200">
|
||||
<template #default="{ row }">
|
||||
<el-button type="text" @click="handleViewItems(row)">查看评分项</el-button>
|
||||
|
||||
<template v-if="queryForm.categoryId">
|
||||
<el-button v-if="!row.isPinned" style="color: #e6a23c" type="text" @click="handleTogglePin(row, true)">置顶</el-button>
|
||||
<el-button v-else style="color: #909399" type="text" @click="handleTogglePin(row, false)">取消置顶</el-button>
|
||||
</template>
|
||||
|
||||
<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>
|
||||
@@ -103,16 +142,40 @@
|
||||
@current-change="handleCurrentChange"
|
||||
@size-change="handleSizeChange"
|
||||
/>
|
||||
|
||||
<topic-edit ref="edit" @fetch-data="fetchData" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getList } from '@/api/rating/topic'
|
||||
import { getList, pinnedTopic } from '@/api/rating/topic'
|
||||
import { getList as getCategoryList } from '@/api/rating/topicCategory'
|
||||
import { reviewTopic } from '@/api/rating/topicOperate'
|
||||
import { formatTime } from '@/utils'
|
||||
import { getThumbUrl } from '@/utils/blessing'
|
||||
import TopicEdit from './components/TopicEdit'
|
||||
import UserInfo from '@/components/UserInfo'
|
||||
|
||||
export default {
|
||||
name: 'RatingTopicIndex',
|
||||
components: { TopicEdit, UserInfo },
|
||||
directives: {
|
||||
loadmore: {
|
||||
bind(el, binding) {
|
||||
setTimeout(() => {
|
||||
const SELECTWRAP_DOM = el.querySelector('.el-select-dropdown .el-select-dropdown__wrap')
|
||||
if (SELECTWRAP_DOM) {
|
||||
SELECTWRAP_DOM.addEventListener('scroll', function () {
|
||||
const condition = this.scrollHeight - this.scrollTop <= this.clientHeight + 2
|
||||
if (condition) {
|
||||
binding.value()
|
||||
}
|
||||
})
|
||||
}
|
||||
}, 0)
|
||||
},
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
list: [],
|
||||
@@ -124,15 +187,46 @@
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
keyword: '',
|
||||
status: '',
|
||||
categoryId: '',
|
||||
},
|
||||
categoryList: [],
|
||||
categoryQuery: { pageNo: 1, pageSize: 20 },
|
||||
categoryTotal: 0,
|
||||
fetchingCategories: false,
|
||||
}
|
||||
},
|
||||
created() {
|
||||
if (this.$route.query.topicId) {
|
||||
this.queryForm.keyword = this.$route.query.topicId
|
||||
}
|
||||
this.fetchCategoryList()
|
||||
this.fetchData()
|
||||
},
|
||||
methods: {
|
||||
formatTime,
|
||||
getThumbUrl,
|
||||
async fetchCategoryList() {
|
||||
if (this.fetchingCategories) return
|
||||
this.fetchingCategories = true
|
||||
try {
|
||||
const { data } = await getCategoryList(this.categoryQuery)
|
||||
this.categoryList = this.categoryList.concat(data.list || [])
|
||||
this.categoryTotal = data.totalCount || 0
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
this.fetchingCategories = false
|
||||
}
|
||||
},
|
||||
loadMoreCategories() {
|
||||
if (this.categoryList.length >= this.categoryTotal || this.fetchingCategories) return
|
||||
this.categoryQuery.pageNo += 1
|
||||
this.fetchCategoryList()
|
||||
},
|
||||
handleAdd() {
|
||||
this.$refs['edit'].showEdit()
|
||||
},
|
||||
handleSizeChange(val) {
|
||||
this.queryForm.pageSize = val
|
||||
this.fetchData()
|
||||
@@ -148,7 +242,9 @@
|
||||
async fetchData() {
|
||||
this.listLoading = true
|
||||
try {
|
||||
const { data } = await getList(this.queryForm)
|
||||
const params = { ...this.queryForm }
|
||||
if (!params.categoryId) delete params.categoryId
|
||||
const { data } = await getList(params)
|
||||
this.list = data.list
|
||||
this.total = data.totalCount
|
||||
} catch (error) {
|
||||
@@ -163,6 +259,59 @@
|
||||
query: { topicId: row.id },
|
||||
})
|
||||
},
|
||||
async handleTogglePin(row, isPinned) {
|
||||
try {
|
||||
const { msg } = await pinnedTopic(row.id, isPinned)
|
||||
this.$baseMessage(msg || (isPinned ? '置顶成功' : '已取消置顶'), 'success')
|
||||
this.fetchData()
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
}
|
||||
},
|
||||
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>
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
<template>
|
||||
<el-dialog :title="title" :visible.sync="dialogFormVisible" width="500px" @close="close">
|
||||
<el-form ref="form" label-width="80px" :model="form" :rules="rules">
|
||||
<el-form-item label="分类名称" prop="title">
|
||||
<el-input v-model.trim="form.title" placeholder="请输入分类名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="排序" prop="sort">
|
||||
<el-input-number v-model="form.sort" :min="0" placeholder="数字越大越靠前" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="close">取 消</el-button>
|
||||
<el-button :loading="saving" type="primary" @click="save">确 定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { doEdit, doAdd } from '@/api/rating/topicCategory'
|
||||
|
||||
export default {
|
||||
name: 'TopicCategoryEdit',
|
||||
data() {
|
||||
return {
|
||||
title: '编辑话题分类',
|
||||
dialogFormVisible: false,
|
||||
saving: false,
|
||||
form: {
|
||||
title: '',
|
||||
sort: 0,
|
||||
},
|
||||
rules: {
|
||||
title: [{ required: true, trigger: 'blur', message: '请输入分类名称' }],
|
||||
},
|
||||
id: '',
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
showEdit(row) {
|
||||
if (!row) {
|
||||
this.title = '创建分类'
|
||||
this.id = ''
|
||||
this.form = this.$options.data().form
|
||||
} else {
|
||||
this.title = '编辑分类'
|
||||
this.id = row.id
|
||||
this.form = {
|
||||
title: row.title || '',
|
||||
sort: row.sort || 0,
|
||||
}
|
||||
}
|
||||
this.dialogFormVisible = true
|
||||
},
|
||||
close() {
|
||||
this.$refs['form'].resetFields()
|
||||
this.form = this.$options.data().form
|
||||
this.id = ''
|
||||
this.saving = false
|
||||
this.dialogFormVisible = false
|
||||
},
|
||||
save() {
|
||||
this.$refs['form'].validate(async (valid) => {
|
||||
if (valid) {
|
||||
this.saving = true
|
||||
try {
|
||||
if (this.id) {
|
||||
const { msg } = await doEdit(this.id, this.form)
|
||||
this.$baseMessage(msg || '编辑成功', 'success')
|
||||
} else {
|
||||
const { msg } = await doAdd({ title: this.form.title })
|
||||
this.$baseMessage(msg || '创建成功', 'success')
|
||||
}
|
||||
this.$emit('fetch-data')
|
||||
this.close()
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
this.saving = false
|
||||
}
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
147
src/views/rating/topicCategory/index.vue
Normal file
147
src/views/rating/topicCategory/index.vue
Normal file
@@ -0,0 +1,147 @@
|
||||
<template>
|
||||
<div class="topic-category-container">
|
||||
<vab-query-form>
|
||||
<vab-query-form-left-panel :span="12">
|
||||
<el-button icon="el-icon-plus" type="primary" @click="handleAdd">创建类别</el-button>
|
||||
</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-table v-loading="listLoading" :data="list" :element-loading-text="elementLoadingText">
|
||||
<el-table-column align="center" label="分类名称" min-width="150" prop="title" width="100" />
|
||||
<el-table-column align="center" label="排序" prop="sort" width="120">
|
||||
<template #default="{ row }">
|
||||
<el-input v-model="row.sort" placeholder="排序" size="mini" @blur="handleMove(row)" @keyup.enter.native="handleMove(row)" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column align="center" label="状态" width="100">
|
||||
<template #default="{ row }">
|
||||
<el-switch v-model="row.enable" :active-value="true" :inactive-value="false" @change="handleToggleStatus(row)" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column align="center" label="操作" width="100">
|
||||
<template #default="{ row }">
|
||||
<el-button type="text" @click="handleEdit(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"
|
||||
/>
|
||||
|
||||
<topic-category-edit ref="edit" @fetch-data="fetchData" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getList, toggleEnable, moveTo } from '@/api/rating/topicCategory'
|
||||
import { formatTime } from '@/utils'
|
||||
import TopicCategoryEdit from './components/TopicCategoryEdit'
|
||||
|
||||
export default {
|
||||
name: 'RatingTopicCategoryIndex',
|
||||
components: { TopicCategoryEdit },
|
||||
data() {
|
||||
return {
|
||||
list: [],
|
||||
listLoading: true,
|
||||
layout: 'total, sizes, prev, pager, next, jumper',
|
||||
total: 0,
|
||||
elementLoadingText: '正在加载...',
|
||||
queryForm: {
|
||||
pageNo: 1,
|
||||
pageSize: 20,
|
||||
keyword: '',
|
||||
},
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.fetchData()
|
||||
},
|
||||
methods: {
|
||||
formatTime,
|
||||
handleAdd() {
|
||||
this.$refs['edit'].showEdit()
|
||||
},
|
||||
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
|
||||
}
|
||||
},
|
||||
handleEdit(row) {
|
||||
this.$refs['edit'].showEdit(row)
|
||||
},
|
||||
async handleToggleStatus(row) {
|
||||
try {
|
||||
const { msg } = await toggleEnable(row.id, row.enable)
|
||||
this.$baseMessage(msg || '状态切换成功', 'success')
|
||||
this.fetchData()
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
row.enable = !row.enable
|
||||
}
|
||||
},
|
||||
async handleMove(row) {
|
||||
// 如果输入为空或不是数字,给出提示并重新获取列表恢复原值
|
||||
const sortVal = Number(row.sort)
|
||||
if (isNaN(sortVal)) {
|
||||
this.$message.error('排序必须是数字')
|
||||
this.fetchData()
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const { msg } = await moveTo(row.id, sortVal)
|
||||
this.$baseMessage(msg || '移动成功', 'success')
|
||||
this.fetchData()
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
this.fetchData()
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.topic-category-container {
|
||||
padding: 20px;
|
||||
}
|
||||
</style>
|
||||
@@ -18,7 +18,7 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="评价主题" prop="topicId">
|
||||
<el-form-item v-if="!isReply" label="评价主题" prop="topicId">
|
||||
<el-select
|
||||
v-model="form.topicId"
|
||||
v-loadmore="loadMoreTopics"
|
||||
@@ -31,7 +31,7 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="评价项" prop="itemId">
|
||||
<el-form-item v-if="!isReply" label="评价项" prop="itemId">
|
||||
<el-select
|
||||
v-model="form.itemId"
|
||||
v-loadmore="loadMoreItems"
|
||||
@@ -54,7 +54,7 @@
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="评论内容" prop="content">
|
||||
<el-input v-model="form.content" maxlength="500" placeholder="请输入您的评论文字" :rows="4" show-word-limit type="textarea" />
|
||||
<el-input v-model="form.content" maxlength="500" :placeholder="contentPlaceholder" :rows="4" show-word-limit type="textarea" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
@@ -96,11 +96,15 @@
|
||||
title: '立即评论',
|
||||
dialogFormVisible: false,
|
||||
saving: false,
|
||||
isReply: false,
|
||||
contentPlaceholder: '请输入您的评论文字',
|
||||
form: {
|
||||
userId: '',
|
||||
topicId: '',
|
||||
itemId: '',
|
||||
content: '',
|
||||
parentCommentId: '',
|
||||
replyToCommentId: '',
|
||||
},
|
||||
rules: {
|
||||
userId: [{ required: true, trigger: 'change', message: '请选择用户' }],
|
||||
@@ -130,11 +134,31 @@
|
||||
},
|
||||
methods: {
|
||||
getThumbUrl,
|
||||
showEdit() {
|
||||
this.title = '立即评论'
|
||||
showEdit(row = null, parentCommentId = null) {
|
||||
this.dialogFormVisible = true
|
||||
this.form = this.$options.data().form
|
||||
|
||||
if (row) {
|
||||
this.isReply = true
|
||||
this.title = '回复评论'
|
||||
this.contentPlaceholder = `回复 @${row.user ? row.user.nickname : '未知用户'}:`
|
||||
|
||||
this.form.parentCommentId = parentCommentId || row.id
|
||||
this.form.replyToCommentId = row.id
|
||||
|
||||
if (row.rating) {
|
||||
this.form.topicId = row.rating.topicId || row.rating.topic?.id || row.topicId
|
||||
this.form.itemId = row.rating.itemId || row.rating.item?.id || row.itemId
|
||||
} else {
|
||||
this.form.topicId = row.topicId
|
||||
this.form.itemId = row.itemId
|
||||
}
|
||||
} else {
|
||||
this.isReply = false
|
||||
this.title = '立即评论'
|
||||
this.contentPlaceholder = '请输入您的评论文字'
|
||||
}
|
||||
|
||||
// 重置列表数据
|
||||
this.userList = []
|
||||
this.userQuery.pageNo = 1
|
||||
@@ -151,7 +175,9 @@
|
||||
|
||||
// 初始化加载第一页数据
|
||||
this.fetchUserList()
|
||||
this.fetchTopicList()
|
||||
if (!this.isReply) {
|
||||
this.fetchTopicList()
|
||||
}
|
||||
},
|
||||
close() {
|
||||
this.$refs['form'].resetFields()
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
<template>
|
||||
<el-dialog :title="title" :visible.sync="dialogFormVisible" width="500px" @close="close">
|
||||
<el-form ref="form" label-width="80px" :model="form" :rules="rules">
|
||||
<el-form-item label="点赞用户" prop="userId">
|
||||
<el-select v-model="form.userId" v-loadmore="loadMoreRobots" filterable placeholder="请选择执行点赞的机器人" style="width: 100%">
|
||||
<el-option v-for="item in robotList" :key="item.id" :label="item.nickname || item.id" :value="item.id">
|
||||
<div style="display: flex; align-items: center">
|
||||
<el-image
|
||||
v-if="item.avatar"
|
||||
:src="getThumbUrl(item.avatar)"
|
||||
style="width: 24px; height: 24px; border-radius: 50%; margin-right: 10px"
|
||||
/>
|
||||
<span>{{ item.nickname || '未知用户' }}</span>
|
||||
</div>
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="close">取 消</el-button>
|
||||
<el-button :loading="saving" type="primary" @click="save">确 定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getListBase as getRobotList } from '@/api/system/robot'
|
||||
import { commentLike } from '@/api/rating/topicOperate'
|
||||
import { getThumbUrl } from '@/utils/blessing'
|
||||
|
||||
export default {
|
||||
name: 'RecordCommentLikeEdit',
|
||||
directives: {
|
||||
loadmore: {
|
||||
bind(el, binding) {
|
||||
setTimeout(() => {
|
||||
const SELECTWRAP_DOM = el.querySelector('.el-select-dropdown .el-select-dropdown__wrap')
|
||||
if (SELECTWRAP_DOM) {
|
||||
SELECTWRAP_DOM.addEventListener('scroll', function () {
|
||||
const condition = this.scrollHeight - this.scrollTop <= this.clientHeight + 2
|
||||
if (condition) {
|
||||
binding.value()
|
||||
}
|
||||
})
|
||||
}
|
||||
}, 0)
|
||||
},
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
title: '选择机器人点赞',
|
||||
dialogFormVisible: false,
|
||||
saving: false,
|
||||
form: {
|
||||
commentId: '',
|
||||
userId: '',
|
||||
},
|
||||
rules: {
|
||||
userId: [{ required: true, trigger: 'change', message: '请选择执行点赞的机器人' }],
|
||||
},
|
||||
|
||||
// 机器人下拉列表状态
|
||||
robotList: [],
|
||||
robotQuery: {
|
||||
appId: '6a0d7dbe4c5de50f2ba66475',
|
||||
pageNo: 1,
|
||||
pageSize: 20,
|
||||
commentId: '',
|
||||
},
|
||||
robotTotal: 0,
|
||||
fetchingRobots: false,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
getThumbUrl,
|
||||
showEdit(row) {
|
||||
this.title = '选择机器人点赞'
|
||||
this.dialogFormVisible = true
|
||||
this.form = this.$options.data().form
|
||||
this.form.commentId = row.id
|
||||
|
||||
// 重置列表并加载第一页
|
||||
this.robotList = []
|
||||
this.robotQuery.pageNo = 1
|
||||
this.robotQuery.commentId = row.id
|
||||
this.robotTotal = 0
|
||||
this.fetchRobotList()
|
||||
},
|
||||
close() {
|
||||
this.$refs['form'].resetFields()
|
||||
this.dialogFormVisible = false
|
||||
},
|
||||
async fetchRobotList() {
|
||||
if (this.fetchingRobots) return
|
||||
this.fetchingRobots = true
|
||||
try {
|
||||
const { data } = await getRobotList(this.robotQuery)
|
||||
this.robotList = this.robotList.concat(data.list || [])
|
||||
this.robotTotal = data.totalCount || 0
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
this.fetchingRobots = false
|
||||
}
|
||||
},
|
||||
loadMoreRobots() {
|
||||
if (this.robotList.length >= this.robotTotal || this.fetchingRobots) return
|
||||
this.robotQuery.pageNo += 1
|
||||
this.fetchRobotList()
|
||||
},
|
||||
save() {
|
||||
this.$refs['form'].validate(async (valid) => {
|
||||
if (valid) {
|
||||
this.saving = true
|
||||
try {
|
||||
const { msg } = await commentLike(this.form)
|
||||
this.$baseMessage(msg || '点赞成功', 'success')
|
||||
this.close()
|
||||
this.$emit('fetch-data')
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
this.saving = false
|
||||
}
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,176 @@
|
||||
<template>
|
||||
<el-dialog :title="title" :visible.sync="dialogVisible" width="900px" @close="close">
|
||||
<el-table v-loading="listLoading" :data="list" :element-loading-text="elementLoadingText">
|
||||
<el-table-column align="center" fixed="left" label="操作" width="120">
|
||||
<template #default="{ row }">
|
||||
<el-button type="text" @click="handleLike(row)">点赞</el-button>
|
||||
<el-button type="text" @click="handleReply(row)">回复</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column align="left" label="回复内容" min-width="250">
|
||||
<template #default="{ row }">
|
||||
<div class="comment-content-cell">
|
||||
<div v-if="row.replyToUser" class="reply-target">回复 @{{ row.replyToUser.nickname || '未知用户' }}:</div>
|
||||
<div class="content-text">{{ row.content }}</div>
|
||||
<div class="comment-meta">
|
||||
<span class="meta-item">
|
||||
<i class="el-icon-thumb" />
|
||||
{{ row.likeCount || 0 }}
|
||||
</span>
|
||||
<el-tag v-if="row.status === 2" size="mini" style="margin-left: 8px" type="success">已展示</el-tag>
|
||||
<el-tag v-else size="mini" style="margin-left: 8px" type="info">隐藏/待审</el-tag>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column align="left" label="用户信息" min-width="180">
|
||||
<template #default="{ row }">
|
||||
<user-info :user="row.user" :user-id="row.userId" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column align="center" label="状态切换" width="80">
|
||||
<template #default="{ row }">
|
||||
<el-switch v-model="row.status" :active-value="2" :inactive-value="4" @change="handleToggleStatus(row)" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<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"
|
||||
/>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { userCommentList, commentStatus } from '@/api/rating/topicOperate'
|
||||
import { formatTime } from '@/utils'
|
||||
import { getThumbUrl } from '@/utils/blessing'
|
||||
import UserInfo from '@/components/UserInfo'
|
||||
|
||||
export default {
|
||||
name: 'RecordCommentReplyList',
|
||||
components: { UserInfo },
|
||||
data() {
|
||||
return {
|
||||
title: '回复列表',
|
||||
dialogVisible: false,
|
||||
list: [],
|
||||
listLoading: false,
|
||||
layout: 'total, prev, pager, next',
|
||||
total: 0,
|
||||
elementLoadingText: '正在加载...',
|
||||
queryForm: {
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
rootCommentId: '',
|
||||
},
|
||||
parentRow: null,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
formatTime,
|
||||
getThumbUrl,
|
||||
show(row) {
|
||||
this.parentRow = row
|
||||
this.title = `回复列表`
|
||||
this.dialogVisible = true
|
||||
this.queryForm.rootCommentId = row.id
|
||||
this.queryForm.pageNo = 1
|
||||
this.fetchData()
|
||||
},
|
||||
close() {
|
||||
this.dialogVisible = false
|
||||
this.list = []
|
||||
},
|
||||
handleSizeChange(val) {
|
||||
this.queryForm.pageSize = val
|
||||
this.fetchData()
|
||||
},
|
||||
handleCurrentChange(val) {
|
||||
this.queryForm.pageNo = val
|
||||
this.fetchData()
|
||||
},
|
||||
async fetchData() {
|
||||
this.listLoading = true
|
||||
try {
|
||||
const { data } = await userCommentList(this.queryForm)
|
||||
this.list = data.list || []
|
||||
this.total = data.totalCount || 0
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
this.listLoading = false
|
||||
}
|
||||
},
|
||||
handleLike(row) {
|
||||
this.$emit('like', row)
|
||||
},
|
||||
handleReply(row) {
|
||||
// 传递当前行作为被回复对象,同时传递根评论ID
|
||||
this.$emit('reply', row, this.queryForm.rootCommentId)
|
||||
},
|
||||
async handleToggleStatus(row) {
|
||||
try {
|
||||
const enable = row.status === 2
|
||||
const { msg } = await commentStatus({ id: row.id, enable })
|
||||
this.$baseMessage(msg || '状态切换成功', 'success')
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
row.status = row.status === 2 ? 4 : 2
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.comment-content-cell {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.reply-target {
|
||||
font-size: 12px;
|
||||
color: #409eff;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.content-text {
|
||||
font-size: 14px;
|
||||
color: #303133;
|
||||
margin-bottom: 8px;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.comment-meta {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.meta-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-right: 12px;
|
||||
}
|
||||
|
||||
.meta-item i {
|
||||
margin-right: 4px;
|
||||
}
|
||||
</style>
|
||||
@@ -83,6 +83,14 @@
|
||||
</vab-query-form>
|
||||
|
||||
<el-table v-loading="listLoading" :data="list" :element-loading-text="elementLoadingText">
|
||||
<el-table-column align="center" fixed="left" label="操作" width="160">
|
||||
<template #default="{ row }">
|
||||
<el-button type="text" @click="handleLike(row)">点赞</el-button>
|
||||
<el-button type="text" @click="handleReply(row)">回复</el-button>
|
||||
<el-button v-if="row.replyCount > 0" type="text" @click="handleViewReplies(row)">查看回复</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column align="left" label="评论内容" min-width="250">
|
||||
<template #default="{ row }">
|
||||
<div class="comment-content-cell">
|
||||
@@ -124,26 +132,13 @@
|
||||
|
||||
<el-table-column align="left" label="用户信息" min-width="200">
|
||||
<template #default="{ row }">
|
||||
<div v-if="row.user" class="user-info-cell">
|
||||
<el-image
|
||||
v-if="row.user.avatar"
|
||||
class="user-avatar"
|
||||
:preview-src-list="[row.user.avatar]"
|
||||
:src="getThumbUrl(row.user.avatar)"
|
||||
/>
|
||||
<div v-else class="user-avatar-placeholder"><i class="el-icon-user" /></div>
|
||||
<div class="user-details">
|
||||
<div class="user-nickname">
|
||||
{{ row.user.nickname || '未知用户' }}
|
||||
<el-tag v-if="row.user.isRobot" size="mini" style="margin-left: 4px" type="info">机器人</el-tag>
|
||||
<el-tag v-else size="mini" style="margin-left: 4px" type="success">真人</el-tag>
|
||||
</div>
|
||||
<div class="user-id">{{ row.user.id }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="user-details">
|
||||
<div class="user-id">{{ row.userId }}</div>
|
||||
</div>
|
||||
<user-info :user="row.user" :user-id="row.userId" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column align="center" label="状态切换" width="100">
|
||||
<template #default="{ row }">
|
||||
<el-switch v-model="row.status" :active-value="2" :inactive-value="4" @change="handleToggleStatus(row)" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
@@ -165,21 +160,26 @@
|
||||
/>
|
||||
|
||||
<record-comment-edit ref="commentEdit" @fetch-data="fetchData" />
|
||||
<record-comment-like-edit ref="likeEdit" @fetch-data="fetchData" />
|
||||
<record-comment-reply-list ref="replyList" @like="handleLikeFromList" @reply="handleReplyFromList" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { userCommentList } from '@/api/rating/topicOperate'
|
||||
import { userCommentList, commentStatus } from '@/api/rating/topicOperate'
|
||||
import { getList as getUserList } from '@/api/system/user'
|
||||
import { getList as getTopicList } from '@/api/rating/topic'
|
||||
import { getList as getItemList } from '@/api/rating/topicItem'
|
||||
import { formatTime } from '@/utils'
|
||||
import { getThumbUrl } from '@/utils/blessing'
|
||||
import UserInfo from '@/components/UserInfo'
|
||||
import RecordCommentEdit from './components/RecordCommentEdit'
|
||||
import RecordCommentLikeEdit from './components/RecordCommentLikeEdit'
|
||||
import RecordCommentReplyList from './components/RecordCommentReplyList'
|
||||
|
||||
export default {
|
||||
name: 'RatingTopicCommentIndex',
|
||||
components: { RecordCommentEdit },
|
||||
components: { RecordCommentEdit, RecordCommentLikeEdit, RecordCommentReplyList, UserInfo },
|
||||
directives: {
|
||||
loadmore: {
|
||||
bind(el, binding) {
|
||||
@@ -340,9 +340,35 @@
|
||||
},
|
||||
|
||||
// -- 列表数据加载 --
|
||||
handleLike(row) {
|
||||
this.$refs['likeEdit'].showEdit(row)
|
||||
},
|
||||
handleReply(row) {
|
||||
this.$refs['commentEdit'].showEdit(row)
|
||||
},
|
||||
handleViewReplies(row) {
|
||||
this.$refs['replyList'].show(row)
|
||||
},
|
||||
handleCommentNow() {
|
||||
this.$refs['commentEdit'].showEdit()
|
||||
},
|
||||
async handleToggleStatus(row) {
|
||||
try {
|
||||
const enable = row.status === 2
|
||||
const { msg } = await commentStatus({ id: row.id, enable })
|
||||
this.$baseMessage(msg || '状态切换成功', 'success')
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
row.status = row.status === 2 ? 4 : 2
|
||||
}
|
||||
},
|
||||
// 子组件触发的方法
|
||||
handleReplyFromList(row, parentCommentId) {
|
||||
this.$refs['commentEdit'].showEdit(row, parentCommentId)
|
||||
},
|
||||
handleLikeFromList(row) {
|
||||
this.$refs['likeEdit'].showEdit(row)
|
||||
},
|
||||
handleSizeChange(val) {
|
||||
this.queryForm.pageSize = val
|
||||
this.fetchData()
|
||||
@@ -409,45 +435,6 @@
|
||||
margin-right: 4px;
|
||||
}
|
||||
|
||||
/* 用户信息列样式 */
|
||||
.user-info-cell {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.user-avatar,
|
||||
.user-avatar-placeholder {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border-radius: 50%;
|
||||
margin-right: 12px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.user-avatar-placeholder {
|
||||
background-color: #f0f2f5;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #909399;
|
||||
font-size: 20px;
|
||||
}
|
||||
.user-details {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
.user-nickname {
|
||||
font-weight: bold;
|
||||
color: #303133;
|
||||
margin-bottom: 4px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.user-id {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
/* 评价目标列样式 */
|
||||
.target-info-cell {
|
||||
display: flex;
|
||||
|
||||
@@ -11,13 +11,18 @@
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option v-for="item in robotList" :key="item.id" :label="item.nickname" :value="item.id">
|
||||
<div style="display: flex; align-items: center">
|
||||
<el-image
|
||||
v-if="item.avatar"
|
||||
:src="getThumbUrl(item.avatar)"
|
||||
style="width: 24px; height: 24px; border-radius: 50%; margin-right: 10px"
|
||||
/>
|
||||
<span>{{ item.nickname }}</span>
|
||||
<div style="display: flex; align-items: center; justify-content: space-between">
|
||||
<div style="display: flex; align-items: center; min-width: 0">
|
||||
<el-image
|
||||
v-if="item.avatar"
|
||||
:src="getThumbUrl(item.avatar)"
|
||||
style="width: 24px; height: 24px; border-radius: 50%; margin-right: 10px"
|
||||
/>
|
||||
<span>{{ item.nickname }}</span>
|
||||
</div>
|
||||
<el-tag v-if="item.score" size="mini" style="margin-left: 12px; flex-shrink: 0" :type="getScoreTagType(item.score)">
|
||||
{{ getScoreText(item.score) }}
|
||||
</el-tag>
|
||||
</div>
|
||||
</el-option>
|
||||
</el-select>
|
||||
@@ -84,6 +89,26 @@
|
||||
},
|
||||
methods: {
|
||||
getThumbUrl,
|
||||
getScoreText(score) {
|
||||
const map = {
|
||||
2: '拉',
|
||||
4: 'npc',
|
||||
6: '人上人',
|
||||
8: '顶级',
|
||||
10: '夯',
|
||||
}
|
||||
return map[score] || score
|
||||
},
|
||||
getScoreTagType(score) {
|
||||
const map = {
|
||||
2: 'info',
|
||||
4: 'warning',
|
||||
6: '',
|
||||
8: 'success',
|
||||
10: 'danger',
|
||||
}
|
||||
return map[score] || 'info'
|
||||
},
|
||||
async showEdit(row, topicId) {
|
||||
this.title = `给 ${row.name} 写评论`
|
||||
this.form = this.$options.data().form
|
||||
@@ -92,6 +117,8 @@
|
||||
this.dialogFormVisible = true
|
||||
|
||||
this.robotQuery.pageNo = 1
|
||||
this.robotQuery.onlyTopicId = topicId
|
||||
this.robotQuery.onlyItemId = row.id
|
||||
this.robotList = []
|
||||
this.robotTotal = 0
|
||||
await this.fetchRobotList()
|
||||
|
||||
@@ -31,10 +31,11 @@
|
||||
/>
|
||||
|
||||
<el-table v-loading="listLoading" :data="list" :element-loading-text="elementLoadingText">
|
||||
<el-table-column align="center" fixed="left" label="操作" width="120">
|
||||
<el-table-column align="center" fixed="left" label="操作" width="180">
|
||||
<template #default="{ row }">
|
||||
<el-button type="text" @click="handleRating(row)">评价</el-button>
|
||||
<el-button type="text" @click="handleComment(row)">评论</el-button>
|
||||
<el-button type="text" @click="handleScoreVote(row)">补评分</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
@@ -61,6 +62,13 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column align="left" label="用户信息" min-width="200" width="300">
|
||||
<template #default="{ row }">
|
||||
<user-info v-if="row.user" :user="row.user" :user-id="row.userId" />
|
||||
<span v-else>系统创建</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column align="left" label="分数统计">
|
||||
<template #default="{ row }">
|
||||
<div class="stat-cell">
|
||||
@@ -84,6 +92,17 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column align="left" label="分段票数" min-width="260">
|
||||
<template #default="{ row }">
|
||||
<div class="score-segment-list">
|
||||
<div v-for="score in scoreOptions" :key="score" class="score-segment-item">
|
||||
<span class="score-segment-label">{{ score }}分</span>
|
||||
<span class="score-segment-value">{{ getScoreCount(row.scores, score) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column align="left" label="互动数据" min-width="150">
|
||||
<template #default="{ row }">
|
||||
<div class="stat-cell">
|
||||
@@ -140,20 +159,41 @@
|
||||
|
||||
<topic-item-rating-edit ref="ratingEdit" @fetch-data="fetchData" />
|
||||
<topic-item-comment-edit ref="commentEdit" @fetch-data="fetchData" />
|
||||
|
||||
<el-dialog title="补充分段评分" :visible.sync="scoreVoteVisible" width="480px" @close="closeScoreVoteDialog">
|
||||
<el-form ref="scoreVoteForm" label-width="100px" :model="scoreVoteForm" :rules="scoreVoteRules">
|
||||
<el-form-item label="评价项">
|
||||
<span>{{ scoreVoteForm.itemName || '-' }}</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="分数段" prop="score">
|
||||
<el-select v-model="scoreVoteForm.score" placeholder="请选择分数段" style="width: 100%">
|
||||
<el-option v-for="score in scoreOptions" :key="score" :label="`${score}分`" :value="score" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="补充数量" prop="count">
|
||||
<el-input-number v-model="scoreVoteForm.count" controls-position="right" :max="100000" :min="1" :step="1" style="width: 100%" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<span slot="footer">
|
||||
<el-button @click="closeScoreVoteDialog">取 消</el-button>
|
||||
<el-button :loading="scoreVoteSubmitting" type="primary" @click="submitScoreVote">确 定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getList } from '@/api/rating/topicItem'
|
||||
import { getList, ItemScorevote } from '@/api/rating/topicItem'
|
||||
import { getList as getTopicList } from '@/api/rating/topic'
|
||||
import { formatTime } from '@/utils'
|
||||
import { getThumbUrl } from '@/utils/blessing'
|
||||
import TopicItemRatingEdit from './components/TopicItemRatingEdit'
|
||||
import TopicItemCommentEdit from './components/TopicItemCommentEdit'
|
||||
import UserInfo from '@/components/UserInfo'
|
||||
|
||||
export default {
|
||||
name: 'RatingTopicItemIndex',
|
||||
components: { TopicItemRatingEdit, TopicItemCommentEdit },
|
||||
components: { TopicItemRatingEdit, TopicItemCommentEdit, UserInfo },
|
||||
data() {
|
||||
return {
|
||||
list: [],
|
||||
@@ -168,6 +208,20 @@
|
||||
keyword: '',
|
||||
topicId: '',
|
||||
},
|
||||
scoreOptions: [2, 4, 6, 8, 10],
|
||||
scoreVoteVisible: false,
|
||||
scoreVoteSubmitting: false,
|
||||
scoreVoteForm: {
|
||||
topicId: '',
|
||||
itemId: '',
|
||||
itemName: '',
|
||||
score: 2,
|
||||
count: 1,
|
||||
},
|
||||
scoreVoteRules: {
|
||||
score: [{ required: true, trigger: 'change', message: '请选择分数段' }],
|
||||
count: [{ required: true, trigger: 'change', message: '请输入补充数量' }],
|
||||
},
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
@@ -235,6 +289,48 @@
|
||||
handleComment(row) {
|
||||
this.$refs['commentEdit'].showEdit(row, this.queryForm.topicId)
|
||||
},
|
||||
getScoreCount(scores, score) {
|
||||
if (!scores) return 0
|
||||
return scores[score] || scores[String(score)] || 0
|
||||
},
|
||||
handleScoreVote(row) {
|
||||
this.scoreVoteForm = {
|
||||
topicId: this.queryForm.topicId,
|
||||
itemId: row.id,
|
||||
itemName: row.name,
|
||||
score: 2,
|
||||
count: 1,
|
||||
}
|
||||
this.scoreVoteVisible = true
|
||||
},
|
||||
closeScoreVoteDialog() {
|
||||
this.scoreVoteVisible = false
|
||||
if (this.$refs['scoreVoteForm']) {
|
||||
this.$refs['scoreVoteForm'].resetFields()
|
||||
}
|
||||
},
|
||||
submitScoreVote() {
|
||||
this.$refs['scoreVoteForm'].validate(async (valid) => {
|
||||
if (!valid) return false
|
||||
this.scoreVoteSubmitting = true
|
||||
try {
|
||||
const params = {
|
||||
topicId: this.scoreVoteForm.topicId,
|
||||
itemId: this.scoreVoteForm.itemId,
|
||||
score: this.scoreVoteForm.score,
|
||||
count: this.scoreVoteForm.count,
|
||||
}
|
||||
const { msg } = await ItemScorevote(params)
|
||||
this.$baseMessage(msg || '补充评分成功', 'success')
|
||||
this.closeScoreVoteDialog()
|
||||
this.fetchData()
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
this.scoreVoteSubmitting = false
|
||||
}
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
@@ -315,4 +411,29 @@
|
||||
color: #409eff;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.score-segment-list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.score-segment-item {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: 4px 10px;
|
||||
background: #f5f7fa;
|
||||
border-radius: 4px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.score-segment-label {
|
||||
color: #606266;
|
||||
margin-right: 6px;
|
||||
}
|
||||
|
||||
.score-segment-value {
|
||||
color: #409eff;
|
||||
font-weight: bold;
|
||||
}
|
||||
</style>
|
||||
|
||||
171
src/views/rating/topicItemReview/index.vue
Normal file
171
src/views/rating/topicItemReview/index.vue
Normal file
@@ -0,0 +1,171 @@
|
||||
<template>
|
||||
<div class="rating-topic-item-review-container">
|
||||
<el-table v-loading="listLoading" :data="list" :element-loading-text="elementLoadingText">
|
||||
<el-table-column align="left" label="评分项" min-width="260">
|
||||
<template #default="{ row }">
|
||||
<div class="item-info-cell">
|
||||
<el-image v-if="row.avatarUrl" class="item-avatar" :src="getThumbUrl(row.avatarUrl)" />
|
||||
<div v-else class="item-avatar-placeholder"><i class="el-icon-picture-outline" /></div>
|
||||
<div class="item-details">
|
||||
<div class="item-name">{{ row.name || '-' }}</div>
|
||||
<div class="item-sub" :title="row.topic && row.topic.title ? row.topic.title : row.topicId">
|
||||
<span class="sub-label">所属话题:</span>
|
||||
<span class="sub-value">{{ row.topic && row.topic.title ? row.topic.title : row.topicId || '-' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<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="createdAt" width="160">
|
||||
<template #default="{ row }">
|
||||
{{ formatTime(row.createdAt) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column align="center" fixed="right" label="操作" width="180">
|
||||
<template #default="{ row }">
|
||||
<el-button size="mini" type="success" @click="handleReview(row, 2)">通过</el-button>
|
||||
<el-button size="mini" type="danger" @click="handleReview(row, 3)">拒绝</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"
|
||||
/>
|
||||
|
||||
<review-edit ref="edit" @fetch-data="fetchData" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getPendingList } from '@/api/rating/topicItem'
|
||||
import { formatTime } from '@/utils'
|
||||
import { getThumbUrl } from '@/utils/blessing'
|
||||
import ReviewEdit from '@/views/rating/topicReview/components/ReviewEdit'
|
||||
|
||||
export default {
|
||||
name: 'RatingTopicItemReviewIndex',
|
||||
components: { ReviewEdit },
|
||||
data() {
|
||||
return {
|
||||
list: [],
|
||||
listLoading: true,
|
||||
layout: 'total, sizes, prev, pager, next, jumper',
|
||||
total: 0,
|
||||
elementLoadingText: '正在加载...',
|
||||
queryForm: {
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
},
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.fetchData()
|
||||
},
|
||||
methods: {
|
||||
formatTime,
|
||||
getThumbUrl,
|
||||
handleSizeChange(val) {
|
||||
this.queryForm.pageSize = val
|
||||
this.fetchData()
|
||||
},
|
||||
handleCurrentChange(val) {
|
||||
this.queryForm.pageNo = val
|
||||
this.fetchData()
|
||||
},
|
||||
async fetchData() {
|
||||
this.listLoading = true
|
||||
try {
|
||||
const { data } = await getPendingList(this.queryForm)
|
||||
this.list = data.list || []
|
||||
this.total = data.totalCount || 0
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
this.listLoading = false
|
||||
}
|
||||
},
|
||||
handleReview(row, status) {
|
||||
this.$refs['edit'].showEdit(row, status, 'topicItem')
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.rating-topic-item-review-container {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.item-info-cell {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.item-avatar,
|
||||
.item-avatar-placeholder {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border-radius: 50%;
|
||||
margin-right: 12px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.item-avatar-placeholder {
|
||||
background-color: #f0f2f5;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #909399;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.item-details {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.item-name {
|
||||
font-weight: bold;
|
||||
color: #303133;
|
||||
margin-bottom: 4px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.item-sub {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.sub-label {
|
||||
margin-right: 4px;
|
||||
}
|
||||
|
||||
.sub-value {
|
||||
color: #606266;
|
||||
}
|
||||
</style>
|
||||
198
src/views/rating/topicItemReviewLog/index.vue
Normal file
198
src/views/rating/topicItemReviewLog/index.vue
Normal file
@@ -0,0 +1,198 @@
|
||||
<template>
|
||||
<div class="rating-review-log-container">
|
||||
<el-table v-loading="listLoading" :data="list" :element-loading-text="elementLoadingText">
|
||||
<el-table-column align="center" label="审核类型" width="100">
|
||||
<template #default="{ row }">
|
||||
<el-tag v-if="row.type === 'topic'">评价主题</el-tag>
|
||||
<el-tag v-else-if="row.type === 'topicItem'" type="warning">评分项</el-tag>
|
||||
<span v-else>{{ row.type }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column align="left" label="审核对象" min-width="260" width="260">
|
||||
<template #default="{ row }">
|
||||
<!-- 评分项类型 -->
|
||||
<div v-if="row.type === 'topicItem'" class="item-info-cell">
|
||||
<el-image v-if="row.itemAvatarUrl" class="item-avatar" :src="getThumbUrl(row.itemAvatarUrl)" />
|
||||
<div v-else class="item-avatar-placeholder"><i class="el-icon-picture-outline" /></div>
|
||||
<div class="item-details">
|
||||
<div class="item-name">{{ row.itemName || '-' }}</div>
|
||||
<div class="item-sub" :title="row.topicTitle">
|
||||
<span class="sub-label">所属话题:</span>
|
||||
<span class="sub-value">{{ row.topicTitle || '-' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 评价主题类型 -->
|
||||
<div v-else class="item-info-cell">
|
||||
<div class="item-avatar-placeholder" style="border-radius: 4px"><i class="el-icon-document" /></div>
|
||||
<div class="item-details">
|
||||
<div class="item-name">{{ row.topicTitle || '-' }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column align="center" label="审核结果" width="100">
|
||||
<template #default="{ row }">
|
||||
<el-tag v-if="row.auditStatus === 2" type="success">已通过</el-tag>
|
||||
<el-tag v-else-if="row.auditStatus === 3" type="danger">已拒绝</el-tag>
|
||||
<el-tag v-else-if="row.auditStatus === 4" type="info">禁用</el-tag>
|
||||
<span v-else>{{ row.auditStatus }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column align="left" label="审核备注 / 拒绝原因" min-width="200">
|
||||
<template #default="{ row }">
|
||||
<div v-if="row.rejectReason" class="remark-row">
|
||||
<span class="remark-label" style="color: #f56c6c">拒绝原因:</span>
|
||||
<span>{{ row.rejectReason }}</span>
|
||||
</div>
|
||||
<div v-if="row.auditRemark" class="remark-row">
|
||||
<span class="remark-label">审核备注:</span>
|
||||
<span>{{ row.auditRemark }}</span>
|
||||
</div>
|
||||
<span v-if="!row.rejectReason && !row.auditRemark">-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column align="center" label="审核员 ID" prop="auditorId" width="220" />
|
||||
|
||||
<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 { getReviewLogList } from '@/api/rating/topicOperate'
|
||||
import { formatTime } from '@/utils'
|
||||
import { getThumbUrl } from '@/utils/blessing'
|
||||
|
||||
export default {
|
||||
name: 'RatingTopicItemReviewLogIndex',
|
||||
data() {
|
||||
return {
|
||||
list: [],
|
||||
listLoading: true,
|
||||
layout: 'total, sizes, prev, pager, next, jumper',
|
||||
total: 0,
|
||||
elementLoadingText: '正在加载...',
|
||||
queryForm: {
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
},
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.fetchData()
|
||||
},
|
||||
methods: {
|
||||
formatTime,
|
||||
getThumbUrl,
|
||||
handleSizeChange(val) {
|
||||
this.queryForm.pageSize = val
|
||||
this.fetchData()
|
||||
},
|
||||
handleCurrentChange(val) {
|
||||
this.queryForm.pageNo = val
|
||||
this.fetchData()
|
||||
},
|
||||
async fetchData() {
|
||||
this.listLoading = true
|
||||
try {
|
||||
const { data } = await getReviewLogList(this.queryForm)
|
||||
this.list = data.list || []
|
||||
this.total = data.totalCount || 0
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
this.listLoading = false
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.rating-review-log-container {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.item-info-cell {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.item-avatar,
|
||||
.item-avatar-placeholder {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border-radius: 50%;
|
||||
margin-right: 12px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.item-avatar-placeholder {
|
||||
background-color: #f0f2f5;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #909399;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.item-details {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.item-name {
|
||||
font-weight: bold;
|
||||
color: #303133;
|
||||
margin-bottom: 4px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.item-sub {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.sub-label {
|
||||
margin-right: 4px;
|
||||
}
|
||||
|
||||
.sub-value {
|
||||
color: #606266;
|
||||
}
|
||||
|
||||
.remark-row {
|
||||
font-size: 13px;
|
||||
line-height: 1.5;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
|
||||
.remark-label {
|
||||
color: #909399;
|
||||
}
|
||||
</style>
|
||||
143
src/views/rating/topicRecommend/components/TopicRecommendAdd.vue
Normal file
143
src/views/rating/topicRecommend/components/TopicRecommendAdd.vue
Normal file
@@ -0,0 +1,143 @@
|
||||
<template>
|
||||
<el-dialog :title="title" :visible.sync="dialogFormVisible" width="560px" @close="close">
|
||||
<el-form ref="form" label-width="100px" :model="form" :rules="rules">
|
||||
<el-form-item label="选择话题" prop="topicId">
|
||||
<el-select
|
||||
v-model="form.topicId"
|
||||
v-loadmore="loadMoreTopics"
|
||||
filterable
|
||||
placeholder="请选择推荐话题"
|
||||
:popper-append-to-body="false"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option v-for="item in topicList" :key="item.id" :label="item.title" :value="item.id">
|
||||
<div class="topic-option">
|
||||
<span class="topic-option-title">{{ item.title }}</span>
|
||||
<el-tag v-if="item.status === 2" size="mini" type="success">已通过</el-tag>
|
||||
<el-tag v-else-if="item.status === 1" size="mini" type="warning">审核中</el-tag>
|
||||
<el-tag v-else-if="item.status === 3" size="mini" type="danger">已拒绝</el-tag>
|
||||
<el-tag v-else-if="item.status === 4" size="mini" type="info">禁用</el-tag>
|
||||
</div>
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="close">取 消</el-button>
|
||||
<el-button :loading="saving" type="primary" @click="save">确 定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getList as getTopicList } from '@/api/rating/topic'
|
||||
import { doAdd } from '@/api/rating/topicRecommend'
|
||||
|
||||
export default {
|
||||
name: 'TopicRecommendAdd',
|
||||
directives: {
|
||||
loadmore: {
|
||||
bind(el, binding) {
|
||||
setTimeout(() => {
|
||||
const SELECTWRAP_DOM = el.querySelector('.el-select-dropdown .el-select-dropdown__wrap')
|
||||
if (SELECTWRAP_DOM) {
|
||||
SELECTWRAP_DOM.addEventListener('scroll', function () {
|
||||
const condition = this.scrollHeight - this.scrollTop <= this.clientHeight + 2
|
||||
if (condition) {
|
||||
binding.value()
|
||||
}
|
||||
})
|
||||
}
|
||||
}, 0)
|
||||
},
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
title: '添加推荐话题',
|
||||
dialogFormVisible: false,
|
||||
saving: false,
|
||||
form: {
|
||||
topicId: '',
|
||||
},
|
||||
rules: {
|
||||
topicId: [{ required: true, trigger: 'change', message: '请选择推荐话题' }],
|
||||
},
|
||||
topicList: [],
|
||||
topicQuery: {
|
||||
pageNo: 1,
|
||||
pageSize: 20,
|
||||
type: 'recommend',
|
||||
},
|
||||
topicTotal: 0,
|
||||
fetchingTopics: false,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
showEdit() {
|
||||
this.form = this.$options.data().form
|
||||
this.dialogFormVisible = true
|
||||
this.topicQuery.pageNo = 1
|
||||
this.topicList = []
|
||||
this.topicTotal = 0
|
||||
this.fetchTopicList()
|
||||
},
|
||||
close() {
|
||||
this.$refs['form'].resetFields()
|
||||
this.form = this.$options.data().form
|
||||
this.dialogFormVisible = false
|
||||
this.saving = false
|
||||
},
|
||||
async fetchTopicList() {
|
||||
if (this.fetchingTopics) return
|
||||
this.fetchingTopics = true
|
||||
try {
|
||||
const { data } = await getTopicList(this.topicQuery)
|
||||
this.topicList = this.topicList.concat(data.list || [])
|
||||
this.topicTotal = data.totalCount || 0
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
this.fetchingTopics = false
|
||||
}
|
||||
},
|
||||
loadMoreTopics() {
|
||||
if (this.topicList.length >= this.topicTotal || this.fetchingTopics) return
|
||||
this.topicQuery.pageNo += 1
|
||||
this.fetchTopicList()
|
||||
},
|
||||
save() {
|
||||
this.$refs['form'].validate(async (valid) => {
|
||||
if (!valid) return false
|
||||
this.saving = true
|
||||
try {
|
||||
const { msg } = await doAdd(this.form)
|
||||
this.$baseMessage(msg || '添加推荐成功', 'success')
|
||||
this.$emit('fetch-data')
|
||||
this.close()
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
this.saving = false
|
||||
}
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.topic-option {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.topic-option-title {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
</style>
|
||||
171
src/views/rating/topicRecommend/index.vue
Normal file
171
src/views/rating/topicRecommend/index.vue
Normal file
@@ -0,0 +1,171 @@
|
||||
<template>
|
||||
<div class="topic-recommend-container">
|
||||
<vab-query-form>
|
||||
<vab-query-form-left-panel :span="12">
|
||||
<el-button icon="el-icon-plus" type="primary" @click="handleAdd">添加推荐</el-button>
|
||||
</vab-query-form-left-panel>
|
||||
</vab-query-form>
|
||||
|
||||
<el-table v-loading="listLoading" :data="list" :element-loading-text="elementLoadingText">
|
||||
<el-table-column align="left" label="推荐话题" min-width="220" width="220">
|
||||
<template #default="{ row }">
|
||||
<div class="topic-cell" @click="handleClick(row.topic)">
|
||||
<div class="topic-title">{{ row.topic ? row.topic.title : '-' }}</div>
|
||||
<div class="topic-meta">
|
||||
<span class="meta-label">Topic ID:</span>
|
||||
<span>{{ row.topicId }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column align="center" label="话题状态" width="100">
|
||||
<template #default="{ row }">
|
||||
<el-tag v-if="row.topic && row.topic.status === 1" type="warning">审核中</el-tag>
|
||||
<el-tag v-else-if="row.topic && row.topic.status === 2" type="success">已通过</el-tag>
|
||||
<el-tag v-else-if="row.topic && row.topic.status === 3" type="danger">已拒绝</el-tag>
|
||||
<el-tag v-else-if="row.topic && row.topic.status === 4" type="info">禁用</el-tag>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column align="center" label="排序" prop="sort" width="120">
|
||||
<template #default="{ row }">
|
||||
<el-input v-model="row.sort" placeholder="排序" size="mini" @blur="handleMove(row)" @keyup.enter.native="handleMove(row)" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column align="center" label="启用" width="100">
|
||||
<template #default="{ row }">
|
||||
<el-switch v-model="row.enable" :active-value="true" :inactive-value="false" @change="handleToggleStatus(row)" />
|
||||
</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"
|
||||
/>
|
||||
|
||||
<topic-recommend-add ref="add" @fetch-data="fetchData" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getList, toggleEnable, moveTo } from '@/api/rating/topicRecommend'
|
||||
import TopicRecommendAdd from './components/TopicRecommendAdd'
|
||||
|
||||
export default {
|
||||
name: 'RatingTopicRecommendIndex',
|
||||
components: { TopicRecommendAdd },
|
||||
data() {
|
||||
return {
|
||||
list: [],
|
||||
listLoading: true,
|
||||
layout: 'total, sizes, prev, pager, next, jumper',
|
||||
total: 0,
|
||||
elementLoadingText: '正在加载...',
|
||||
queryForm: {
|
||||
pageNo: 1,
|
||||
pageSize: 20,
|
||||
},
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.fetchData()
|
||||
},
|
||||
methods: {
|
||||
handleAdd() {
|
||||
this.$refs['add'].showEdit()
|
||||
},
|
||||
handleSizeChange(val) {
|
||||
this.queryForm.pageSize = val
|
||||
this.fetchData()
|
||||
},
|
||||
handleCurrentChange(val) {
|
||||
this.queryForm.pageNo = val
|
||||
this.fetchData()
|
||||
},
|
||||
handleClick(topic) {
|
||||
this.$router.push({
|
||||
path: '/rating/topic',
|
||||
query: {
|
||||
topicId: topic.id,
|
||||
},
|
||||
})
|
||||
},
|
||||
async fetchData() {
|
||||
this.listLoading = true
|
||||
try {
|
||||
const { data } = await getList(this.queryForm)
|
||||
this.list = data.list || []
|
||||
this.total = data.totalCount || 0
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
this.listLoading = false
|
||||
}
|
||||
},
|
||||
async handleToggleStatus(row) {
|
||||
try {
|
||||
const { msg } = await toggleEnable(row.id, row.enable)
|
||||
this.$baseMessage(msg || '状态切换成功', 'success')
|
||||
this.fetchData()
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
row.enable = !row.enable
|
||||
}
|
||||
},
|
||||
async handleMove(row) {
|
||||
const sortVal = Number(row.sort)
|
||||
if (isNaN(sortVal)) {
|
||||
this.$message.error('排序必须是数字')
|
||||
this.fetchData()
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const { msg } = await moveTo(row.id, sortVal)
|
||||
this.$baseMessage(msg || '移动成功', 'success')
|
||||
this.fetchData()
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
this.fetchData()
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.topic-recommend-container {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.topic-cell {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.topic-title {
|
||||
color: #303133;
|
||||
font-weight: bold;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
|
||||
.topic-meta {
|
||||
color: #909399;
|
||||
font-size: 12px;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.meta-label {
|
||||
margin-right: 4px;
|
||||
}
|
||||
</style>
|
||||
81
src/views/rating/topicReview/components/ReviewEdit.vue
Normal file
81
src/views/rating/topicReview/components/ReviewEdit.vue
Normal file
@@ -0,0 +1,81 @@
|
||||
<template>
|
||||
<el-dialog :title="title" :visible.sync="dialogFormVisible" width="500px" @close="close">
|
||||
<el-form ref="form" label-width="100px" :model="form">
|
||||
<el-form-item label="审核结果">
|
||||
<el-tag :type="form.status === 2 ? 'success' : 'danger'">
|
||||
{{ form.status === 2 ? '通过' : '拒绝' }}
|
||||
</el-tag>
|
||||
</el-form-item>
|
||||
<el-form-item v-if="form.status === 3" label="拒绝原因">
|
||||
<el-input v-model="form.rejectReason" placeholder="选填,请输入拒绝原因" :rows="3" type="textarea" />
|
||||
</el-form-item>
|
||||
<el-form-item label="审核备注">
|
||||
<el-input v-model="form.auditRemark" placeholder="选填,请输入内部审核备注" :rows="3" type="textarea" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="close">取 消</el-button>
|
||||
<el-button :loading="saving" type="primary" @click="save">确 定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { reviewTopic } from '@/api/rating/topicOperate'
|
||||
|
||||
export default {
|
||||
name: 'ReviewEdit',
|
||||
data() {
|
||||
return {
|
||||
title: '审核确认',
|
||||
dialogFormVisible: false,
|
||||
saving: false,
|
||||
form: {
|
||||
topicId: '',
|
||||
itemId: '',
|
||||
userId: '',
|
||||
status: '',
|
||||
type: '', // topic 或 topicItem
|
||||
rejectReason: '',
|
||||
auditRemark: '',
|
||||
},
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
showEdit(row, status, type) {
|
||||
this.title = `审核确认 (${type === 'topic' ? '话题' : '评价项'})`
|
||||
this.form = {
|
||||
topicId: type === 'topic' ? row.id : row.topicId || '',
|
||||
itemId: type === 'topicItem' ? row.id : '',
|
||||
userId: this.$store.state.user.userId || '',
|
||||
status,
|
||||
type,
|
||||
rejectReason: '',
|
||||
auditRemark: '',
|
||||
}
|
||||
this.dialogFormVisible = true
|
||||
},
|
||||
close() {
|
||||
this.dialogFormVisible = false
|
||||
this.saving = false
|
||||
},
|
||||
async save() {
|
||||
this.saving = true
|
||||
try {
|
||||
const payload = { ...this.form }
|
||||
if (payload.itemId && !payload.itemmId) {
|
||||
payload.itemmId = payload.itemId
|
||||
}
|
||||
const { msg } = await reviewTopic(payload)
|
||||
this.$baseMessage(msg || '操作成功', 'success')
|
||||
this.$emit('fetch-data')
|
||||
this.close()
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
this.saving = false
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
284
src/views/rating/topicReview/index.vue
Normal file
284
src/views/rating/topicReview/index.vue
Normal file
@@ -0,0 +1,284 @@
|
||||
<template>
|
||||
<div class="rating-topic-review-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">
|
||||
<!-- 展开行,展示评价项(topicItems) -->
|
||||
<el-table-column type="expand">
|
||||
<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" 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)" />
|
||||
<span>{{ scope.row.name }}</span>
|
||||
</div>
|
||||
</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>
|
||||
<el-tag v-else-if="scope.row.status === 2" size="mini" type="success">已审通过</el-tag>
|
||||
<el-tag v-else-if="scope.row.status === 3" size="mini" type="danger">已拒绝</el-tag>
|
||||
<el-tag v-else-if="scope.row.status === 4" size="mini" type="info">禁用</el-tag>
|
||||
<span v-else>-</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column align="center" label="创建时间" prop="createdAt" width="160">
|
||||
<template #default="scope">
|
||||
{{ formatTime(scope.row.createdAt) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<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>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
<div v-else class="expand-empty">该话题下暂无评价项</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<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>
|
||||
</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>
|
||||
</el-table-column>
|
||||
|
||||
<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="createdAt" width="160">
|
||||
<template #default="{ row }">
|
||||
{{ formatTime(row.createdAt) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column align="center" label="操作" width="180">
|
||||
<template #default="{ row }">
|
||||
<el-button :disabled="!canReviewTopic(row)" size="mini" type="success" @click="handleReview(row, 2, 'topic')">通过</el-button>
|
||||
<el-button :disabled="!canReviewTopic(row)" size="mini" type="danger" @click="handleReview(row, 3, 'topic')">拒绝</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"
|
||||
/>
|
||||
|
||||
<review-edit ref="edit" @fetch-data="fetchData" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getPendingList } from '@/api/rating/topic'
|
||||
import { formatTime } from '@/utils'
|
||||
import { getThumbUrl } from '@/utils/blessing'
|
||||
import ReviewEdit from './components/ReviewEdit'
|
||||
|
||||
export default {
|
||||
name: 'RatingTopicReviewIndex',
|
||||
components: { ReviewEdit },
|
||||
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,
|
||||
canReviewTopic(row) {
|
||||
const items = row && row.topicItems ? row.topicItems : []
|
||||
if (!items.length) return true
|
||||
return items.every((item) => [2, 3, 4].includes(item && item.status))
|
||||
},
|
||||
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 getPendingList(this.queryForm)
|
||||
this.list = data.list
|
||||
this.total = data.totalCount
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
this.listLoading = false
|
||||
}
|
||||
},
|
||||
handleReview(row, status, type) {
|
||||
if (type === 'topic' && !this.canReviewTopic(row)) {
|
||||
this.$message.warning('请先审核该话题下所有评分项,再审核话题')
|
||||
return
|
||||
}
|
||||
this.$refs['edit'].showEdit(row, status, type)
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.rating-topic-review-container {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.expand-content {
|
||||
padding: 15px 40px;
|
||||
background-color: #fafafa;
|
||||
border-radius: 4px;
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.expand-content h4 {
|
||||
margin: 0 0 15px 0;
|
||||
color: #606266;
|
||||
font-size: 14px;
|
||||
}
|
||||
.expand-empty {
|
||||
padding: 20px;
|
||||
text-align: center;
|
||||
color: #909399;
|
||||
}
|
||||
.item-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
.item-avatar {
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
border-radius: 50%;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.topic-info-cell {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.topic-cover,
|
||||
.topic-cover-placeholder {
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
border-radius: 4px;
|
||||
margin-right: 12px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.topic-cover-placeholder {
|
||||
background-color: #f0f2f5;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #909399;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.topic-details {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.topic-title {
|
||||
font-weight: bold;
|
||||
color: #303133;
|
||||
margin-bottom: 4px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.topic-desc {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.stat-cell {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.stat-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.stat-label {
|
||||
color: #909399;
|
||||
width: 90px;
|
||||
}
|
||||
|
||||
.stat-value {
|
||||
color: #606266;
|
||||
}
|
||||
</style>
|
||||
@@ -108,26 +108,7 @@
|
||||
</el-table-column>
|
||||
<el-table-column align="left" label="用户信息" min-width="200">
|
||||
<template #default="{ row }">
|
||||
<div v-if="row.user" class="user-info-cell">
|
||||
<el-image
|
||||
v-if="row.user.avatar"
|
||||
class="user-avatar"
|
||||
:preview-src-list="[row.user.avatar]"
|
||||
:src="getThumbUrl(row.user.avatar)"
|
||||
/>
|
||||
<div v-else class="user-avatar-placeholder"><i class="el-icon-user" /></div>
|
||||
<div class="user-details">
|
||||
<div class="user-nickname">
|
||||
{{ row.user.nickname || '未知用户' }}
|
||||
<el-tag v-if="row.user.isRobot" size="mini" style="margin-left: 4px" type="info">机器人</el-tag>
|
||||
<el-tag v-else size="mini" style="margin-left: 4px" type="success">真人</el-tag>
|
||||
</div>
|
||||
<div class="user-id">{{ row.user.id }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="user-details">
|
||||
<div class="user-id">{{ row.userId }}</div>
|
||||
</div>
|
||||
<user-info :user="row.user" :user-id="row.userId" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
@@ -161,11 +142,12 @@
|
||||
import { getList as getItemList } from '@/api/rating/topicItem'
|
||||
import { formatTime } from '@/utils'
|
||||
import { getThumbUrl } from '@/utils/blessing'
|
||||
import UserInfo from '@/components/UserInfo'
|
||||
import RecordRatingEdit from './components/RecordRatingEdit'
|
||||
|
||||
export default {
|
||||
name: 'RatingTopicRecordIndex',
|
||||
components: { RecordRatingEdit },
|
||||
components: { RecordRatingEdit, UserInfo },
|
||||
directives: {
|
||||
loadmore: {
|
||||
bind(el, binding) {
|
||||
@@ -392,45 +374,6 @@
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
/* 用户信息列样式 */
|
||||
.user-info-cell {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
.user-avatar,
|
||||
.user-avatar-placeholder {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border-radius: 50%;
|
||||
margin-right: 12px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.user-avatar-placeholder {
|
||||
background-color: #f0f2f5;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: #909399;
|
||||
font-size: 20px;
|
||||
}
|
||||
.user-details {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
.user-nickname {
|
||||
font-weight: bold;
|
||||
color: #303133;
|
||||
margin-bottom: 4px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.user-id {
|
||||
font-size: 12px;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
/* 评价目标列样式 */
|
||||
.target-info-cell {
|
||||
display: flex;
|
||||
|
||||
@@ -92,6 +92,18 @@
|
||||
<robot-rating-edit ref="ratingEdit" @fetch-data="fetchData" />
|
||||
<robot-comment-edit ref="commentEdit" @fetch-data="fetchData" />
|
||||
<robot-comment-view ref="commentView" />
|
||||
|
||||
<el-dialog title="生成机器人" :visible.sync="generateDialogVisible" width="420px" @close="closeGenerateDialog">
|
||||
<el-form ref="generateForm" label-width="100px" :model="generateForm" :rules="generateRules">
|
||||
<el-form-item label="生成个数" prop="count">
|
||||
<el-input-number v-model="generateForm.count" controls-position="right" :max="1000" :min="1" :step="1" style="width: 100%" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<span slot="footer">
|
||||
<el-button @click="closeGenerateDialog">取消</el-button>
|
||||
<el-button :loading="generateSubmitting" type="primary" @click="submitGenerate">确定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -121,6 +133,14 @@
|
||||
keyword: '',
|
||||
},
|
||||
applicationList: [],
|
||||
generateDialogVisible: false,
|
||||
generateSubmitting: false,
|
||||
generateForm: {
|
||||
count: 1,
|
||||
},
|
||||
generateRules: {
|
||||
count: [{ required: true, trigger: 'change', message: '请输入生成个数' }],
|
||||
},
|
||||
}
|
||||
},
|
||||
created() {
|
||||
@@ -150,13 +170,30 @@
|
||||
this.$baseMessage('请先选择应用', 'error')
|
||||
return
|
||||
}
|
||||
try {
|
||||
const { msg } = await generate(this.queryForm.appId)
|
||||
this.$baseMessage(msg || '生成成功', 'success')
|
||||
this.fetchData()
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
this.generateDialogVisible = true
|
||||
},
|
||||
closeGenerateDialog() {
|
||||
this.generateDialogVisible = false
|
||||
if (this.$refs['generateForm']) {
|
||||
this.$refs['generateForm'].resetFields()
|
||||
}
|
||||
this.generateForm.count = 1
|
||||
},
|
||||
submitGenerate() {
|
||||
this.$refs['generateForm'].validate(async (valid) => {
|
||||
if (!valid) return false
|
||||
this.generateSubmitting = true
|
||||
try {
|
||||
const { msg } = await generate(this.queryForm.appId, this.generateForm.count)
|
||||
this.$baseMessage(msg || '生成成功', 'success')
|
||||
this.closeGenerateDialog()
|
||||
this.fetchData()
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
this.generateSubmitting = false
|
||||
}
|
||||
})
|
||||
},
|
||||
handleSizeChange(val) {
|
||||
this.queryForm.pageSize = val
|
||||
|
||||
Reference in New Issue
Block a user