TestCard.vue 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <template>
  2. <div class="test-container">
  3. <el-card class="test-card" shadow="hover">
  4. <div class="test-card__header">
  5. <div class="test-card__name">{{ exam.examName }}</div>
  6. <!-- 和style绑定 -->
  7. <div class="test-card__status">
  8. <div class="test-card__tag has-started" v-if="exam.status === '进行中'">进行中</div>
  9. <div class="test-card__tag not-start" v-else-if="exam.status === '未开始'">未开始</div>
  10. <div class="test-card__tag finished" v-else>已结束</div>
  11. <div v-if="exam.isJoined" class="test-card__tag has-started">已加入</div>
  12. </div>
  13. </div>
  14. <div class="test-card__option">
  15. <div class="test-card__time">
  16. <div class="test-card__startTime">开始时间: {{ exam.startTime }}</div>
  17. <div class="test-card__endTime">结束时间: {{ exam.endTime }}</div>
  18. <div class="test-card__invigilate">是否监考: {{ exam.antiCheating?'是': '否' }}</div>
  19. </div>
  20. <div class="test-card__btn">
  21. <el-button type="primary" plain @click.native="goEval">查看信息</el-button>
  22. <el-button v-if="exam.isJoined && isStarted" type="success" plain @click.native="beginExam( exam.location )">前往考试</el-button>
  23. </div>
  24. </div>
  25. </el-card>
  26. </div>
  27. </template>
  28. <script>
  29. export default {
  30. name: 'TestCard',
  31. data () {
  32. return {
  33. isStarted: false
  34. }
  35. },
  36. props: {
  37. exam: {
  38. type: Object,
  39. default () {
  40. return {}
  41. }
  42. }
  43. },
  44. mounted () {
  45. const now = new Date()
  46. if (new Date(this.exam.startTime) < now && new Date(this.exam.endTime) > now) {
  47. this.isStarted = true
  48. }
  49. },
  50. methods: {
  51. beginExam: function (location) {
  52. window.location.href = location
  53. },
  54. goEval: function () {
  55. const location = 'https://eval.seec.seecoder.cn'
  56. window.location.href = location
  57. }
  58. }
  59. }
  60. </script>
  61. <style scoped>
  62. @import '~/assets/css/test-card.css';
  63. </style>