From 13d0e57d9a2da2177a73481731bc014c697faafa Mon Sep 17 00:00:00 2001 From: wangchenguang <728837162@qq.com> Date: Tue, 25 Apr 2023 20:17:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/match/add/index.vue | 34 +++++++++++++++++++++++++++++--- src/pages/match/add/step1.vue | 6 +++--- src/pages/match/add/step2.vue | 6 +++--- src/pages/match/add/step3.vue | 4 ++-- src/pages/match/manage/index.vue | 14 +++++++++++++ src/pages/project/list/index.vue | 1 + 6 files changed, 54 insertions(+), 11 deletions(-) diff --git a/src/pages/match/add/index.vue b/src/pages/match/add/index.vue index f9e3f12..0a09664 100644 --- a/src/pages/match/add/index.vue +++ b/src/pages/match/add/index.vue @@ -106,6 +106,21 @@ export default { step3, step4 }, + // 离开的时候判断是否有保存更改的信息,没有则拦截并提示 + beforeRouteLeave(to, from, next) { + const { updateTime } = this.$refs['step' + this.step] + if(updateTime){ + this.$confirm(`您所更改的内容未更新,是否更新?`, '提示', { + type: 'warning' + }).then(() => { + this.save(this.step,to.path,next) + }).catch(() => { + next() + }) + }else{ + next() + } + }, mounted() { this.getPer() }, @@ -134,8 +149,11 @@ export default { this.loadIns.close() }, // 提交 - save(status, next = 0) { - this.$refs['step' + this.step].save(status, next, this.releaseType) + save(status, next = 0,cb) { + console.log('status=>',status) + console.log('cb=>',cb) + console.log('this.step=>',this.step) + this.$refs['step' + this.step].save(status, next, this.releaseType,cb) }, // 上一步 prev() { @@ -154,7 +172,10 @@ export default { } }, // 发布后的逻辑 - next(next, setupId, competitionId) { + next(next, setupId, competitionId,type) { + console.log('next==>',next) + console.log('setupId==>',setupId) + console.log('competitionId==>',competitionId) if (!next) { this.$router.push(`/match?page=${this.$store.state.matchPage}`) } else if (next === 2) { @@ -167,6 +188,13 @@ export default { this.step++ } else if (next === 1) { this.step-- + } else { + console.log(99999999) + if(typeof setupId === 'function') { + setupId() + }else if(typeof type === 'function') { + type() + } } }, // 点击步骤条跳转 diff --git a/src/pages/match/add/step1.vue b/src/pages/match/add/step1.vue index 055ca86..a65f859 100644 --- a/src/pages/match/add/step1.vue +++ b/src/pages/match/add/step1.vue @@ -589,7 +589,7 @@ export default { * next 0:返回,1:不做任何操作,2:下一步 * releaseType 发布类型(0发布信息,1完整比赛) * */ - save(status, next = 0, releaseType = 0) { + save(status, next = 0, releaseType = 0,cb) { const { form } = this form.sponsor = this.sponsorList.filter(d => d).join(); form.undertaker = this.undertakerList.filter(d => d).join(); @@ -633,7 +633,7 @@ export default { this.updateTime = 0 this.$parent.hideLoad() util.successMsg("修改成功"); - this.$emit('next', next) + this.$emit('next', next,cb) }).catch(err => { this.$parent.hideLoad() }); @@ -642,7 +642,7 @@ export default { this.updateTime = 0 this.$parent.hideLoad() util.successMsg("创建成功"); - this.$emit('next', next, setupId, competitionId) + this.$emit('next', next, setupId, competitionId,cb) }).catch(err => { this.$parent.hideLoad() }); diff --git a/src/pages/match/add/step2.vue b/src/pages/match/add/step2.vue index aa0511a..e3fb959 100644 --- a/src/pages/match/add/step2.vue +++ b/src/pages/match/add/step2.vue @@ -295,7 +295,7 @@ export default { } }, // 提交 - save(status, next = 0) { + save(status, next = 0,releaseType,cb) { let { form } = this const { rule } = form let invalid = 0 @@ -396,7 +396,7 @@ export default { this.$post(this.api.editCompetitionRule, form).then(res => { this.$parent.hideLoad() util.successMsg("修改成功"); - this.$emit('next', next) + this.$emit('next', next,cb) }).catch(err => { this.$parent.hideLoad() }) @@ -405,7 +405,7 @@ export default { this.$post(this.api.addCompetitionRule, form).then(res => { this.$parent.hideLoad() util.successMsg("创建成功"); - this.$emit('next', next) + this.$emit('next', next,cb) }).catch(err => { this.$parent.hideLoad() }) diff --git a/src/pages/match/add/step3.vue b/src/pages/match/add/step3.vue index 7d6824b..ba73ef6 100644 --- a/src/pages/match/add/step3.vue +++ b/src/pages/match/add/step3.vue @@ -201,7 +201,7 @@ export default { this.competitionId && this.$post(`${this.api.publishCompetition}?competitionId=${this.competitionId}&publishStatus=1`).then(res => {}).catch(err => {}) }, // 提交 - save(status, next = 0) { + save(status, next = 0,releaseType,cb) { const { form } = this if (!form.length) { this.$parent.hideLoad() @@ -280,7 +280,7 @@ export default { // 新增赛事,并且点的是发布按钮,则发布该赛事 status && this.publish(status) util.successMsg((status ? '发布' : '保存') + '成功') - this.$emit('next', next) + this.$emit('next', next,cb) }).catch(err => { this.$parent.hideLoad() }) diff --git a/src/pages/match/manage/index.vue b/src/pages/match/manage/index.vue index 006ce81..25e1649 100644 --- a/src/pages/match/manage/index.vue +++ b/src/pages/match/manage/index.vue @@ -61,6 +61,20 @@ export default { mounted() { Setting.dynamicRoute && this.initTabs() }, + beforeRouteLeave(to, from, next) { + const detail = this.$refs.detail + if (detail.step < 4 && detail.$refs['step' + detail.step].updateTime) { + this.$confirm(`编辑的内容未保存,是否保存并且发布?`, '提示.......', { + type: 'warning' + }).then(() => { + detail.save(1,to.path,next) + }).catch(() => { + next() + }) + } else { + next() + } + }, methods: { initTabs() { const { btns } = this diff --git a/src/pages/project/list/index.vue b/src/pages/project/list/index.vue index 1b25140..a6e3e20 100644 --- a/src/pages/project/list/index.vue +++ b/src/pages/project/list/index.vue @@ -254,6 +254,7 @@ export default { }, mounted() { this.getSystemData() + this.getData() if(this.queryDataStatus.platformId) { this.queryData = this.queryDataStatus }