|
|
@@ -1,12 +1,12 @@
|
|
|
<template>
|
|
|
<el-row>
|
|
|
<el-col :span="20" class="box">
|
|
|
- <el-card class="box-card" v-if="this.examInfo">
|
|
|
+ <el-card class="box-card" v-if="examInfo">
|
|
|
<span>评测详情</span>
|
|
|
<el-divider></el-divider>
|
|
|
<template #header>
|
|
|
<div class="card-header">
|
|
|
- <el-tooltip v-if="this.examInfo.isPublic" class="box-item" content="无需邀请码即可加入" placement="top"
|
|
|
+ <el-tooltip v-if="examInfo.isPublic" class="box-item" content="无需邀请码即可加入" placement="top"
|
|
|
effect="dark">
|
|
|
<el-icon>
|
|
|
<Unlock/>
|
|
|
@@ -17,62 +17,62 @@
|
|
|
<Lock/>
|
|
|
</el-icon>
|
|
|
</el-tooltip>
|
|
|
- <span style="font-size: 20px">评测「{{ this.examInfo.examName }}」</span>
|
|
|
- <el-tag class="ml-2" :type="statusToType(state)">{{ state }}</el-tag>
|
|
|
- <el-tag v-if="this.examInfo.isFinished" class="ml-2" type="info">已完成</el-tag>
|
|
|
+ <span style="font-size: 20px">评测「{{ examInfo.examName }}」</span>
|
|
|
+ <el-tag class="ml-2" :type="statusType">{{ state }}</el-tag>
|
|
|
+ <el-tag v-if="examInfo.isFinished" class="ml-2" type="info">已完成</el-tag>
|
|
|
<el-button
|
|
|
v-if="!isJoined && (state === '未开始' || state === '进行中')"
|
|
|
- :disabled="this.isJoined"
|
|
|
+ :disabled="isJoined"
|
|
|
type="primary"
|
|
|
style="float: right"
|
|
|
@click="onJoinExam">
|
|
|
报名参加
|
|
|
</el-button>
|
|
|
<el-button
|
|
|
- v-if="this.isJoined && state === '未开始'"
|
|
|
- :disabled="this.isJoined"
|
|
|
+ v-if="isJoined && state === '未开始'"
|
|
|
+ :disabled="isJoined"
|
|
|
type="primary"
|
|
|
style="float: right">
|
|
|
等待加入
|
|
|
</el-button>
|
|
|
<el-button
|
|
|
- v-if="this.isJoined && state === '进行中' && !this.examInfo.isFinished"
|
|
|
+ v-if="isJoined && state === '进行中' && !examInfo.isFinished"
|
|
|
type="success"
|
|
|
style="float: right"
|
|
|
@click="onStartExam">
|
|
|
开始评测
|
|
|
</el-button>
|
|
|
<el-button
|
|
|
- v-if="this.isJoined && (state === '已结束' || this.examInfo.isFinished)"
|
|
|
+ v-if="isJoined && (state === '已结束' || examInfo.isFinished)"
|
|
|
style="float: right"
|
|
|
@click="onOpenResult">
|
|
|
结果报告
|
|
|
</el-button>
|
|
|
</div>
|
|
|
</template>
|
|
|
- <el-row>评测ID: {{ this.examInfo.examId }}</el-row>
|
|
|
+ <el-row>评测ID: {{ examInfo.examId }}</el-row>
|
|
|
<el-row>
|
|
|
<el-col :span="12">
|
|
|
- 所属课程: {{ this.courseInfo.name }}
|
|
|
+ 所属课程: {{ courseInfo.name }}
|
|
|
</el-col>
|
|
|
<el-col :span="12">
|
|
|
- 监考:{{ this.examInfo.antiCheating ? "是" : "否" }}
|
|
|
+ 监考:{{ examInfo.antiCheating ? "是" : "否" }}
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
<el-row>
|
|
|
<el-col :span="12">
|
|
|
- 职位: {{ this.examInfo.position }}
|
|
|
+ 职位: {{ examInfo.position }}
|
|
|
</el-col>
|
|
|
<el-col :span="12">
|
|
|
- 技能点: {{ this.examInfo.skills }}
|
|
|
+ 技能点: {{ examInfo.skills }}
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
<el-row>
|
|
|
<el-col :span="12">
|
|
|
- 开始时间:{{ this.examInfo.startTime }}
|
|
|
+ 开始时间:{{ examInfo.startTime }}
|
|
|
</el-col>
|
|
|
<el-col :span="12">
|
|
|
- 结束时间:{{ this.examInfo.endTime }}
|
|
|
+ 结束时间:{{ examInfo.endTime }}
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
<el-row>
|
|
|
@@ -111,7 +111,7 @@ export default {
|
|
|
courseInfo: [],
|
|
|
examId: 0,
|
|
|
isJoined: false,
|
|
|
- state: "",
|
|
|
+ isFinished: false,
|
|
|
inputInviteCode: false,
|
|
|
examQuestionsNum: 0,
|
|
|
examCodeQuestionsNum: 0,
|
|
|
@@ -120,40 +120,25 @@ export default {
|
|
|
totalNum: 0
|
|
|
};
|
|
|
},
|
|
|
- created() {
|
|
|
- this.examId = this.$route.query.examId;
|
|
|
- this.isJoined = this.$route.query.isJoined === "true";
|
|
|
- this.$apis.getExamById(this.examId).then(_res => {
|
|
|
- this.examInfo = _res.data.data.result;
|
|
|
- this.examInfo.skills = this.examInfo.skills.toString();
|
|
|
- this.courseInfo = this.examInfo.course;
|
|
|
- this.state = this.computeExamStateText(
|
|
|
- this.examInfo.startTime,
|
|
|
- this.examInfo.endTime
|
|
|
- );
|
|
|
- this.$apis.getExamSubmitRecordsByUserId(this.examId).then(({data}) => {
|
|
|
- this.examInfo.isFinished = !!data.data.result.find((val) => !val.message);
|
|
|
- });
|
|
|
- });
|
|
|
- },
|
|
|
|
|
|
- mounted() {
|
|
|
- },
|
|
|
+ computed: {
|
|
|
+ state() {
|
|
|
+ const TIME_FORMAT = "YYYY-MM-DD HH:mm:ss";
|
|
|
+ const now = dayjs();
|
|
|
+ const formattedStartTime = dayjs(this.examInfo.startTime, TIME_FORMAT);
|
|
|
+ const formattedEndTime = dayjs(this.examInfo.endTime, TIME_FORMAT);
|
|
|
|
|
|
- updated() {
|
|
|
- this.state = this.computeExamStateText(
|
|
|
- this.examInfo.startTime,
|
|
|
- this.examInfo.endTime
|
|
|
- );
|
|
|
- this.$apis.getExamSubmitRecordsByUserId(this.examId).then(({data}) => {
|
|
|
- console.log(data.data.result);
|
|
|
- this.examInfo.isFinished = !!data.data.result.find((val) => !val.message);
|
|
|
- });
|
|
|
- },
|
|
|
+ if (formattedEndTime < now) {
|
|
|
+ return "已结束";
|
|
|
+ }
|
|
|
+ if (formattedStartTime > now) {
|
|
|
+ return "未开始";
|
|
|
+ }
|
|
|
+ return "进行中";
|
|
|
+ },
|
|
|
|
|
|
- methods: {
|
|
|
- statusToType(state) {
|
|
|
- switch (state) {
|
|
|
+ statusType() {
|
|
|
+ switch (this.state) {
|
|
|
case "未开始":
|
|
|
return "info";
|
|
|
case "进行中":
|
|
|
@@ -161,21 +146,19 @@ export default {
|
|
|
case "已结束":
|
|
|
return "danger";
|
|
|
}
|
|
|
+ return "";
|
|
|
},
|
|
|
|
|
|
- computeExamStateText(startTime, endTime) {
|
|
|
- const TIME_FORMAT = "YYYY-MM-DD HH:mm:ss";
|
|
|
- const now = dayjs();
|
|
|
- const formattedStartTime = dayjs(startTime, TIME_FORMAT);
|
|
|
- const formattedEndTime = dayjs(endTime, TIME_FORMAT);
|
|
|
+ },
|
|
|
|
|
|
- if (formattedEndTime < now) {
|
|
|
- return "已结束";
|
|
|
- }
|
|
|
- if (formattedStartTime > now) {
|
|
|
- return "未开始";
|
|
|
- }
|
|
|
- return "进行中";
|
|
|
+ methods: {
|
|
|
+ initial() {
|
|
|
+ this.examId = this.$route.params.examId;
|
|
|
+ this.$apis.getExamById(this.examId).then(({data}) => {
|
|
|
+ this.examInfo = data.data.result;
|
|
|
+ this.examInfo.skills = this.examInfo.skills.toString();
|
|
|
+ this.courseInfo = this.examInfo.course;
|
|
|
+ });
|
|
|
},
|
|
|
|
|
|
onJoinExam() {
|
|
|
@@ -199,20 +182,20 @@ export default {
|
|
|
const examId = this.examInfo.examId ?? 0;
|
|
|
const inviteCode = this.inviteCode;
|
|
|
this.$apis.joinExamByInviteCode(inviteCode, examId)
|
|
|
- .then(() => {
|
|
|
- this.inputInviteCode = false;
|
|
|
- this.isJoined = true;
|
|
|
- console.log(this.examInfo);
|
|
|
- ElMessage({
|
|
|
- message: "加入考试成功",
|
|
|
- type: "success",
|
|
|
+ .then(() => {
|
|
|
+ this.inputInviteCode = false;
|
|
|
+ this.isJoined = true;
|
|
|
+ console.log(this.examInfo);
|
|
|
+ ElMessage({
|
|
|
+ message: "加入考试成功",
|
|
|
+ type: "success",
|
|
|
+ });
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ })
|
|
|
+ .finally(() => {
|
|
|
+ this.inviteCode = "";
|
|
|
});
|
|
|
- })
|
|
|
- .catch(() => {
|
|
|
- })
|
|
|
- .finally(() => {
|
|
|
- this.inviteCode = "";
|
|
|
- });
|
|
|
},
|
|
|
|
|
|
onStartExam() {
|
|
|
@@ -226,7 +209,26 @@ export default {
|
|
|
window.open(url + "?id_token=" + this.$store.state.user.token);
|
|
|
},
|
|
|
|
|
|
- }
|
|
|
+ },
|
|
|
+
|
|
|
+ created() {
|
|
|
+ this.initial();
|
|
|
+ },
|
|
|
+
|
|
|
+ mounted() {
|
|
|
+ this.$apis.getExamJoinedUsers(this.examId).then(({data}) =>{
|
|
|
+ let curUserId = this.$store.state.user.id;
|
|
|
+ let userLists = data.data.result;
|
|
|
+ userLists.forEach((item) => {
|
|
|
+ if(item.id === curUserId) this.isJoined = true;
|
|
|
+ });
|
|
|
+ });
|
|
|
+ this.$apis.getExamSubmitRecordsByUserId(this.examId).then(({data}) => {
|
|
|
+ this.isFinished = !!data.data.result.find((val) => !val.message);
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
};
|
|
|
</script>
|
|
|
|