
<template>
  <div class='studentOut'>
    <!-- 搜索类型 -->
    <el-form :inline="true"
             class="searchForm"
             v-model.trim="searchForm">
      <el-form-item>
        <el-input placeholder="课程名称"
                  @keyup.enter.native='onSearch'
                  v-model.trim="searchForm.search"></el-input>
      </el-form-item>
       <el-form-item label="课程状态">
        <el-select v-model.trim="searchForm.groupStatus" clearable>
          <el-option
            v-for="(item,index) in courseGroupStatus"
            :key="index"
            :value="item.value"
            :label="item.label"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button @click="onSearch"
                   type="danger">搜索</el-button>
      </el-form-item>
    </el-form>

    <div class="tableWrap">
      <el-table :header-cell-style="{background:'#EDEEF0',color:'#444'}"
                :data='tableList'>
        <el-table-column label="编号"
                         align='center'
                         prop='id'>
        </el-table-column>
        <el-table-column label="课程组名称"
                         align='center'
                         prop="name">
        </el-table-column>
        <el-table-column label="课程组状态"
                         align='center'>
          <template slot-scope="scope">
            {{ scope.row.status | courseGroup }}
          </template>
        </el-table-column>
        <el-table-column label="老师"
                         align='center'
                         prop="teacherName">
        </el-table-column>
        <el-table-column label="班级人数"
                         align='center'
                         prop="studentNum">
        </el-table-column>

        <el-table-column label="开课时间"
                         align='center'
                         prop="coursesStartDate">
        </el-table-column>
        <el-table-column label="当前课次"
                         align='center'
                         prop="currentClassTimes">
          <template slot-scope="scope">
            {{ scope.row.currentClassTimes }}/{{ scope.row.totalClassTimes }}
          </template>
        </el-table-column>
      </el-table>
      <pagination :total="pageInfo.total"
                  :page.sync="pageInfo.page"
                  :limit.sync="pageInfo.limit"
                  :page-sizes="pageInfo.page_size"
                  @pagination="getCourseList" />

      <!-- <el-dialog :title="dialogTitle"
                 :visible.sync="dialogTableVisible">
        <el-table :data="gridData">
          <el-table-column prop="courseDate"
                           label="时间"
                           align='center'
                           width="150"></el-table-column>
          <el-table-column prop="classGroupName"
                           label="课程名称"
                           align='center'
                           width="200"></el-table-column>
          <el-table-column label="课程类型"
                           align='center'>
            <template slot-scope="scope">
              {{ scope.row.teachMode == 'ONLINE' ? '线上' : '线下' }}
            </template>
          </el-table-column>
          <el-table-column prop="courseStatus"
                           align='center'
                           label="课程状态">
            <template slot-scope="scope">
              {{ scope.row.courseStatus |coursesStatus }}
            </template>
          </el-table-column>
        </el-table>
      </el-dialog> -->
    </div>
  </div>
</template>
<script>
import pagination from '@/components/Pagination/index'
import { courseGroupStatus } from "@/utils/searchArray";
import { findStudentCourseGroupsWithWeb } from '@/api/studentManager'
export default {
  name: 'studentvip',
  components: { pagination },
  data () {
    return {
      searchForm: {
        studentId: null,
        search: null,
        groupStatus:null
      },
      checkIndex: null, // 选中的课程
      dialogTableVisible: false,
      tableList: [],
      courseList: [],
      courseGroupStatus:courseGroupStatus,
      pageInfo: {
        // 分页规则
        limit: 10, // 限制显示条数
        page: 1, // 当前页
        total: 0, // 总条数
        page_size: [10, 20, 40, 50] // 选择限制显示条数
      },
      dialogTitle: '',
      gridData: [],
      userId: ''
    }
  },
  created () {
    this.userId = this.$route.query.userId || null;
  },
  mounted () {
    this.searchForm.studentId = this.$route.query.userId
    this.getCourseList()
  },
  activated() {
    this.userId = this.$route.query.userId || null
    this.searchForm.studentId = this.$route.query.userId
    this.getCourseList()
  },
  methods: {
    // onCheckCourse(item) {
    //   this.checkIndex = item.id
    //   this.getList()
    // },
    getCourseList () {
      let params = this.searchForm
      params.rows = this.pageInfo.limit
      params.page = this.pageInfo.page
      findStudentCourseGroupsWithWeb(params).then(res => {
        if (res.code == 200) {
          this.tableList = res.data.rows
          this.pageInfo.total = res.data.total
        }
      })
    },
    onSearch () {
      this.pageInfo.page = 1
      this.getCourseList()
    }
    // getList() {
    //   findStudentCourses({
    //     vipGroupId: this.checkIndex,
    //     rows: this.pageInfo.limit,
    //     page: this.pageInfo.page
    //   }).then(res => {
    //     if(res.code ==200) {
    //       this.tableList = res.data.rows
    //       this.pageInfo.total = res.data.total
    //     }
    //   })
    // }
  }
}
</script>
<style lang="scss">
.studentOut {
  .topCard {
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    margin-bottom: 30px;
    .cardItem {
      margin-right: 15px;
      width: 300px;
      height: 130px;
      padding: 20px 24px;
      box-shadow: 0px 8px 20px 0px rgba(0, 0, 0, 0.1);
      box-sizing: border-box;
      border-radius: 6px;
      .top {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        margin-bottom: 23px;
        .name {
          font-size: 14px;
          color: #323c47;
          font-weight: 500;
        }
        .type {
          font-size: 14px;
          color: #aaa;
        }
      }
      .bottom {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        text-align: center;
        p {
          font-size: 14px;
          color: #444;
        }
        .title {
          color: #aaa;
          margin-bottom: 8px;
        }
      }
    }
    .cardItem.active {
      background-color: #14928a;
      .name {
        font-size: 14px;
        color: #fff;
        font-weight: 500;
      }
      .type {
        font-size: 14px;
        color: #fff;
      }
      .bottom {
        p {
          color: #fff;
        }
        .title {
          color: #fff;
        }
      }
    }
  }
}
</style>