<template>
  <div class='courseInfo'>
    <div class="tableWrap tableMargin">
      <el-table :data='teamList'
                :header-cell-style="{background:'#EDEEF0',color:'#444'}">
        <el-table-column label="VIP编号"
                         prop="id">
        </el-table-column>
        <el-table-column label="VIP课名称"
                         prop="name">
        </el-table-column>
        <el-table-column label="VIP课状态">
          <template slot-scope="scope">
            {{ scope.row.status | formatterStatus}}
          </template>
        </el-table-column>
        <el-table-column label="班级人数"
                         prop="studentNum">
        </el-table-column>
        <el-table-column label="课程单价">
          <template slot-scope="scope">
            线上：{{ scope.row.onlineClassesUnitPrice }} <br />
            线下：{{ scope.row.offlineClassesUnitPrice }}
          </template>
        </el-table-column>
        <el-table-column label="活动方案"
                         prop="vipGroupActivityName">
        </el-table-column>
        <el-table-column label="当前课次">
          <template slot-scope="scope">
            <p>{{scope.row.currentClassTimes + '/' + scope.row.totalClassTimes}}</p>
          </template>
        </el-table-column>
        <el-table-column label="月均消耗">
          <template slot-scope="scope">
            {{ scope.row.monthConsumeRate }}%
          </template>
        </el-table-column>
        <el-table-column label="开课时间">
          <template slot-scope="scope">
            {{scope.row.courseStartDate | formatterTime}}
          </template>
        </el-table-column>
        <el-table-column label="截止时间">
          <template slot-scope="scope">
            {{ scope.row.coursesExpireDate | formatTimer }}
          </template>
        </el-table-column>
        <el-table-column label="申请时间">
          <template slot-scope="scope">
            {{scope.row.createTime | formatterTime}}
          </template>
        </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 { getTeacherVipClass } from '@/api/teacherManager'
import { getVipList } from '@/api/vipSeting'
import pagination from '@/components/Pagination/index'
import store from '@/store'
export default {
  components: {
    pagination
  },
  data () {
    return {
      teamList: [],
      organId: store.getters.organ,
      teacherId: this.$route.query.teacherId,
      pageInfo: {
        // 分页规则
        limit: 10, // 限制显示条数
        page: 1, // 当前页
        total: 1, // 总条数
        page_size: [10, 20, 40, 50] // 选择限制显示条数
      }
    }
  },
  mounted () {
    this.getList()
  },
  methods: {
    getList () {
      getVipList({
        rows: this.pageInfo.limit,
        page: this.pageInfo.page,
        teacherId: this.teacherId
      }).then(res => {
        if (res.code == 200) {
          this.teamList = res.data.rows
          this.pageInfo.total = res.data.total
        }
      })
    }
  },
  filters: {
    formatterTime (val) {
      let result
      if (val) {
        result = val.split(' ')[0];
      } else {
        result = ''
      }
      return result
    },
    formatterStatus (val) {
      let arr = ["未开始", "报名中", "报名结束", '取消', '停止']
      return arr[val];
    }
  }
}
</script>
<style lang="scss" scope>
.courseInfo {
  h4 {
    margin-bottom: 20px;
  }
  .tableMargin {
    margin-top: 20px;
  }
}
</style>