From e84f049fe7684ff5331a2d09372b25d78bd976ce Mon Sep 17 00:00:00 2001 From: yujialong <479214531@qq.com> Date: Thu, 2 Dec 2021 15:14:35 +0800 Subject: [PATCH] 12.2 --- src/pages/achievement/show/index.vue | 2 +- src/pages/achievement/teach/index.vue | 7 +- src/pages/match/manage/index.vue | 30 +++- src/pages/match/manage/matchProgress.vue | 175 ++++++++++++++++++----- src/store/modules/match.js | 4 + 5 files changed, 172 insertions(+), 46 deletions(-) diff --git a/src/pages/achievement/show/index.vue b/src/pages/achievement/show/index.vue index ae1cc18..933b8d0 100644 --- a/src/pages/achievement/show/index.vue +++ b/src/pages/achievement/show/index.vue @@ -166,7 +166,7 @@ export default { getData() { if (this.type) { let data = { - recordId: this.id + reportId: this.reportId }; this.$get(this.api.experimentOverview, data).then(res => { this.form = res.report; diff --git a/src/pages/achievement/teach/index.vue b/src/pages/achievement/teach/index.vue index 254da68..ee8cec7 100644 --- a/src/pages/achievement/teach/index.vue +++ b/src/pages/achievement/teach/index.vue @@ -114,8 +114,6 @@ export default { }, created() { this.classList = JSON.parse(this.$route.query.classList); - - // console.log(this.classList); const activeName = sessionStorage.getItem('activeName') if(activeName) { this.classId = activeName @@ -147,8 +145,9 @@ export default { }, show(row) { // 查看成绩报告 if (this.permissions) { - // row.recordId row.studentId - this.$router.push(`show?id=${row.recordId}&projectId=${row.projectId}&reportId=${row.reportId}&studentId=${row.studentId}`); + // row.recordId row.studentId ??? + // this.$router.push(`show?id=${row.recordId}&projectId=${row.projectId}&reportId=${row.reportId}&studentId=${row.studentId}`); + this.$router.push(`show?reportId=${row.reportId}`); } else { this.$router.push(`show?id=${row.recordId}&type=1`); } diff --git a/src/pages/match/manage/index.vue b/src/pages/match/manage/index.vue index 723c63c..8a1f7ff 100644 --- a/src/pages/match/manage/index.vue +++ b/src/pages/match/manage/index.vue @@ -8,7 +8,7 @@
- {{ item }} + {{ item }}
@@ -51,7 +51,33 @@ export default { this.$router.back(); }, tabChange(index) { - this.active = index; + console.log('changewait?') + console.log(this.wait) + // this.active = index; + if(!this.wait) { + this.active = index; + }else { + sessionStorage.setItem('tabIndex', index) + } + }, + tabChangeWait() { + tabChange(sessionStorage.setItem('tabIndex', index)) + }, + beforeLeave(newTab, oldTab) { + console.log(newTab) + console.log(oldTab) + // if(sessionStorage.getItem('wait')) { + // this.$confirm('暂未保存,是否保存本次编辑?', '提示', { + // confirmButtonText: '确定', + // cancelButtonText: '取消', + // type: 'warning' + // }) + // } + } + }, + computed: { + wait() { + return this.$store.state.match.wait } } }; diff --git a/src/pages/match/manage/matchProgress.vue b/src/pages/match/manage/matchProgress.vue index 5741310..65a9aad 100644 --- a/src/pages/match/manage/matchProgress.vue +++ b/src/pages/match/manage/matchProgress.vue @@ -9,24 +9,25 @@ @@ -44,6 +45,7 @@ export default { name: "matchProgress", data() { return { + save: false, id: this.$route.query.id, statusList: [ { @@ -65,19 +67,58 @@ export default { pageSize: 10, totals: 0, touchTime:0, + timeOut: {} }; }, mounted() { this.getData(); + console.log(this.listData) }, methods: { + operateIt(row) { + this.$store.commit("match/setWait", true); + row.operate = true + }, + blur(row) { + // if(this.save) { + // console.log('are you save?') + // } + this.timeOut = setTimeout(() => { + this.$confirm('暂未保存,是否保存本次编辑?', '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(() => { + this.saveData(row) + + }).catch(() => { + this.$message({ + type: 'success', + message: '已取消保存' + }); + }); + }, 500) + + }, + focus() { + + clearInterval(this.timeOut) + // this.save = false + }, getData() { this.$get(`${this.api.getContestProgress}/${this.id}`).then(res => { this.listData = res.contestProgressList; + for(let index=0; index { }); }, saveData(row) { + // 有点编辑的时候就要等待确认 + this.$store.commit("match/setWait", false); let data = row; if (data.title.length) { if (row.id) { @@ -132,7 +173,8 @@ export default { id: "", title: "", description: "", - status: 0 + status: 0, + operate: true }); console.log(this.listData) } else { @@ -144,53 +186,108 @@ export default { id: "", title: "", description: "", - status: 0 + status: 1, // status为1时表示未保存的 + operate: true }); } }, - }, - beforeDestroy() { - if (this.touchTime>0){ - this.$confirm('暂未保存,是否保存本次编辑?', '提示', { - confirmButtonText: '确定', - cancelButtonText: '取消', - type: 'warning' - }).then(() => { - let num = 0; - for(var i=0;i { + waitSave() { + if(this.hasEdit) { + this.$confirm('暂未保存,是否保存本次编辑?', '提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).then(() => { + let num = 0; + for(var i=0;i { - }).catch(res => { - }); + }).catch(res => { + }); + }else{ + num = num+1 + } }else{ num = num+1 } + } + if (num >0){ + this.$message({ + type: 'error', + message: '保存失败,有未填项目' + }); }else{ - num = num+1 + this.$message({ + type: 'success', + message: '保存成功!' + }); } - } - if (num >0){ + this.$store.commit("match/setWait", false); + this.$emit('waitChange') + }).catch(() => { this.$message({ - type: 'error', - message: '保存失败,有未填项目' + type: 'info', + message: '已取消保存' }); - }else{ - this.$message({ - type: 'success', - message: '保存成功!' - }); - } - }).catch(() => { - this.$message({ - type: 'info', - message: '已取消保存' + this.$store.commit("match/setWait", false); + this.$emit('waitChange') }); - }); + } } }, + computed: { + hasEdit() { + const judge = this.listData.some(item => item.operate) + return judge + } + }, + beforeDestroy() { + + // if (this.touchTime>0){ + // if (this.hasEdit){ + // this.$confirm('暂未保存,是否保存本次编辑?', '提示', { + // confirmButtonText: '确定', + // cancelButtonText: '取消', + // type: 'warning' + // }).then(() => { + // let num = 0; + // for(var i=0;i { + + // }).catch(res => { + // }); + // }else{ + // num = num+1 + // } + // }else{ + // num = num+1 + // } + // } + // if (num >0){ + // this.$message({ + // type: 'error', + // message: '保存失败,有未填项目' + // }); + // }else{ + // this.$message({ + // type: 'success', + // message: '保存成功!' + // }); + // } + // }).catch(() => { + // this.$message({ + // type: 'info', + // message: '已取消保存' + // }); + // }); + // } + }, }; diff --git a/src/store/modules/match.js b/src/store/modules/match.js index d33cbec..f0b0e4d 100644 --- a/src/store/modules/match.js +++ b/src/store/modules/match.js @@ -5,10 +5,14 @@ export default { namespaced: true, state: { matchId: "", + wait: false }, mutations: { SET_MATCH_ID: (state, id) => { state.matchId = id; + }, + setWait: (state, wait) => { + state.wait = wait; } }, actions: {