diff --git a/src/components/TestPanel.vue b/src/components/TestPanel.vue index 4d8c0fd..5c64a3f 100644 --- a/src/components/TestPanel.vue +++ b/src/components/TestPanel.vue @@ -191,12 +191,13 @@ export default { competitionId: Cookie.get('admin-competitionId'), stageId: Cookie.get('admin-stageId'), teamId: Cookie.get('admin-teamId'), + mallId: Cookie.get('admin-mallId'), resultsDetails: Cookie.get('admin-resultsDetails'), resultAnnouncementTime: Cookie.get('admin-resultAnnouncementTime'), curriculumName: Cookie.get('admin-curriculumName') ? unescape(Cookie.get('admin-curriculumName')) : 'python', // 课程名称 curSystemId: 1, projectPermissions: 0, // 项目权限(0、练习 1、考核 2、竞赛) - isSubmit: false, // 是否提交的标识 + isSubmit: Cookie.get('admin-isSubmit') == 'true' ? true : false, // 是否提交的标识 entryTime: new Date(), startTime: Cookie.get('admin-startTime'), endTime: Cookie.get('admin-stopTime'), @@ -233,6 +234,10 @@ export default { if (this.assessmentId) { // 考核(考核才会从外面带进来assessmentId,练习是默认显示第一个项目,竞赛会带进来competitionId) this.getAssList() } else { // 练习 + if (Cookie.get('doneProjectId')) { + this.projectId = +Cookie.get('doneProjectId') + } + Cookie.remove('doneProjectId') // 获取项目列表 this.getList().then(() => { let cache = localStorage.getItem('codeCache') // 获取本地缓存 @@ -277,7 +282,7 @@ export default { }, // 获取项目详情 getProDetail () { - const projectId = this.projectId + const { projectId } = this return new Promise((resolve, reject) => { this.$get(this.api.getProjectDetail, { projectId, @@ -339,6 +344,12 @@ export default { this.$parent.loadIns.close() this.$parent.loaded = true }, + // 设置isSubmit + setSubmit (status) { + this.isSubmit = status + newmain.$emit('isSubmit', status) + Cookie.set('admin-isSubmit', status) + }, // 获取考核列表来查询该考核是否已经考过 getAssList () { this.$post(`${this.api.pageStuAssessment}`, { @@ -346,14 +357,13 @@ export default { pageSize: 10000 }).then(res => { const list = res.list - const assessmentId = this.assessmentId + const { assessmentId } = this let done = false const classId = this.classId // 匹配到该考核,并且已经提交过(有reportId则说明有实验记录),并且classId跟当前用户的classId相同,就提示提交了考核然后返回上一页 if (list.find(e => e.assessmentId == assessmentId && e.reportId && e.classId == classId)) { done = true - this.isSubmit = true - newmain.$emit('isSubmit', this.isSubmit) + this.setSubmit(true) this.$message.error('你已经提交过该考核!') setTimeout(_ => { history.back() // 直接返回上一页面 @@ -518,15 +528,15 @@ export default { this.getProDetail().then(() => { this.getCache() }).catch(res => { }) - this.isSubmit = false + this.setSubmit(false) this.countVal = 0 this.grade = '00' this.pannelTab = 'first' this.$emit('recoveryCode') // 切换实训项目后回到第一个判分点 - newmain.$emit('isSubmit', this.isSubmit) // 选择项目后把提交状态重置为未提交 }, // 查看实验报告 toReport () { + Cookie.set('doneProjectId', this.projectId) // 进入实验报告之前先存储当前项目id,从实验报告返回来后把这个id恢复 this.$router.push(`/report?reportId=${this.reportId}`) }, //重新开始 @@ -534,8 +544,7 @@ export default { this.reloadCount() this.grade = '00' localStorage.removeItem('codeCache') - this.isSubmit = false - newmain.$emit('isSubmit', this.isSubmit) + this.setSubmit(false) const points = this.points // code和codeId,还有运行结果全部清空 points.map(e => { @@ -616,12 +625,12 @@ export default { competitionId: this.competitionId, stageId: this.stageId, teamId: this.teamId, + mallId: this.mallId } this.$post(this.api.submit, data).then(({ retInfo, reportId }) => { localStorage.removeItem('codeCache') - this.isSubmit = true - newmain.$emit('isSubmit', this.isSubmit) + this.setSubmit(true) clearInterval(this.statusTimer) let list = retInfo let taskList = this.taskList diff --git a/src/components/codemirror.vue b/src/components/codemirror.vue index 9e159c7..574fb8c 100644 --- a/src/components/codemirror.vue +++ b/src/components/codemirror.vue @@ -195,7 +195,7 @@ export default { runResult: '', // 运行结果 isError: false, // 运行正确与否 errLine: '', // 错误代码的位置 - isSubmit: false, // 是否提交了 + isSubmit: Cookie.get('admin-isSubmit') == 'true' ? true : false, // 是否提交的标识 runEnable: false, // 是否禁用运行按钮 tipsVisible: false, // 答案提示弹框显示标识 picSrcList: [], @@ -608,6 +608,9 @@ export default { \ No newline at end of file