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