LearnItem.vue 5.98 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
    <div class="title" style="text-align: center">{{ itemData.courseType||'-' }}</div>
12 13 14 15 16
    <div class="allone" style="position:relative">
      <!--<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"/>-->
      <div class="content">{{itemData.dataKind==0?"培训课程":"随机考试"}}</div>
      <div class="border"></div>
17
      <div class="lesson zzz" style="width: 75%" :title="itemData.courseName">  {{ itemData.courseName }}</div>
18
    </div>
耿迪迪's avatar
耿迪迪 committed
19 20
    <div class="time">发布时间:{{ itemData.createTime }}</div>
    <div class="bottom flex">
21
      <div v-if="itemData.state!=4 && !(itemData.state===3 && itemData.dataKind==='1')"  @click="click" class="btn" :class="{ again: yesOrNo }">
22
        {{ yesOrNo  }}
耿迪迪's avatar
耿迪迪 committed
23 24 25 26 27 28 29
      </div>
    </div>
    <div
      class="img"
      :class="{
        no: itemData.state === 1,
        yes: itemData.state === 2,
30 31
        ygq:itemData.state === 3,
        wks:itemData.state === 4,
耿迪迪's avatar
耿迪迪 committed
32 33 34 35
      }"
    >
      {{ state[itemData.state] }}
    </div>
36 37 38 39
    <AnswerLesson
      v-if="answerOpen"
      :courseId="itemData.courseId"
      :userCourseId="itemData.userCourseId"
40
      :courseName = "itemData.courseName"
41 42 43
      :visible.sync="answerOpen"
      @jj="jj"
    />
耿迪迪's avatar
耿迪迪 committed
44 45 46 47
  </div>
</template>

<script>
48
  import AnswerLesson from "./AnswerLesson";
耿迪迪's avatar
耿迪迪 committed
49 50
export default {
  name: "",
51 52 53
  components: {
    AnswerLesson,
  },
耿迪迪's avatar
耿迪迪 committed
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
  props: {
    itemData: {
      type: Object,
      default: () => {
        return {
          again: 2,
        };
      },
    },
    state: {
      type: Object,
    },
  },
  computed: {
    yesOrNo() {
69 70 71 72 73
      console.log(this.itemData)
      if(this.itemData.dataKind==="0"){
        if( this.itemData.state === 0){
          return '开始学习'
        }else if(this.itemData.state === 1){
74
          return '查看课程'
75
        }else if(this.itemData.state === 2){
76
          return '查看课程'
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
        }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
96 97 98
    },
  },
  data() {
99 100 101
    return {
      answerOpen:false
    };
耿迪迪's avatar
耿迪迪 committed
102 103
  },
  methods: {
104 105 106 107 108 109
    jj(e) {
      if (e.answer >= e.qualifiedNum) {
        this.fenshu = Math.floor((e.answer / e.topicNum) * 100);
        this.state = 2;
      }
    },
耿迪迪's avatar
耿迪迪 committed
110
    click() {
111 112 113 114
      if(this.itemData.dataKind==='1'){
        this.answerOpen = true;
        return;
      }
耿迪迪's avatar
耿迪迪 committed
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
      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 },
        });
130

耿迪迪's avatar
耿迪迪 committed
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 193 194
      // } 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;
      }
    }
  }
195 196 197 198 199
  .allone{
    display:flex;
    flex-direction:row;
    justify-content:flex-start;
  }
耿迪迪's avatar
耿迪迪 committed
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218
  .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;
    }
219 220 221 222 223 224
    &.ygq {
      background: red !important;
    }
    &.wks {
      background: yellow !important;
    }
耿迪迪's avatar
耿迪迪 committed
225 226
  }
}
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249
.border {
  width: 0;
  height: 0;
  border: 10px solid;
  border-color: transparent transparent transparent #1d84ff;
}
.border:after {
  content: '';
  border-style: solid;
  border-width: 10px;
  border-color: transparent transparent transparent  #fff;
  position: absolute;
  top: 0px;
  left: 49px;
}
  .content{
    border: 1.5px solid #1d84ff;
    height: 20px;
    font-size: 10px;
    color: #1d84ff;
    line-height: 18px;
  }

耿迪迪's avatar
耿迪迪 committed
250
</style>