<template>
  <component ref="curriculum" :is="activeName" />
</template>

<script>
import Mine from './components/mine'
import Video from './components/video'
import Pdf from './components/pdf'
import Courseware from './components/courseware'
import Question from '../../question/index'
import CurriculumStudy from '../study/components/edit'
import CurriculumExam from '../exam/components/edit'
import StageExam from '../../stage/exam/components/edit'
import Info from './components/info'
import Edit from './components/edit'
export default {
  components: {
    Mine,
    Video,
    Pdf,
    Courseware,
    Question,
    CurriculumStudy,
    CurriculumExam,
    StageExam,
    Edit,
    Info
  },
  data() {
    return {
      activeName: 'Mine',
      CURRICULUM_ID: '',
      loginUserId: sessionStorage.getItem('user').USER_ID,
      STUDYTASK_ID: '',
      STAGEEXAMPAPER_ID: '',
      COURSESTUDENTRELATION_ID: '',
      STAGESTUDENTRELATION_ID: '',
      videoMoudel: {},
      pdfMoudel: {}
    }
  },
  beforeRouteLeave(to, from, next) {
    if (this.activeName == 'CurriculumExam') {
      if (!this.$refs.curriculum.isDisabled) {
        this.$confirm('课程考试已开始，确定要退出考试么？', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          next()
        }).catch(() => {
        })
      } else {
        next()
      }
    } else {
      next()
    }
  }
}
</script>

<style scoped>

</style>
