42 Commits

Author SHA1 Message Date
zzc
0ef2b697a3 fix: type
All checks were successful
continuous-integration/drone/tag Build is passing
2026-06-15 23:44:29 +08:00
zzc
97f2e6a17c fix: pk comment
All checks were successful
continuous-integration/drone/tag Build is passing
2026-06-15 22:28:39 +08:00
zzc
9e59ae710a fix: pk comment 2026-06-15 22:02:59 +08:00
zzc
5f9a5aeae7 fix: pk comment 2026-06-15 20:15:44 +08:00
zzc
a260b98725 feat: audit 2026-06-15 15:49:51 +08:00
zzc
4fb04c2be8 feat: audit 2026-06-15 15:37:27 +08:00
zzc
2d84ee213c feat: rating 2026-06-14 23:11:04 +08:00
zzc
e032412adf Merge branch 'main' of repository.lihailezzc.com:zzc/api-client
All checks were successful
continuous-integration/drone/tag Build is passing
2026-06-13 19:47:54 +08:00
zzc
d44f88b124 feat: rating 2026-06-13 19:47:40 +08:00
zzc
790a2658d5 fix: youhua 2026-06-10 01:38:55 +08:00
zzc
993b5f8eef fix: rating 2026-06-09 16:07:02 +08:00
zzc
acef084df7 fix: rating 2026-06-09 10:05:24 +08:00
zzc
b5a246f11b fix: rating 2026-06-09 07:52:09 +08:00
zzc
ffbd355393 fix: rating 2026-06-08 23:07:09 +08:00
zzc
0dc2c2f0c3 fix: rating 2026-06-08 19:08:39 +08:00
zzc
6f99958275 rating 2026-06-01 23:54:12 +08:00
zzc
6b3dbec68e rating 2026-06-01 19:00:17 +08:00
zzc
908f3ad1b1 rating 2026-06-01 18:50:47 +08:00
zzc
4789ac6ca0 rating 2026-06-01 18:25:23 +08:00
zzc
af23adfd2b rating 2026-06-01 16:26:51 +08:00
zzc
ca1585962b rating 2026-06-01 16:18:27 +08:00
zzc
99bc334d0b rating 2026-06-01 16:10:52 +08:00
zzc
f3c42fb83c rating 2026-06-01 16:05:28 +08:00
zzc
77ca847b38 rating 2026-06-01 15:39:58 +08:00
zzc
4f81850583 rating 2026-06-01 10:30:44 +08:00
zzc
6cb7be6658 rating 2026-06-01 10:22:07 +08:00
zzc
69fa3f4a43 rating 2026-06-01 08:00:44 +08:00
zzc
d26db99e54 rating 2026-06-01 07:21:43 +08:00
zzc
5df4664b16 rating 2026-06-01 06:35:41 +08:00
zzc
9928bc3329 robot 2026-05-27 23:35:27 +08:00
zzc
6322b0962b rating 2026-05-27 22:28:15 +08:00
zzc
4bb09a0fb1 fix: system
All checks were successful
continuous-integration/drone/tag Build is passing
2026-04-22 21:51:49 +08:00
zzc
90bbed91f0 fix: message obj 2026-04-22 19:20:32 +08:00
zzc
6b8e8ab5d8 fix: message obj 2026-04-22 19:13:28 +08:00
zzc
f86e4b5b9a fix: add black 2026-04-21 23:09:36 +08:00
zzc
b52d832986 fix: add black 2026-04-21 22:46:53 +08:00
zzc
1121a6fa64 feat: card musin
All checks were successful
continuous-integration/drone/tag Build is passing
2026-03-19 16:44:33 +08:00
zzc
6bf6aee099 fix: avatar page
All checks were successful
continuous-integration/drone/tag Build is passing
2026-03-17 10:23:27 +08:00
zzc
897179d48e fix: avatar page 2026-03-17 10:17:16 +08:00
zzc
f9eed6f020 fix: reward page 2026-03-17 10:02:17 +08:00
zzc
2a89ef310b fix: reward page 2026-03-17 08:52:08 +08:00
zzc
2aec094d27 fix: reward page 2026-03-17 08:41:56 +08:00
76 changed files with 9396 additions and 51 deletions

99
src/api/rating/pk.js Normal file
View File

@@ -0,0 +1,99 @@
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 } 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,
})
}

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

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

View File

@@ -0,0 +1,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,
})
}

View File

@@ -0,0 +1,60 @@
import request from '@/utils/request'
export function getList(data) {
return request({
url: 'management/api/rating/topicItem/list',
method: 'get',
params: data,
})
}
export function getAllList(data) {
return request({
url: 'management/api/rating/topicItem/list/all',
method: 'get',
params: data,
})
}
export function doAdd(data) {
return request({
url: 'management/api/rating/topicItem',
method: 'post',
data,
})
}
export function doEdit(id, data) {
return request({
url: `/management/api/rating/topicItem/${id}`,
method: 'put',
data,
})
}
export function doDelete(data) {
return request({
url: `/management/api/rating/topicItem`,
method: 'delete',
data,
})
}
export function toggleEnable(id, isEnabled) {
return request({
url: `/management/api/rating/topicItem/enable/${id}`,
method: 'patch',
data: { isEnabled },
})
}
/**
* 评分项审核列表
*/
export function getPendingList(data) {
return request({
url: 'management/api/rating/topicItem/pending/list',
method: 'get',
params: data,
})
}

View File

@@ -0,0 +1,96 @@
import request from '@/utils/request'
// 评分
/**
* 评分
* @param {*} { topicId, itemId, scoreType, userId }
* @returns
*/
export function score(data) {
return request({
url: 'management/api/rating/topicItemOperate/score',
method: 'post',
data,
})
}
/**
* 评分记录
* @param {*} { pageNo, pageSize, userId?, topicId?, itemId?, trueUser? }
* @returns
*/
export function scoreRecordList(data) {
return request({
url: 'management/api/rating/topicItemOperate/score/list',
method: 'get',
params: data,
})
}
/**
* 评论记录
* @param {*} { pageNo, pageSize, userId?, topicId?, itemId?, trueUser? }
* @returns
*/
export function userCommentList(data) {
return request({
url: 'management/api/rating/topicItemOperate/comment/list',
method: 'get',
params: data,
})
}
/**
* 评论
* @param {*} { topicId, itemId, comment, userId }
* @returns
*/
export function comment(data) {
return request({
url: 'management/api/rating/topicItemOperate/comment',
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,
})
}

View 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,
})
}

View File

@@ -0,0 +1,62 @@
import request from '@/utils/request'
export function getList(data) {
return request({
url: '/management/api/spring/avatar-category/list',
method: 'get',
params: data,
})
}
export function getAll() {
return request({
url: '/management/api/spring/avatar-category/all',
method: 'get',
})
}
export function doAdd(data) {
return request({
url: '/management/api/spring/avatar-category',
method: 'post',
data,
})
}
export function doEdit(id, data) {
return request({
url: `/management/api/spring/avatar-category/${id}`,
method: 'put',
data,
})
}
export function doDelete(data) {
return request({
url: '/management/api/spring/avatar-category/delete',
method: 'put',
data,
})
}
export function doMoveUp(id) {
return request({
url: `/management/api/spring/avatar-category/moveUp/${id}`,
method: 'patch',
})
}
export function doMoveDown(id) {
return request({
url: `/management/api/spring/avatar-category/moveDown/${id}`,
method: 'patch',
})
}
export function toggleEnable(id, isEnabled) {
return request({
url: `/management/api/spring/avatar-category/enable/${id}`,
method: 'patch',
data: { isEnabled },
})
}

View File

@@ -0,0 +1,55 @@
import request from '@/utils/request'
export function getList(data) {
return request({
url: '/management/api/spring/card-music/list',
method: 'get',
params: data,
})
}
export function doAdd(data) {
return request({
url: '/management/api/spring/card-music',
method: 'post',
data,
})
}
export function doEdit(id, data) {
return request({
url: `/management/api/spring/card-music/${id}`,
method: 'put',
data,
})
}
export function doDelete(data) {
return request({
url: '/management/api/spring/card-music/delete',
method: 'put',
data,
})
}
export function doMoveUp(id) {
return request({
url: `/management/api/spring/card-music/moveUp/${id}`,
method: 'patch',
})
}
export function doMoveDown(id) {
return request({
url: `/management/api/spring/card-music/moveDown/${id}`,
method: 'patch',
})
}
export function toggleEnable(id, isEnabled) {
return request({
url: `/management/api/spring/card-music/enable/${id}`,
method: 'patch',
data: { isEnabled },
})
}

41
src/api/system/ability.js Normal file
View File

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

25
src/api/system/ipBlack.js Normal file
View File

@@ -0,0 +1,25 @@
import request from '@/utils/request'
export function getList(data) {
return request({
url: 'management/api/system/blacklist/ip/list',
method: 'get',
params: data,
})
}
export function doAdd(data) {
return request({
url: 'management/api/system/blacklist/ip',
method: 'post',
data,
})
}
export function doRemove(data) {
return request({
url: 'management/api/system/blacklist/ip/remove',
method: 'post',
data,
})
}

40
src/api/system/reward.js Normal file
View File

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

30
src/api/system/robot.js Normal file
View File

@@ -0,0 +1,30 @@
import request from '@/utils/request'
export function getList(data) {
return request({
url: 'management/api/system/robot/list',
method: 'get',
params: data,
})
}
/**
* 获取机器人列表(基础信息) {appId, pageNo, pageSize, topicId, itemId, commentId?}
* @param {*} data
* @returns
*/
export function getListBase(data) {
return request({
url: 'management/api/system/robot/list/base',
method: 'get',
params: data,
})
}
export function generate(appId) {
return request({
url: 'management/api/system/robot',
method: 'post',
data: { appId },
})
}

9
src/api/system/system.js Normal file
View File

@@ -0,0 +1,9 @@
import request from '@/utils/request'
export function getUserSignStatList(data) {
return request({
url: 'management/api/system/user-sign-stat/list',
method: 'get',
params: data,
})
}

14
src/api/system/user.js Normal file
View File

@@ -0,0 +1,14 @@
import request from '@/utils/request'
/**
* 获取用户列表
* @param {*} { pageNo, pageSize, appId?, trueUser? }
* @returns
*/
export function getList(data) {
return request({
url: 'management/api/system/user/list',
method: 'get',
params: data,
})
}

View File

@@ -0,0 +1,25 @@
import request from '@/utils/request'
export function getList(data) {
return request({
url: 'management/api/system/blacklist/user/list',
method: 'get',
params: data,
})
}
export function doAdd(data) {
return request({
url: 'management/api/system/blacklist/user',
method: 'post',
data,
})
}
export function doRemove(data) {
return request({
url: 'management/api/system/blacklist/user/remove',
method: 'post',
data,
})
}

View File

@@ -48,6 +48,109 @@ export const asyncRoutes = [
},
],
},
{
path: '/rating',
component: Layout,
redirect: 'noRedirect',
name: 'RatingMini',
meta: { title: '夯拉评分', icon: 'gift', permissions: ['admin'] },
children: [
{
path: 'topic',
name: 'RatingTopicIndex',
component: () => import('@/views/rating/topic/index'),
meta: { title: '评分话题' },
},
{
path: 'topic-recommend',
name: 'RatingTopicRecommendIndex',
component: () => import('@/views/rating/topicRecommend/index'),
meta: { title: '话题推荐' },
},
{
path: 'topic-item',
name: 'RatingTopicItemIndex',
component: () => import('@/views/rating/topicItem/index'),
meta: { title: '评分项' },
},
{
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: 'topic-category',
name: 'RatingTopicCategoryIndex',
component: () => import('@/views/rating/topicCategory/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: '审核',
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: '审核日志' },
},
],
},
],
},
{
path: '/spring',
component: Layout,
@@ -149,6 +252,12 @@ export const asyncRoutes = [
component: () => import('@/views/spring/blessing/titleTemplate/index'),
meta: { title: '图片标题模版' },
},
{
path: 'music',
name: 'Music',
component: () => import('@/views/spring/blessing/music/index'),
meta: { title: '背景音乐' },
},
{
path: 'contentTemplate',
name: 'contentTemplate',
@@ -201,6 +310,12 @@ export const asyncRoutes = [
permissions: ['admin'],
},
children: [
{
path: 'avatarCategory',
name: 'AvatarCategory',
component: () => import('@/views/spring/avatar/category/index'),
meta: { title: '头像类型' },
},
{
path: 'systemAvatar',
name: 'SystemAvatar',
@@ -296,8 +411,8 @@ export const asyncRoutes = [
meta: { title: '用户签到记录' },
},
{
path: 'userChat',
name: 'UserChat',
path: 'userDevice',
name: 'UserDevice',
component: () => import('@/views/spring/user/device/index'),
meta: { title: '设备' },
},
@@ -329,6 +444,75 @@ export const asyncRoutes = [
},
],
},
{
path: '/systemManagement',
component: Layout,
redirect: 'noRedirect',
name: 'SystemManagement',
meta: { title: '系统', icon: 'users-cog', permissions: ['admin'] },
children: [
{
path: 'deviceManagement',
name: 'DeviceManagement',
component: () => import('@/views/systemManagement/device/index'),
meta: { title: '设备管理' },
},
{
path: 'rewardManagement',
name: 'RewardManagement',
component: () => import('@/views/systemManagement/reward/index'),
meta: { title: '奖励管理' },
},
{
path: 'robotManagement',
name: 'RobotManagement',
component: () => import('@/views/systemManagement/robot/index'),
meta: { title: '机器人' },
},
{
path: 'abilityManagement',
name: 'AbilityManagement',
component: () => import('@/views/systemManagement/ability/index'),
meta: { title: '用户能力管理' },
},
{
path: 'userSignStat',
name: 'UserSignStat',
component: () => import('@/views/systemManagement/userSignStat/index'),
meta: { title: '用户签到信息' },
},
{
path: 'accessLogManagement',
name: 'AccessLogManagement',
component: () => import('@/views/personnelManagement/accessLogManagement/index'),
meta: { title: '访问日志' },
},
{
path: 'suspiciousRequest',
name: 'SuspiciousRequest',
component: () => import('@/views/personnelManagement/suspiciousRequest/index'),
meta: { title: '异常请求' },
},
{
path: 'ipBlacklist',
name: 'IPBlacklist',
component: () => import('@/views/systemManagement/ipBlack/index'),
meta: { title: 'IP 黑名单' },
},
{
path: 'userBlacklist',
name: 'UserBlacklist',
component: () => import('@/views/systemManagement/userBlack/index'),
meta: { title: '用户 黑名单' },
},
{
path: 'uploadedFileManagement',
name: 'UploadedFileManagement',
component: () => import('@/views/personnelManagement/uploadedFileManagement/index'),
meta: { title: '已上传文件' },
},
],
},
// {
// path: '/maomaotou',
// component: Layout,
@@ -395,8 +579,8 @@ export const asyncRoutes = [
// meta: { title: '用户' },
// },
// {
// path: 'userChat',
// name: 'UserChat',
// path: 'userDevice',
// name: 'userDevice',
// component: () => import('@/views/maomao/user/chat/index'),
// meta: { title: '聊天' },
// },
@@ -694,39 +878,7 @@ export const asyncRoutes = [
},
],
},
{
path: '/systemManagement',
component: Layout,
redirect: 'noRedirect',
name: 'SystemManagement',
meta: { title: '系统', icon: 'users-cog', permissions: ['admin'] },
children: [
{
path: 'deviceManagement',
name: 'DeviceManagement',
component: () => import('@/views/systemManagement/device/index'),
meta: { title: '设备管理' },
},
{
path: 'accessLogManagement',
name: 'AccessLogManagement',
component: () => import('@/views/personnelManagement/accessLogManagement/index'),
meta: { title: '访问日志' },
},
{
path: 'suspiciousRequest',
name: 'SuspiciousRequest',
component: () => import('@/views/personnelManagement/suspiciousRequest/index'),
meta: { title: '异常请求' },
},
{
path: 'uploadedFileManagement',
name: 'UploadedFileManagement',
component: () => import('@/views/personnelManagement/uploadedFileManagement/index'),
meta: { title: '已上传文件' },
},
],
},
// {
// path: '/mall',
// component: Layout,

View File

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

View File

@@ -54,6 +54,8 @@ instance.interceptors.request.use(
}
if (store.getters['user/appId']) {
config.headers['x-app-id'] = store.getters['user/appId']
} else {
config.headers['x-app-id'] = '69665538a49b8ae3be50fe5d'
}
if (config.method === 'get' && config.params) {
config.params = Vue.prototype.$baseLodash.pickBy(config.params, Vue.prototype.$baseLodash.identity)

View File

@@ -63,6 +63,9 @@
<el-form-item>
<el-button icon="el-icon-search" type="primary" @click="handleQuery">查询</el-button>
<el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
<el-button :type="excludeAcquaintance ? 'primary' : 'default'" @click="toggleExcludeAcquaintance">去掉熟人</el-button>
<el-button :type="onlyUserId === true ? 'primary' : 'default'" @click="toggleOnlyUserId(true)">只显示有用户请求</el-button>
<el-button :type="onlyNoUserId === true ? 'primary' : 'default'" @click="toggleOnlyNoUserId()">只显示无用户请求</el-button>
</el-form-item>
</el-form>
</el-card>
@@ -136,6 +139,14 @@
<el-link type="primary" :underline="false" @click="goToUser(row.userId)">{{ row.userId }}</el-link>
</template>
</el-table-column>
<el-table-column label="Device ID" prop="deviceId" show-overflow-tooltip>
<template slot-scope="{ row }">
<el-link v-if="row.deviceId" type="primary" :underline="false" @click="goToDevice(row.deviceId)">
{{ row.deviceId }}
</el-link>
<span v-else>-</span>
</template>
</el-table-column>
</el-table>
<el-pagination
background
@@ -175,6 +186,9 @@
},
data() {
return {
excludeAcquaintance: false,
onlyUserId: null, // null: all, true: only with user
onlyNoUserId: null, // null: all, true: only without user
eventNameMap,
eventTypeMap,
appMap,
@@ -273,6 +287,16 @@
pageSize: 10000, // 获取足够多的数据进行前端统计,或者应该依赖后端聚合接口
}
if (this.excludeAcquaintance) {
params.excludeAcquaintance = true
}
if (this.onlyUserId !== null) {
params.onlyUserId = this.onlyUserId
}
if (this.onlyNoUserId !== null) {
params.onlyNoUserId = this.onlyNoUserId
}
const { data } = await getTrackingLogsList(params)
this.list = data.list || []
@@ -314,6 +338,28 @@
this.pageSize = val
this.currentPage = 1
},
toggleExcludeAcquaintance() {
this.excludeAcquaintance = !this.excludeAcquaintance
this.fetchData()
},
toggleOnlyUserId(value) {
if (this.onlyUserId === value) {
this.onlyUserId = null // Toggle off if already selected
} else {
this.onlyUserId = value
this.onlyNoUserId = null // 互斥
}
this.fetchData()
},
toggleOnlyNoUserId() {
if (this.onlyNoUserId === true) {
this.onlyNoUserId = null // Toggle off if already selected
} else {
this.onlyNoUserId = true
this.onlyUserId = null // 互斥
}
this.fetchData()
},
handleCurrentChange(val) {
this.currentPage = val
},
@@ -330,6 +376,10 @@
query: { userId },
})
},
goToDevice(deviceId) {
if (!deviceId) return
this.$router.push({ path: '/spring/user/userDevice', query: { deviceId } })
},
handleEventNameClick(params) {
const name = params.name
// name 可能是中文映射名,需要反向查找 key或者在 processData 时把 key 存入

View File

@@ -27,6 +27,7 @@ export const eventTypeMap = {
export const appMap = {
'69665538a49b8ae3be50fe5d': '新春祝福',
'6a0d7dbe4c5de50f2ba66475': '夯拉评',
}
export const userMap = {

View File

@@ -1,5 +1,9 @@
<template>
<div class="accessLogManagement-container">
<el-tabs v-model="queryForm.appId" type="card" @tab-click="handleTabClick">
<el-tab-pane v-for="item in applicationList" :key="item.id" :label="item.name" :name="item.id" />
</el-tabs>
<vab-query-form>
<vab-query-form-right-panel :span="12">
<el-form :inline="true" :model="queryForm" @submit.native.prevent>
@@ -24,7 +28,7 @@
</el-table-column>
<el-table-column align="center" label="类型" show-overflow-tooltip>
<template #default="{ row }">
<el-tag v-if="row.url.includes('api/v')" type="success">应用</el-tag>
<el-tag v-if="row.platform.includes('weixin')" type="success">微信小程序</el-tag>
<el-tag v-else type="info">后台</el-tag>
</template>
</el-table-column>
@@ -39,8 +43,13 @@
{{ row.userName || row.userId }}
</template>
</el-table-column>
<el-table-column align="center" label="method" prop="method" show-overflow-tooltip width="80" />
<el-table-column align="center" label="statusCode" prop="statusCode" show-overflow-tooltip width="100" />
<el-table-column align="center" label="耗时(ms)" prop="duration" show-overflow-tooltip width="100" />
<el-table-column align="center" label="平台" prop="platform" show-overflow-tooltip width="100" />
<el-table-column align="center" label="userAgent" prop="userAgent" show-overflow-tooltip />
<el-table-column align="center" label="referrer" prop="referrer" show-overflow-tooltip />
<el-table-column align="center" label="body" prop="body" show-overflow-tooltip />
</el-table>
<el-pagination
background
@@ -56,6 +65,7 @@
<script>
import { getList } from '@/api/accessLogManagement'
import { getList as getApplicationList } from '@/api/appManagement'
import { formatTime } from '@/utils'
export default {
@@ -69,14 +79,17 @@
selectRows: '',
elementLoadingText: '正在加载...',
queryForm: {
appId: '',
pageNo: 1,
pageSize: 10,
permission: '',
},
applicationList: [],
timeOutID: null,
}
},
created() {
this.fetchApplicationList()
this.fetchData()
},
@@ -84,6 +97,13 @@
clearTimeout(this.timeOutID)
},
methods: {
async fetchApplicationList() {
const { data } = await getApplicationList({ pageNo: 1, pageSize: 100 })
this.applicationList = data.list
},
handleTabClick() {
this.queryData()
},
formatTime,
setSelectRows(val) {
this.selectRows = val

View File

@@ -32,9 +32,12 @@
</vab-query-form>
<el-table v-loading="listLoading" :data="list" :element-loading-text="elementLoadingText">
<el-table-column align="center" label="IP" prop="ip" show-overflow-tooltip />
<el-table-column align="center" label="地址" prop="address" show-overflow-tooltip />
<el-table-column align="center" label="用户" show-overflow-tooltip>
<template slot-scope="{ row }">
{{ row.userName || row.userId }}
{{ row.userId }}
</template>
</el-table-column>
<el-table-column align="center" label="应用" show-overflow-tooltip>
@@ -42,7 +45,6 @@
{{ row.appName || row.appId }}
</template>
</el-table-column>
<el-table-column align="center" label="IP" prop="ip" show-overflow-tooltip />
<el-table-column align="center" label="路径" prop="path" show-overflow-tooltip />
<el-table-column align="center" label="原因" prop="reason" show-overflow-tooltip />
<el-table-column align="center" label="UserAgent" prop="userAgent" show-overflow-tooltip />

View File

@@ -0,0 +1,233 @@
<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 }">
<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>
</div>
<div v-else class="user-details">
<div class="user-id">{{ row.userId }}</div>
</div>
</template>
</el-table-column>
<el-table-column align="center" label="状态切换" width="80">
<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="时间" 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, toggleEnable } from '@/api/rating/pk'
import { formatTime } from '@/utils'
import { getThumbUrl } from '@/utils/blessing'
export default {
name: 'CommentReplyList',
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 { msg } = await toggleEnable({ id: row.id, enable: row.enable })
this.$baseMessage(msg || '状态切换成功', 'success')
} catch (error) {
console.error(error)
row.enable = !row.enable
}
},
},
}
</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;
}
.user-info-cell {
display: flex;
align-items: center;
}
.user-avatar,
.user-avatar-placeholder {
width: 32px;
height: 32px;
border-radius: 50%;
margin-right: 8px;
flex-shrink: 0;
}
.user-avatar-placeholder {
background-color: #f0f2f5;
display: flex;
align-items: center;
justify-content: center;
color: #909399;
font-size: 16px;
}
.user-details {
display: flex;
flex-direction: column;
overflow: hidden;
}
.user-nickname {
font-weight: bold;
color: #303133;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.user-id {
font-size: 12px;
color: #909399;
}
</style>

View 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.leftItem ? item.leftItem.name : '未知'
const right = item.rightItem ? item.rightItem.name : '未知'
return `[${item.topic ? item.topic.title : '未知主题'}] ${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>

View 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>

View File

@@ -0,0 +1,376 @@
<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.pk" class="target-info-cell">
<div class="topic-title">[{{ row.pk.topic ? row.pk.topic.title : '未知主题' }}]</div>
<div class="item-info">
<span>{{ row.pk.leftItem ? row.pk.leftItem.name : '未知' }}</span>
<span style="margin: 0 8px; color: #f56c6c; font-weight: bold">VS</span>
<span>{{ row.pk.rightItem ? row.pk.rightItem.name : '未知' }}</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 }">
<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>
</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="评论时间" 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, toggleEnable, getList as getPkList } from '@/api/rating/pk'
import { formatTime } from '@/utils'
import { getThumbUrl } from '@/utils/blessing'
import PkCommentEdit from './components/PkCommentEdit'
import PkCommentLikeEdit from './components/PkCommentLikeEdit'
import CommentReplyList from './components/CommentReplyList'
export default {
name: 'PkComment',
components: { PkCommentEdit, PkCommentLikeEdit, CommentReplyList },
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.leftItem ? item.leftItem.name : '未知'
const right = item.rightItem ? item.rightItem.name : '未知'
return `[${item.topic ? item.topic.title : '未知主题'}] ${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 {
const { msg } = await toggleEnable({ id: row.id, enable: row.enable })
this.$baseMessage(msg || '状态切换成功', 'success')
} catch (error) {
console.error(error)
row.enable = !row.enable
}
},
// 子组件触发的方法
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;
}
.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;
}
</style>

View 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>

View File

@@ -0,0 +1,133 @@
<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 }">
<div class="user-info-cell">
<el-image v-if="row.avatar" class="user-avatar" :preview-src-list="[row.avatar]" :src="getThumbUrl(row.avatar)" />
<div v-else class="user-avatar-placeholder"><i class="el-icon-user" /></div>
<div class="user-details">
<div class="user-nickname">{{ row.nickname || '未知用户' }}</div>
<div class="user-id">{{ row.id }}</div>
</div>
</div>
</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'
export default {
name: 'PkParticipantList',
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>
<style scoped>
.user-info-cell {
display: flex;
align-items: center;
}
.user-avatar,
.user-avatar-placeholder {
width: 36px;
height: 36px;
border-radius: 50%;
margin-right: 10px;
flex-shrink: 0;
}
.user-avatar-placeholder {
background-color: #f0f2f5;
display: flex;
align-items: center;
justify-content: center;
color: #909399;
font-size: 18px;
}
.user-details {
display: flex;
flex-direction: column;
overflow: hidden;
}
.user-nickname {
font-weight: bold;
color: #303133;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.user-id {
font-size: 12px;
color: #909399;
}
</style>

View File

@@ -0,0 +1,138 @@
<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="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 { 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: '',
userId: '',
},
rules: {
userId: [{ 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) {
this.saving = true
try {
const { msg } = await vote(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>

View File

@@ -0,0 +1,364 @@
<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>
<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" />
</div>
</template>
<script>
import { getList } from '@/api/rating/pk'
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 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,
}
},
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)
},
},
}
</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>

View 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>

View File

@@ -0,0 +1,305 @@
<template>
<div class="rating-topic-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-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>
<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="left" label="评价主题" min-width="200" width="200">
<template #default="{ row }">
<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>
</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="允许评论" width="100">
<template #default="{ row }">
<el-tag v-if="row.allowComment === 1 || row.allowComment === true" type="success"></el-tag>
<el-tag v-else type="danger"></el-tag>
</template>
</el-table-column>
<el-table-column align="left" label="互动统计" width="180">
<template #default="{ row }">
<div class="stat-cell">
<div class="stat-row">
<span class="stat-label">
<i class="el-icon-view" />
浏览数
</span>
<span class="stat-value">{{ row.viewCount }}</span>
</div>
<div class="stat-row">
<span class="stat-label">
<i class="el-icon-user" />
参与人数
</span>
<span class="stat-value">{{ row.participantCount }}</span>
</div>
<div class="stat-row">
<span class="stat-label">
<i class="el-icon-star-on" />
评价人数
</span>
<span class="stat-value">{{ row.scoreCount }}</span>
</div>
<div class="stat-row">
<span class="stat-label">
<i class="el-icon-chat-dot-round" />
评论人数
</span>
<span class="stat-value">{{ row.commentCount }}</span>
</div>
</div>
</template>
</el-table-column>
<el-table-column align="left" label="热门分数" prop="hotScore" width="100" />
<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" label="操作" width="150">
<template #default="{ row }">
<el-button type="text" @click="handleViewItems(row)">查看评分项</el-button>
<el-button v-if="row.status !== 4" style="color: #f56c6c" type="text" @click="handleDisable(row)">禁用</el-button>
<el-button v-if="row.status === 4" style="color: #67c23a" type="text" @click="handleEnable(row)">启用</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination
background
:current-page="queryForm.pageNo"
:layout="layout"
:page-size="queryForm.pageSize"
:total="total"
@current-change="handleCurrentChange"
@size-change="handleSizeChange"
/>
<topic-edit ref="edit" @fetch-data="fetchData" />
</div>
</template>
<script>
import { getList } from '@/api/rating/topic'
import { reviewTopic } from '@/api/rating/topicOperate'
import { formatTime } from '@/utils'
import { getThumbUrl } from '@/utils/blessing'
import TopicEdit from './components/TopicEdit'
export default {
name: 'RatingTopicIndex',
components: { TopicEdit },
data() {
return {
list: [],
listLoading: true,
layout: 'total, sizes, prev, pager, next, jumper',
total: 0,
elementLoadingText: '正在加载...',
queryForm: {
pageNo: 1,
pageSize: 10,
keyword: '',
status: '',
},
}
},
created() {
this.fetchData()
},
methods: {
formatTime,
getThumbUrl,
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
}
},
handleViewItems(row) {
this.$router.push({
path: '/rating/topic-item',
query: { topicId: row.id },
})
},
handleDisable(row) {
this.$confirm('确定要禁用该话题吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(async () => {
try {
const { msg } = await reviewTopic({
topicId: row.id,
userId: this.$store.state.user.userId || '',
status: 4,
type: 'topic',
})
this.$baseMessage(msg || '已禁用', 'success')
this.fetchData()
} catch (error) {
console.error(error)
}
})
.catch(() => {})
},
handleEnable(row) {
this.$confirm('确定要启用该话题吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'success',
})
.then(async () => {
try {
const { msg } = await reviewTopic({
topicId: row.id,
userId: this.$store.state.user.userId || '',
status: 2,
type: 'topic',
})
this.$baseMessage(msg || '已启用', 'success')
this.fetchData()
} catch (error) {
console.error(error)
}
})
.catch(() => {})
},
},
}
</script>
<style scoped>
.rating-topic-container {
padding: 20px;
}
.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>

View File

@@ -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>

View 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>

View File

@@ -0,0 +1,257 @@
<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="loadMoreUsers" filterable placeholder="请选择参与评论的用户" style="width: 100%">
<el-option v-for="item in userList" :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>
<el-tag v-if="item.isRobot" size="mini" style="margin-left: 8px" type="info">机器人</el-tag>
<el-tag v-else size="mini" style="margin-left: 8px" type="success">真人</el-tag>
</div>
</el-option>
</el-select>
</el-form-item>
<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="itemId">
<el-select
v-model="form.itemId"
v-loadmore="loadMoreItems"
:disabled="!form.topicId"
filterable
placeholder="请先选择主题,再选择评价项"
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-item label="评论内容" prop="content">
<el-input v-model="form.content" maxlength="500" placeholder="请输入您的评论文字" :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 { getList as getUserList } from '@/api/system/user'
import { getList as getTopicList } from '@/api/rating/topic'
import { getList as getItemList } from '@/api/rating/topicItem'
import { comment } from '@/api/rating/topicOperate'
import { getThumbUrl } from '@/utils/blessing'
export default {
name: 'RecordCommentEdit',
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: {
userId: '',
topicId: '',
itemId: '',
content: '',
},
rules: {
userId: [{ required: true, trigger: 'change', message: '请选择用户' }],
topicId: [{ required: true, trigger: 'change', message: '请选择评价主题' }],
itemId: [{ required: true, trigger: 'change', message: '请选择评价项' }],
content: [{ required: true, trigger: 'blur', message: '请输入评论内容' }],
},
// 用户列表
userList: [],
userQuery: { pageNo: 1, pageSize: 20 },
userTotal: 0,
fetchingUsers: false,
// 主题列表
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 = '立即评论'
this.dialogFormVisible = true
this.form = this.$options.data().form
// 重置列表数据
this.userList = []
this.userQuery.pageNo = 1
this.userTotal = 0
this.topicList = []
this.topicQuery.pageNo = 1
this.topicTotal = 0
this.itemList = []
this.itemQuery.pageNo = 1
this.itemQuery.topicId = ''
this.itemTotal = 0
// 初始化加载第一页数据
this.fetchUserList()
this.fetchTopicList()
},
close() {
this.$refs['form'].resetFields()
this.dialogFormVisible = false
},
// -- 用户列表加载 --
async fetchUserList() {
if (this.fetchingUsers) return
this.fetchingUsers = true
try {
const params = { pageNo: this.userQuery.pageNo, pageSize: this.userQuery.pageSize }
const { data } = await getUserList(params)
this.userList = this.userList.concat(data.list || [])
this.userTotal = data.totalCount || 0
} catch (error) {
console.error(error)
} finally {
this.fetchingUsers = false
}
},
loadMoreUsers() {
if (this.userList.length >= this.userTotal || this.fetchingUsers) return
this.userQuery.pageNo += 1
this.fetchUserList()
},
// -- 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.itemId = ''
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 { msg } = await comment(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>

View 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 { 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>

View File

@@ -0,0 +1,493 @@
<template>
<div class="rating-topic-comment-record-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.userId"
v-loadmore="loadMoreUsers"
clearable
filterable
placeholder="请选择用户"
style="width: 200px"
@change="handleFilterChange"
>
<el-option v-for="item in userList" :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>
<el-tag v-if="item.isRobot" size="mini" style="margin-left: 8px" type="info">机器人</el-tag>
<el-tag v-else size="mini" style="margin-left: 8px" type="success">真人</el-tag>
</div>
</el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-select
v-model="queryForm.topicId"
v-loadmore="loadMoreTopics"
clearable
filterable
placeholder="请选择评价主题"
style="width: 200px"
@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>
<el-select
v-model="queryForm.itemId"
v-loadmore="loadMoreItems"
clearable
:disabled="!queryForm.topicId"
filterable
placeholder="请先选择主题,再选择评价项"
style="width: 220px"
@change="handleFilterChange"
>
<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-item>
<el-button :type="queryForm.trueUser ? 'warning' : 'default'" @click="toggleTrueUser">
{{ queryForm.trueUser ? '已去掉机器人' : '去掉机器人' }}
</el-button>
</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="100">
<template #default="{ row }">
<el-button type="text" @click="handleLike(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="评价目标" min-width="200">
<template #default="{ row }">
<div class="target-info-cell">
<div class="topic-title">
[{{ row.rating ? (row.rating.topic ? row.rating.topic.title : '未知主题') : row.topicName || '未知主题' }}]
</div>
<div class="item-info">
<el-image
v-if="row.rating && row.rating.item && row.rating.item.avatarUrl"
class="item-avatar"
:src="getThumbUrl(row.rating.item.avatarUrl)"
/>
<el-image v-else-if="row.itemAvatarUrl" class="item-avatar" :src="getThumbUrl(row.itemAvatarUrl)" />
<span class="item-name">{{ row.rating && row.rating.item ? row.rating.item.name : row.itemName || '未知评价项' }}</span>
</div>
</div>
</template>
</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>
</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"
/>
<record-comment-edit ref="commentEdit" @fetch-data="fetchData" />
<record-comment-like-edit ref="likeEdit" @fetch-data="fetchData" />
</div>
</template>
<script>
import { userCommentList } 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 RecordCommentEdit from './components/RecordCommentEdit'
import RecordCommentLikeEdit from './components/RecordCommentLikeEdit'
export default {
name: 'RatingTopicCommentIndex',
components: { RecordCommentEdit, 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 {
list: [],
listLoading: true,
layout: 'total, sizes, prev, pager, next, jumper',
total: 0,
elementLoadingText: '正在加载...',
queryForm: {
pageNo: 1,
pageSize: 10,
userId: '',
topicId: '',
itemId: '',
trueUser: false,
},
// 用户下拉列表状态
userList: [],
userQuery: { pageNo: 1, pageSize: 20, trueUser: false },
userTotal: 0,
fetchingUsers: false,
// Topic 下拉列表状态
topicList: [],
topicQuery: { pageNo: 1, pageSize: 20 },
topicTotal: 0,
fetchingTopics: false,
// Item 下拉列表状态
itemList: [],
itemQuery: { pageNo: 1, pageSize: 20, topicId: '' },
itemTotal: 0,
fetchingItems: false,
}
},
created() {
this.fetchUserList()
this.fetchTopicList()
this.fetchData()
},
methods: {
formatTime,
getThumbUrl,
// -- 用户列表加载 --
async fetchUserList() {
if (this.fetchingUsers) return
this.fetchingUsers = true
try {
const params = { pageNo: this.userQuery.pageNo, pageSize: this.userQuery.pageSize, appId: '6a0d7dbe4c5de50f2ba66475' }
if (this.userQuery.trueUser) params.trueUser = true
const { data } = await getUserList(params)
this.userList = this.userList.concat(data.list || [])
this.userTotal = data.totalCount || 0
} catch (error) {
console.error(error)
} finally {
this.fetchingUsers = false
}
},
loadMoreUsers() {
if (this.userList.length >= this.userTotal || this.fetchingUsers) return
this.userQuery.pageNo += 1
this.fetchUserList()
},
// -- 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()
},
// -- 交互与筛选 --
toggleTrueUser() {
this.queryForm.trueUser = !this.queryForm.trueUser
// 同步更新 userQuery
this.userQuery.trueUser = this.queryForm.trueUser
// 重新拉取用户下拉列表
this.userQuery.pageNo = 1
this.userList = []
this.userTotal = 0
this.fetchUserList()
// 重新拉取表格数据
this.queryData()
},
handleTopicChange(val) {
// 重置 item 选择
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()
},
handleFilterChange() {
this.queryData()
},
// -- 列表数据加载 --
handleLike(row) {
this.$refs['likeEdit'].showEdit(row)
},
handleCommentNow() {
this.$refs['commentEdit'].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 params = { pageNo: this.queryForm.pageNo, pageSize: this.queryForm.pageSize }
if (this.queryForm.userId) params.userId = this.queryForm.userId
if (this.queryForm.topicId) params.topicId = this.queryForm.topicId
if (this.queryForm.itemId) params.itemId = this.queryForm.itemId
if (this.queryForm.trueUser) params.trueUser = true
const { data } = await userCommentList(params)
this.list = data.list || []
this.total = data.totalCount || 0
} catch (error) {
console.error(error)
} finally {
this.listLoading = false
}
},
},
}
</script>
<style scoped>
.rating-topic-comment-record-container {
padding: 20px;
}
/* 评论内容列样式 */
.comment-content-cell {
display: flex;
flex-direction: column;
gap: 8px;
}
.content-text {
font-size: 14px;
color: #303133;
line-height: 1.5;
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;
}
/* 用户信息列样式 */
.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;
flex-direction: column;
}
.topic-title {
color: #409eff;
font-weight: bold;
margin-bottom: 6px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.item-info {
display: flex;
align-items: center;
}
.item-avatar {
width: 24px;
height: 24px;
border-radius: 4px;
margin-right: 8px;
flex-shrink: 0;
}
.item-name {
color: #606266;
font-size: 14px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
</style>

View File

@@ -0,0 +1,146 @@
<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="请选择评价机器人"
:popper-append-to-body="false"
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>
</el-option>
</el-select>
</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-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="close"> </el-button>
<el-button :loading="loading" type="primary" @click="save"> </el-button>
</div>
</el-dialog>
</template>
<script>
import { getListBase as getRobotList } from '@/api/system/robot'
import { comment } from '@/api/rating/topicOperate'
import { getThumbUrl } from '@/utils/blessing'
export default {
name: 'TopicItemCommentEdit',
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,
loading: false,
form: {
topicId: '',
itemId: '',
content: '',
userId: '',
},
rules: {
userId: [{ required: true, trigger: 'change', message: '请选择评价机器人' }],
content: [{ required: true, trigger: 'blur', message: '请输入评论内容' }],
},
robotList: [],
robotQuery: {
pageNo: 1,
pageSize: 20,
appId: '6a0d7dbe4c5de50f2ba66475',
},
robotTotal: 0,
fetchingRobots: false,
}
},
methods: {
getThumbUrl,
async showEdit(row, topicId) {
this.title = `${row.name} 写评论`
this.form = this.$options.data().form
this.form.topicId = topicId
this.form.itemId = row.id
this.dialogFormVisible = true
this.robotQuery.pageNo = 1
this.robotList = []
this.robotTotal = 0
await this.fetchRobotList()
},
close() {
this.$refs['form'].resetFields()
this.form = this.$options.data().form
this.robotList = []
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.loading = true
try {
const { msg } = await comment(this.form)
this.$baseMessage(msg || '评论成功', 'success')
this.close()
this.$emit('fetch-data')
} catch (error) {
console.error(error)
} finally {
this.loading = false
}
} else {
return false
}
})
},
},
}
</script>

View File

@@ -0,0 +1,159 @@
<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="请选择评价机器人"
:popper-append-to-body="false"
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>
</el-option>
</el-select>
</el-form-item>
<el-form-item label="评分" prop="scoreType">
<el-radio-group v-model="form.scoreType">
<el-radio :label="5"></el-radio>
<el-radio :label="4">顶级</el-radio>
<el-radio :label="3">人上人</el-radio>
<el-radio :label="2">NPC</el-radio>
<el-radio :label="1"></el-radio>
</el-radio-group>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="close"> </el-button>
<el-button :loading="loading" type="primary" @click="save"> </el-button>
</div>
</el-dialog>
</template>
<script>
import { getListBase as getRobotList } from '@/api/system/robot'
import { score } from '@/api/rating/topicOperate'
import { getThumbUrl } from '@/utils/blessing'
export default {
name: 'TopicItemRatingEdit',
directives: {
loadmore: {
bind(el, binding) {
// 在 bind 阶段由于使用了 :popper-append-to-body="false" 可以确保 DOM 存在于 el 内部
// 但是下拉框容器渲染可能有延迟,我们可以通过 setTimeout 确保获取到 DOM
setTimeout(() => {
const SELECTWRAP_DOM = el.querySelector('.el-select-dropdown .el-select-dropdown__wrap')
if (SELECTWRAP_DOM) {
SELECTWRAP_DOM.addEventListener('scroll', function () {
// 判断滚动到底部的条件,加一个小容差 2px 防止不同浏览器下的精度问题
const condition = this.scrollHeight - this.scrollTop <= this.clientHeight + 2
if (condition) {
binding.value()
}
})
}
}, 0)
},
},
},
data() {
return {
title: '评价项打分',
dialogFormVisible: false,
loading: false,
form: {
topicId: '',
itemId: '',
scoreType: '',
userId: '',
},
rules: {
userId: [{ required: true, trigger: 'change', message: '请选择评价机器人' }],
scoreType: [{ required: true, trigger: 'change', message: '请选择评分' }],
},
robotList: [],
robotQuery: {
pageNo: 1,
pageSize: 20,
appId: '6a0d7dbe4c5de50f2ba66475',
topicId: '',
itemId: '',
},
robotTotal: 0,
fetchingRobots: false,
}
},
methods: {
getThumbUrl,
async showEdit(row, topicId) {
this.title = `${row.name} 打分`
this.form = this.$options.data().form
this.form.topicId = topicId
this.form.itemId = row.id
this.dialogFormVisible = true
this.robotQuery.pageNo = 1
this.robotQuery.topicId = topicId
this.robotQuery.itemId = row.id
this.robotList = []
this.robotTotal = 0
await this.fetchRobotList()
},
close() {
this.$refs['form'].resetFields()
this.form = this.$options.data().form
this.robotList = []
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.loading = true
try {
const { msg } = await score(this.form)
this.$baseMessage(msg || '评分成功', 'success')
this.close()
this.$emit('fetch-data')
} catch (error) {
console.error(error)
} finally {
this.loading = false
}
} else {
return false
}
})
},
},
}
</script>

View File

@@ -0,0 +1,318 @@
<template>
<div class="rating-topic-item-container">
<vab-query-form>
<vab-query-form-left-panel :span="12">
<el-form :inline="true" :model="queryForm" @submit.native.prevent>
<el-form-item>
<el-select v-model="queryForm.topicId" clearable filterable placeholder="请选择评价主题" @change="handleTopicChange">
<el-option v-for="item in topicList" :key="item.id" :label="item.title" :value="item.id" />
</el-select>
</el-form-item>
</el-form>
</vab-query-form-left-panel>
<vab-query-form-right-panel :span="12">
<el-form :inline="true" :model="queryForm" @submit.native.prevent>
<el-form-item>
<el-input v-model.trim="queryForm.keyword" clearable placeholder="请输入评价项名称" />
</el-form-item>
<el-form-item>
<el-button icon="el-icon-search" type="primary" @click="queryData">查询</el-button>
</el-form-item>
</el-form>
</vab-query-form-right-panel>
</vab-query-form>
<el-alert
v-if="!queryForm.topicId"
show-icon
style="margin-bottom: 20px"
title="请先在左侧选择一个评价主题,或从主题列表点击跳转过来"
type="warning"
/>
<el-table v-loading="listLoading" :data="list" :element-loading-text="elementLoadingText">
<el-table-column align="center" fixed="left" label="操作" width="120">
<template #default="{ row }">
<el-button type="text" @click="handleRating(row)">评价</el-button>
<el-button type="text" @click="handleComment(row)">评论</el-button>
</template>
</el-table-column>
<el-table-column align="left" label="评价项" min-width="200">
<template #default="{ row }">
<div class="item-info-cell">
<el-image v-if="row.avatarUrl" class="item-avatar" :preview-src-list="[row.avatarUrl]" :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 v-if="row.description" class="item-desc" :title="row.description">{{ row.description }}</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="left" label="分数统计">
<template #default="{ row }">
<div class="stat-cell">
<div class="stat-row">
<span class="stat-label">排名分</span>
<span class="stat-value highlight">{{ row.rankScore }}</span>
</div>
<div class="stat-row">
<span class="stat-label">平均分数</span>
<span class="stat-value highlight">{{ row.scoreAvg }}</span>
</div>
<div class="stat-row">
<span class="stat-label">累计总分</span>
<span class="stat-value">{{ row.scoreTotal }}</span>
</div>
<div class="stat-row">
<span class="stat-label">热门分</span>
<span class="stat-value">{{ row.hotScore }}</span>
</div>
</div>
</template>
</el-table-column>
<el-table-column align="left" label="互动数据" min-width="150">
<template #default="{ row }">
<div class="stat-cell">
<div class="stat-row">
<span class="stat-label">
<i class="el-icon-view" />
浏览数
</span>
<span class="stat-value">{{ row.viewCount }}</span>
</div>
<div class="stat-row">
<span class="stat-label">
<i class="el-icon-chat-dot-round" />
评论数
</span>
<span class="stat-value">{{ row.commentCount }}</span>
</div>
<!-- <div class="stat-row">
<span class="stat-label">
<i class="el-icon-star-off" />
打分次数
</span>
<span class="stat-value">{{ row.ratingCount }}</span>
</div> -->
<div class="stat-row">
<span class="stat-label">
<i class="el-icon-user" />
评价人数
</span>
<span class="stat-value">{{ row.scoreCount }}</span>
</div>
</div>
</template>
</el-table-column>
<el-table-column align="center" label="排序" prop="sortOrder" width="80" />
<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"
/>
<topic-item-rating-edit ref="ratingEdit" @fetch-data="fetchData" />
<topic-item-comment-edit ref="commentEdit" @fetch-data="fetchData" />
</div>
</template>
<script>
import { getList } from '@/api/rating/topicItem'
import { getList as getTopicList } from '@/api/rating/topic'
import { formatTime } from '@/utils'
import { getThumbUrl } from '@/utils/blessing'
import TopicItemRatingEdit from './components/TopicItemRatingEdit'
import TopicItemCommentEdit from './components/TopicItemCommentEdit'
export default {
name: 'RatingTopicItemIndex',
components: { TopicItemRatingEdit, TopicItemCommentEdit },
data() {
return {
list: [],
topicList: [],
listLoading: false,
layout: 'total, sizes, prev, pager, next, jumper',
total: 0,
elementLoadingText: '正在加载...',
queryForm: {
pageNo: 1,
pageSize: 10,
keyword: '',
topicId: '',
},
}
},
watch: {
'$route.query.topicId': {
handler(newVal) {
if (newVal && newVal !== this.queryForm.topicId) {
this.queryForm.topicId = newVal
this.fetchData()
}
},
immediate: true,
},
},
created() {
this.initData()
},
methods: {
formatTime,
getThumbUrl,
async initData() {
// 先获取下拉列表的主题数据暂时取100条
try {
const { data } = await getTopicList({ pageNo: 1, pageSize: 100 })
this.topicList = data.list || []
} catch (error) {
console.error(error)
}
},
handleTopicChange() {
this.queryForm.pageNo = 1
this.fetchData()
},
handleSizeChange(val) {
this.queryForm.pageSize = val
this.fetchData()
},
handleCurrentChange(val) {
this.queryForm.pageNo = val
this.fetchData()
},
queryData() {
this.queryForm.pageNo = 1
this.fetchData()
},
async fetchData() {
if (!this.queryForm.topicId) {
this.list = []
this.total = 0
return
}
this.listLoading = true
try {
const { data } = await getList(this.queryForm)
this.list = data.list
this.total = data.totalCount
} catch (error) {
console.error(error)
} finally {
this.listLoading = false
}
},
handleRating(row) {
this.$refs['ratingEdit'].showEdit(row, this.queryForm.topicId)
},
handleComment(row) {
this.$refs['commentEdit'].showEdit(row, this.queryForm.topicId)
},
},
}
</script>
<style scoped>
.rating-topic-item-container {
padding: 20px;
}
.item-info-cell {
display: flex;
align-items: center;
}
.item-avatar,
.item-avatar-placeholder {
width: 50px;
height: 50px;
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: 20px;
}
.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-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;
}
.stat-value.highlight {
color: #409eff;
font-weight: bold;
}
</style>

View 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>

View 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>

View 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>

View File

@@ -0,0 +1,162 @@
<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">
<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()
},
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;
}
.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>

View 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>

View 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>

View File

@@ -0,0 +1,263 @@
<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="loadMoreUsers" filterable placeholder="请选择参与评分的用户" style="width: 100%">
<el-option v-for="item in userList" :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>
<el-tag v-if="item.isRobot" size="mini" style="margin-left: 8px" type="info">机器人</el-tag>
<el-tag v-else size="mini" style="margin-left: 8px" type="success">真人</el-tag>
</div>
</el-option>
</el-select>
</el-form-item>
<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="itemId">
<el-select
v-model="form.itemId"
v-loadmore="loadMoreItems"
:disabled="!form.topicId"
filterable
placeholder="请先选择主题,再选择评价项"
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-item label="评分" prop="scoreType">
<el-radio-group v-model="form.scoreType">
<el-radio :label="5"></el-radio>
<el-radio :label="4">顶级</el-radio>
<el-radio :label="3">人上人</el-radio>
<el-radio :label="2">NPC</el-radio>
<el-radio :label="1"></el-radio>
</el-radio-group>
</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 getUserList } from '@/api/system/user'
import { getList as getTopicList } from '@/api/rating/topic'
import { getList as getItemList } from '@/api/rating/topicItem'
import { score } from '@/api/rating/topicOperate'
import { getThumbUrl } from '@/utils/blessing'
export default {
name: 'RecordRatingEdit',
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: {
userId: '',
topicId: '',
itemId: '',
scoreType: '',
},
rules: {
userId: [{ required: true, trigger: 'change', message: '请选择用户' }],
topicId: [{ required: true, trigger: 'change', message: '请选择评价主题' }],
itemId: [{ required: true, trigger: 'change', message: '请选择评价项' }],
scoreType: [{ required: true, trigger: 'change', message: '请选择评分' }],
},
// 用户列表
userList: [],
userQuery: { pageNo: 1, pageSize: 20 },
userTotal: 0,
fetchingUsers: false,
// 主题列表
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 = '立即评分'
this.dialogFormVisible = true
this.form = this.$options.data().form
// 重置列表数据
this.userList = []
this.userQuery.pageNo = 1
this.userTotal = 0
this.topicList = []
this.topicQuery.pageNo = 1
this.topicTotal = 0
this.itemList = []
this.itemQuery.pageNo = 1
this.itemQuery.topicId = ''
this.itemTotal = 0
// 初始化加载第一页数据
this.fetchUserList()
this.fetchTopicList()
},
close() {
this.$refs['form'].resetFields()
this.dialogFormVisible = false
},
// -- 用户列表加载 --
async fetchUserList() {
if (this.fetchingUsers) return
this.fetchingUsers = true
try {
const params = { pageNo: this.userQuery.pageNo, pageSize: this.userQuery.pageSize }
const { data } = await getUserList(params)
this.userList = this.userList.concat(data.list || [])
this.userTotal = data.totalCount || 0
} catch (error) {
console.error(error)
} finally {
this.fetchingUsers = false
}
},
loadMoreUsers() {
if (this.userList.length >= this.userTotal || this.fetchingUsers) return
this.userQuery.pageNo += 1
this.fetchUserList()
},
// -- 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.itemId = ''
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 { msg } = await score(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>

View File

@@ -0,0 +1,477 @@
<template>
<div class="rating-topic-score-record-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.userId"
v-loadmore="loadMoreUsers"
clearable
filterable
placeholder="请选择用户"
style="width: 200px"
@change="handleFilterChange"
>
<el-option v-for="item in userList" :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>
<el-tag v-if="item.isRobot" size="mini" style="margin-left: 8px" type="info">机器人</el-tag>
<el-tag v-else size="mini" style="margin-left: 8px" type="success">真人</el-tag>
</div>
</el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-select
v-model="queryForm.topicId"
v-loadmore="loadMoreTopics"
clearable
filterable
placeholder="请选择评价主题"
style="width: 200px"
@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>
<el-select
v-model="queryForm.itemId"
v-loadmore="loadMoreItems"
clearable
:disabled="!queryForm.topicId"
filterable
placeholder="请先选择主题,再选择评价项"
style="width: 220px"
@change="handleFilterChange"
>
<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-item>
<el-button :type="queryForm.trueUser ? 'warning' : 'default'" @click="toggleTrueUser">
{{ queryForm.trueUser ? '已去掉机器人' : '去掉机器人' }}
</el-button>
</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="handleRateNow">立即评分</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="left" label="评分" min-width="120">
<template #default="{ row }">
<div class="score-cell">
<el-tag :type="getScoreTypeTag(row.scoreType)">{{ getScoreTypeText(row.scoreType) }}</el-tag>
<div class="score-value">分值: {{ row.score }}</div>
</div>
</template>
</el-table-column>
<el-table-column align="left" label="评价目标" min-width="250">
<template #default="{ row }">
<div v-if="row.rating" class="target-info-cell">
<div class="topic-title">[{{ row.rating.topic ? row.rating.topic.title : '未知主题' }}]</div>
<div v-if="row.rating.item" class="item-info">
<el-image v-if="row.rating.item.avatarUrl" class="item-avatar" :src="getThumbUrl(row.rating.item.avatarUrl)" />
<span class="item-name">{{ row.rating.item.name }}</span>
</div>
</div>
<div v-else class="target-info-cell">
<div class="topic-title">[未知主题]</div>
<div class="item-info"><span class="item-name">未知评价项</span></div>
</div>
</template>
</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>
</template>
</el-table-column>
<el-table-column align="center" label="记录日期" prop="day" width="120" />
<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"
/>
<record-rating-edit ref="ratingEdit" @fetch-data="fetchData" />
</div>
</template>
<script>
import { scoreRecordList } 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 RecordRatingEdit from './components/RecordRatingEdit'
export default {
name: 'RatingTopicRecordIndex',
components: { RecordRatingEdit },
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,
userId: '',
topicId: '',
itemId: '',
trueUser: false,
},
// 用户下拉列表状态
userList: [],
userQuery: { pageNo: 1, pageSize: 20, trueUser: false },
userTotal: 0,
fetchingUsers: false,
// Topic 下拉列表状态
topicList: [],
topicQuery: { pageNo: 1, pageSize: 20 },
topicTotal: 0,
fetchingTopics: false,
// Item 下拉列表状态
itemList: [],
itemQuery: { pageNo: 1, pageSize: 20, topicId: '' },
itemTotal: 0,
fetchingItems: false,
}
},
created() {
this.fetchUserList()
this.fetchTopicList()
this.fetchData()
},
methods: {
formatTime,
getThumbUrl,
// -- 用户列表加载 --
async fetchUserList() {
if (this.fetchingUsers) return
this.fetchingUsers = true
try {
// 清理传参
const params = { pageNo: this.userQuery.pageNo, pageSize: this.userQuery.pageSize, appId: '6a0d7dbe4c5de50f2ba66475' }
if (this.userQuery.trueUser) params.trueUser = true
const { data } = await getUserList(params)
this.userList = this.userList.concat(data.list || [])
this.userTotal = data.totalCount || 0
} catch (error) {
console.error(error)
} finally {
this.fetchingUsers = false
}
},
loadMoreUsers() {
if (this.userList.length >= this.userTotal || this.fetchingUsers) return
this.userQuery.pageNo += 1
this.fetchUserList()
},
// -- 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()
},
// -- 交互与筛选 --
toggleTrueUser() {
this.queryForm.trueUser = !this.queryForm.trueUser
// 同步更新 userQuery
this.userQuery.trueUser = this.queryForm.trueUser
// 重新拉取用户下拉列表
this.userQuery.pageNo = 1
this.userList = []
this.userTotal = 0
this.fetchUserList()
// 重新拉取表格数据
this.queryData()
},
handleTopicChange(val) {
// 重置 item 选择
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()
},
handleFilterChange() {
this.queryData()
},
// -- 列表数据加载 --
handleRateNow() {
this.$refs['ratingEdit'].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 params = { pageNo: this.queryForm.pageNo, pageSize: this.queryForm.pageSize }
if (this.queryForm.userId) params.userId = this.queryForm.userId
if (this.queryForm.topicId) params.topicId = this.queryForm.topicId
if (this.queryForm.itemId) params.itemId = this.queryForm.itemId
if (this.queryForm.trueUser) params.trueUser = true
const { data } = await scoreRecordList(params)
this.list = data.list || []
this.total = data.totalCount || 0
} catch (error) {
console.error(error)
} finally {
this.listLoading = false
}
},
// -- 辅助展示方法 --
getScoreTypeText(type) {
const map = {
5: '夯',
4: '顶级',
3: '人上人',
2: 'NPC',
1: '拉',
}
return map[type] || '未知'
},
getScoreTypeTag(type) {
const map = {
5: 'success', // 夯
4: 'primary', // 顶级
3: 'warning', // 人上人
2: 'info', // NPC
1: 'danger', // 拉
}
return map[type] || 'info'
},
},
}
</script>
<style scoped>
.rating-topic-score-record-container {
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;
flex-direction: column;
}
.topic-title {
color: #409eff;
font-weight: bold;
margin-bottom: 6px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.item-info {
display: flex;
align-items: center;
}
.item-avatar {
width: 24px;
height: 24px;
border-radius: 4px;
margin-right: 8px;
flex-shrink: 0;
}
.item-name {
color: #606266;
font-size: 14px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
/* 评分列样式 */
.score-cell {
display: flex;
flex-direction: column;
align-items: center;
gap: 6px;
}
.score-value {
font-size: 12px;
color: #909399;
}
</style>

View File

@@ -0,0 +1,78 @@
<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="name">
<el-input v-model.trim="form.name" autocomplete="off" />
</el-form-item>
<el-form-item label="是否启用" prop="isEnabled">
<el-switch v-model="form.isEnabled" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="close"> </el-button>
<el-button type="primary" @click="save"> </el-button>
</div>
</el-dialog>
</template>
<script>
import { doAdd, doEdit } from '@/api/spring/avatar/category'
export default {
name: 'AvatarCategoryEdit',
data() {
return {
form: {
name: '',
sort: 1,
isEnabled: true,
},
rules: {
name: [{ required: true, trigger: 'blur', message: '请输入分类名称' }],
},
title: '',
dialogFormVisible: false,
}
},
methods: {
showEdit(row) {
if (!row) {
this.title = '添加'
this.form = this.$options.data().form
} else {
this.title = '编辑'
this.form = Object.assign({}, row)
}
this.dialogFormVisible = true
},
close() {
this.$refs['form'].resetFields()
this.form = this.$options.data().form
this.dialogFormVisible = false
},
save() {
this.$refs['form'].validate(async (valid) => {
if (valid) {
try {
if (this.title === '添加') {
const { msg } = await doAdd(this.form)
this.$baseMessage(msg, 'success')
} else {
const { msg } = await doEdit(this.form.id, this.form)
this.$baseMessage(msg, 'success')
}
this.$refs['form'].resetFields()
this.dialogFormVisible = false
this.$emit('fetch-data')
this.form = this.$options.data().form
} catch (error) {
console.error(error)
}
} else {
return false
}
})
},
},
}
</script>

View File

@@ -0,0 +1,172 @@
<template>
<div class="avatar-category-container">
<vab-query-form>
<vab-query-form-left-panel :span="12">
<el-button icon="el-icon-plus" type="primary" @click="handleEdit">添加</el-button>
<el-button icon="el-icon-delete" type="danger" @click="handleDelete">批量删除</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.name" 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="分类名称" prop="name" show-overflow-tooltip />
<el-table-column align="center" label="排序" prop="sort" sortable width="100" />
<el-table-column align="center" label="状态" prop="isEnabled" width="100">
<template #default="{ row }">
<el-switch v-model="row.isEnabled" @change="handleStatusChange(row)" />
</template>
</el-table-column>
<el-table-column align="center" label="创建时间" prop="createdAt" width="200">
<template #default="{ row }">
{{ formatTime(row.createdAt) }}
</template>
</el-table-column>
<el-table-column align="center" fixed="right" label="操作" show-overflow-tooltip width="200">
<template #default="{ row }">
<el-button type="text" @click="handleEdit(row)">编辑</el-button>
<el-button type="text" @click="handleDelete(row)">删除</el-button>
<el-button type="text" @click="handleMoveUp(row)">上移</el-button>
<el-button type="text" @click="handleMoveDown(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"
/>
<edit ref="edit" @fetch-data="fetchData" />
</div>
</template>
<script>
import { getList, doDelete, toggleEnable, doMoveUp, doMoveDown } from '@/api/spring/avatar/category'
import { formatTime } from '@/utils'
import Edit from './components/AvatarCategoryEdit'
export default {
name: 'AvatarCategory',
components: { Edit },
data() {
return {
list: [],
listLoading: true,
layout: 'total, sizes, prev, pager, next, jumper',
total: 0,
selectRows: [],
elementLoadingText: '正在加载...',
queryForm: {
pageNo: 1,
pageSize: 10,
name: '',
},
}
},
created() {
this.fetchData()
},
methods: {
formatTime,
setSelectRows(val) {
this.selectRows = val
},
handleEdit(row) {
if (row.id) {
this.$refs['edit'].showEdit(row)
} else {
this.$refs['edit'].showEdit()
}
},
handleDelete(row) {
if (row.id) {
this.$baseConfirm('你确定要删除当前项吗', null, async () => {
const { msg } = await doDelete({ ids: [row.id] })
this.$baseMessage(msg, 'success')
this.fetchData()
})
} else {
if (this.selectRows.length > 0) {
const ids = this.selectRows.map((item) => item.id).join()
this.$baseConfirm('你确定要删除选中项吗', null, async () => {
const { msg } = await doDelete({ ids: ids.split(',') })
this.$baseMessage(msg, 'success')
this.fetchData()
})
} else {
this.$baseMessage('未选中任何行', 'error')
return false
}
}
},
async handleStatusChange(row) {
try {
const { msg } = await toggleEnable(row.id, row.isEnabled)
this.$baseMessage(msg, 'success')
} catch (error) {
row.isEnabled = !row.isEnabled
}
},
async handleMoveUp(row) {
try {
await doMoveUp(row.id)
this.fetchData()
} catch (error) {
console.error(error)
}
},
async handleMoveDown(row) {
try {
await doMoveDown(row.id)
this.fetchData()
} catch (error) {
console.error(error)
}
},
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
}
},
},
}
</script>
<style scoped>
.avatar-category-container {
padding: 20px;
}
</style>

View File

@@ -122,7 +122,7 @@
this.fetchData()
},
goToDevice(deviceId) {
this.$router.push({ path: '/spring/user/userChat', query: { deviceId } })
this.$router.push({ path: '/spring/user/userDevice', query: { deviceId } })
},
async fetchData() {
this.listLoading = true

View File

@@ -9,6 +9,11 @@
@upload-success="handleUploadSuccess"
/>
</el-form-item>
<el-form-item label="分类" prop="categoryId">
<el-select v-model="form.categoryId" placeholder="请选择分类" style="width: 100%">
<el-option v-for="item in categoryList" :key="item.id" :label="item.name" :value="item.id" />
</el-select>
</el-form-item>
<el-form-item label="类型" prop="type">
<el-input v-model.trim="form.type" placeholder="请输入类型" />
</el-form-item>
@@ -26,6 +31,7 @@
<script>
import { doEdit, doAdd } from '@/api/spring/avatar'
import { getAll } from '@/api/spring/avatar/category'
import SingleUpload from '@/components/SingleUpload'
export default {
@@ -34,14 +40,17 @@
data() {
return {
id: '',
categoryList: [],
form: {
imageUrl: '',
type: '',
categoryId: '',
isEnabled: true,
},
rules: {
imageUrl: [{ required: true, trigger: 'blur', message: '请上传头像图片' }],
isEnabled: [{ required: true, trigger: 'blur', message: '请选择是否启用' }],
categoryId: [{ required: true, trigger: 'change', message: '请选择分类' }],
},
title: '',
dialogFormVisible: false,
@@ -52,8 +61,14 @@
return `${process.env.VUE_APP_API_BASE_URL}/management/api/common/upload`
},
},
created() {},
created() {
this.fetchCategoryList()
},
methods: {
async fetchCategoryList() {
const { data } = await getAll()
this.categoryList = data
},
handleUploadSuccess(url) {
this.form.imageUrl = url
},
@@ -65,6 +80,7 @@
this.form = {
imageUrl: row.imageUrl,
type: row.type,
categoryId: row.categoryId,
isEnabled: row.isEnabled,
}
this.id = row.id

View File

@@ -186,7 +186,7 @@
this.fetchData()
},
goToDevice(deviceId) {
this.$router.push({ path: '/spring/user/userChat', query: { deviceId } })
this.$router.push({ path: '/spring/user/userDevice', query: { deviceId } })
},
goToTemplate(templateId) {
this.$router.push({ path: '/spring/blessing/template', query: { templateId } })

View File

@@ -0,0 +1,183 @@
<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="name">
<el-input v-model="form.name" autocomplete="off" placeholder="请输入音乐名称" />
</el-form-item>
<el-form-item label="场景" prop="scene">
<el-select v-model="form.scene" clearable placeholder="请选择场景(可为空)" style="width: 100%">
<el-option v-for="item in sceneList" :key="item.scene" :label="item.sceneName" :value="item.scene" />
</el-select>
</el-form-item>
<el-form-item label="标签" prop="tag">
<el-input v-model="form.tag" autocomplete="off" placeholder="请输入标签(可选)" />
</el-form-item>
<el-form-item label="音乐文件" prop="musicUrl">
<el-upload
accept="audio/*"
:action="uploadUrl"
:before-upload="beforeUpload"
:headers="uploadHeaders"
:on-error="handleUploadError"
:on-success="handleUploadSuccess"
:show-file-list="false"
>
<el-button size="small" type="primary">点击上传</el-button>
<div slot="tip" class="el-upload__tip">只能上传音频文件且不超过 10MB</div>
</el-upload>
<div v-if="form.musicUrl" style="margin-top: 10px">
<audio controls :src="form.musicUrl" style="width: 100%"></audio>
</div>
</el-form-item>
<el-form-item v-if="!form.id" label="是否启用" prop="isEnabled">
<el-switch v-model="form.isEnabled" active-text="启用" :active-value="true" inactive-text="禁用" :inactive-value="false" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="close"> </el-button>
<el-button :loading="loading" type="primary" @click="save"> </el-button>
</div>
</el-dialog>
</template>
<script>
import { doEdit, doAdd } from '@/api/spring/blessing/music/index'
import { getAll as getAllScenes } from '@/api/spring/blessing/scene'
import { getAccessToken } from '@/utils/accessToken'
export default {
name: 'MusicManagementEdit',
data() {
return {
id: '',
form: {
name: '',
scene: '',
musicUrl: '',
tag: '',
isEnabled: true,
},
rules: {
name: [{ required: true, trigger: 'blur', message: '请输入音乐名称' }],
musicUrl: [{ required: true, trigger: 'change', message: '请上传音乐文件' }],
},
title: '',
dialogFormVisible: false,
sceneList: [],
token: getAccessToken() || '',
loading: false,
}
},
computed: {
uploadUrl() {
return `${process.env.VUE_APP_API_BASE_URL}/management/api/common/upload`
},
uploadHeaders() {
let userId = ''
let appId = ''
if (this.$store.state?.user?.userId) {
userId = this.$store.state?.user?.userId
}
if (this.$store.state?.user?.appId) {
appId = this.$store.state?.user?.appId
}
return {
Authorization: `${this.token}`,
'x-user-id': userId,
'x-app-id': appId,
}
},
},
created() {
this.fetchSceneList()
},
methods: {
async fetchSceneList() {
try {
const { data } = await getAllScenes()
this.sceneList = data || []
} catch (error) {
console.error(error)
}
},
beforeUpload(file) {
const isValidSize = file.size / 1024 / 1024 < 10
if (!isValidSize) {
this.$message.error('文件大小不能超过 10MB')
return false
}
this.loading = true
return true
},
handleUploadSuccess(response) {
this.loading = false
if (response.code === 200) {
this.form.musicUrl = `https://file.lihailezzc.com/${response.data.key}`
this.$message.success('上传成功!')
} else {
this.$message.error('上传失败,请重试!')
}
},
handleUploadError() {
this.loading = false
this.$message.error('上传失败,请重试!')
},
showEdit(row) {
if (!row) {
this.title = '添加'
this.id = ''
this.form = {
name: '',
scene: '',
musicUrl: '',
tag: '',
isEnabled: true,
}
} else {
this.title = '编辑'
this.id = row.id
this.form = {
id: row.id,
name: row.name,
scene: row.scene,
musicUrl: row.musicUrl,
tag: row.tag,
isEnabled: row.isEnabled,
}
}
this.dialogFormVisible = true
},
close() {
this.$refs['form'].resetFields()
this.form = this.$options.data().form
this.id = ''
this.dialogFormVisible = false
},
save() {
this.$refs['form'].validate(async (valid) => {
if (valid) {
this.loading = true
try {
if (this.id) {
const { msg } = await doEdit(this.id, this.form)
this.$baseMessage(msg, 'success')
} else {
const { msg } = await doAdd(this.form)
this.$baseMessage(msg, 'success')
}
this.$emit('fetch-data')
this.close()
} catch (error) {
console.error(error)
} finally {
this.loading = false
}
} else {
return false
}
})
},
},
}
</script>

View File

@@ -0,0 +1,228 @@
<template>
<div class="music-management-container">
<vab-query-form>
<vab-query-form-left-panel :span="12">
<el-button icon="el-icon-plus" type="primary" @click="handleEdit">添加</el-button>
<el-button icon="el-icon-delete" type="danger" @click="handleDelete">批量删除</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.scene" clearable placeholder="请选择场景" @change="queryData">
<el-option v-for="item in sceneList" :key="item.scene" :label="item.sceneName" :value="item.scene" />
</el-select>
</el-form-item>
<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" @selection-change="setSelectRows">
<el-table-column align="center" show-overflow-tooltip type="selection" width="55" />
<el-table-column align="center" label="排序" prop="sort" sortable width="100" />
<el-table-column align="center" label="音乐名称" prop="name" show-overflow-tooltip />
<el-table-column align="center" label="场景" show-overflow-tooltip>
<template #default="{ row }">
{{ getSceneName(row.scene) }}
</template>
</el-table-column>
<el-table-column align="center" label="试听" width="300">
<template slot-scope="scope">
<audio controls :src="scope.row.musicUrl" style="width: 250px; height: 40px"></audio>
</template>
</el-table-column>
<el-table-column align="center" label="标签" prop="tag" show-overflow-tooltip />
<el-table-column align="center" label="状态" prop="isEnabled" width="100">
<template #default="{ row }">
<el-switch active-color="#13ce66" inactive-color="#ff4949" :value="row.isEnabled" @change="handleToggleEnable(row, $event)" />
</template>
</el-table-column>
<el-table-column align="center" fixed="right" label="操作" width="200">
<template slot-scope="scope">
<el-button type="text" @click="handleEdit(scope.row)">编辑</el-button>
<el-button :disabled="!scope.row.isEnabled || isFirstEnabled(scope.row)" type="text" @click="handleMoveUp(scope.row)">
上移
</el-button>
<el-button :disabled="!scope.row.isEnabled || isLastEnabled(scope.row)" type="text" @click="handleMoveDown(scope.row)">
下移
</el-button>
<el-button type="text" @click="handleDelete(scope.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"
/>
<edit ref="edit" @fetch-data="fetchData" />
</div>
</template>
<script>
import { doDelete, getList, toggleEnable, doMoveUp, doMoveDown } from '@/api/spring/blessing/music/index'
import { getAll as getAllScenes } from '@/api/spring/blessing/scene'
import Edit from './components/AppManagementEdit'
export default {
name: 'MusicManagement',
components: { Edit },
data() {
return {
list: [],
listLoading: true,
layout: 'total, sizes, prev, pager, next, jumper',
total: 0,
selectRows: [],
elementLoadingText: '正在加载...',
queryForm: {
pageNo: 1,
pageSize: 10,
keyword: '',
scene: '',
},
sceneList: [],
}
},
created() {
this.fetchSceneList()
this.fetchData()
},
methods: {
setSelectRows(val) {
this.selectRows = val
},
handleEdit(row) {
if (row && row.id) {
this.$refs['edit'].showEdit(row)
} else {
this.$refs['edit'].showEdit()
}
},
handleDelete(row) {
if (row && row.id) {
this.$baseConfirm('你确定要删除当前项吗', null, async () => {
try {
const { msg } = await doDelete({ ids: [row.id] })
this.$baseMessage(msg, 'success')
this.fetchData()
} catch (error) {
console.error(error)
}
})
} else {
if (this.selectRows.length > 0) {
const ids = this.selectRows.map((item) => item.id)
this.$baseConfirm('你确定要删除选中项吗', null, async () => {
try {
const { msg } = await doDelete({ ids })
this.$baseMessage(msg, 'success')
this.fetchData()
} catch (error) {
console.error(error)
}
})
} else {
this.$baseMessage('未选中任何行', 'error')
return false
}
}
},
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
}
},
async handleToggleEnable(row, value) {
this.$baseConfirm(`你确定要${value ? '启用' : '禁用'}当前项吗`, null, async () => {
try {
const { msg } = await toggleEnable(row.id, value)
this.$baseMessage(msg, 'success')
this.fetchData()
} catch (error) {
console.error(error)
}
})
},
async handleMoveUp(row) {
try {
const { msg } = await doMoveUp(row.id)
this.$baseMessage(msg, 'success')
this.fetchData()
} catch (error) {
console.error(error)
}
},
async handleMoveDown(row) {
try {
const { msg } = await doMoveDown(row.id)
this.$baseMessage(msg, 'success')
this.fetchData()
} catch (error) {
console.error(error)
}
},
isFirstEnabled(row) {
const enabledList = this.list.filter((item) => item.isEnabled)
return enabledList.length > 0 && enabledList[0].id === row.id
},
isLastEnabled(row) {
const enabledList = this.list.filter((item) => item.isEnabled)
return enabledList.length > 0 && enabledList[enabledList.length - 1].id === row.id
},
async fetchSceneList() {
try {
const { data } = await getAllScenes()
this.sceneList = data || []
} catch (error) {
console.error(error)
}
},
getSceneName(scene) {
if (!scene) return '通用'
const found = this.sceneList.find((item) => item.scene === scene)
return found ? found.sceneName : scene
},
},
}
</script>
<style scoped>
.music-management-container {
padding: 20px;
}
</style>

View File

@@ -136,7 +136,7 @@
this.fetchData()
},
goToDevice(deviceId) {
this.$router.push({ path: '/spring/user/userChat', query: { deviceId } })
this.$router.push({ path: '/spring/user/userDevice', query: { deviceId } })
},
goToCard(cardId) {
// Assuming there is a card detail or list page, but for now just placeholder or link to card list

View File

@@ -139,7 +139,7 @@
this.fetchData()
},
goToDevice(deviceId) {
this.$router.push({ path: '/spring/user/userChat', query: { deviceId } })
this.$router.push({ path: '/spring/user/userDevice', query: { deviceId } })
},
async fetchData() {
this.listLoading = true

View File

@@ -199,7 +199,7 @@
this.fetchData()
},
goToDevice(deviceId) {
this.$router.push({ path: '/spring/user/userChat', query: { deviceId } })
this.$router.push({ path: '/spring/user/userDevice', query: { deviceId } })
},
goToContent(row) {
if (row.scene === 'card_generate') {

View File

@@ -202,7 +202,7 @@
this.fetchData()
},
goToDevice(deviceId) {
this.$router.push({ path: '/spring/user/userChat', query: { deviceId } })
this.$router.push({ path: '/spring/user/userDevice', query: { deviceId } })
},
goToContent(row) {
if (row.type === 1) {

View File

@@ -165,7 +165,7 @@
this.fetchData()
},
goToDevice(deviceId) {
this.$router.push({ path: '/spring/user/userChat', query: { deviceId } })
this.$router.push({ path: '/spring/user/userDevice', query: { deviceId } })
},
goToShareRecord(userId) {
this.$router.push({ path: '/spring/user/shareRecord', query: { userId } })

View File

@@ -200,7 +200,7 @@
this.$router.push({ path: '/spring/user/shareRecord', query: { keyword: shareToken } })
},
goToDevice(deviceId) {
this.$router.push({ path: '/spring/user/userChat', query: { deviceId } })
this.$router.push({ path: '/spring/user/userDevice', query: { deviceId } })
},
goToTemplate(templateId) {
this.$router.push({ path: '/spring/blessing/template', query: { templateId } })

View File

@@ -214,7 +214,7 @@
this.fetchData()
},
goToDevice(deviceId) {
this.$router.push({ path: '/spring/user/userChat', query: { deviceId } })
this.$router.push({ path: '/spring/user/userDevice', query: { deviceId } })
},
goToShareRecord(userId) {
this.$router.push({ path: '/spring/user/shareRecord', query: { userId } })

View File

@@ -0,0 +1,129 @@
<template>
<el-dialog :title="title" :visible.sync="dialogFormVisible" width="500px" @close="close">
<el-form ref="form" label-width="100px" :model="form" :rules="rules">
<el-form-item label="应用" prop="appId">
<el-select v-model="form.appId" placeholder="请选择应用" style="width: 100%">
<el-option v-for="item in applicationList" :key="item.id" :label="item.name" :value="item.id" />
</el-select>
</el-form-item>
<el-form-item label="规则名称" prop="name">
<el-input v-model="form.name" placeholder="请输入规则名称" />
</el-form-item>
<el-form-item label="功能场景" prop="scene">
<el-input v-model="form.scene" placeholder="请输入功能场景标识" />
</el-form-item>
<el-form-item label="消耗积分" prop="costPoints">
<el-input-number v-model="form.costPoints" :min="0" placeholder="本次行为消耗的积分值" style="width: 100%" />
</el-form-item>
<el-form-item label="增加经验" prop="gainExp">
<el-input-number v-model="form.gainExp" :min="0" placeholder="本次行为增加的经验值" style="width: 100%" />
</el-form-item>
<el-form-item label="每日限制" prop="limitCount">
<el-input-number v-model="form.limitCount" :min="-1" placeholder="每日经验增长限制次数 (-1为无限制)" style="width: 100%" />
<div style="font-size: 12px; color: #909399; margin-top: 4px">-1 表示无限制</div>
</el-form-item>
<el-form-item label="规则描述" prop="description">
<el-input v-model="form.description" placeholder="请输入规则描述" :rows="3" type="textarea" />
</el-form-item>
<el-form-item label="是否启用" prop="isEnabled">
<el-switch v-model="form.isEnabled" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="close"> </el-button>
<el-button type="primary" @click="save"> </el-button>
</div>
</el-dialog>
</template>
<script>
import { doAdd, doEdit } from '@/api/system/ability'
import { getList as getApplicationList } from '@/api/appManagement'
export default {
name: 'AbilityManagementEdit',
data() {
return {
form: {
appId: '',
name: '',
scene: '',
costPoints: 0,
gainExp: 0,
limitCount: -1,
description: '',
isEnabled: true,
},
rules: {
appId: [{ required: true, trigger: 'blur', message: '请选择应用' }],
name: [{ required: true, trigger: 'blur', message: '请输入规则名称' }],
scene: [{ required: true, trigger: 'blur', message: '请输入功能场景' }],
},
title: '',
dialogFormVisible: false,
applicationList: [],
}
},
created() {
this.fetchApplicationList()
},
methods: {
async fetchApplicationList() {
try {
const { data } = await getApplicationList({ pageNo: 1, pageSize: 100 })
this.applicationList = data.list
} catch (error) {
console.error('获取应用列表失败', error)
}
},
showEdit(row) {
if (!row || !row.id) {
this.title = '添加'
this.form = Object.assign({}, this.$options.data().form)
if (row) {
this.form = Object.assign(this.form, row)
}
} else {
this.title = '编辑'
this.form = Object.assign({}, row)
}
this.dialogFormVisible = true
},
close() {
this.$refs['form'].resetFields()
this.form = this.$options.data().form
this.dialogFormVisible = false
},
save() {
this.$refs['form'].validate(async (valid) => {
if (valid) {
try {
if (this.title === '添加') {
const { msg } = await doAdd(this.form)
this.$baseMessage(msg, 'success')
} else {
const { msg } = await doEdit(this.form.id, this.form)
this.$baseMessage(msg, 'success')
}
this.$refs['form'].resetFields()
this.dialogFormVisible = false
this.$emit('fetch-data')
this.form = this.$options.data().form
} catch (error) {
console.error(error)
}
} else {
return false
}
})
},
},
}
</script>

View File

@@ -0,0 +1,189 @@
<template>
<div class="ability-management-container">
<el-tabs v-model="queryForm.appId" type="card" @tab-click="handleTabClick">
<el-tab-pane v-for="item in applicationList" :key="item.id" :label="item.name" :name="item.id" />
</el-tabs>
<vab-query-form>
<vab-query-form-left-panel :span="12">
<el-button icon="el-icon-plus" type="primary" @click="handleEdit">添加</el-button>
<el-button icon="el-icon-delete" type="danger" @click="handleDelete">批量删除</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.name" 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="name" show-overflow-tooltip />
<el-table-column align="center" label="场景" prop="scene" show-overflow-tooltip width="120" />
<el-table-column align="center" label="描述" min-width="200" prop="description" show-overflow-tooltip />
<el-table-column align="center" label="数值设置" width="180">
<template #default="{ row }">
<div v-if="row.costPoints">消耗积分: {{ row.costPoints }}</div>
<div v-if="row.gainExp">增加经验: {{ row.gainExp }}</div>
<div>每日限制: {{ row.limitCount === -1 ? '无限制' : row.limitCount }}</div>
</template>
</el-table-column>
<el-table-column align="center" label="状态" prop="isEnabled" width="100">
<template #default="{ row }">
<el-switch v-model="row.isEnabled" @change="handleStatusChange(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-column align="center" fixed="right" label="操作" show-overflow-tooltip width="150">
<template #default="{ row }">
<el-button type="text" @click="handleEdit(row)">编辑</el-button>
<el-button type="text" @click="handleDelete(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"
/>
<edit ref="edit" @fetch-data="fetchData" />
</div>
</template>
<script>
import { getList, doDelete, toggleEnable } from '@/api/system/ability'
import { getList as getApplicationList } from '@/api/appManagement'
import { formatTime } from '@/utils'
import Edit from './components/AbilityManagementEdit'
export default {
name: 'AbilityManagement',
components: { Edit },
data() {
return {
list: [],
listLoading: true,
layout: 'total, sizes, prev, pager, next, jumper',
total: 0,
selectRows: [],
elementLoadingText: '正在加载...',
queryForm: {
pageNo: 1,
pageSize: 10,
name: '',
appId: '',
},
applicationList: [],
}
},
created() {
this.fetchApplicationList()
this.fetchData()
},
methods: {
formatTime,
async fetchApplicationList() {
try {
const { data } = await getApplicationList({ pageNo: 1, pageSize: 100 })
this.applicationList = data.list
} catch (error) {
console.error('获取应用列表失败', error)
}
},
handleTabClick(tab) {
this.queryForm.appId = tab.name
this.queryForm.pageNo = 1
this.fetchData()
},
setSelectRows(val) {
this.selectRows = val
},
handleEdit(row) {
if (row.id) {
this.$refs['edit'].showEdit(row)
} else {
// 如果当前选中了某个应用,自动填入 appId
const defaultData = this.queryForm.appId ? { appId: this.queryForm.appId } : null
this.$refs['edit'].showEdit(defaultData)
}
},
handleDelete(row) {
if (row.id) {
this.$baseConfirm('你确定要删除当前项吗', null, async () => {
const { msg } = await doDelete({ ids: [row.id] })
this.$baseMessage(msg, 'success')
this.fetchData()
})
} else {
if (this.selectRows.length > 0) {
const ids = this.selectRows.map((item) => item.id).join()
this.$baseConfirm('你确定要删除选中项吗', null, async () => {
const { msg } = await doDelete({ ids: ids.split(',') })
this.$baseMessage(msg, 'success')
this.fetchData()
})
} else {
this.$baseMessage('未选中任何行', 'error')
return false
}
}
},
async handleStatusChange(row) {
try {
const { msg } = await toggleEnable(row.id, row.isEnabled)
this.$baseMessage(msg, 'success')
} catch (error) {
row.isEnabled = !row.isEnabled
}
},
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
}
},
},
}
</script>
<style scoped>
.ability-management-container {
padding: 20px;
}
</style>

View File

@@ -69,6 +69,10 @@
}
},
created() {
const { permission } = this.$route.query
if (permission) {
this.queryForm.permission = permission
}
this.fetchData()
},

View File

@@ -0,0 +1,63 @@
<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="IP地址" prop="ip">
<el-input v-model.trim="form.ip" autocomplete="off" placeholder="请输入需要拉黑的IP地址" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="close"> </el-button>
<el-button type="primary" @click="save"> </el-button>
</div>
</el-dialog>
</template>
<script>
import { doAdd } from '@/api/system/ipBlack'
export default {
name: 'IPBlacklistEdit',
data() {
return {
form: {
ip: '',
},
rules: {
ip: [{ required: true, trigger: 'blur', message: '请输入IP地址' }],
},
title: '新增',
dialogFormVisible: false,
}
},
methods: {
showEdit() {
this.title = '新增'
this.form = this.$options.data().form
this.dialogFormVisible = true
},
close() {
this.$refs['form'].resetFields()
this.form = this.$options.data().form
this.dialogFormVisible = false
},
save() {
this.$refs['form'].validate(async (valid) => {
if (valid) {
try {
const { msg } = await doAdd(this.form)
this.$baseMessage(msg, 'success')
this.$refs['form'].resetFields()
this.dialogFormVisible = false
this.$emit('fetch-data')
this.form = this.$options.data().form
} catch (error) {
console.error(error)
}
} else {
return false
}
})
},
},
}
</script>

View File

@@ -0,0 +1,130 @@
<template>
<div class="ip-blacklist-container">
<vab-query-form>
<vab-query-form-left-panel :span="12">
<el-button icon="el-icon-plus" type="primary" @click="handleAdd">新增</el-button>
<el-button icon="el-icon-delete" type="danger" @click="handleDelete">移除选中</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.ip" clearable placeholder="请输入查询的IP" />
</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" @selection-change="setSelectRows">
<el-table-column align="center" show-overflow-tooltip type="selection" width="55" />
<el-table-column align="center" label="IP" prop="ip" show-overflow-tooltip />
<el-table-column align="center" label="地址" prop="address" show-overflow-tooltip />
<el-table-column align="center" fixed="right" label="操作" show-overflow-tooltip width="200">
<template #default="{ row }">
<el-button type="text" @click="handleDelete(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"
/>
<edit ref="edit" @fetch-data="fetchData" />
</div>
</template>
<script>
import { getList, doRemove } from '@/api/system/ipBlack'
import Edit from './components/IPBlacklistEdit'
export default {
name: 'IPBlacklist',
components: { Edit },
data() {
return {
list: [],
listLoading: true,
layout: 'total, sizes, prev, pager, next, jumper',
total: 0,
selectRows: [],
elementLoadingText: '正在加载...',
queryForm: {
pageNo: 1,
pageSize: 10,
ip: '',
},
}
},
created() {
this.fetchData()
},
methods: {
setSelectRows(val) {
this.selectRows = val
},
handleAdd() {
this.$refs['edit'].showEdit()
},
handleDelete(row) {
if (row.ip) {
this.$baseConfirm('你确定要将当前IP从黑名单中移除吗', null, async () => {
const { msg } = await doRemove({ ips: [row.ip] })
this.$baseMessage(msg, 'success')
this.fetchData()
})
} else {
if (this.selectRows.length > 0) {
const ips = this.selectRows.map((item) => item.ip)
this.$baseConfirm('你确定要将选中的IP从黑名单中移除吗', null, async () => {
const { msg } = await doRemove({ ips })
this.$baseMessage(msg, 'success')
this.fetchData()
})
} else {
this.$baseMessage('未选中任何行', 'error')
return false
}
}
},
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
}
},
},
}
</script>
<style scoped>
.ip-blacklist-container {
padding: 20px;
}
</style>

View File

@@ -0,0 +1,140 @@
<template>
<el-dialog :title="title" :visible.sync="dialogFormVisible" width="500px" @close="close">
<el-form ref="form" label-width="100px" :model="form" :rules="rules">
<el-form-item label="应用" prop="appId">
<el-select v-model="form.appId" placeholder="请选择应用" style="width: 100%">
<el-option v-for="item in applicationList" :key="item.id" :label="item.name" :value="item.id" />
</el-select>
</el-form-item>
<el-form-item label="规则名称" prop="name">
<el-input v-model="form.name" placeholder="请输入规则名称" />
</el-form-item>
<el-form-item label="奖励场景" prop="scene">
<el-input v-model="form.scene" placeholder="请输入奖励场景标识 (如: login, share)" />
</el-form-item>
<el-form-item label="限制类型" prop="limitType">
<el-select v-model="form.limitType" placeholder="请选择限制类型" style="width: 100%">
<el-option label="每日" value="daily" />
<el-option label="每周" value="weekly" />
<el-option label="终身" value="lifetime" />
<el-option label="无限制" value="none" />
</el-select>
</el-form-item>
<el-form-item v-if="form.limitType !== 'none'" label="限制次数" prop="limitCount">
<el-input-number v-model="form.limitCount" :min="-1" placeholder="周期内最大次数 (-1为无限制)" style="width: 100%" />
<div style="font-size: 12px; color: #909399; margin-top: 4px">-1 表示无限制</div>
</el-form-item>
<el-form-item label="奖励积分" prop="gainPoints">
<el-input-number v-model="form.gainPoints" :min="0" placeholder="增加的积分值" style="width: 100%" />
</el-form-item>
<el-form-item label="奖励经验" prop="gainExp">
<el-input-number v-model="form.gainExp" :min="0" placeholder="增加的经验值" style="width: 100%" />
</el-form-item>
<el-form-item label="规则描述" prop="description">
<el-input v-model="form.description" placeholder="请输入规则描述" :rows="3" type="textarea" />
</el-form-item>
<el-form-item label="是否启用" prop="isEnabled">
<el-switch v-model="form.isEnabled" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="close"> </el-button>
<el-button type="primary" @click="save"> </el-button>
</div>
</el-dialog>
</template>
<script>
import { doAdd, doEdit } from '@/api/system/reward'
import { getList as getApplicationList } from '@/api/appManagement'
export default {
name: 'RewardManagementEdit',
data() {
return {
form: {
appId: '',
name: '',
scene: '',
limitType: 'daily',
limitCount: 1,
gainPoints: 0,
gainExp: 0,
description: '',
isEnabled: true,
},
rules: {
appId: [{ required: true, trigger: 'blur', message: '请选择应用' }],
name: [{ required: true, trigger: 'blur', message: '请输入规则名称' }],
scene: [{ required: true, trigger: 'blur', message: '请输入奖励场景' }],
limitType: [{ required: true, trigger: 'blur', message: '请选择限制类型' }],
},
title: '',
dialogFormVisible: false,
applicationList: [],
}
},
created() {
this.fetchApplicationList()
},
methods: {
async fetchApplicationList() {
try {
const { data } = await getApplicationList({ pageNo: 1, pageSize: 100 })
this.applicationList = data.list
} catch (error) {
console.error('获取应用列表失败', error)
}
},
showEdit(row) {
if (!row || !row.id) {
this.title = '添加'
this.form = Object.assign({}, this.$options.data().form)
if (row) {
this.form = Object.assign(this.form, row)
}
} else {
this.title = '编辑'
this.form = Object.assign({}, row)
}
this.dialogFormVisible = true
},
close() {
this.$refs['form'].resetFields()
this.form = this.$options.data().form
this.dialogFormVisible = false
},
save() {
this.$refs['form'].validate(async (valid) => {
if (valid) {
try {
if (this.title === '添加') {
const { msg } = await doAdd(this.form)
this.$baseMessage(msg, 'success')
} else {
const { msg } = await doEdit(this.form.id, this.form)
this.$baseMessage(msg, 'success')
}
this.$refs['form'].resetFields()
this.dialogFormVisible = false
this.$emit('fetch-data')
this.form = this.$options.data().form
} catch (error) {
console.error(error)
}
} else {
return false
}
})
},
},
}
</script>

View File

@@ -0,0 +1,201 @@
<template>
<div class="reward-management-container">
<el-tabs v-model="queryForm.appId" type="card" @tab-click="handleTabClick">
<el-tab-pane v-for="item in applicationList" :key="item.id" :label="item.name" :name="item.id" />
</el-tabs>
<vab-query-form>
<vab-query-form-left-panel :span="12">
<el-button icon="el-icon-plus" type="primary" @click="handleEdit">添加</el-button>
<el-button icon="el-icon-delete" type="danger" @click="handleDelete">批量删除</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.name" 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="name" show-overflow-tooltip />
<el-table-column align="center" label="场景" prop="scene" show-overflow-tooltip width="120" />
<el-table-column align="center" label="描述" min-width="200" prop="description" show-overflow-tooltip />
<el-table-column align="center" label="奖励内容" width="150">
<template #default="{ row }">
<div v-if="row.gainPoints">积分: +{{ row.gainPoints }}</div>
<div v-if="row.gainExp">经验: +{{ row.gainExp }}</div>
</template>
</el-table-column>
<el-table-column align="center" label="限制规则" width="150">
<template #default="{ row }">
<div>
类型:
<el-tag v-if="row.limitType === 'daily'" size="mini">每日</el-tag>
<el-tag v-else-if="row.limitType === 'weekly'" size="mini" type="success">每周</el-tag>
<el-tag v-else-if="row.limitType === 'lifetime'" size="mini" type="warning">终身</el-tag>
<el-tag v-else size="mini" type="info">无限制</el-tag>
</div>
<div v-if="row.limitType !== 'none'">次数: {{ row.limitCount === -1 ? '无限制' : row.limitCount }}</div>
</template>
</el-table-column>
<el-table-column align="center" label="状态" prop="isEnabled" width="100">
<template #default="{ row }">
<el-switch v-model="row.isEnabled" @change="handleStatusChange(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-column align="center" fixed="right" label="操作" show-overflow-tooltip width="150">
<template #default="{ row }">
<el-button type="text" @click="handleEdit(row)">编辑</el-button>
<el-button type="text" @click="handleDelete(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"
/>
<edit ref="edit" @fetch-data="fetchData" />
</div>
</template>
<script>
import { getRewardRuleList, doDelete, toggleEnable } from '@/api/system/reward'
import { getList as getApplicationList } from '@/api/appManagement'
import { formatTime } from '@/utils'
import Edit from './components/RewardManagementEdit'
export default {
name: 'RewardManagement',
components: { Edit },
data() {
return {
list: [],
listLoading: true,
layout: 'total, sizes, prev, pager, next, jumper',
total: 0,
selectRows: [],
elementLoadingText: '正在加载...',
queryForm: {
pageNo: 1,
pageSize: 10,
name: '',
appId: '',
},
applicationList: [],
}
},
created() {
this.fetchApplicationList()
this.fetchData()
},
methods: {
formatTime,
async fetchApplicationList() {
try {
const { data } = await getApplicationList({ pageNo: 1, pageSize: 100 })
this.applicationList = data.list
} catch (error) {
console.error('获取应用列表失败', error)
}
},
handleTabClick(tab) {
this.queryForm.appId = tab.name
this.queryForm.pageNo = 1
this.fetchData()
},
setSelectRows(val) {
this.selectRows = val
},
handleEdit(row) {
if (row.id) {
this.$refs['edit'].showEdit(row)
} else {
// 如果当前选中了某个应用,自动填入 appId
const defaultData = this.queryForm.appId ? { appId: this.queryForm.appId } : null
this.$refs['edit'].showEdit(defaultData)
}
},
handleDelete(row) {
if (row.id) {
this.$baseConfirm('你确定要删除当前项吗', null, async () => {
const { msg } = await doDelete({ ids: [row.id] })
this.$baseMessage(msg, 'success')
this.fetchData()
})
} else {
if (this.selectRows.length > 0) {
const ids = this.selectRows.map((item) => item.id).join()
this.$baseConfirm('你确定要删除选中项吗', null, async () => {
const { msg } = await doDelete({ ids: ids.split(',') })
this.$baseMessage(msg, 'success')
this.fetchData()
})
} else {
this.$baseMessage('未选中任何行', 'error')
return false
}
}
},
async handleStatusChange(row) {
try {
const { msg } = await toggleEnable(row.id, row.isEnabled)
this.$baseMessage(msg, 'success')
} catch (error) {
row.isEnabled = !row.isEnabled
}
},
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 getRewardRuleList(this.queryForm)
this.list = data.list
this.total = data.totalCount
} catch (error) {
console.error(error)
} finally {
this.listLoading = false
}
},
},
}
</script>
<style scoped>
.reward-management-container {
padding: 20px;
}
</style>

View File

@@ -0,0 +1,114 @@
<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" 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="itemId">
<el-select v-model="form.itemId" filterable placeholder="请选择评价项" 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: 20px; height: 20px; border-radius: 50%; margin-right: 10px"
/>
<span>{{ item.name }}</span>
</div>
</el-option>
</el-select>
</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-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="close"> </el-button>
<el-button type="primary" @click="save"> </el-button>
</div>
</el-dialog>
</template>
<script>
import { getAllList as getTopicList } from '@/api/rating/topic'
import { getAllList as getTopicItemList } from '@/api/rating/topicItem'
import { comment } from '@/api/rating/topicOperate'
import { getThumbUrl } from '@/utils/blessing'
export default {
name: 'RobotCommentEdit',
data() {
return {
title: '机器人评论',
dialogFormVisible: false,
form: {
topicId: '',
itemId: '',
content: '',
userId: '',
},
rules: {
topicId: [{ required: true, trigger: 'change', message: '请选择评价主题' }],
itemId: [{ required: true, trigger: 'change', message: '请选择评价项' }],
content: [{ required: true, trigger: 'blur', message: '请输入评论内容' }],
},
topicList: [],
itemList: [],
}
},
methods: {
getThumbUrl,
async showEdit(row) {
this.title = '机器人评论'
this.form = this.$options.data().form
this.form.userId = row.userId || row.id
this.dialogFormVisible = true
await this.fetchTopicList()
},
close() {
this.$refs['form'].resetFields()
this.form = this.$options.data().form
this.itemList = []
this.dialogFormVisible = false
},
async fetchTopicList() {
try {
const { data } = await getTopicList()
this.topicList = data || []
} catch (error) {
console.error(error)
}
},
async handleTopicChange(val) {
this.form.itemId = ''
this.itemList = []
if (val) {
try {
const { data } = await getTopicItemList({ topicId: val })
this.itemList = data || []
} catch (error) {
console.error(error)
}
}
},
save() {
this.$refs['form'].validate(async (valid) => {
if (valid) {
try {
const { msg } = await comment(this.form)
this.$baseMessage(msg || '评论成功', 'success')
this.close()
this.$emit('fetch-data')
} catch (error) {
console.error(error)
}
} else {
return false
}
})
},
},
}
</script>

View File

@@ -0,0 +1,166 @@
<template>
<el-dialog title="用户评论" :visible.sync="dialogVisible" width="600px" @close="close">
<div v-if="commentList && commentList.length > 0" class="comment-list">
<div v-for="item in commentList" :key="item.id" class="comment-item">
<div class="comment-header">
<el-image
v-if="item.itemAvatarUrl"
class="comment-avatar"
:preview-src-list="[item.itemAvatarUrl]"
:src="getThumbUrl(item.itemAvatarUrl)"
/>
<div class="comment-meta">
<div class="comment-title">
<span class="topic-name">[{{ item.topicName }}]</span>
<span class="item-name">{{ item.itemName }}</span>
</div>
<div class="comment-time">{{ formatTime(item.createdAt) }}</div>
</div>
<el-tag size="mini" :type="item.status === 2 ? 'success' : 'info'">
{{ item.status === 2 ? '已展示' : '隐藏/待审' }}
</el-tag>
</div>
<div class="comment-content">
{{ item.content }}
</div>
<div class="comment-footer">
<span>
<i class="el-icon-thumb" />
{{ item.likeCount || 0 }}
</span>
<span>
<i class="el-icon-chat-dot-round" />
{{ item.replyCount || 0 }}
</span>
</div>
</div>
</div>
<el-empty v-else description="暂无评论数据" />
<div slot="footer" class="dialog-footer">
<el-button @click="close"> </el-button>
</div>
</el-dialog>
</template>
<script>
import { formatTime } from '@/utils'
import { getThumbUrl } from '@/utils/blessing'
export default {
name: 'RobotCommentView',
data() {
return {
dialogVisible: false,
commentList: [],
}
},
methods: {
formatTime,
getThumbUrl,
show(comments) {
this.commentList = comments || []
this.dialogVisible = true
},
close() {
this.commentList = []
this.dialogVisible = false
},
},
}
</script>
<style scoped>
.comment-list {
max-height: 500px;
overflow-y: auto;
padding-right: 10px;
}
.comment-item {
padding: 15px;
margin-bottom: 15px;
background-color: #f8f9fa;
border-radius: 8px;
border: 1px solid #ebeef5;
}
.comment-item:last-child {
margin-bottom: 0;
}
.comment-header {
display: flex;
align-items: flex-start;
margin-bottom: 10px;
}
.comment-avatar {
width: 40px;
height: 40px;
border-radius: 4px;
margin-right: 10px;
flex-shrink: 0;
}
.comment-meta {
flex: 1;
overflow: hidden;
}
.comment-title {
font-size: 14px;
margin-bottom: 4px;
display: flex;
align-items: center;
}
.topic-name {
color: #409eff;
margin-right: 5px;
font-weight: bold;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 150px;
}
.item-name {
font-weight: bold;
color: #303133;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
flex: 1;
}
.comment-time {
font-size: 12px;
color: #909399;
}
.comment-content {
font-size: 14px;
color: #606266;
line-height: 1.6;
margin-bottom: 10px;
word-break: break-all;
white-space: pre-wrap;
background-color: #fff;
padding: 10px;
border-radius: 4px;
}
.comment-footer {
display: flex;
align-items: center;
gap: 15px;
font-size: 12px;
color: #909399;
}
.comment-footer span {
display: flex;
align-items: center;
gap: 4px;
}
</style>

View File

@@ -0,0 +1,120 @@
<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" 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="itemId">
<el-select v-model="form.itemId" filterable placeholder="请选择评价项" 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: 20px; height: 20px; border-radius: 50%; margin-right: 10px"
/>
<span>{{ item.name }}</span>
</div>
</el-option>
</el-select>
</el-form-item>
<el-form-item label="评分" prop="scoreType">
<el-radio-group v-model="form.scoreType">
<el-radio :label="5"></el-radio>
<el-radio :label="4">顶级</el-radio>
<el-radio :label="3">人上人</el-radio>
<el-radio :label="2">NPC</el-radio>
<el-radio :label="1"></el-radio>
</el-radio-group>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="close"> </el-button>
<el-button type="primary" @click="save"> </el-button>
</div>
</el-dialog>
</template>
<script>
import { getAllList as getTopicList } from '@/api/rating/topic'
import { getAllList as getTopicItemList } from '@/api/rating/topicItem'
import { score } from '@/api/rating/topicOperate'
import { getThumbUrl } from '@/utils/blessing'
export default {
name: 'RobotRatingEdit',
data() {
return {
title: '机器人评分',
dialogFormVisible: false,
form: {
topicId: '',
itemId: '',
scoreType: '',
userId: '',
},
rules: {
topicId: [{ required: true, trigger: 'change', message: '请选择评价主题' }],
itemId: [{ required: true, trigger: 'change', message: '请选择评价项' }],
scoreType: [{ required: true, trigger: 'change', message: '请选择评分' }],
},
topicList: [],
itemList: [],
}
},
methods: {
getThumbUrl,
async showEdit(row) {
this.title = '机器人评分'
this.form = this.$options.data().form
this.form.userId = row.userId || row.id
this.dialogFormVisible = true
await this.fetchTopicList()
},
close() {
this.$refs['form'].resetFields()
this.form = this.$options.data().form
this.itemList = []
this.dialogFormVisible = false
},
async fetchTopicList() {
try {
const { data } = await getTopicList()
this.topicList = data || []
} catch (error) {
console.error(error)
}
},
async handleTopicChange(val) {
this.form.itemId = ''
this.itemList = []
if (val) {
try {
const { data } = await getTopicItemList({ topicId: val })
this.itemList = data || []
} catch (error) {
console.error(error)
}
}
},
save() {
this.$refs['form'].validate(async (valid) => {
if (valid) {
try {
const { msg } = await score(this.form)
this.$baseMessage(msg || '评分成功', 'success')
this.close()
this.$emit('fetch-data')
} catch (error) {
console.error(error)
}
} else {
return false
}
})
},
},
}
</script>

View File

@@ -0,0 +1,281 @@
<template>
<div class="robot-management-container">
<el-tabs v-model="queryForm.appId" type="card" @tab-click="handleTabClick">
<el-tab-pane v-for="item in applicationList" :key="item.id" :label="item.name" :name="item.id" />
</el-tabs>
<vab-query-form>
<vab-query-form-left-panel :span="12">
<el-button icon="el-icon-plus" type="primary" @click="handleGenerate">生成机器人</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="left" label="用户信息" width="150">
<template #default="{ row }">
<div v-if="row" style="display: flex; align-items: center; justify-content: flex-start">
<el-image
v-if="row.avatar"
:src="getThumbUrl(row.avatar)"
style="width: 40px; height: 40px; border-radius: 50%; margin-right: 10px"
/>
<div>
<div>{{ row.nickname }}</div>
</div>
</div>
<div v-else>-</div>
</template>
</el-table-column>
<el-table-column align="left" label="用户ID" prop="id" show-overflow-tooltip width="220" />
<el-table-column align="center" label="创建时间" prop="createdAt" width="160">
<template #default="{ row }">
{{ formatTime(row.createdAt) }}
</template>
</el-table-column>
<el-table-column v-if="queryForm.appId === '6a0d7dbe4c5de50f2ba66475'" label="评价信息" min-width="300">
<template #default="{ row }">
<div v-if="row.ratingInfo && row.ratingInfo.length > 0" class="rating-info-list">
<div v-for="item in row.ratingInfo" :key="item.id" class="rating-info-item">
<el-image
v-if="item.itemAvatarUrl"
:preview-src-list="[item.itemAvatarUrl]"
:src="getThumbUrl(item.itemAvatarUrl)"
style="width: 30px; height: 30px; border-radius: 4px; margin-right: 8px; flex-shrink: 0"
/>
<div class="rating-info-content">
<div class="rating-info-title">
<span class="topic-name">[{{ item.topicName }}]</span>
<span class="item-name">{{ item.itemName }}</span>
</div>
<div class="rating-info-meta">
<el-tag size="mini" :type="getScoreTypeTag(item.scoreType)">{{ getScoreTypeText(item.scoreType) }}</el-tag>
<span class="score-count">评价人数: {{ item.itemScoreCount }}</span>
</div>
</div>
</div>
</div>
<div v-else>-</div>
</template>
</el-table-column>
<el-table-column v-if="queryForm.appId === '6a0d7dbe4c5de50f2ba66475'" align="center" fixed="right" label="操作" width="100">
<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="handleViewComment(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"
/>
<robot-rating-edit ref="ratingEdit" @fetch-data="fetchData" />
<robot-comment-edit ref="commentEdit" @fetch-data="fetchData" />
<robot-comment-view ref="commentView" />
</div>
</template>
<script>
import { getList, generate } from '@/api/system/robot'
import { getList as getApplicationList } from '@/api/appManagement'
import { formatTime } from '@/utils'
import { getThumbUrl } from '@/utils/blessing'
import RobotRatingEdit from './components/RobotRatingEdit'
import RobotCommentEdit from './components/RobotCommentEdit'
import RobotCommentView from './components/RobotCommentView'
export default {
name: 'RobotManagement',
components: { RobotRatingEdit, RobotCommentEdit, RobotCommentView },
data() {
return {
list: [],
listLoading: true,
layout: 'total, sizes, prev, pager, next, jumper',
total: 0,
elementLoadingText: '正在加载...',
queryForm: {
appId: '',
pageNo: 1,
pageSize: 10,
keyword: '',
},
applicationList: [],
}
},
created() {
this.fetchApplicationList()
},
methods: {
formatTime,
getThumbUrl,
async fetchApplicationList() {
try {
const { data } = await getApplicationList({ pageNo: 1, pageSize: 100 })
this.applicationList = data.list
if (this.applicationList.length > 0) {
this.queryForm.appId = this.applicationList[0].id
this.fetchData()
}
} catch (error) {
console.error(error)
}
},
handleTabClick() {
this.queryForm.pageNo = 1
this.fetchData()
},
async handleGenerate() {
if (!this.queryForm.appId) {
this.$baseMessage('请先选择应用', 'error')
return
}
try {
const { msg } = await generate(this.queryForm.appId)
this.$baseMessage(msg || '生成成功', 'success')
this.fetchData()
} catch (error) {
console.error(error)
}
},
handleSizeChange(val) {
this.queryForm.pageSize = val
this.fetchData()
},
handleCurrentChange(val) {
this.queryForm.pageNo = val
this.fetchData()
},
queryData() {
this.queryForm.pageNo = 1
this.fetchData()
},
async fetchData() {
if (!this.queryForm.appId) return
this.listLoading = true
try {
const { data } = await getList(this.queryForm)
this.list = data.list
this.total = data.totalCount
} catch (error) {
console.error(error)
} finally {
this.listLoading = false
}
},
handleRating(row) {
this.$refs['ratingEdit'].showEdit(row)
},
handleComment(row) {
this.$refs['commentEdit'].showEdit(row)
},
handleViewComment(row) {
this.$refs['commentView'].show(row.commentInfo || [])
},
getScoreTypeText(type) {
const map = {
5: '夯',
4: '顶级',
3: '人上人',
2: 'NPC',
1: '拉',
}
return map[type] || '未知'
},
getScoreTypeTag(type) {
const map = {
5: 'success', // 夯
4: 'primary', // 顶级
3: 'warning', // 人上人
2: 'info', // NPC
1: 'danger', // 拉
}
return map[type] || 'info'
},
},
}
</script>
<style scoped>
.robot-management-container {
padding: 20px;
}
.rating-info-list {
display: flex;
flex-direction: column;
gap: 10px;
padding: 5px 0;
}
.rating-info-item {
display: flex;
align-items: center;
background-color: #f5f7fa;
padding: 8px;
border-radius: 4px;
}
.rating-info-content {
display: flex;
flex-direction: column;
flex: 1;
overflow: hidden;
}
.rating-info-title {
display: flex;
align-items: center;
margin-bottom: 4px;
font-size: 13px;
}
.topic-name {
color: #409eff;
margin-right: 5px;
font-weight: bold;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 120px;
}
.item-name {
font-weight: bold;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
flex: 1;
}
.rating-info-meta {
display: flex;
align-items: center;
font-size: 12px;
}
.score-count {
color: #909399;
margin-left: 8px;
}
</style>

View File

@@ -0,0 +1,63 @@
<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="用户ID" prop="userId">
<el-input v-model.trim="form.userId" autocomplete="off" placeholder="请输入需要拉黑的用户ID" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="close"> </el-button>
<el-button type="primary" @click="save"> </el-button>
</div>
</el-dialog>
</template>
<script>
import { doAdd } from '@/api/system/userBlack'
export default {
name: 'UserBlacklistEdit',
data() {
return {
form: {
userId: '',
},
rules: {
userId: [{ required: true, trigger: 'blur', message: '请输入用户ID' }],
},
title: '新增',
dialogFormVisible: false,
}
},
methods: {
showEdit() {
this.title = '新增'
this.form = this.$options.data().form
this.dialogFormVisible = true
},
close() {
this.$refs['form'].resetFields()
this.form = this.$options.data().form
this.dialogFormVisible = false
},
save() {
this.$refs['form'].validate(async (valid) => {
if (valid) {
try {
const { msg } = await doAdd(this.form)
this.$baseMessage(msg, 'success')
this.$refs['form'].resetFields()
this.dialogFormVisible = false
this.$emit('fetch-data')
this.form = this.$options.data().form
} catch (error) {
console.error(error)
}
} else {
return false
}
})
},
},
}
</script>

View File

@@ -0,0 +1,129 @@
<template>
<div class="user-blacklist-container">
<vab-query-form>
<vab-query-form-left-panel :span="12">
<el-button icon="el-icon-plus" type="primary" @click="handleAdd">新增</el-button>
<el-button icon="el-icon-delete" type="danger" @click="handleDelete">移除选中</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.userId" clearable placeholder="请输入查询的用户ID" />
</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" @selection-change="setSelectRows">
<el-table-column align="center" show-overflow-tooltip type="selection" width="55" />
<el-table-column align="center" label="用户ID" prop="userId" show-overflow-tooltip />
<el-table-column align="center" fixed="right" label="操作" show-overflow-tooltip width="200">
<template #default="{ row }">
<el-button type="text" @click="handleDelete(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"
/>
<edit ref="edit" @fetch-data="fetchData" />
</div>
</template>
<script>
import { getList, doRemove } from '@/api/system/userBlack'
import Edit from './components/UserBlacklistEdit'
export default {
name: 'UserBlacklist',
components: { Edit },
data() {
return {
list: [],
listLoading: true,
layout: 'total, sizes, prev, pager, next, jumper',
total: 0,
selectRows: [],
elementLoadingText: '正在加载...',
queryForm: {
pageNo: 1,
pageSize: 10,
userId: '',
},
}
},
created() {
this.fetchData()
},
methods: {
setSelectRows(val) {
this.selectRows = val
},
handleAdd() {
this.$refs['edit'].showEdit()
},
handleDelete(row) {
if (row.userId) {
this.$baseConfirm('你确定要将当前用户从黑名单中移除吗?', null, async () => {
const { msg } = await doRemove({ userIds: [row.userId] })
this.$baseMessage(msg, 'success')
this.fetchData()
})
} else {
if (this.selectRows.length > 0) {
const userIds = this.selectRows.map((item) => item.userId)
this.$baseConfirm('你确定要将选中的用户从黑名单中移除吗?', null, async () => {
const { msg } = await doRemove({ userIds })
this.$baseMessage(msg, 'success')
this.fetchData()
})
} else {
this.$baseMessage('未选中任何行', 'error')
return false
}
}
},
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
}
},
},
}
</script>
<style scoped>
.user-blacklist-container {
padding: 20px;
}
</style>

View File

@@ -0,0 +1,109 @@
<template>
<div class="user-sign-stat-container">
<vab-query-form>
<vab-query-form-left-panel :span="12">
<el-form :inline="true" :model="queryForm" @submit.native.prevent>
<el-form-item>
<el-input v-model.trim="queryForm.userId" clearable placeholder="请输入用户ID" />
</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-left-panel>
</vab-query-form>
<el-table v-loading="listLoading" :data="list" :element-loading-text="elementLoadingText">
<el-table-column align="center" label="用户信息" width="200">
<template #default="{ row }">
<div v-if="row.user" style="display: flex; align-items: center; justify-content: center">
<el-image
v-if="row.user.avatar"
:src="getThumbUrl(row.user.avatar)"
style="width: 40px; height: 40px; border-radius: 50%; margin-right: 10px"
/>
<div>
<div>{{ row.user.nickname }}</div>
<div style="font-size: 12px; color: #999">ID: {{ row.user.id }}</div>
</div>
</div>
<div v-else>{{ row.userId }}</div>
</template>
</el-table-column>
<el-table-column align="center" label="应用ID" prop="appId" show-overflow-tooltip />
<el-table-column align="center" label="最后签到日期" prop="lastSignDate" show-overflow-tooltip />
<el-table-column align="center" label="当前连续签到天数" prop="continuousDays" show-overflow-tooltip />
<el-table-column align="center" label="累计签到天数" prop="totalDays" show-overflow-tooltip />
</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 { getUserSignStatList } from '@/api/system/system'
import { getThumbUrl } from '@/utils/blessing'
export default {
name: 'UserSignStat',
data() {
return {
list: [],
listLoading: true,
layout: 'total, sizes, prev, pager, next, jumper',
total: 0,
elementLoadingText: '正在加载...',
queryForm: {
pageNo: 1,
pageSize: 10,
userId: '',
},
}
},
created() {
this.fetchData()
},
methods: {
getThumbUrl,
handleSizeChange(val) {
this.queryForm.pageSize = val
this.fetchData()
},
handleCurrentChange(val) {
this.queryForm.pageNo = val
this.fetchData()
},
queryData() {
this.queryForm.pageNo = 1
this.fetchData()
},
async fetchData() {
this.listLoading = true
try {
const { data } = await getUserSignStatList(this.queryForm)
this.list = data.list
this.total = data.totalCount
} catch (error) {
console.error(error)
} finally {
this.listLoading = false
}
},
},
}
</script>
<style scoped>
.user-sign-stat-container {
padding: 20px;
}
</style>