This commit is contained in:
2025-12-14 17:39:19 +08:00
parent 0f3cfee622
commit 78291bb76b
12 changed files with 181 additions and 44 deletions

View File

@@ -126,6 +126,8 @@ export default {
organization: '',
phone: ''
},
competitionId: '',
projectIds: [],
errors: [],
showHint: false,
showToast: false,
@@ -133,6 +135,19 @@ export default {
showIdTypePicker: false
};
},
onLoad(options) {
// 接收赛事ID和项目ID
if (options.competitionId) {
this.competitionId = options.competitionId
}
if (options.projectIds) {
this.projectIds = options.projectIds.split(',').map(id => parseInt(id))
}
console.log('新增选手页面接收参数:', {
competitionId: this.competitionId,
projectIds: this.projectIds
})
},
computed: {
isFormValid() {
return (
@@ -252,7 +267,7 @@ export default {
const info = this.extractInfoFromIdCard(this.formData.idCard)
// 调用API保存选手信息使用后端实体类的字段名
await athleteAPI.submitAthlete({
const submitData = {
playerName: this.formData.name,
idCard: this.formData.idCard,
teamName: this.formData.team,
@@ -262,7 +277,19 @@ export default {
gender: info.gender,
age: info.age,
birthDate: info.birthDate
})
}
// 如果有赛事ID和项目ID一起提交
if (this.competitionId) {
submitData.competitionId = parseInt(this.competitionId)
}
if (this.projectIds && this.projectIds.length > 0) {
// 如果有多个项目取第一个项目ID
submitData.projectId = this.projectIds[0]
}
console.log('提交选手数据:', submitData)
await athleteAPI.submitAthlete(submitData)
// 保存成功
uni.showToast({
@@ -415,9 +442,9 @@ export default {
.btn {
width: 100%;
text-align: center;
padding: 30rpx;
padding: 24rpx;
border-radius: 12rpx;
font-size: 32rpx;
font-size: 30rpx;
font-weight: bold;
}