d41baa03 by zhangmeng

赛事报名限制

1 parent 852a632e
...@@ -759,71 +759,55 @@ function switchTabletype() { ...@@ -759,71 +759,55 @@ function switchTabletype() {
759 } 759 }
760 } 760 }
761 761
762 let hasPproperty = ''
763 let hasPlevel = ''
764 let hasMtype = ''
765 let hasAlmighty = {}
766 let hasPpropertyLength = 0
767 let isDanNum = 0 762 let isDanNum = 0
768 let isShuangNum = 0 763 let isShuangNum = 0
769 watch(projectIds, (newVal, oldVal) => { 764 watch(projectIds, (newVal, oldVal) => {
770 let currProject = {}
771 if (newVal.length > oldVal.length) { 765 if (newVal.length > oldVal.length) {
772 currProjectId.value = _.last(newVal) 766 currProjectId.value = _.last(newVal)
773 } else { 767 } else {
774 currProjectId.value = '' 768 currProjectId.value = ''
775 } 769 }
776 for (const p of projectList.value) {
777 if (p.id == _.last(newVal)) {
778 currProject = p
779 }
780 }
781 if (newVal.length > 0) { 770 if (newVal.length > 0) {
782 hasPproperty = ''
783 hasPlevel = ''
784 hasMtype = ''
785 hasAlmighty = {}
786 isDanNum = 0 771 isDanNum = 0
787 isShuangNum = 0 772 isShuangNum = 0
788 hasPpropertyLength = 0
789 for (const hh of projectList.value) { 773 for (const hh of projectList.value) {
790 if (projectIds.value.indexOf(hh.id) > -1 && hh.pproperty) { 774 if (!projectIds.value.includes(hh.id)) {
791 hasPproperty = hh.pproperty 775 continue
792 hasPpropertyLength = hh.danceTypeDetailStr.split(',').length
793 hasMtype = hh.mtype
794 }
795 if (projectIds.value.indexOf(hh.id) > -1 && hh.plevel) {
796 hasPlevel = hh.plevel
797 } 776 }
798 if (projectIds.value.indexOf(hh.id) > -1 && hh.almightyFlag == '1') { 777 if (hh.singleFlag == '1') {
799 hasAlmighty = hh
800 }
801 if (projectIds.value.indexOf(hh.id) > -1 && hh.singleFlag == '1') {
802 isDanNum += 1 778 isDanNum += 1
803 } 779 }
804 if (projectIds.value.indexOf(hh.id) > -1 && hh.doubleSingleProjectFlag == '1') { 780 if (hh.doubleSingleProjectFlag == '1') {
805 isShuangNum += 1 781 isShuangNum += 1
806 } 782 }
807 } 783 }
808 console.log(hasPproperty, hasPlevel, hasPpropertyLength) 784 filterProjectList()
809 filterProjectList(currProject)
810 } else { 785 } else {
811 resetProjectList() 786 resetProjectList()
812 } 787 }
813 }) 788 })
814 789
790 function getSelectedProjects() {
791 return projectList.value.filter(p => projectIds.value.includes(p.id))
792 }
793
794 function isSameMtype(a, b) {
795 return a.mtype === b.mtype
796 }
797
815 function hasDanceCountConflict(pp) { 798 function hasDanceCountConflict(pp) {
816 if (!pp.pproperty || !pp.danceTypeDetailStr) { 799 if (!pp.pproperty || !pp.danceTypeDetailStr) {
817 return false 800 return false
818 } 801 }
819 const ppDanceCount = pp.danceTypeDetailStr.split(',').length 802 const ppDanceCount = pp.danceTypeDetailStr.split(',').length
820 const selectedProjects = projectList.value.filter(p => projectIds.value.includes(p.id) && p.pproperty) 803 return getSelectedProjects().some(selected => {
821 return selectedProjects.some(selected => { 804 if (!selected.pproperty || !selected.danceTypeDetailStr) {
822 if (selected.pproperty !== pp.pproperty) { 805 return false
806 }
807 if (!isSameMtype(selected, pp)) {
823 return false 808 return false
824 } 809 }
825 // 名次赛与等级赛不互斥,仅同类型项目限制三支/四支舞兼报 810 if (selected.pproperty !== pp.pproperty) {
826 if (selected.mtype !== pp.mtype) {
827 return false 811 return false
828 } 812 }
829 const selectedDanceCount = selected.danceTypeDetailStr.split(',').length 813 const selectedDanceCount = selected.danceTypeDetailStr.split(',').length
...@@ -835,35 +819,68 @@ function hasPpropertyConflict(pp) { ...@@ -835,35 +819,68 @@ function hasPpropertyConflict(pp) {
835 if (!pp.pproperty) { 819 if (!pp.pproperty) {
836 return false 820 return false
837 } 821 }
838 const selectedProjects = projectList.value.filter(p => projectIds.value.includes(p.id) && p.pproperty) 822 return getSelectedProjects().some(selected => {
839 return selectedProjects.some(selected => { 823 if (!selected.pproperty) {
840 // 名次赛与等级赛不互斥,ABC 属性仅在同一赛事类型内互斥 824 return false
841 if (selected.mtype !== pp.mtype) { 825 }
826 if (!isSameMtype(selected, pp)) {
842 return false 827 return false
843 } 828 }
844 return selected.pproperty !== pp.pproperty 829 return selected.pproperty !== pp.pproperty
845 }) 830 })
846 } 831 }
847 832
848 function filterProjectList(currProject) { 833 function hasPlevelConflict(pp) {
834 if (!pp.plevel) {
835 return false
836 }
837 return getSelectedProjects().some(selected => {
838 if (!selected.plevel) {
839 return false
840 }
841 if (!isSameMtype(selected, pp)) {
842 return false
843 }
844 return selected.plevel !== pp.plevel
845 })
846 }
847
848 function hasAlmightyDanceCountConflict(pp) {
849 if (pp.almightyFlag !== '1' || !pp.danceTypeDetailStr) {
850 return false
851 }
852 const ppDanceCount = pp.danceTypeDetailStr.split(',').length
853 return getSelectedProjects().some(selected => {
854 if (selected.almightyFlag !== '1' || !selected.danceTypeDetailStr) {
855 return false
856 }
857 if (!isSameMtype(selected, pp)) {
858 return false
859 }
860 return selected.danceTypeDetailStr.split(',').length !== ppDanceCount
861 })
862 }
863
864 function hasSingleEntryLimitReached(pp) {
865 return isDanNum == Number(singlePersonEntryLimit.value) &&
866 pp.singleFlag == '1' &&
867 !projectIds.value.includes(pp.id)
868 }
869
870 function hasDoubleSingleEntryLimitReached(pp) {
871 return isShuangNum == Number(doublePersonEntryLimit.value) &&
872 pp.doubleSingleProjectFlag == '1' &&
873 !projectIds.value.includes(pp.id)
874 }
875
876 function filterProjectList() {
849 for (const pp of projectList.value) { 877 for (const pp of projectList.value) {
850 if ( 878 pp.disabled = hasDanceCountConflict(pp) ||
851 hasDanceCountConflict(pp) ||
852 hasPpropertyConflict(pp) || 879 hasPpropertyConflict(pp) ||
853 (hasPlevel && pp.plevel && pp.plevel != hasPlevel) || 880 hasPlevelConflict(pp) ||
854 (isDanNum == Number(singlePersonEntryLimit.value) && pp.singleFlag == '1' && projectIds.value.indexOf(pp.id) == -1) || 881 hasAlmightyDanceCountConflict(pp) ||
855 (isShuangNum == Number(doublePersonEntryLimit.value) && pp.doubleSingleProjectFlag == '1' && projectIds.value.indexOf(pp.id) == -1) 882 hasSingleEntryLimitReached(pp) ||
856 ) { 883 hasDoubleSingleEntryLimitReached(pp)
857 console.log(pp.name)
858 pp.disabled = true
859 } else if ((hasAlmighty.almightyFlag == '1' && pp.almightyFlag == '1') &&
860 (hasAlmighty.danceTypeDetailStr.split(',').length != pp.danceTypeDetailStr.split(',').length)
861 ) {
862 console.log(pp.name)
863 pp.disabled = true
864 } else {
865 pp.disabled = false
866 }
867 } 884 }
868 } 885 }
869 886
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!