From 41e46a983ec52d6861702ecb0bc677a36dd9041c Mon Sep 17 00:00:00 2001 From: joylink_zhaoerwei Date: Mon, 4 Mar 2024 12:15:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=AB=9E=E8=B5=9B=E5=BC=80?= =?UTF-8?q?=E5=A7=8B=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/contest.js | 19 +++++++++++++++++++ src/views/contest/contestList.vue | 12 ++++++------ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/api/contest.js b/src/api/contest.js index 10aaa2467..c5013e53c 100644 --- a/src/api/contest.js +++ b/src/api/contest.js @@ -329,3 +329,22 @@ export function getTaskTree(paperId, moduleId) { method: 'get' }); } + +/** 竞赛开始训练 + * @param {String} paperId 试卷id + * @param {String} moduleId 模块id + */ +export function beginContestExercise(paperId, moduleId) { + return request({ + url: `/api/race/${paperId}/${moduleId}`, + method: 'POST' + }); +} + +/** 竞赛完成训练 */ +export function finishContestExercise() { + return request({ + url: '/api/race/finish', + method: 'PUT' + }); +} diff --git a/src/views/contest/contestList.vue b/src/views/contest/contestList.vue index 316cd728e..f9e616eb3 100644 --- a/src/views/contest/contestList.vue +++ b/src/views/contest/contestList.vue @@ -45,7 +45,7 @@ import paperList from './paperList'; import drapLeft from '@/views/components/drapLeft/index'; import ScoreRule from './scoreRule'; -import { getPaperDetail, getContextScoreDetail} from '@/api/contest'; +import { getPaperDetail, getContextScoreDetail, beginContestExercise} from '@/api/contest'; let id = 1; export default { @@ -64,7 +64,6 @@ export default { moduleList:[], moduleTreeDatas:[], taskTreeDatas:[], - ruleData:[], defaultProps: { disabled: true } @@ -100,9 +99,6 @@ export default { }; }); this.taskTreeDatas = this.moduleTreeDatas[0].children; - getContextScoreDetail(this.moduleTreeDatas[0].moduleScoreRuleId).then(res => { - this.ruleData = res.data.rule ? res.data.rule.units : []; - }).catch(() => { this.ruleData = []; }); }).catch(error => { this.$message.error(error.message); }); @@ -111,7 +107,11 @@ export default { this.$refs.scoreRule.doShow(moduleScoreRuleId); }, beginExercise(moduleId) { - this.$router.push({path: '/contest/detail', query:{paperId:this.paperId, moduleId }}); + beginContestExercise(this.paperId, moduleId).then(res => { + this.$router.push({path: '/contest/detail', query:{paperId:this.paperId, moduleId }}); + }).catch(error => { + this.$message.error(error.message); + }); }, transformTree(data) { const result = {label:data.name, children:[], id:id++, type:'taskCatalog' };