This commit is contained in:
zzc
2026-06-01 18:25:23 +08:00
parent af23adfd2b
commit 4789ac6ca0
4 changed files with 468 additions and 0 deletions

View File

@@ -14,6 +14,19 @@ export function score(data) {
})
}
/**
* 评分记录
* @param {*} { pageNo, pageSize, userId?, topicId?, itemId? }
* @returns
*/
export function scoreRecordList(data) {
return request({
url: 'management/api/rating/topicItemOperate/score/list',
method: 'get',
params: data,
})
}
/**
* 评论
* @param {*} { topicId, itemId, comment, userId }

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

@@ -67,6 +67,12 @@ export const asyncRoutes = [
component: () => import('@/views/rating/topicItem/index'),
meta: { title: '评分项' },
},
{
path: 'topic-record',
name: 'RatingTopicRecordIndex',
component: () => import('@/views/rating/topicScoreRecord/index'),
meta: { title: '用户评分记录' },
},
],
},
{

View File

@@ -0,0 +1,435 @@
<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>
</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 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="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 || '未知用户' }}</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"
/>
</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'
export default {
name: 'RatingTopicRecordIndex',
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: '',
},
// 用户下拉列表状态
userList: [],
userQuery: { pageNo: 1, pageSize: 20 },
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 { data } = await getUserList(this.userQuery)
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) {
// 重置 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()
},
// -- 列表数据加载 --
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
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>