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

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
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})
const aa = resp.data.filter((v) => {
return this.rightApplyUserList.includes(v.userId)
})
const groupData = groupBy(aa, (v) => {
return v.userId
})
// 未配置限报数时不限制单项报名,避免 null 被 JavaScript 当作 0 比较。
const hasSingleEventLimit = this.activityTableData.eveProjectType === '1' &&
Number.isInteger(this.eventData.restrictRegNumber) && this.eventData.restrictRegNumber >= 0
const cc = hasSingleEventLimit ? groupData.filter((v) => {
return v.length >= this.eventData.restrictRegNumber
}) : []
this.$axios.post(loc() + "/getActivityData", {activityId: this.activityData.id}).then((resp) => {
const aa = resp.data.filter((v) => {
return this.rightApplyUserList.includes(v.userId)
})
const groupData = groupBy(aa, (v) => {
return v.userId
})
// 每人限报项目数只在综合赛单项中配置;个人赛不能使用隐藏的历史限报值。
const hasSingleEventLimit = this.activityTableData.applyType === 2 &&
this.activityTableData.eveProjectType === '1' &&
Number.isInteger(this.eventData.restrictRegNumber) && this.eventData.restrictRegNumber >= 0
const cc = hasSingleEventLimit ? groupData.filter((v) => {
return v.length >= this.eventData.restrictRegNumber
}) : []
//从全部人员里找出右边框选择的人
const arr = this.userList.filter((v) => {
return this.rightApplyUserList.includes(v.id)
})
//表格的人员
arr.forEach((v) => {
this.applyFromData.teamName=this.teamList.find(t=>t.id===this.applyFromData.teamId)?.name
const data = {
id: null,
loginname: v.loginname,
username: v.username,
age: v.age,
professionalLevel: v.professionalLevel,
birthday: v.birthday,
unitId: v.unitId,
unionId: v.unionId,
unitname: v.unitname,
userId: v.id,
mobile: v.mobile,
sex: v.sex,
awardsMode: this.activityTableData.eveProjectType,
activityId: this.activityData.id,
teamId: this.applyFromData.teamId,
team: this.applyFromData.teamName,
identity: ["1"],
eventId: this.eventData.eventId
}
//然后把每一个人加到全部报名的字段中
this.applyUserList.push(data)
//从全部人员里找出右边框选择的人
const arr = this.userList.filter((v) => {
return this.rightApplyUserList.includes(v.id)
})
//表格的人员
arr.forEach((v) => {
this.applyFromData.teamName=this.teamList.find(t=>t.id===this.applyFromData.teamId)?.name
const data = {
id: null,
loginname: v.loginname,
username: v.username,
age: v.age,
professionalLevel: v.professionalLevel,
birthday: v.birthday,
unitId: v.unitId,
unionId: v.unionId,
unitname: v.unitname,
userId: v.id,
mobile: v.mobile,
sex: v.sex,
awardsMode: this.activityTableData.eveProjectType,
activityId: this.activityData.id,
teamId: this.applyFromData.teamId,
team: this.applyFromData.teamName,
identity: ["1"],
eventId: this.eventData.eventId
}
//然后把每一个人加到全部报名的字段中
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) {
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)
}
}
})
const usernames = cc.map((v) => v[0].username).join(",")
if (usernames) {
this.$notify({
title: "警告",
message: usernames + "已报" + this.eventData.restrictRegNumber + "项",
type: "warning"
})
}
}
})
//如果是单项判断每个人可以报几项
if (hasSingleEventLimit) {
const usernames = cc.map((v) => v[0].username).join(",")
if (usernames) {
this.$notify({
title: "警告",
message: usernames + "已报" + this.eventData.restrictRegNumber + "项",
type: "warning"
})
}
}
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.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()
})
this.rightApplyUserList = []
this.sortApplyUserTableData()
},
//勾选左边的框设置角色
setUserRole(num) {