修复个人只能报两项的限制

This commit is contained in:
2026-10-14 16:38:38 +08:00
parent 3e152181ea
commit e784b5d4a8
@@ -635,7 +635,7 @@ var ACTIVITY_SPORTS_APPLY_USER = {
} }
}, },
//点击添加运动员操作 //点击添加运动员操作
async applyUser() { applyUser() {
const {isManGirlNum, restrictGirlNum, restrictBoyNum} = this.eventData const {isManGirlNum, restrictGirlNum, restrictBoyNum} = this.eventData
if (!this.rightApplyUserList.length) { if (!this.rightApplyUserList.length) {
@@ -696,83 +696,85 @@ var ACTIVITY_SPORTS_APPLY_USER = {
} }
} }
const resp = await this.$axios.post(loc() + "/getActivityData", {activityId: this.activityData.id}) this.$axios.post(loc() + "/getActivityData", {activityId: this.activityData.id}).then((resp) => {
const aa = resp.data.filter((v) => { const aa = resp.data.filter((v) => {
return this.rightApplyUserList.includes(v.userId) return this.rightApplyUserList.includes(v.userId)
}) })
const groupData = groupBy(aa, (v) => { const groupData = groupBy(aa, (v) => {
return v.userId return v.userId
}) })
// 未配置限报数时不限制单项报名,避免 null 被 JavaScript 当作 0 比较。 // 每人限报项目数只在综合赛单项中配置;个人赛不能使用隐藏的历史限报值。
const hasSingleEventLimit = this.activityTableData.eveProjectType === '1' && const hasSingleEventLimit = this.activityTableData.applyType === 2 &&
Number.isInteger(this.eventData.restrictRegNumber) && this.eventData.restrictRegNumber >= 0 this.activityTableData.eveProjectType === '1' &&
const cc = hasSingleEventLimit ? groupData.filter((v) => { Number.isInteger(this.eventData.restrictRegNumber) && this.eventData.restrictRegNumber >= 0
return v.length >= this.eventData.restrictRegNumber const cc = hasSingleEventLimit ? groupData.filter((v) => {
}) : [] return v.length >= this.eventData.restrictRegNumber
}) : []
//从全部人员里找出右边框选择的人 //从全部人员里找出右边框选择的人
const arr = this.userList.filter((v) => { const arr = this.userList.filter((v) => {
return this.rightApplyUserList.includes(v.id) return this.rightApplyUserList.includes(v.id)
}) })
//表格的人员 //表格的人员
arr.forEach((v) => { arr.forEach((v) => {
this.applyFromData.teamName=this.teamList.find(t=>t.id===this.applyFromData.teamId)?.name this.applyFromData.teamName=this.teamList.find(t=>t.id===this.applyFromData.teamId)?.name
const data = { const data = {
id: null, id: null,
loginname: v.loginname, loginname: v.loginname,
username: v.username, username: v.username,
age: v.age, age: v.age,
professionalLevel: v.professionalLevel, professionalLevel: v.professionalLevel,
birthday: v.birthday, birthday: v.birthday,
unitId: v.unitId, unitId: v.unitId,
unionId: v.unionId, unionId: v.unionId,
unitname: v.unitname, unitname: v.unitname,
userId: v.id, userId: v.id,
mobile: v.mobile, mobile: v.mobile,
sex: v.sex, sex: v.sex,
awardsMode: this.activityTableData.eveProjectType, awardsMode: this.activityTableData.eveProjectType,
activityId: this.activityData.id, activityId: this.activityData.id,
teamId: this.applyFromData.teamId, teamId: this.applyFromData.teamId,
team: this.applyFromData.teamName, team: this.applyFromData.teamName,
identity: ["1"], identity: ["1"],
eventId: this.eventData.eventId eventId: this.eventData.eventId
} }
//然后把每一个人加到全部报名的字段中 //然后把每一个人加到全部报名的字段中
this.applyUserList.push(data) this.applyUserList.push(data)
//如果是单项判断每个人可以报几项
if (hasSingleEventLimit) {
cc.forEach((z) => {
if (z[0]) {
const index = this.applyUserList.findIndex((x) => x.userId === z[0].userId && x.id === null)
if (index > -1) {
this.applyUserList.splice(index, 1)
}
}
})
}
})
//如果是单项判断每个人可以报几项 //如果是单项判断每个人可以报几项
if (hasSingleEventLimit) { if (hasSingleEventLimit) {
cc.forEach((z) => { const usernames = cc.map((v) => v[0].username).join(",")
if (z[0]) { if (usernames) {
const index = this.applyUserList.findIndex((x) => x.userId === z[0].userId && x.id === null) this.$notify({
if (index > -1) { title: "警告",
this.applyUserList.splice(index, 1) message: usernames + "已报" + this.eventData.restrictRegNumber + "项",
} type: "warning"
} })
}) }
} }
})
//如果是单项判断每个人可以报几项 this.flushApplyUser(this.applyUserList)
if (hasSingleEventLimit) { this.$refs.transfer.clearQuery("right")
const usernames = cc.map((v) => v[0].username).join(",") this.$refs.transfer.clearQuery("left")
if (usernames) { this.leftApplyUserList = this.leftApplyUserList.filter((v) => {
this.$notify({ return !this.applyUserTableData.map((v) => v.userId).includes(v.id)
title: "警告", })
message: usernames + "已报" + this.eventData.restrictRegNumber + "项", this.rightApplyUserList = []
type: "warning" this.sortApplyUserTableData()
})
}
}
this.flushApplyUser(this.applyUserList)
this.$refs.transfer.clearQuery("right")
this.$refs.transfer.clearQuery("left")
this.leftApplyUserList = this.leftApplyUserList.filter((v) => {
return !this.applyUserTableData.map((v) => v.userId).includes(v.id)
}) })
this.rightApplyUserList = []
this.sortApplyUserTableData()
}, },
//勾选左边的框设置角色 //勾选左边的框设置角色
setUserRole(num) { setUserRole(num) {