<template>
  <div class="app-container" style="width: 80%;">
    <el-descriptions title="基本信息" :column="2" border style="color: #6379bb;padding-left: 20%">
      <el-descriptions-item label="当前模式">考试</el-descriptions-item>
      <el-descriptions-item label="模拟类型" >
        <template>
          <dict-tag class="text-navy" :options="dict.type.sim_sim_type" :value="simType"/>
        </template>
      </el-descriptions-item>
      <el-descriptions-item label="模拟状态">
        <template>
          <dict-tag class="text-navy" :options="dict.type.sim_sim_state" :value="simStateText"/>
        </template>
      </el-descriptions-item>
      <el-descriptions-item label="考试学员">{{nickName}}</el-descriptions-item>
      <el-descriptions-item label="学员座号">{{simNum}}</el-descriptions-item>
    </el-descriptions>

    <el-descriptions title="注意事项" :column="1" border style="margin-top: 2%;color: #6379bb;padding-left: 20%"></el-descriptions>
    <div class="shixiang">
        <div>1.遵守考场纪律‌</div>
        <div>2.合理安排时间</div>
        <!-- <div>3.注意事项</div> -->
    </div>

    <el-form ref="elForm" size="medium" label-width="100px" style="margin-top: 10%;">
        <el-form-item size="large">
            <el-button type="primary" :class="{ isDisabled }" @click="submitForm" :disabled="isDisabled">开始考试</el-button>
        </el-form-item>
    </el-form>

  </div>
</template>

<style>
.el-form-item__content{
  /* margin-top: 15%; */
  text-align: center;
}
.shixiang{
    color: rgb(192, 74, 84);
    height: 30px;
    line-height: 30px;
    padding-left: 22%
}
</style>

<script>
import { examStudentPrepare,examStudentStart } from "@/api/sim/exam";
export default {
  name: "exam",
  dicts: ['sim_sim_type','sim_sim_state'],
  data() {
    return {
      // 遮罩层
      loading: true,
      simStateText:null,
      simType:null,
      simNum:null,
      nickName:null,
      isDisabled: true, // 初始化按钮为不可用状态
      examId:'',
    };
  },
  created() {
    this.getList(this.isDisabled);
  },
  computed: {
  },
  mounted() {
    this.examId = this.$route.params.examId;
    let timer = setInterval(() => {
      console.log(this.isDisabled)
      if (this.isDisabled == true) {
        this.getList();
      }
    }, 5000);
  },
  methods: {
    getList() {
      this.loading = true;
      console.log(this.examId)
      console.log('this.examId')
      const examId = this.$route.params.examId;
      examStudentPrepare(examId).then(response => {
        this.loading = false;
        this.simType = response.data.realExamCollection.simType;
        this.simNum = response.data.sim.simNum;
        this.nickName = response.data.student.nickName;
        this.simStateText = response.data.sim.simState;
        if(response.data.next== true){
          this.isDisabled = false;
        }
        // this.isDisabled = false; 
      });
    },
    /** 提交按钮 */
    submitForm() {
      const examId = this.$route.params.examId;
      examStudentStart(examId).then(response => {
        if(response.code='200'){
          this.$router.push("/people/exam-exam2/examid/"+examId);
        }
      });
      
    }
  },
};
</script>