fix: add robot score
This commit is contained in:
@@ -58,3 +58,16 @@ export function getPendingList(data) {
|
||||
params: data,
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 给某个分数段投票
|
||||
* @param {topicId: string, itemId: string, score: number, count: number} data
|
||||
* @returns
|
||||
*/
|
||||
export function ItemScorevote(data) {
|
||||
return request({
|
||||
url: 'management/api/rating/topicItem/vote/robot',
|
||||
method: 'post',
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -31,10 +31,11 @@
|
||||
/>
|
||||
|
||||
<el-table v-loading="listLoading" :data="list" :element-loading-text="elementLoadingText">
|
||||
<el-table-column align="center" fixed="left" label="操作" width="120">
|
||||
<el-table-column align="center" fixed="left" label="操作" width="180">
|
||||
<template #default="{ row }">
|
||||
<el-button type="text" @click="handleRating(row)">评价</el-button>
|
||||
<el-button type="text" @click="handleComment(row)">评论</el-button>
|
||||
<el-button type="text" @click="handleScoreVote(row)">补评分</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
@@ -91,6 +92,17 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column align="left" label="分段票数" min-width="260">
|
||||
<template #default="{ row }">
|
||||
<div class="score-segment-list">
|
||||
<div v-for="score in scoreOptions" :key="score" class="score-segment-item">
|
||||
<span class="score-segment-label">{{ score }}分</span>
|
||||
<span class="score-segment-value">{{ getScoreCount(row.scores, score) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column align="left" label="互动数据" min-width="150">
|
||||
<template #default="{ row }">
|
||||
<div class="stat-cell">
|
||||
@@ -147,11 +159,31 @@
|
||||
|
||||
<topic-item-rating-edit ref="ratingEdit" @fetch-data="fetchData" />
|
||||
<topic-item-comment-edit ref="commentEdit" @fetch-data="fetchData" />
|
||||
|
||||
<el-dialog title="补充分段评分" :visible.sync="scoreVoteVisible" width="480px" @close="closeScoreVoteDialog">
|
||||
<el-form ref="scoreVoteForm" label-width="100px" :model="scoreVoteForm" :rules="scoreVoteRules">
|
||||
<el-form-item label="评价项">
|
||||
<span>{{ scoreVoteForm.itemName || '-' }}</span>
|
||||
</el-form-item>
|
||||
<el-form-item label="分数段" prop="score">
|
||||
<el-select v-model="scoreVoteForm.score" placeholder="请选择分数段" style="width: 100%">
|
||||
<el-option v-for="score in scoreOptions" :key="score" :label="`${score}分`" :value="score" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="补充数量" prop="count">
|
||||
<el-input-number v-model="scoreVoteForm.count" controls-position="right" :max="100000" :min="1" :step="1" style="width: 100%" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<span slot="footer">
|
||||
<el-button @click="closeScoreVoteDialog">取 消</el-button>
|
||||
<el-button :loading="scoreVoteSubmitting" type="primary" @click="submitScoreVote">确 定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getList } from '@/api/rating/topicItem'
|
||||
import { getList, ItemScorevote } from '@/api/rating/topicItem'
|
||||
import { getList as getTopicList } from '@/api/rating/topic'
|
||||
import { formatTime } from '@/utils'
|
||||
import { getThumbUrl } from '@/utils/blessing'
|
||||
@@ -176,6 +208,20 @@
|
||||
keyword: '',
|
||||
topicId: '',
|
||||
},
|
||||
scoreOptions: [2, 4, 6, 8, 10],
|
||||
scoreVoteVisible: false,
|
||||
scoreVoteSubmitting: false,
|
||||
scoreVoteForm: {
|
||||
topicId: '',
|
||||
itemId: '',
|
||||
itemName: '',
|
||||
score: 2,
|
||||
count: 1,
|
||||
},
|
||||
scoreVoteRules: {
|
||||
score: [{ required: true, trigger: 'change', message: '请选择分数段' }],
|
||||
count: [{ required: true, trigger: 'change', message: '请输入补充数量' }],
|
||||
},
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
@@ -243,6 +289,48 @@
|
||||
handleComment(row) {
|
||||
this.$refs['commentEdit'].showEdit(row, this.queryForm.topicId)
|
||||
},
|
||||
getScoreCount(scores, score) {
|
||||
if (!scores) return 0
|
||||
return scores[score] || scores[String(score)] || 0
|
||||
},
|
||||
handleScoreVote(row) {
|
||||
this.scoreVoteForm = {
|
||||
topicId: this.queryForm.topicId,
|
||||
itemId: row.id,
|
||||
itemName: row.name,
|
||||
score: 2,
|
||||
count: 1,
|
||||
}
|
||||
this.scoreVoteVisible = true
|
||||
},
|
||||
closeScoreVoteDialog() {
|
||||
this.scoreVoteVisible = false
|
||||
if (this.$refs['scoreVoteForm']) {
|
||||
this.$refs['scoreVoteForm'].resetFields()
|
||||
}
|
||||
},
|
||||
submitScoreVote() {
|
||||
this.$refs['scoreVoteForm'].validate(async (valid) => {
|
||||
if (!valid) return false
|
||||
this.scoreVoteSubmitting = true
|
||||
try {
|
||||
const params = {
|
||||
topicId: this.scoreVoteForm.topicId,
|
||||
itemId: this.scoreVoteForm.itemId,
|
||||
score: this.scoreVoteForm.score,
|
||||
count: this.scoreVoteForm.count,
|
||||
}
|
||||
const { msg } = await ItemScorevote(params)
|
||||
this.$baseMessage(msg || '补充评分成功', 'success')
|
||||
this.closeScoreVoteDialog()
|
||||
this.fetchData()
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
} finally {
|
||||
this.scoreVoteSubmitting = false
|
||||
}
|
||||
})
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
@@ -323,4 +411,29 @@
|
||||
color: #409eff;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.score-segment-list {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.score-segment-item {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
padding: 4px 10px;
|
||||
background: #f5f7fa;
|
||||
border-radius: 4px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.score-segment-label {
|
||||
color: #606266;
|
||||
margin-right: 6px;
|
||||
}
|
||||
|
||||
.score-segment-value {
|
||||
color: #409eff;
|
||||
font-weight: bold;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user