LearnItem.vue 5.4 KB
Newer Older
耿迪迪's avatar
耿迪迪 committed
1 2 3 4
<!--
 * @Author: 纪泽龙 jizelong@qq.com
 * @Date: 2022-09-20 14:29:26
 * @LastEditors: 纪泽龙 jizelong@qq.com
5
 * @LastEditTime: 2023-01-03 15:10:43
耿迪迪's avatar
耿迪迪 committed
6 7 8 9 10
 * @FilePath: /danger-manage-web/src/views/myLessons/components/LearnItem.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <div class="item flex">
11 12 13 14
    <div class="title" style="text-align: center">{{ itemData.courseType||'-' }}</div>
    <div class="allone">
      <img v-if="itemData.dataKind==0" style="height: 18px" src="@/assets/img/ykao.png"/>
      <img v-if="itemData.dataKind==1" style="height: 18px" src="@/assets/img/skao.png"/>
15
      <div class="lesson zzz" style="width: 75%" :title="itemData.courseName">  {{ itemData.courseName }}</div>
16
    </div>
耿迪迪's avatar
耿迪迪 committed
17 18
    <div class="time">发布时间:{{ itemData.createTime }}</div>
    <div class="bottom flex">
19 20
      <div v-if="!itemData.state===4 || !(itemData.state===3 && itemData.dataKind==='1')"  @click="click" class="btn" :class="{ again: yesOrNo }">
        {{ yesOrNo  }}
耿迪迪's avatar
耿迪迪 committed
21 22 23 24 25 26 27
      </div>
    </div>
    <div
      class="img"
      :class="{
        no: itemData.state === 1,
        yes: itemData.state === 2,
28 29
        ygq:itemData.state === 3,
        wks:itemData.state === 4,
耿迪迪's avatar
耿迪迪 committed
30 31 32 33
      }"
    >
      {{ state[itemData.state] }}
    </div>
34 35 36 37
    <AnswerLesson
      v-if="answerOpen"
      :courseId="itemData.courseId"
      :userCourseId="itemData.userCourseId"
38
      :courseName = "itemData.courseName"
39 40 41
      :visible.sync="answerOpen"
      @jj="jj"
    />
耿迪迪's avatar
耿迪迪 committed
42 43 44 45
  </div>
</template>

<script>
46
  import AnswerLesson from "./AnswerLesson";
耿迪迪's avatar
耿迪迪 committed
47 48
export default {
  name: "",
49 50 51
  components: {
    AnswerLesson,
  },
耿迪迪's avatar
耿迪迪 committed
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
  props: {
    itemData: {
      type: Object,
      default: () => {
        return {
          again: 2,
        };
      },
    },
    state: {
      type: Object,
    },
  },
  computed: {
    yesOrNo() {
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
      console.log(this.itemData)
      if(this.itemData.dataKind==="0"){
        if( this.itemData.state === 0){
          return '开始学习'
        }else if(this.itemData.state === 1){
          return '重新考试'
        }else if(this.itemData.state === 2){
          return '重新考试'
        }else if(this.itemData.state === 3){
          return '开始学习'
        }else if(this.itemData.state === 4){
          return '还未开始'
        }
      }else{
        if( this.itemData.state === 0){
          return '开始考试'
        }else if(this.itemData.state === 1){
          return '重新考试'
        }else if(this.itemData.state === 2){
          return '重新考试'
        }else if(this.itemData.state === 3){
          return '开始学习'
        }else if(this.itemData.state === 4){
          return '还未开始'
        }
      }

耿迪迪's avatar
耿迪迪 committed
94 95 96
    },
  },
  data() {
97 98 99
    return {
      answerOpen:false
    };
耿迪迪's avatar
耿迪迪 committed
100 101
  },
  methods: {
102 103 104 105 106 107
    jj(e) {
      if (e.answer >= e.qualifiedNum) {
        this.fenshu = Math.floor((e.answer / e.topicNum) * 100);
        this.state = 2;
      }
    },
耿迪迪's avatar
耿迪迪 committed
108
    click() {
109 110 111 112
      if(this.itemData.dataKind==='1'){
        this.answerOpen = true;
        return;
      }
耿迪迪's avatar
耿迪迪 committed
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
      const { courseId, userCourseId, state, examinationResult, topicNum } =
        this.itemData;
      // if (!this.yesOrNo) {
        // this.$router.push("myLessons/CheckLesson");

        let fenshu;
        if (examinationResult) {
          fenshu = Math.floor((examinationResult / topicNum) * 100);
        } else {
          fenshu = 0;
        }
        this.$router.push({
          path: "myLessons/CheckLesson",
          query: { courseId, userCourseId, state, fenshu },
        });
128

耿迪迪's avatar
耿迪迪 committed
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
      // } else {
      //   this.$emit("examination", { courseId, userCourseId });
      // }
      // $router.push("myLessons/CheckLesson");
    },
  },
};
</script>
<style lang="scss" scoped>
.item {
  width: 100%;
  height: 100%;
  // background: red;
  overflow: hidden;
  padding-top: 15px;
  padding-left: 18px;
  box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.12);
  border-radius: 5px;
  flex-direction: column;
  position: relative;
  > div {
    font-size: 14px;
  }
  .title {
    color: #606266;
    margin-bottom: 8%;
  }
  .lesson {
    color: #1d84ff;
    text-align: center;
    margin-bottom: 3%;
  }
  .time {
    text-align: center;
    font-size: 12px;
    color: #7b808a;
    margin-bottom: 5%;
  }
  .bottom {
    flex: 1;
    justify-content: center;
    .btn {
      width: 110px;
      height: 40px;
      border-radius: 4px;
      font-size: 14px;
      text-align: center;
      line-height: 40px;
      color: #1d84ff;
      border: 1px solid #a3d3ff;
      background: #e8f4ff;
      font-size: 14;
      cursor: pointer;
      &.again {
        color: #ffffff;
        border: 1px solid #a3d3ff;
        background: #1d84ff 100%;
      }
      &:hover {
        background: rgba(29, 132, 255, 0.5);
        color: #ffffff;
      }
    }
  }
193 194 195 196 197
  .allone{
    display:flex;
    flex-direction:row;
    justify-content:flex-start;
  }
耿迪迪's avatar
耿迪迪 committed
198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216
  .img {
    position: absolute;
    width: 100px;
    height: 20px;
    background: #1d84ff;
    // opacity: .2;
    top: 3%;
    right: -7%;
    text-align: center;
    line-height: 20px;
    font-size: 10px;
    color: #ffffff;
    transform: rotateZ(40deg);
    &.no {
      background: #e2852a;
    }
    &.yes {
      background: #3cc426 !important;
    }
217 218 219 220 221 222
    &.ygq {
      background: red !important;
    }
    &.wks {
      background: yellow !important;
    }
耿迪迪's avatar
耿迪迪 committed
223 224 225
  }
}
</style>