d41baa03 by zhangmeng

赛事报名限制

1 parent 852a632e
......@@ -759,71 +759,55 @@ function switchTabletype() {
}
}
let hasPproperty = ''
let hasPlevel = ''
let hasMtype = ''
let hasAlmighty = {}
let hasPpropertyLength = 0
let isDanNum = 0
let isShuangNum = 0
watch(projectIds, (newVal, oldVal) => {
let currProject = {}
if (newVal.length > oldVal.length) {
currProjectId.value = _.last(newVal)
} else {
currProjectId.value = ''
}
for (const p of projectList.value) {
if (p.id == _.last(newVal)) {
currProject = p
}
}
if (newVal.length > 0) {
hasPproperty = ''
hasPlevel = ''
hasMtype = ''
hasAlmighty = {}
isDanNum = 0
isShuangNum = 0
hasPpropertyLength = 0
for (const hh of projectList.value) {
if (projectIds.value.indexOf(hh.id) > -1 && hh.pproperty) {
hasPproperty = hh.pproperty
hasPpropertyLength = hh.danceTypeDetailStr.split(',').length
hasMtype = hh.mtype
}
if (projectIds.value.indexOf(hh.id) > -1 && hh.plevel) {
hasPlevel = hh.plevel
if (!projectIds.value.includes(hh.id)) {
continue
}
if (projectIds.value.indexOf(hh.id) > -1 && hh.almightyFlag == '1') {
hasAlmighty = hh
}
if (projectIds.value.indexOf(hh.id) > -1 && hh.singleFlag == '1') {
if (hh.singleFlag == '1') {
isDanNum += 1
}
if (projectIds.value.indexOf(hh.id) > -1 && hh.doubleSingleProjectFlag == '1') {
if (hh.doubleSingleProjectFlag == '1') {
isShuangNum += 1
}
}
console.log(hasPproperty, hasPlevel, hasPpropertyLength)
filterProjectList(currProject)
filterProjectList()
} else {
resetProjectList()
}
})
function getSelectedProjects() {
return projectList.value.filter(p => projectIds.value.includes(p.id))
}
function isSameMtype(a, b) {
return a.mtype === b.mtype
}
function hasDanceCountConflict(pp) {
if (!pp.pproperty || !pp.danceTypeDetailStr) {
return false
}
const ppDanceCount = pp.danceTypeDetailStr.split(',').length
const selectedProjects = projectList.value.filter(p => projectIds.value.includes(p.id) && p.pproperty)
return selectedProjects.some(selected => {
if (selected.pproperty !== pp.pproperty) {
return getSelectedProjects().some(selected => {
if (!selected.pproperty || !selected.danceTypeDetailStr) {
return false
}
if (!isSameMtype(selected, pp)) {
return false
}
// 名次赛与等级赛不互斥,仅同类型项目限制三支/四支舞兼报
if (selected.mtype !== pp.mtype) {
if (selected.pproperty !== pp.pproperty) {
return false
}
const selectedDanceCount = selected.danceTypeDetailStr.split(',').length
......@@ -835,35 +819,68 @@ function hasPpropertyConflict(pp) {
if (!pp.pproperty) {
return false
}
const selectedProjects = projectList.value.filter(p => projectIds.value.includes(p.id) && p.pproperty)
return selectedProjects.some(selected => {
// 名次赛与等级赛不互斥,ABC 属性仅在同一赛事类型内互斥
if (selected.mtype !== pp.mtype) {
return getSelectedProjects().some(selected => {
if (!selected.pproperty) {
return false
}
if (!isSameMtype(selected, pp)) {
return false
}
return selected.pproperty !== pp.pproperty
})
}
function filterProjectList(currProject) {
function hasPlevelConflict(pp) {
if (!pp.plevel) {
return false
}
return getSelectedProjects().some(selected => {
if (!selected.plevel) {
return false
}
if (!isSameMtype(selected, pp)) {
return false
}
return selected.plevel !== pp.plevel
})
}
function hasAlmightyDanceCountConflict(pp) {
if (pp.almightyFlag !== '1' || !pp.danceTypeDetailStr) {
return false
}
const ppDanceCount = pp.danceTypeDetailStr.split(',').length
return getSelectedProjects().some(selected => {
if (selected.almightyFlag !== '1' || !selected.danceTypeDetailStr) {
return false
}
if (!isSameMtype(selected, pp)) {
return false
}
return selected.danceTypeDetailStr.split(',').length !== ppDanceCount
})
}
function hasSingleEntryLimitReached(pp) {
return isDanNum == Number(singlePersonEntryLimit.value) &&
pp.singleFlag == '1' &&
!projectIds.value.includes(pp.id)
}
function hasDoubleSingleEntryLimitReached(pp) {
return isShuangNum == Number(doublePersonEntryLimit.value) &&
pp.doubleSingleProjectFlag == '1' &&
!projectIds.value.includes(pp.id)
}
function filterProjectList() {
for (const pp of projectList.value) {
if (
hasDanceCountConflict(pp) ||
pp.disabled = hasDanceCountConflict(pp) ||
hasPpropertyConflict(pp) ||
(hasPlevel && pp.plevel && pp.plevel != hasPlevel) ||
(isDanNum == Number(singlePersonEntryLimit.value) && pp.singleFlag == '1' && projectIds.value.indexOf(pp.id) == -1) ||
(isShuangNum == Number(doublePersonEntryLimit.value) && pp.doubleSingleProjectFlag == '1' && projectIds.value.indexOf(pp.id) == -1)
) {
console.log(pp.name)
pp.disabled = true
} else if ((hasAlmighty.almightyFlag == '1' && pp.almightyFlag == '1') &&
(hasAlmighty.danceTypeDetailStr.split(',').length != pp.danceTypeDetailStr.split(',').length)
) {
console.log(pp.name)
pp.disabled = true
} else {
pp.disabled = false
}
hasPlevelConflict(pp) ||
hasAlmightyDanceCountConflict(pp) ||
hasSingleEntryLimitReached(pp) ||
hasDoubleSingleEntryLimitReached(pp)
}
}
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!