CourseCard.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <template>
  2. <el-card class="course-card" shadow="hover" @click="toCourseInfo">
  3. <div class="image">
  4. <img :src="imageUrl" alt="">
  5. </div>
  6. <el-row>
  7. <el-col :span="16" class="name">{{ courseVO.name }}</el-col>
  8. <el-col :span="8" class="status">
  9. <el-tag v-if="state==='NOT_STARTED'" size="small" type="info">未开始</el-tag>
  10. <el-tag v-else-if="state==='RUNNING'" size="small">进行中</el-tag>
  11. <el-tag v-else-if="state==='OVER'" size="small" type="danger">已结束</el-tag>
  12. </el-col>
  13. </el-row>
  14. <el-row class="teacher">
  15. 教师: {{ courseVO.teacher.name }}
  16. </el-row>
  17. <el-row class="semester">
  18. 季度: {{ courseVO.semester }}
  19. </el-row>
  20. <el-row class="time">
  21. 时间: {{ timestampToTime(courseVO.startTime) }} 至 {{ timestampToTime(courseVO.endTime) }}
  22. </el-row>
  23. <el-row class="description">
  24. {{ courseVO.description }}
  25. </el-row>
  26. <!-- <el-row class="button">-->
  27. <!-- <el-col :span="24">-->
  28. <!-- <el-button v-if="state==='FINISHED'" plain size="small" type="success">结果报告</el-button>-->
  29. <!-- <el-button v-else plain size="small" type="primary">查看详情</el-button>-->
  30. <!-- </el-col>-->
  31. <!-- </el-row>-->
  32. </el-card>
  33. </template>
  34. <script>
  35. export default {
  36. name: "CourseCard",
  37. props: {
  38. courseVO: {
  39. type: Object
  40. }
  41. },
  42. computed: {
  43. state: function () {
  44. if (new Date(this.courseVO.endTime) < new Date()) {
  45. return "OVER";
  46. } else if (new Date(this.courseVO.startTime) > new Date()) {
  47. return "NOT_STARTED";
  48. } else if (this.courseVO.finished) {
  49. return "FINISHED";
  50. } else {
  51. return "RUNNING";
  52. }
  53. },
  54. imageUrl() {
  55. return this.courseVO.imageUrl === null ? "https://mjh1.oss-cn-hangzhou.aliyuncs.com/hci/no-image.png" : this.courseVO.imageUrl;
  56. },
  57. },
  58. mounted() {
  59. },
  60. methods: {
  61. timestampToTime(timestamp) {
  62. const date = new Date(timestamp);
  63. const Y = date.getFullYear() + "-";
  64. const M = (date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1) + "-";
  65. const D = (date.getDate() < 10 ? "0" + date.getDate() : date.getDate());
  66. return Y + M + D;
  67. },
  68. toCourseInfo() {
  69. this.$router.push("/course/" + this.courseVO.id);
  70. },
  71. },
  72. };
  73. </script>
  74. <style scoped>
  75. .course-card {
  76. margin-bottom: 10px;
  77. border-radius: 4px;
  78. height: calc(100% - 10px);
  79. position: relative;
  80. border: 1px solid #cccccc;
  81. }
  82. .course-card:hover {
  83. cursor: pointer;
  84. }
  85. .image {
  86. height: 80px;
  87. outline: solid 1px #eeeeee;
  88. margin-bottom: 10px;
  89. border-radius: 4px;
  90. }
  91. .image img {
  92. height: 100%;
  93. width: 100%;
  94. }
  95. .name {
  96. font-weight: bold;
  97. }
  98. .status {
  99. text-align: right;
  100. }
  101. .teacher {
  102. font-size: 10px;
  103. margin-top: 10px;
  104. color: #999999;
  105. }
  106. .semester {
  107. margin-top: 4px;
  108. font-size: 10px;
  109. color: #999999;
  110. }
  111. .time {
  112. margin-top: 4px;
  113. font-size: 10px;
  114. color: #999999;
  115. }
  116. .description {
  117. background-color: #f6f6f6;
  118. margin-top: 10px;
  119. border-radius: 8px;
  120. padding: 10px;
  121. font-size: 10px;
  122. color: #777777;
  123. }
  124. /*.button {*/
  125. /* position: absolute;*/
  126. /* bottom: 8px;*/
  127. /* left: calc(50% - 40px);*/
  128. /* text-align: center;*/
  129. /*}*/
  130. </style>