<template>
  <Row :gutter="30">
    <i-col :xs="24" :sm="24" :md="24" :lg="getCurrentLang()=='tw'?12:24" class="title-part">
      <h2 class="event-title">
        <span class="title-mark" v-if=" eventType=='自主學習' &&from!='hiteach'">
          {{ getCurrentLang()=='tw'?'评量':transTypetoEn(eventType) }}456
        </span>
        <span class="title-mark" v-if=" eventType!='自主學習' &&from=='hiteach'">
          {{ 'T'+this.$store.getters.getItemTitle.eventID.substr(0, 5) }}456
        </span>
        <span
          class="title-mark"
          v-if="eventType!='自主學習' &&from!='hiteach'"
        >评量</span>
        {{ this.$store.getters.getItemTitle.name }}
      </h2>
    </i-col>
    <i-col :xs="24" :sm="24" :md="24" :lg="getCurrentLang()=='tw'?12:24" class="info-part">
      <ul class="base-info" :class="{'base-infoEn':getCurrentLang()=='en'}">
        <li
          v-if="this.$store.getters.getItemTitle.eventType == 'exam' && paper.length !== 0 "
        >
          <svg-icon icon-class="subject" class="base-info-icon" />{{ $t('studentWeb.baseInfo.subject')}}
          <span class="base-info-text">{{paper.length > 1? '综合科目':paper[0].subject.name }}</span>
          <span class="base-info-text" v-if="getCurrentLang()=='en'">{{ transSubjecttoEn(this.$store.getters.getItemTitle.eventSubject) }}</span>
        </li>

        <!--<li>
          <svg-icon icon-class="teacher" class="base-info-icon" />{{ $t('studentWeb.baseInfo.teacher')}}
          <span class="base-info-text">{{ this.$store.getters.getItemTitle.teacher }}</span>
        </li>-->

        <li>
          <svg-icon icon-class="time" class="base-info-icon" />

          <!--<span v-if="from == '通知' || from == 'hiteach'">
            {{$t('studentWeb.baseInfo.postTime')}}
          </span>-->
          <span>{{ !eventType ?  $t('studentWeb.baseInfo.period') :  $t('studentWeb.baseInfo.postTime') }}</span>







          <span class="base-info-text" v-if="from != '通知'&&from != 'hiteach'">
              <span v-if="this.$store.getters.getItemTitle.eventType = 'exam'">
                  {{ !eventType ? dateFormat(this.$store.getters.getItemTitle.startTime) + "～" : ""}}
              </span>
              {{ dateFormat(this.$store.getters.getItemTitle.endTime) }}
              <!--<span v-if="dateFormat(this.$store.getters.getItemTitle.endTime)>='2020.12.10'&& !eventType">{{$t('studentWeb.baseInfo.Closed')}}</span>-->
          </span>




          <span
            class="base-info-text"
            v-if="from == '通知'||from == 'hiteach'"
          >{{ this.$store.getters.getItemTitle.endTime + " 14:20" }}54345</span>
        </li>
        <!--<li v-if=" from == 'hiteach'">
           <svg-icon icon-class="time" class="base-info-icon" />{{$t('studentWeb.baseInfo.classTime')}}:
          <span class="base-info-text">{{ this.$store.getters.getItemTitle.endTime }}</span>
        </li>-->
        <!--<li v-if="finishedCondition && !eventType && from != '通知'&&from!='hiteach'">
           <svg-icon icon-class="done" class="base-info-icon" />
          <span class="base-info-text">{{ $t('studentWeb.baseInfo.Fineshed')}}</span>
        </li>
        <li v-if="unfinishedCondition && !eventType && from != '通知'&&from!='hiteach'">
           <svg-icon icon-class="undone" class="base-info-icon" />
          <span class="base-info-text">{{ $t('studentWeb.baseInfo.unFinished')}}</span>
        </li>-->
      </ul>
    </i-col>
  </Row>
</template>

<script>
export default {
  name: "EventBasicInfo",
        props: [
            "eventType", "from",
            "paper"
        ],

  computed: {
    finishedCondition: function () {
      return (
        this.$store.getters.getItemTitle.isDone ||
        this.$store.getters.getFinishedItem.includes(
          this.$store.getters.getItemTitle.eventID
        ) == true
      );
    },
    unfinishedCondition: function () {
      return (
        !this.$store.getters.getItemTitle.isDone &&
        this.$store.getters.getFinishedItem.includes(
          this.$store.getters.getItemTitle.eventID
        ) == false
      );
    },
        },
        mounted() {
        },
        methods: {
            dateFormat(timestamp) {
                var date = new Date(timestamp)
                var Y = date.getFullYear() + '-'
                var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-'
                var D = date.getDate() + ' '
                return Y + M + D;
            },
    getCurrentLang() {
      return localStorage.getItem('lang');
    },
     transTypetoEn(type) {
      if (type == "投票") return "Vote";
      else if (type == "評量") return "Exam";
      else if (type == "作業") return "Homework";
      else if (type == "課前預習") return "Preview";
      else if (type == "公告") return "Billboard";
      else if (type == "教師私訊") return "Message";
      else if(type == "自主學習") return "Self-study";
      else if (type == "Hiteach電子筆記") return "HiTeach Note";
    },
    transSubjecttoEn(type){
      if (type == "國文") return "Chinese";
      else if (type == "英文") return "English";
      else if (type == "數學") return "Math";
      else if (type == "綜合學科") return "Comprehensive";
    }
  },
};
</script>

<style></style>
