<template>
  <div class='courseInfo'>
    <div class="tableWrap tableMargin">
      <!-- <h4>试听课</h4> -->
      <el-table :data='teamList'
                :header-cell-style="{background:'#EDEEF0',color:'#444'}">
        <el-table-column label="星期"
                         width="180px">
          <template slot-scope="scope">
            {{ scope.row.classDate | formatWeek }}
          </template>
        </el-table-column>
        <el-table-column label="试听安排"
                         prop="startTimes">
        </el-table-column>
        <el-table-column label="试听专业"
                         prop="subjectNames">
        </el-table-column>
      </el-table>
      <pagination :total="pageInfo.total"
                  :page.sync="pageInfo.page"
                  :limit.sync="pageInfo.limit"
                  :page-sizes="pageInfo.page_size"
                  @pagination="getList" />
    </div>
  </div>
</template>
<script>
import { findTeacherDemoGroups } from '@/api/teacherManager'
import pagination from '@/components/Pagination/index'
import store from '@/store'
export default {
  name: 'courseInfo2',
  components: {
    pagination
  },
  data () {
    return {
      teamList: [],
      organId: null,
      teacherId: this.$route.query.teacherId,
      pageInfo: {
        // 分页规则
        limit: 10, // 限制显示条数
        page: 1, // 当前页
        total: 1, // 总条数
        page_size: [10, 20, 40, 50] // 选择限制显示条数
      }
    }
  },
  mounted () {
    this.getList()
  },
  activated () {
    this.teacherId = this.$route.query.teacherId
    this.getList()
  },
  methods: {
    getList () {
      findTeacherDemoGroups({
        rows: this.pageInfo.limit,
        page: this.pageInfo.page,
        teacherId: this.teacherId
      }).then(res => {
        if (res.code == 200) {
          let data = res.data.rows
          data.forEach(item => {
            if (item.startTimes) {
              item.startTimes = item.startTimes.replace(/\s+/g, '-')
            }
          })
          this.teamList = data
          this.pageInfo.total = res.data.total
        }
      })
    }
  }
}
</script>
<style lang="scss" scope>
.courseInfo {
  h4 {
    margin-bottom: 20px;
  }
  .tableMargin {
    margin-top: 20px;
  }
}
</style>