<template>
  <div class='courseInfo'>
    <el-form :model="searchList"
             :inline='true'>
      <el-form-item label="课程状态">
        <el-select v-model.trim="searchList.status"
                   clearable>
          <el-option v-for="(item,index) in musicGroupStatus"
                     :key="item.value"
                     :label="item.text"
                     :value="item.value">
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="danger"
                   @click='search'>搜索</el-button>
      </el-form-item>
    </el-form>
    <div class="tableWrap">
      <el-table :data='tableList'
                :header-cell-style="{background:'#EDEEF0',color:'#444'}">
        <el-table-column label="乐团编号"
                         prop="musicGroupId">
        </el-table-column>
        <el-table-column label="乐团名称"
                         prop="musicGroupName">
        </el-table-column>
        <el-table-column label="老师类型"
                         prop="jobType">
          <template slot-scope="scope">
            {{ scope.row.jobNature | jobNature }}
          </template>
        </el-table-column>
        <el-table-column label="乐团职位">
          <template slot-scope="scope">
            {{ scope.row.teacherRole | workType }}
          </template>
        </el-table-column>
        <el-table-column label="执教班级">
          <template slot-scope="scope">
            {{ scope.row.classGroupNames | joinArray }}
          </template>
        </el-table-column>
        <el-table-column label="乐团状态">
          <template slot-scope="scope">
            {{ scope.row.status | musicGroupType }}
          </template>
        </el-table-column>
        <el-table-column label="出勤次数"
                         prop="attendanceNum">
        </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 { getTeacherMusicClass } from '@/api/teacherManager'
import { musicGroupStatus } from '@/utils/searchArray'
import pagination from '@/components/Pagination/index'
import store from '@/store'
export default {
  name: 'courseInfo',
  components: {
    pagination
  },
  data () {
    return {
      tableList: [],
      teacherId: this.$route.query.teacherId,
      organId: null,
      searchList: {
        status: ''
      },
      musicGroupStatus,
      pageInfo: {
        // 分页规则
        limit: 10, // 限制显示条数
        page: 1, // 当前页
        total: 1, // 总条数
        page_size: [10, 20, 40, 50] // 选择限制显示条数
      }
    }
  },
  activated () {
    this.teacherId = this.$route.query.teacherId
    this.getList()
    this.musicGroupStatus = musicGroupStatus
  },
  mounted () {
    this.getList()
    this.musicGroupStatus = musicGroupStatus
  },
  methods: {
    search () {
      this.pageInfo.page = 1;
      this.getList();
    },
    getList () {
      getTeacherMusicClass({
        rows: this.pageInfo.limit,
        page: this.pageInfo.page,
        search: this.teacherId,
        status: this.searchList.status || null
      }).then(res => {
        if (res.code == 200) {
          this.tableList = res.data.rows
          this.pageInfo.total = res.data.total
        }
      })
    }
  }
}
</script>
<style lang="scss" scope>
.courseInfo {
  h4 {
    margin-bottom: 20px;
  }
  .tableMargin {
    margin-top: 20px;
  }
}
</style>