<style>
  .OtherCourseNum {
    display: inline-block;
    width: 25px;
    height: 25px;
    text-align: center;
    line-height: 25px;
    border: 1px solid #2961FE;
    border-radius: 50%;
    cursor: pointer;
    color: #2961FE;
  }

  .OCourseTable {
    width: 400px;
    text-align: center;
  }

  .OCourseTable tr td {
    height: 40px;
  }

  .OCourseTable tr th {
    height: 40px;
    background-color: rgb(238, 238, 239);
  }

</style>
<template>
  <div class="page-body">
    <div class="page-search row items-center">
      <div class="col row wrap q-mr-lg q-col-gutter-md">
        <div class="col-3">
          <q-input @change="getClassList" clearable standout="bg-primary text-white" v-model="msg.ClassName"
            label="班级名称" @clear="getClassList" maxlength="20" />
        </div>
        <div class="col-3">
          <q-select @input="getClassList" standout="bg-primary text-white" option-value="Id" option-label="Name"
            v-model="msg.ClassStatus" :options="classStatusList" emit-value map-options label="班级状态" />
        </div>
        <div class="col-3">
          <q-select @input="getClassList" standout="bg-primary text-white" v-model="msg.CourseSubject"
            :options="CourseSubjectList" option-label="SubjectName" option-value="Id" emit-value map-options label="所属科目"
            clearable />
        </div>
        <div class="col-3">
          <q-input @change="getClassList" clearable standout="bg-primary text-white" v-model="msg.CourseName"
            label="学习课程" @clear="getClassList" maxlength="20" />
        </div>
        <div class="col-3">
          <q-select @input="getClassList" standout="bg-primary text-white" option-value="SId" option-label="SName"
            v-model="msg.School_Id" :options="schoolList" emit-value map-options label="关联校区" />
        </div>
      </div>
    </div>
    <div class="page-content">
      <classlist :data="data" :authObj="authObj" :loading="loading" @success="refreshPage"></classlist>
      <q-pagination class="full-width justify-end" v-model="msg.pageIndex" color="primary" :max="pageCount"
        :input="true" @input="changePage" />
    </div>
  </div>
</template>
<script>
  import {
    queryClassStatusList,
  } from '../../api/course/class';
  import {
    GetClassPageList
  } from '../../api/teacher/index';
  import {
    getCourseSubject
  } from "../../api/course/index";
  //获取校区列表
  import {
    getSchoolDropdown,
  } from '../../api/school/index';
  import classlist from '../../components/course/classlist';
  export default {
    meta: {
      title: "我的班级"
    },
    components: {
      classlist,
    },
    data() {
      return {
        data: [],
        msg: {
          pageIndex: 1,
          pageSize: 12,
          rowsPerPage: 12,
          ClassName: '', //班级名称
          ClassStatus: 0, //班级状态
          TeacherName: '', //带班老师
          Teacher_Id: 0,
          CourseName: '', //学习课程
          School_Id: -1, //关联校区
          CourseSubject: "", //所属科目
        },
        //班级状态
        classStatusList: [],
        //关联校区列表
        schoolList: [],
        pageCount: 0,
        //权限判断
        authObj: {
          isShowLessonCost: true, //显示月度课耗
        },
        loading: false,
        CourseSubjectList: [], //所属科目
      }
    },
    created() {
      if (this.$route.query && this.$route.query.ClassName) {
        this.msg.ClassName = decodeURI(this.$route.query.ClassName)
      }
      let userInfo = this.getLocalStorage();
      this.msg.Teacher_Id = userInfo.AccountId;
      this.getClassStatus();
      this.getSchool();
      this.queryCourseSubject()
    },
    mounted() {
      this.getClassList();
    },
    methods: {
      queryCourseSubject() {
        getCourseSubject({}).then(res => {
          if (res.Code == 1) {
            this.CourseSubjectList = res.Data;
          }
        })
      },
      //获取校区列表
      getSchool() {
        getSchoolDropdown({}).then(res => {
          if (res.Code == 1) {
            var tempArray = res.Data;
            if (!tempArray) {
              tempArray = [];
            }
            tempArray.unshift({
              SId: -1,
              SName: "不限"
            })
            this.schoolList = tempArray;
          }
        })
      },
      //获取班级状态列表
      getClassStatus() {
        queryClassStatusList({}).then(res => {
          if (res.Code == 1) {
            this.classStatusList = res.Data;
          }
        })
      },
      //翻页
      changePage(val) {
        this.msg.pageIndex = val;
        this.getClassList()
      },
      //获取菜单分页列表
      getClassList() {
        this.loading = true;
        this.data = [];
        GetClassPageList(this.msg).then(res => {
          this.loading = false;
          this.data = res.Data.PageData;
          this.pageCount = res.Data.PageCount;
        }).catch(() => {
          this.loading = false
        })
      },
      //刷新页面
      refreshPage() {
        this.getClassList();
      },
    }
  }

</script>
<style lang="sass">
  @import url('~assets/css/table.sass')

</style>
