fix: add robot score
This commit is contained in:
@@ -95,9 +95,9 @@
|
||||
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}`
|
||||
const left = item.leftItemName ? item.leftItemName : '未知'
|
||||
const right = item.rightItemName ? item.rightItemName : '未知'
|
||||
return `[${item.topicTitle ? item.topicTitle : '未知主题'}] ${left} vs ${right}`
|
||||
},
|
||||
showEdit(replyToRow = null, parentCommentId = null) {
|
||||
this.dialogFormVisible = true
|
||||
|
||||
@@ -65,12 +65,12 @@
|
||||
|
||||
<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 v-if="row.leftItemName && row.rightItemName" class="target-info-cell">
|
||||
<div class="topic-title">[{{ row.topicTitle ? row.topicTitle : '未知主题' }}]</div>
|
||||
<div class="item-info">
|
||||
<span>{{ row.pk.leftItem ? row.pk.leftItem.name : '未知' }}</span>
|
||||
<span>{{ row.leftItemName ? row.leftItemName : '未知123' }}</span>
|
||||
<span style="margin: 0 8px; color: #f56c6c; font-weight: bold">VS</span>
|
||||
<span>{{ row.pk.rightItem ? row.pk.rightItem.name : '未知' }}</span>
|
||||
<span>{{ row.rightItemName ? row.rightItemName : '未知123' }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else>{{ row.pkId }}</div>
|
||||
@@ -171,9 +171,9 @@
|
||||
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}`
|
||||
const left = item.leftItemName ? item.leftItemName : '未知'
|
||||
const right = item.rightItemName ? item.rightItemName : '未知'
|
||||
return `[${item.topicTitle ? item.topicTitle : '未知主题'}] ${left} vs ${right}`
|
||||
},
|
||||
|
||||
// -- PK 列表加载 --
|
||||
|
||||
@@ -94,6 +94,12 @@
|
||||
{{ formatTime(row.createdAt) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column align="center" fixed="right" label="操作" width="100">
|
||||
<template #default="{ row }">
|
||||
<el-button type="text" @click="handleComment(row)">评论</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<el-pagination
|
||||
@@ -109,13 +115,48 @@
|
||||
<pk-generate ref="generate" @fetch-data="fetchData" />
|
||||
<pk-participant-list ref="participantList" />
|
||||
<pk-vote-edit ref="voteEdit" @fetch-data="fetchData" />
|
||||
|
||||
<el-dialog title="立即评论" :visible.sync="commentDialogVisible" width="600px" @close="closeCommentDialog">
|
||||
<el-form ref="commentForm" label-width="100px" :model="commentForm" :rules="commentRules">
|
||||
<el-form-item label="参与机器人" prop="userId">
|
||||
<el-select
|
||||
v-model="commentForm.userId"
|
||||
v-loadmore="loadMoreCommentUsers"
|
||||
filterable
|
||||
placeholder="请选择参与评论的机器人"
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option v-for="item in commentUserList" :key="item.id" :label="item.nickname || item.id" :value="item.id">
|
||||
<div style="display: flex; align-items: center">
|
||||
<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="commentForm.content" maxlength="500" placeholder="请输入评论内容" :rows="4" show-word-limit type="textarea" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<div slot="footer">
|
||||
<el-button @click="closeCommentDialog">取消</el-button>
|
||||
<el-button :loading="commentSaving" type="primary" @click="submitComment">确定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getList } from '@/api/rating/pk'
|
||||
import { comment, getList } from '@/api/rating/pk'
|
||||
import { getList as getTopicList } from '@/api/rating/topic'
|
||||
import { getList as getItemList } from '@/api/rating/topicItem'
|
||||
import { getListBase as getRobotListBase } from '@/api/system/robot'
|
||||
import { formatTime } from '@/utils'
|
||||
import { getThumbUrl } from '@/utils/blessing'
|
||||
import PkGenerate from './components/PkGenerate'
|
||||
@@ -172,6 +213,26 @@
|
||||
},
|
||||
itemTotal: 0,
|
||||
fetchingItems: false,
|
||||
commentDialogVisible: false,
|
||||
commentSaving: false,
|
||||
commentForm: {
|
||||
pkId: '',
|
||||
userId: '',
|
||||
content: '',
|
||||
},
|
||||
commentRules: {
|
||||
userId: [{ required: true, trigger: 'change', message: '请选择参与评论的机器人' }],
|
||||
content: [{ required: true, trigger: 'blur', message: '请输入评论内容' }],
|
||||
},
|
||||
commentUserList: [],
|
||||
commentUserQuery: {
|
||||
appId: '6a0d7dbe4c5de50f2ba66475',
|
||||
pkId: '',
|
||||
pageNo: 1,
|
||||
pageSize: 20,
|
||||
},
|
||||
commentUserTotal: 0,
|
||||
fetchingCommentUsers: false,
|
||||
}
|
||||
},
|
||||
created() {
|
||||
@@ -281,6 +342,58 @@
|
||||
handleVote(pkId, itemId, itemName) {
|
||||
this.$refs['voteEdit'].showEdit(pkId, itemId, itemName)
|
||||
},
|
||||
handleComment(row) {
|
||||
this.commentDialogVisible = true
|
||||
this.commentForm = {
|
||||
pkId: row.id,
|
||||
userId: '',
|
||||
content: '',
|
||||
}
|
||||
this.commentUserList = []
|
||||
this.commentUserTotal = 0
|
||||
this.commentUserQuery.pageNo = 1
|
||||
this.commentUserQuery.pkId = row.id
|
||||
this.fetchCommentUsers()
|
||||
},
|
||||
closeCommentDialog() {
|
||||
if (this.$refs['commentForm']) {
|
||||
this.$refs['commentForm'].resetFields()
|
||||
}
|
||||
this.commentDialogVisible = false
|
||||
},
|
||||
async fetchCommentUsers() {
|
||||
if (this.fetchingCommentUsers || !this.commentUserQuery.pkId) return
|
||||
this.fetchingCommentUsers = true
|
||||
try {
|
||||
const { data } = await getRobotListBase(this.commentUserQuery)
|
||||
this.commentUserList = this.commentUserList.concat(data.list || [])
|
||||
this.commentUserTotal = data.totalCount || 0
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
this.fetchingCommentUsers = false
|
||||
}
|
||||
},
|
||||
loadMoreCommentUsers() {
|
||||
if (this.commentUserList.length >= this.commentUserTotal || this.fetchingCommentUsers) return
|
||||
this.commentUserQuery.pageNo += 1
|
||||
this.fetchCommentUsers()
|
||||
},
|
||||
submitComment() {
|
||||
this.$refs['commentForm'].validate(async (valid) => {
|
||||
if (!valid) return false
|
||||
this.commentSaving = true
|
||||
try {
|
||||
const { msg } = await comment(this.commentForm)
|
||||
this.$baseMessage(msg || '评论成功', 'success')
|
||||
this.closeCommentDialog()
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
this.commentSaving = false
|
||||
}
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user