|
|
@@ -34,11 +34,14 @@
|
|
|
</el-row>
|
|
|
|
|
|
<el-row class="time">
|
|
|
- {{ timePeriod.replace(/-/g,".") }}
|
|
|
+ {{ startTime }}
|
|
|
+ </el-row>
|
|
|
+ <el-row class="time">
|
|
|
+ {{ endTime }}
|
|
|
</el-row>
|
|
|
|
|
|
- <el-row v-if="type==='eval'" class="comment">
|
|
|
- {{ testVO.comment }}
|
|
|
+ <el-row v-if="type==='eval'&&testVO['comment']!==''" class="comment">
|
|
|
+ {{ testVO["comment"] }}
|
|
|
</el-row>
|
|
|
</el-card>
|
|
|
</template>
|
|
|
@@ -46,6 +49,7 @@
|
|
|
<script>
|
|
|
import {ElMessage, ElMessageBox} from "element-plus";
|
|
|
import store from "@/store";
|
|
|
+import timeUtil from "@/utils/time";
|
|
|
|
|
|
export default {
|
|
|
name: "TestCard",
|
|
|
@@ -68,7 +72,7 @@ export default {
|
|
|
isCreator() {
|
|
|
if (this.testVO.examId) {
|
|
|
return Number(this.testVO.course.teacherId) === Number(this.$store.state.user.id);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
return this.testVO.creator.username === this.$store.state.user.username;
|
|
|
}
|
|
|
},
|
|
|
@@ -94,24 +98,41 @@ export default {
|
|
|
},
|
|
|
course() {
|
|
|
if (this.type === "eval") {
|
|
|
- return "";
|
|
|
+ return "课程: " + this.testVO.course.name;
|
|
|
} else {
|
|
|
- return "所属课程: " + this.testVO.course;
|
|
|
+ return "课程: " + this.testVO.course;
|
|
|
}
|
|
|
},
|
|
|
teacherName() {
|
|
|
- if (this.type === "eval") {
|
|
|
- return "教师: " + this.teacher.name;
|
|
|
- } else {
|
|
|
- return "教师: " + this.teacher;
|
|
|
+ return "教师: " + this.teacher;
|
|
|
+ },
|
|
|
+ startTime() {
|
|
|
+ let start = "开始: ";
|
|
|
+ switch (this.type) {
|
|
|
+ case "eval":
|
|
|
+ start += this.testVO.startTime.substring(0, 16);
|
|
|
+ break;
|
|
|
+ case "coder":
|
|
|
+ start += timeUtil.timestampToTime(this.testVO.startAt);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
}
|
|
|
+ return start;
|
|
|
},
|
|
|
- timePeriod() {
|
|
|
- if (this.type === "eval") {
|
|
|
- return "时间: " + this.testVO.startTime.substring(0, 16) + "至" + this.testVO.endTime.substring(0, 16);
|
|
|
- } else {
|
|
|
- return "时间: " + this.timestampToTime(this.testVO.startAt) + "至" + this.timestampToTime(this.testVO.endAt);
|
|
|
+ endTime() {
|
|
|
+ let end = "结束: ";
|
|
|
+ switch (this.type) {
|
|
|
+ case "eval":
|
|
|
+ end += this.testVO.endTime.substring(0, 16);
|
|
|
+ break;
|
|
|
+ case "coder":
|
|
|
+ end += timeUtil.timestampToTime(this.testVO.endAt);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
}
|
|
|
+ return end;
|
|
|
},
|
|
|
state() {
|
|
|
const now = new Date();
|
|
|
@@ -140,23 +161,19 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
},
|
|
|
- async created() {
|
|
|
- if (this.type === "eval") {
|
|
|
- this.teacher = (await this.$apis.getUserAPI(this.testVO.course["teacherId"])).data.data;
|
|
|
- } else {
|
|
|
- this.teacher = (await this.$apis.getNameByUsernameAPI(this.testVO.creator.username)).data.data;
|
|
|
+ async mounted() {
|
|
|
+ switch (this.type) {
|
|
|
+ case "eval":
|
|
|
+ this.teacher = (await this.$apis.getUserAPI(this.testVO.course["teacherId"])).data.data.name;
|
|
|
+ break;
|
|
|
+ case "coder":
|
|
|
+ this.teacher = (await this.$apis.getNameByUsernameAPI(this.testVO.creator.username)).data.data;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
- timestampToTime(timestamp) {
|
|
|
- const date = new Date(timestamp * 1000);
|
|
|
- const Y = date.getFullYear() + "-";
|
|
|
- const M = (date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1) + "-";
|
|
|
- const D = (date.getDate() < 10 ? "0" + date.getDate() : date.getDate()) + " ";
|
|
|
- const h = (date.getHours() < 10 ? "0" + date.getHours() : date.getHours()) + ":";
|
|
|
- const m = (date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes());
|
|
|
- return Y + M + D + h + m;
|
|
|
- },
|
|
|
// TODO 分情况处理跳转
|
|
|
async toTestInfo() {
|
|
|
if (!this.isLogin) {
|
|
|
@@ -226,7 +243,7 @@ export default {
|
|
|
if (isCourseSelected) {
|
|
|
messageBoxContent = "是否立即查看测试详情";
|
|
|
confirmButtonText = "立即查看";
|
|
|
- this.$router.push("/exam/"+this.testVO.id);
|
|
|
+ this.$router.push("/exam/" + this.testVO.id);
|
|
|
// nextURL = "https://coder.seec.seecoder.cn/exam?id_token=" + this.$store.state.user.token;
|
|
|
} else {
|
|
|
messageBoxContent = "尚未选择课程,是否立即参加?";
|
|
|
@@ -288,14 +305,14 @@ export default {
|
|
|
|
|
|
.teacher {
|
|
|
font-size: 10px;
|
|
|
- margin-top: 10px;
|
|
|
+ margin-top: 4px;
|
|
|
color: #999999;
|
|
|
}
|
|
|
|
|
|
.time {
|
|
|
margin-top: 4px;
|
|
|
font-size: 10px;
|
|
|
- margin-bottom: 16px;
|
|
|
+ /*margin-bottom: 16px;*/
|
|
|
color: #999999;
|
|
|
}
|
|
|
|