<template>
  <div>
    <a-table :columns="columns" :data-source="dataList">
      <template slot="timeSlot" slot-scope="text, record">
        {{ record.timeSlot }}<a-button @click="handlerGoExam(record)" style="margin-left: 6px;" type="primary" size="small">进入考试</a-button>
      </template>
    </a-table>
  </div>
</template>

<script>
import { reqSimulateTestList } from '@/api/mycourse/index'
export default {
  data () {
    return {
      columns: [
        { dataIndex: 'testName', title: '课程' },
        { dataIndex: 'assessMode', title: '考核方式' },
        { dataIndex: 'testManner', title: '考试方式' },
        { dataIndex: 'submitWay', title: '提交形式' },
        { dataIndex: 'timeSlot', title: '考试时间段', scopedSlots: { customRender: 'timeSlot' } },
        { dataIndex: 'examTime', title: '考试时长' }
      ],
      dataList: [
      ]
    }
  },
  mounted () {
    this.initData()
  },
  methods: {
    initData () {
      const { person } = this.$store.state.user
      reqSimulateTestList({ personId: person.id, projectId: this.$route.query.courseId }).then(res => {
        // console.log('模拟', res)
        this.dataList = res.data
      })
    },
    handlerGoExam (row) {
      this.$router.push({
        path: '/myexamDetail',
        query: { type: 'test', projectId: this.$route.query.courseId }
      })
    }
  }
}
</script>

<style></style>
