| | |
| | | <!-- 右侧面板:评分表单 --> |
| | | <div class="right-panel"> |
| | | <RatingForm |
| | | v-if="detail.ratingForm" |
| | | :rating-form="detail.ratingForm" |
| | | v-if="ratingScheme" |
| | | :rating-form="ratingScheme" |
| | | :activity-player-id="detail.id" |
| | | :current-judge-name="currentJudgeInfo?.name" |
| | | :judge-ratings="judgeRatings" |
| | | :average-score="averageScore" |
| | | :existing-rating="currentJudgeRating" |
| | | @submit="handleRatingSubmit" |
| | | /> |
| | | <div v-else class="no-rating"> |
| | |
| | | import { ref, onMounted } from 'vue' |
| | | import { useRoute } from 'vue-router' |
| | | import { ElMessage, ElSkeleton, ElEmpty } from 'element-plus' |
| | | import { getActivityPlayerDetail, saveActivityPlayerRating } from '@/api/activityPlayer' |
| | | import { |
| | | getActivityPlayerDetail, |
| | | saveActivityPlayerRating, |
| | | getJudgeRatingsForPlayer, |
| | | getCurrentJudgeRating, |
| | | getAverageScoreForPlayer, |
| | | getCurrentJudgeInfo |
| | | } from '@/api/activityPlayer' |
| | | import PlayerInfoCard from '@/components/PlayerInfoCard.vue' |
| | | import SubmissionFiles from '@/components/SubmissionFiles.vue' |
| | | import RatingForm from '@/components/RatingForm.vue' |
| | |
| | | const route = useRoute() |
| | | const loading = ref(true) |
| | | const detail = ref(null) |
| | | const ratingScheme = ref(null) |
| | | const currentJudgeInfo = ref(null) |
| | | const judgeRatings = ref([]) |
| | | const currentJudgeRating = ref(null) |
| | | const averageScore = ref(0) |
| | | |
| | | const loadDetail = async () => { |
| | | try { |
| | | loading.value = true |
| | | const id = route.params.id |
| | | const response = await getActivityPlayerDetail(id) |
| | | const response = await getActivityPlayerDetail(route.params.id) |
| | | console.log('API响应:', response) |
| | | |
| | | // 检查响应数据结构 |
| | | if (!response) { |
| | | throw new Error('API响应数据为空') |
| | | } |
| | | |
| | | if (!response.activityPlayerDetail) { |
| | | throw new Error('未找到选手详情数据') |
| | | } |
| | | |
| | | detail.value = response.activityPlayerDetail |
| | | |
| | | // 使用从后端获取的真实评分模板数据 |
| | | if (detail.value.ratingForm) { |
| | | ratingScheme.value = { |
| | | schemeId: detail.value.ratingForm.schemeId, |
| | | schemeName: detail.value.ratingForm.schemeName, |
| | | items: detail.value.ratingForm.items || [], |
| | | totalMaxScore: detail.value.ratingForm.totalMaxScore || 0 |
| | | } |
| | | console.log('使用真实评分模板数据:', ratingScheme.value) |
| | | } else { |
| | | console.warn('未找到评分模板数据,使用默认模板') |
| | | // 如果没有评分模板数据,使用默认模板 |
| | | ratingScheme.value = { |
| | | schemeId: "1", |
| | | schemeName: "默认评分标准", |
| | | items: [ |
| | | { id: "1", name: "综合评分", maxScore: 100, orderNo: 1 } |
| | | ], |
| | | totalMaxScore: 100 |
| | | } |
| | | } |
| | | |
| | | // 获取当前评委信息 |
| | | try { |
| | | const judgeInfoResponse = await getCurrentJudgeInfo() |
| | | console.log('评委信息响应:', judgeInfoResponse) |
| | | if (judgeInfoResponse && judgeInfoResponse.currentJudgeInfo) { |
| | | currentJudgeInfo.value = judgeInfoResponse.currentJudgeInfo |
| | | } |
| | | } catch (error) { |
| | | console.error('加载报名详情失败:', error) |
| | | ElMessage.error('加载报名详情失败') |
| | | console.error('获取评委信息失败:', error) |
| | | } |
| | | |
| | | // 获取所有评委评分状态 |
| | | try { |
| | | const judgeRatingsResponse = await getJudgeRatingsForPlayer(route.params.id) |
| | | console.log('评委评分状态响应:', judgeRatingsResponse) |
| | | if (judgeRatingsResponse && judgeRatingsResponse.judgeRatingsForPlayer) { |
| | | judgeRatings.value = judgeRatingsResponse.judgeRatingsForPlayer |
| | | } |
| | | } catch (error) { |
| | | console.error('获取评委评分状态失败:', error) |
| | | } |
| | | |
| | | // 获取当前评委的评分 |
| | | try { |
| | | const currentRatingResponse = await getCurrentJudgeRating(route.params.id) |
| | | console.log('当前评委评分响应:', currentRatingResponse) |
| | | if (currentRatingResponse && currentRatingResponse.currentJudgeRating) { |
| | | currentJudgeRating.value = currentRatingResponse.currentJudgeRating |
| | | } |
| | | } catch (error) { |
| | | console.error('获取当前评委评分失败:', error) |
| | | } |
| | | |
| | | // 获取平均分 |
| | | try { |
| | | const averageScoreResponse = await getAverageScoreForPlayer(route.params.id) |
| | | console.log('平均分响应:', averageScoreResponse) |
| | | if (averageScoreResponse && averageScoreResponse.averageScoreForPlayer !== undefined) { |
| | | averageScore.value = averageScoreResponse.averageScoreForPlayer |
| | | } |
| | | } catch (error) { |
| | | console.error('获取平均分失败:', error) |
| | | } |
| | | } catch (error) { |
| | | console.error('加载详情失败:', error) |
| | | ElMessage.error('加载详情失败') |
| | | } finally { |
| | | loading.value = false |
| | | } |
| | |
| | | try { |
| | | console.log('评分提交:', ratingData) |
| | | |
| | | // 构造提交数据 |
| | | // 构造提交数据 - 将 scores 对象转换为 ratings 数组 |
| | | const ratings = Object.entries(ratingData.scores || {}).map(([itemId, score]) => ({ |
| | | itemId: parseInt(itemId), |
| | | score: score |
| | | })) |
| | | |
| | | const input = { |
| | | activityPlayerId: detail.value.id, |
| | | ratings: ratingData.ratings.map(item => ({ |
| | | itemId: item.itemId, |
| | | score: item.score |
| | | })), |
| | | ratings: ratings, |
| | | comment: ratingData.comment || '' |
| | | } |
| | | |
| | |
| | | |
| | | if (result.saveActivityPlayerRating) { |
| | | ElMessage.success('评分提交成功') |
| | | |
| | | // 重新加载数据以更新评分状态 |
| | | await loadDetail() |
| | | } else { |
| | | ElMessage.error('评分提交失败') |
| | | } |