<style>
  .Sysuser_Date .el-input__inner {
    background-color: transparent;
    width: 100%;
    border: none;
  }

  .Sysuser_Date .el-range-input {
    background-color: transparent;
  }
</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 @keyup.enter="resetSearch" @clear="resetSearch" dense clearable filled v-model="msg.StuName" label="昵称" maxlength="20" />
        </div>
        <div class="col-3" >
          <q-select @input="changeCourse" dense filled v-model="msg.CourseId" class="col-6" option-label="CourseName"
            option-value="CourseId" use-input :options="CourseList" @filter="filterCourse" emit-value map-options
            label="课程" clearable>
            <template v-slot:no-option>
              <q-item>
                <q-item-section class="text-grey">
                  未找到相关数据
                </q-item-section>
              </q-item>
            </template>
          </q-select>
        </div>
        
      </div>
    </div>
    <div class="page-content">
      <stulist :dataList="data" @success="refreshPage" :loading="loading" ref="stuList" :authObj="AuthObj"
        :queryMsg="msg" :Count="AuthObj.Count">
      </stulist>
      <div class="row" style="justify-content: flex-end;padding: 5px 20px">
        <q-pagination v-model="msg.pageIndex" :max="pageCount" @input="changePage" class="full-width justify-end"
          color="primary" :input="true">
        </q-pagination>
      </div>
    </div>
  </div>
</template>
<script>
  import {
    GetStudentTypeList,
    GetStudentCoursePage 
  } from '../../api/school/index'

  import {
    queryEmployee
  } from '../../api/users/user'
  import {
    resetPassword
  } from '../../api/users/user.js'
  import {
    GetStudentAdvisorConfigList
  } from "../../api/customerstudent/customerstudent";
  import {
    queryCourseDropdownList
  } from "../../api/course/index";
  import stulist from '../../components/school/student/stuCourselist'
  import {
    mapGetters
  } from "vuex";

  export default {
    meta: {
      title: "客户管理"
    },
    components: {
      stulist
    },
    data() {
      return {
        currentUrl: "",
        data: [],
        CourseList: [],
        AllCourseList:[],
        loading: true,
        msg: {
          pageIndex: 1,
          pageSize: 12,
          rowsPerPage: 12,
          CourseId: 0, //课程id
          StuName: "",//学生
          ClassScrollType:2,
        },
       
        pageCount: 0,
     
        AuthObj: {
          isShowDownload: true,
          Count: 0
        },
      }
    },
    computed: {
      ...mapGetters(["userInfo"])
    },
    created() {
    
      
    },
    mounted() {
      this.currentUrl = this.$route.path;
     
      this.getCourseList();
      this.getStudent()
    },
    methods: {
      changeCourse(val) {
        this.msg.CourseId = val;
        this.getStudent();
        this.resetSearch();
      },
       //筛选课程
       filterCourse(val, update) {
        update(() => {
          if (val === "") {
            this.CourseList = JSON.parse(JSON.stringify(this.AllCourseList));
          } else {
            const needle = val.toLowerCase();
            this.CourseList = this.AllCourseList.filter(
              v => v.CourseName.toLowerCase().indexOf(needle) > -1
            );
          }
        });
      },
      resetSearch() {
        this.msg.pageIndex = 1;
       
        this.getStudent()
      },
         //获取课程
         getCourseList() {
        queryCourseDropdownList({}).then(res => {
          if (res.Code == 1) {
            var tempArray = res.Data;
            if (!tempArray) {
              tempArray = [];
            }
            tempArray.unshift({
              CourseId: 0,
              CourseName: "不限"
            });
            this.CourseList = tempArray;
            this.AllCourseList = tempArray;
          }
        });
      },
      changePage(val) {
        this.msg.pageIndex = val;
        this.getStudent();
      },
      getStudent() {
       
        this.loading = true;
        GetStudentCoursePage(this.msg).then(res => {
          this.loading = false;
          this.data = res.Data.PageData
          this.pageCount = res.Data.PageCount
          this.AuthObj.Count = res.Data.Count
         
        }).catch(() => {
          this.loading = false
        })
      },
      refreshPage() {
        this.getStudent()
      },
    },
  }
</script>
<style lang="sass">
  @import url('~assets/css/table.sass')
</style>
