裁判长修改分数功能优化

1. 限制裁判长修改分数范围为±0.050
2. 优化评委评分展示样式,添加灰色边框背景块

🤖 Generated with Claude Code

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
DevOps
2025-12-21 15:22:03 +08:00
parent bcf040bb15
commit 569f8a14d1

View File

@@ -18,7 +18,7 @@
<view class="player-name">{{ athleteInfo.name }}</view>
<view class="total-score-label">
<text class="label-text">总分</text>
<text class="score-value">{{ athleteInfo.totalScore }}</text>
<text class="score-value">{{ formatScore(athleteInfo.totalScore) }}</text>
</view>
</view>
<view class="player-details">
@@ -46,7 +46,7 @@
<!-- 修改总分区域 -->
<view class="modify-section">
<view class="modify-header">
<text class="modify-label">修改总分+-0.005</text>
<text class="modify-label">修改总分±0.050</text>
</view>
<view class="score-control">
@@ -65,10 +65,6 @@
<text class="btn-value">+0.001</text>
</view>
</view>
<!-- <view class="modify-tip">
裁判长修改保留3位小数点超过上限或下限时按钮置灰
</view> -->
</view>
<!-- 备注 -->
@@ -110,10 +106,10 @@ export default {
judgeScores: [],
modification: null,
modifierId: '',
currentScore: 8.000,
originalScore: 8.000,
currentScore: 0,
originalScore: 0,
note: '',
minScore: 5.0,
minScore: 0,
maxScore: 10.0
}
},
@@ -173,21 +169,51 @@ export default {
// 获取裁判长ID
this.modifierId = globalData.judgeId
// 🔥 关键修复:先用传递过来的选手数据初始化页面
this.athleteInfo = {
athleteId: currentAthlete.athleteId,
name: currentAthlete.name || '',
idCard: currentAthlete.idCard || '',
team: currentAthlete.team || '',
number: currentAthlete.number || '',
totalScore: currentAthlete.totalScore || 0
}
// 设置初始分数(使用传递过来的总分)
const totalScore = parseFloat(currentAthlete.totalScore) || 0
this.originalScore = totalScore
this.currentScore = totalScore
// 调试信息
if (config.debug) {
console.log('修改评分页加载:', {
currentAthlete: currentAthlete,
athleteId: currentAthlete.athleteId,
totalScore: totalScore,
modifierId: this.modifierId
})
}
// 加载选手评分详情
// 尝试加载选手评分详情(获取各评委的评分)
if (currentAthlete.athleteId) {
await this.loadScoreDetail(currentAthlete.athleteId)
}
},
methods: {
formatScore(score) {
if (score === null || score === undefined || score === -1 || score === '-1') {
return '--'
}
if (typeof score === 'string' && !isNaN(parseFloat(score))) {
return parseFloat(score).toFixed(3)
}
if (typeof score === 'number') {
return score.toFixed(3)
}
return score
},
async loadScoreDetail(athleteId) {
try {
uni.showLoading({
@@ -195,27 +221,35 @@ export default {
mask: true
})
// 🔥 关键改动:使用 dataAdapter 获取评分详情
// Mock模式调用 mock/score.js 的 getScoreDetail 函数
// API模式调用 api/score.js 的 getScoreDetail 函数GET /api/mini/score/detail/{athleteId}
const response = await dataAdapter.getData('getScoreDetail', {
athleteId: athleteId
})
uni.hideLoading()
// 保存选手信息和评分详情
this.athleteInfo = response.data.athleteInfo || {}
// 如果接口返回了数据,更新页面
if (response && response.data) {
// 更新评委评分列表
this.judgeScores = response.data.judgeScores || []
this.modification = response.data.modification || null
// 设置初始分数
this.originalScore = this.athleteInfo.totalScore || 8.000
this.currentScore = this.originalScore
// 如果接口返回了选手信息,更新(但保留传递过来的数据作为备用)
if (response.data.athleteInfo) {
const apiAthleteInfo = response.data.athleteInfo
this.athleteInfo = {
athleteId: apiAthleteInfo.athleteId || this.athleteInfo.athleteId,
name: apiAthleteInfo.name || this.athleteInfo.name,
idCard: apiAthleteInfo.idCard || this.athleteInfo.idCard,
team: apiAthleteInfo.team || this.athleteInfo.team,
number: apiAthleteInfo.number || this.athleteInfo.number,
totalScore: apiAthleteInfo.totalScore || this.athleteInfo.totalScore
}
// 如果之前已修改过,加载修改后的分数
if (this.modification && this.modification.modifiedScore) {
this.currentScore = this.modification.modifiedScore
// 更新分数
const totalScore = parseFloat(apiAthleteInfo.totalScore) || this.originalScore
this.originalScore = totalScore
this.currentScore = totalScore
}
}
// 调试信息
@@ -232,10 +266,10 @@ export default {
} catch (error) {
uni.hideLoading()
console.error('加载评分详情失败:', error)
uni.showToast({
title: error.message || '加载失败',
icon: 'none'
})
// 不显示错误提示,因为已经有传递过来的数据可以使用
if (config.debug) {
console.log('使用传递过来的选手数据')
}
}
},
@@ -244,22 +278,28 @@ export default {
},
decreaseScore() {
if (this.currentScore > this.minScore) {
// 限制最小值为原始分数-0.050
const minAllowed = parseFloat((this.originalScore - 0.050).toFixed(3))
if (this.currentScore > minAllowed) {
this.currentScore = parseFloat((this.currentScore - 0.001).toFixed(3))
}
},
increaseScore() {
if (this.currentScore < this.maxScore) {
// 限制最大值为原始分数+0.050
const maxAllowed = parseFloat((this.originalScore + 0.050).toFixed(3))
if (this.currentScore < maxAllowed) {
this.currentScore = parseFloat((this.currentScore + 0.001).toFixed(3))
}
},
async handleModify() {
// 验证评分范围
if (this.currentScore < this.minScore || this.currentScore > this.maxScore) {
// 验证评分范围±0.050
const minAllowed = parseFloat((this.originalScore - 0.050).toFixed(3))
const maxAllowed = parseFloat((this.originalScore + 0.050).toFixed(3))
if (this.currentScore < minAllowed || this.currentScore > maxAllowed) {
uni.showToast({
title: `评分必须在${this.minScore}-${this.maxScore}分之间`,
title: '评分只能在原始分数±0.050范围内',
icon: 'none'
})
return
@@ -280,13 +320,11 @@ export default {
mask: true
})
// 🔥 关键改动:使用 dataAdapter 修改评分
// Mock模式调用 mock/score.js 的 modifyScore 函数
// API模式调用 api/score.js 的 modifyScore 函数PUT /mini/score/modify
const response = await dataAdapter.getData('modifyScore', {
modifierId: this.modifierId,
athleteId: this.athleteInfo.athleteId,
newScore: this.currentScore,
reason: this.note
modifiedScore: this.currentScore,
note: this.note
})
uni.hideLoading()
@@ -463,15 +501,21 @@ export default {
}
.judge-score-item {
font-size: 26rpx;
color: #333333;
display: flex;
align-items: center;
padding: 12rpx 20rpx;
background-color: #F5F5F5;
border-radius: 8rpx;
border: 2rpx solid #E5E5E5;
}
.judge-name {
font-size: 24rpx;
color: #666666;
}
.judge-score {
font-size: 28rpx;
color: #333333;
font-weight: 500;
}