From b7f293929552298b693d3f867ac1f9d83220d5de Mon Sep 17 00:00:00 2001 From: e <2432808546@qq.com> Date: Fri, 26 Nov 2021 17:30:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/achievement/show/index.vue | 9 +++- src/pages/assessment/list/index.vue | 74 ++++++++++++++++------------ 2 files changed, 50 insertions(+), 33 deletions(-) diff --git a/src/pages/achievement/show/index.vue b/src/pages/achievement/show/index.vue index 1c137c5..0565754 100644 --- a/src/pages/achievement/show/index.vue +++ b/src/pages/achievement/show/index.vue @@ -61,10 +61,17 @@ + + + + {{index+1}}. {{item.name}} + + + - {{index+1}}. {{item.userAnswer}} + {{index+1}}. {{item.ruleAnswer}} diff --git a/src/pages/assessment/list/index.vue b/src/pages/assessment/list/index.vue index a985a88..bd53800 100644 --- a/src/pages/assessment/list/index.vue +++ b/src/pages/assessment/list/index.vue @@ -86,7 +86,7 @@ - {{ scope.row.countDown | timeFilter }} + {{ timeFilter(scope.row.countDown) }} @@ -186,7 +186,8 @@ export default { listData: [], // 表格数据 multipleSelection: [], // 多选 listLoading:false,// 列表加载 - ticker: null // 倒计时定时器 + ticker: null, // 倒计时定时器 + sss:1 }; }, watch: { @@ -218,13 +219,39 @@ export default { mounted() { // 页面离开的时候销毁手机和邮箱验证码定时器 this.$once("hook:beforeDestroy", function() { - clearInterval(this.ticker); - this.ticker = null; + this.sss = 0 + // clearInterval(this.ticker); + // this.ticker = null; }); this.getData(); this.getschoolCourse(); }, - filters: { + methods: { + beginTimer() { + this.ticker = setInterval(() => { + if(this.sss == 0){ + this.ticker = null; + clearInterval(this.ticker); + }else{ + for (let i = 0; i < this.listData.length; i++) { + const item = this.listData[i]; + if (item.countDown > 0) { + item.countDown--; + } else { + if (item.status == 0 && item.type == 2) { // 待开始-定时发布 + item.status = 1; + item.countDown = (new Date(item.stopTime).getTime() - new Date().getTime()) / 1000; + // } + } else if (item.status == 1) { + // item.status = 2; + } + } + item.show = true; + this.$set(this.listData, i, item); + } + } + }, 1000); + }, timeFilter(countDown) { if (countDown > 0) { let h = Math.floor(countDown / (60 * 60)); @@ -234,35 +261,11 @@ export default { } else { return "00:00:00"; } - } - }, - methods: { - beginTimer() { - this.ticker = setInterval(() => { - for (let i = 0; i < this.listData.length; i++) { - const item = this.listData[i]; - if (item.countDown > 0) { - item.countDown--; - } else { - if (item.status == 0 && item.type == 2) { // 待开始-定时发布 - item.status = 1; - item.countDown = (new Date(item.stopTime).getTime() - new Date().getTime()) / 1000; - // } - } else if (item.status == 1) { - // item.status = 2; - } - } - item.show = true; - this.$set(this.listData, i, item); - } - }, 1000); }, getData() { this.listLoading = true; this.listData.splice(0); - if (this.ticker) { - clearInterval(this.ticker); - } + this.sss = 0 let data = { ...this.form, keyWord: this.keyWord, @@ -272,7 +275,6 @@ export default { }; this.$post(this.api.pageByCondition, data).then(res => { this.listData = res.list; - console.log(this.listData) this.total = res.total; this.listData.forEach(i => { i.show = false; @@ -298,7 +300,8 @@ export default { } } }); - this.beginTimer(); + this.sss = 1 + this.beginTimer() this.listLoading = false; }).catch(err => { this.listLoading = false; @@ -307,6 +310,7 @@ export default { initData() { this.$refs.table.clearSelection(); this.pageNum = 1; + this.sss = 0 this.getData(); }, getschoolCourse() { // 获取课程下拉框数据 @@ -329,6 +333,7 @@ export default { start(row) { this.$post(`${this.api.enableAssessment}?id=${row.id}`).then(res => { util.successMsg("启动成功!"); + this.sss = 0 this.getData(); }).catch(err => { console.log(err); @@ -345,6 +350,7 @@ export default { }; this.$post(`${this.api.collectPaper}?id=${row.id}`).then(res => { util.successMsg("提前结束成功!"); + this.sss = 0 this.getData(); }).catch(err => { console.log(err); @@ -358,6 +364,7 @@ export default { }).then(() => { this.$post(this.api.deleteAssessment, [row.id]).then(res => { util.successMsg("删除成功"); + this.sss = 0 this.getData(); }).catch(res => { }); @@ -376,6 +383,7 @@ export default { this.multipleSelection = []; this.$refs.table.clearSelection(); util.successMsg("删除成功"); + this.sss = 0 this.getData(); }).catch(res => { }); @@ -390,10 +398,12 @@ export default { }, onSearch() { this.pageNum = 1; + this.sss = 0 this.getData(); }, handleCurrentChange(val) { this.pageNum = val; + this.sss = 0 this.getData(); }, transferTime(date) {