| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- <template>
- <el-card class="course-card" shadow="hover" @click="toCourseInfo">
- <div class="image">
- <img :src="imageUrl" alt="">
- </div>
- <el-row>
- <el-col :span="16" class="name">{{ courseVO.name }}</el-col>
- <el-col :span="8" class="status">
- <el-tag v-if="state==='NOT_STARTED'" size="small" type="info">未开始</el-tag>
- <el-tag v-else-if="state==='RUNNING'" size="small">进行中</el-tag>
- <el-tag v-else-if="state==='OVER'" size="small" type="danger">已结束</el-tag>
- </el-col>
- </el-row>
- <el-row class="teacher">
- 教师: {{ courseVO.teacher.name }}
- </el-row>
- <el-row class="semester">
- 季度: {{ courseVO.semester }}
- </el-row>
- <el-row class="time">
- 时间: {{ timestampToTime(courseVO.startTime) }} 至 {{ timestampToTime(courseVO.endTime) }}
- </el-row>
- <el-row class="description">
- {{ courseVO.description }}
- </el-row>
- <!-- <el-row class="button">-->
- <!-- <el-col :span="24">-->
- <!-- <el-button v-if="state==='FINISHED'" plain size="small" type="success">结果报告</el-button>-->
- <!-- <el-button v-else plain size="small" type="primary">查看详情</el-button>-->
- <!-- </el-col>-->
- <!-- </el-row>-->
- </el-card>
- </template>
- <script>
- export default {
- name: "CourseCard",
- props: {
- courseVO: {
- type: Object
- }
- },
- computed: {
- state: function () {
- if (new Date(this.courseVO.endTime) < new Date()) {
- return "OVER";
- } else if (new Date(this.courseVO.startTime) > new Date()) {
- return "NOT_STARTED";
- } else if (this.courseVO.finished) {
- return "FINISHED";
- } else {
- return "RUNNING";
- }
- },
- imageUrl() {
- return this.courseVO.imageUrl === null ? "https://mjh1.oss-cn-hangzhou.aliyuncs.com/hci/no-image.png" : this.courseVO.imageUrl;
- },
- },
- mounted() {
- },
- methods: {
- timestampToTime(timestamp) {
- const date = new Date(timestamp);
- 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());
- return Y + M + D;
- },
- toCourseInfo() {
- this.$router.push("/course/" + this.courseVO.id);
- },
- },
- };
- </script>
- <style scoped>
- .course-card {
- margin-bottom: 10px;
- border-radius: 4px;
- height: calc(100% - 10px);
- position: relative;
- border: 1px solid #cccccc;
- }
- .course-card:hover {
- cursor: pointer;
- }
- .image {
- height: 80px;
- outline: solid 1px #eeeeee;
- margin-bottom: 10px;
- border-radius: 4px;
- }
- .image img {
- height: 100%;
- width: 100%;
- }
- .name {
- font-weight: bold;
- }
- .status {
- text-align: right;
- }
- .teacher {
- font-size: 10px;
- margin-top: 10px;
- color: #999999;
- }
- .semester {
- margin-top: 4px;
- font-size: 10px;
- color: #999999;
- }
- .time {
- margin-top: 4px;
- font-size: 10px;
- color: #999999;
- }
- .description {
- background-color: #f6f6f6;
- margin-top: 10px;
- border-radius: 8px;
- padding: 10px;
- font-size: 10px;
- color: #777777;
- }
- /*.button {*/
- /* position: absolute;*/
- /* bottom: 8px;*/
- /* left: calc(50% - 40px);*/
- /* text-align: center;*/
- /*}*/
- </style>
|