From 56565ded13dbfebf833798eb1a17841596350afc Mon Sep 17 00:00:00 2001 From: yujialong <479214531@qq.com> Date: Mon, 20 May 2024 10:44:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=A7=E8=B5=9B=E8=87=AA=E5=8A=A8=E5=88=86?= =?UTF-8?q?=E9=85=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/api.js | 3 ++- src/views/match/add/step1.vue | 22 +++++++++++++-- src/views/match/add/step2.vue | 29 +++++--------------- src/views/match/add/step3.vue | 51 +++++++++++++++++++++++++---------- 4 files changed, 65 insertions(+), 40 deletions(-) diff --git a/src/utils/api.js b/src/utils/api.js index 271b686..15e1a57 100644 --- a/src/utils/api.js +++ b/src/utils/api.js @@ -329,8 +329,9 @@ export default { getRedisCacheCompetition: `competition/competition/management/getRedisCache`, copyCompetition: `competition/competition/management/copyCompetition`, checkCustomerBySchool: `competition/competition/team/checkCustomerBySchool`, - automaticAllocationSave: `competition/competitionAutomaticAllocationRecord/updateEventAllocationRecord`, + updateEventAllocationRecord: `competition/competitionAutomaticAllocationRecord/updateEventAllocationRecord`, editWhetherPopUpsAppear: `competition/competitionAutomaticAllocationRecord/editWhetherPopUpsAppear`, + automaticAllocation: `competition/competition/automaticAllocation/automaticAllocation`, // 赛事内容 addCompetitionContent: `competition/competition/content/addCompetitionContent`, diff --git a/src/views/match/add/step1.vue b/src/views/match/add/step1.vue index 5966462..74f0d96 100644 --- a/src/views/match/add/step1.vue +++ b/src/views/match/add/step1.vue @@ -392,7 +392,8 @@ export default { }, submiting: false, updateTime: 0, - quillShow: true + quillShow: true, + originSignUpEndTime: '', }; }, components: { @@ -488,6 +489,7 @@ export default { }) this.rangeName = range.join(',') } + this.originSignUpEndTime = competition.signUpEndTime this.form = competition this.$parent.resumeData() this.$nextTick(() => { @@ -685,10 +687,11 @@ export default { form.releaseType = releaseType form.id = this.$route.query.id if (form.id) { - this.$post(this.api.editCompetition, form).then(res => { + this.$post(this.api.editCompetition, form).then(async () => { this.$parent.hideLoad() this.updateTime && util.successMsg("修改成功"); this.updateTime = 0 + await this.automaticAllocation() this.$emit('next', next) }).catch(err => { this.$parent.hideLoad() @@ -704,6 +707,21 @@ export default { }); } }, + // 保存自动分配人员条件 + async automaticAllocation () { + // 团队赛 + if (this.form.completeCompetitionSetup.competitionType) { + const { signUpEndTime, id } = this.form + + // 报名结束之后修改的报名结束时间晚于当前现实时间的话,就调接口 + if (signUpEndTime !== this.originSignUpEndTime && new Date(signUpEndTime) > Date.now()) { + await this.$post(this.api.updateEventAllocationRecord, { + competitionId: id, + whetherToModifyTheRule: 1, + }) + } + } + }, // 预览 preview () { util.local.set('match', this.form) diff --git a/src/views/match/add/step2.vue b/src/views/match/add/step2.vue index ff46428..d5251ee 100644 --- a/src/views/match/add/step2.vue +++ b/src/views/match/add/step2.vue @@ -381,7 +381,7 @@ export default { this.form.competitionStageList = stages.slice(0, val) } }, - // 自动分配人员 + // 保存自动分配人员条件 async automaticAllocation (next) { // 团队赛 if (this.step1.completeCompetitionSetup.competitionType) { @@ -397,28 +397,11 @@ export default { } } if (form.rule !== originForm.rule || form.stageNum !== originForm.stageNum || form.teamLimit !== originForm.teamLimit || changeLimit) { - const res = await this.$post(`${this.api.editWhetherPopUpsAppear}?competitionId=${this.id}`) - if (res.popupState) { - this.$confirm('报名的团队将按照新设置的规则进行自动分配阶段参赛人员,当前已分配的阶段参赛人员是否需要保留?', '提示', { - cancelButtonText: '已分配的保留', - confirmButtonText: '全部重新分配', - type: 'success', - closeOnClickModal: false, - }).then(() => { - // this.automaticAllocation(1, next) - }).catch(() => { - // this.automaticAllocation(0, next) - }); - - // await this.$post(this.api.automaticAllocationSave, { - // assignOrNot, - // competitionId: this.competitionId, - // whetherToModifyTheRule: whethwer, - // }) - this.$emit('next', next) - } else { - this.$emit('next', next) - } + await this.$post(this.api.updateEventAllocationRecord, { + competitionId: +this.id, + whetherToModifyTheRule: 1, + }) + this.$emit('next', next) } else { this.$emit('next', next) } diff --git a/src/views/match/add/step3.vue b/src/views/match/add/step3.vue index d74054f..1ac3df0 100644 --- a/src/views/match/add/step3.vue +++ b/src/views/match/add/step3.vue @@ -361,7 +361,7 @@ export default { }, // 自动分配人员 async automaticAllocation (assignOrNot, next) { - await this.$post(this.api.automaticAllocationSave, { + await this.$post(this.api.updateEventAllocationRecord, { assignOrNot, competitionId: this.competitionId, }) @@ -369,18 +369,40 @@ export default { }, // 自动分配人员弹框 async autoAllocationConfirm (next) { - // 新增 - this.$confirm('

团队赛已发布,是否要自动分配阶段人员?

(点击“是”将会给报名的团队自动分配阶段参赛人员

', '提示', { - confirmButtonText: '是', - cancelButtonText: '否', - type: 'success', - closeOnClickModal: false, - dangerouslyUseHTMLString: true, - }).then(() => { - this.automaticAllocation(1, next) - }).catch(() => { - this.automaticAllocation(0, next) - }); + if (this.form[0].contentId) { + // 编辑的时候查询是否需要弹框选择重新分配 + const res = await this.$post(`${this.api.editWhetherPopUpsAppear}?competitionId=${this.id}`) + if (res.popupState) { + this.$confirm('报名的团队将按照新设置的规则进行自动分配阶段参赛人员,当前已分配的阶段参赛人员是否需要保留?', '提示', { + cancelButtonText: '已分配的保留', + confirmButtonText: '全部重新分配', + type: 'success', + closeOnClickModal: false, + showClose: false, + }).then(async () => { + await this.$post(`${this.api.automaticAllocation}?competitionId=${this.id}`) + this.$emit('next', next) + }).catch(() => { + this.$emit('next', next) + // this.automaticAllocation(0, next) + }); + } else { + this.$emit('next', next) + } + } else { + // 新增 + this.$confirm('

团队赛已发布,是否要自动分配阶段人员?

(点击“是”将会在报名结束后给报名的团队自动分配阶段参赛人员

', '提示', { + confirmButtonText: '是', + cancelButtonText: '否', + type: 'success', + closeOnClickModal: false, + dangerouslyUseHTMLString: true, + }).then(() => { + this.automaticAllocation(1, next) + }).catch(() => { + this.automaticAllocation(0, next) + }); + } }, // 提交 save (status, next = 0) { @@ -477,7 +499,8 @@ export default { // 新增赛事,并且点的是发布按钮,则发布该赛事 status && this.publish(status) util.successMsg((status ? '发布' : '保存') + '成功') - if (this.$parent.$refs.step1.form.completeCompetitionSetup.competitionType && !form[0].contentId) { + this.updateTime = 0 + if (this.$parent.$refs.step1.form.completeCompetitionSetup.competitionType) { this.autoAllocationConfirm() // 团队并且第一次发布才需要弹框询问是否自动分配人员 } else { this.$emit('next', next)