This commit is contained in:
2025-12-14 17:38:35 +08:00
parent 8c56251d72
commit b7b8947939
16 changed files with 659 additions and 201 deletions

View File

@@ -107,6 +107,8 @@ export default {
},
judgeId: '',
projectId: '',
competitionId: '',
venueId: '',
currentScore: 8.000,
note: '',
minScore: 5.0,
@@ -137,10 +139,9 @@ export default {
// 加载评委ID和项目ID
this.judgeId = globalData.judgeId
const projects = globalData.projects || []
const currentIndex = globalData.currentProjectIndex || 0
const currentProject = projects[currentIndex] || {}
this.projectId = currentProject.projectId
this.projectId = globalData.currentProjectId || ''
this.competitionId = globalData.matchId || globalData.matchCode || ''
this.venueId = globalData.currentVenueId || globalData.venueId || ''
// 调试信息
if (config.debug) {
@@ -148,6 +149,8 @@ export default {
athlete: this.player,
judgeId: this.judgeId,
projectId: this.projectId,
competitionId: this.competitionId,
venueId: this.venueId,
initialScore: this.currentScore
})
}
@@ -166,9 +169,12 @@ export default {
projectId: this.projectId
})
// 为每个扣分项添加 checked 状态
this.deductions = (response.data || []).map(item => ({
...item,
// 为每个扣分项添加 checked 状态,并映射字段名
const records = response.data?.records || []
this.deductions = records.map(item => ({
deductionId: item.id,
deductionName: item.itemName,
deductionScore: parseFloat(item.deductionPoint || 0),
checked: false
}))
@@ -187,7 +193,20 @@ export default {
},
goBack() {
uni.navigateBack()
if (config.debug) {
console.log('返回上一页')
}
uni.navigateBack({
delta: 1,
fail: (err) => {
console.error('返回失败:', err)
// 如果返回失败,尝试跳转到评分列表页
uni.redirectTo({
url: '/pages/score-list/score-list'
})
}
})
},
decreaseScore() {
@@ -216,14 +235,27 @@ export default {
return
}
// 收集选中的扣分项
// 验证必需字段
if (!this.competitionId) {
uni.showToast({
title: '缺少比赛ID请重新登录',
icon: 'none'
})
return
}
if (!this.projectId) {
uni.showToast({
title: '缺少项目ID请返回重新选择',
icon: 'none'
})
return
}
// 收集选中的扣分项ID
const selectedDeductions = this.deductions
.filter(item => item.checked)
.map(item => ({
deductionId: item.deductionId,
deductionName: item.deductionName,
deductionScore: item.deductionScore
}))
.map(item => item.deductionId)
try {
uni.showLoading({
@@ -231,16 +263,27 @@ export default {
mask: true
})
// 🔥 关键改动:使用 dataAdapter 提交评分
// Mock模式调用 mock/score.js 的 submitScore 函数
// API模式调用 api/score.js 的 submitScore 函数POST /martial/score/submit
const response = await dataAdapter.getData('submitScore', {
// 准备提交数据
const submitData = {
athleteId: this.player.athleteId,
judgeId: this.judgeId,
projectId: this.projectId,
competitionId: this.competitionId,
venueId: this.venueId,
score: this.currentScore,
deductions: selectedDeductions,
note: this.note
})
}
// 调试日志:打印提交数据
if (config.debug) {
console.log('准备提交评分数据:', submitData)
}
// 🔥 关键改动:使用 dataAdapter 提交评分
// Mock模式调用 mock/score.js 的 submitScore 函数
// API模式调用 api/score.js 的 submitScore 函数POST /martial/score/submit
const response = await dataAdapter.getData('submitScore', submitData)
uni.hideLoading()
@@ -301,12 +344,19 @@ export default {
.nav-left {
position: absolute;
left: 30rpx;
width: 60rpx;
height: 60rpx;
left: 0;
top: 0;
width: 120rpx;
height: 90rpx;
display: flex;
align-items: center;
justify-content: center;
z-index: 10;
cursor: pointer;
}
.nav-left:active {
opacity: 0.6;
}
.back-icon {