<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="getList" clearable standout="bg-primary text-white" v-model="msg.className"
            label="班级名称" />
        </div>
        <div class="col-3">
          <q-select @input="getList" 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-input @change="getList" clearable standout="bg-primary text-white" v-model="msg.teacher"
            label="带班老师" />
        </div>
        <div class="col-3">
          <q-input @change="getList" clearable standout="bg-primary text-white" v-model="msg.LearningCourses"
            label="学习课程" />
        </div>
        <div class="col-3">
          <q-select @input="getList" standout="bg-primary text-white" option-value="Id"
          option-label="Name" v-model="msg.guanlianxiaoqu" :options="schoolList"
            emit-value map-options label="关联校区" />
        </div>
      </div>
      <div class="page-option">
        <q-btn color="accent" class="q-mr-md" icon="add" label="新增班级" @click="EditCourse(null)" />
      </div>
    </div>
    <div class="page-content">
      <q-table :pagination="msg" :loading="loading" no-data-label="暂无相关数据" flat class="sticky-tow-column-table"
        separator="none" title="班级信息" :data="data" :columns="columns" row-key="name">
        <!-- <template v-slot:body-cell-CoverImg="props">
          <q-td :props="props">
            <q-avatar square size="100px">
              <img :src="props.value" />
            </q-avatar>
          </q-td>
        </template>
        <template v-slot:body-cell-CourseIntro="props">
          <q-td :props="props">
            <span v-html="props.value"></span>
          </q-td>
        </template>
        <template v-slot:body-cell-Status="props">
          <q-td :props="props">
            <q-badge :color="props.value==1?'negative':'primary'" :label="props.value==0?'正常':'禁用'" />
          </q-td>
        </template>
        <template v-slot:bottom>
          <q-pagination class="full-width justify-end" v-model="msg.pageIndex" color="primary" :max="pageCount"
            :input="true" @input="changePage" />
        </template> -->
        <template v-slot:body-cell-optioned="props">
          <q-td :props="props">
            <q-btn flat size="xs" icon="edit" color="accent" style="font-weight:400" label="订单中心"></q-btn>
            <q-btn flat size="xs" icon="edit" color="accent" style="font-weight:400" label="收支明细"></q-btn>
            <q-btn flat size="xs" icon="edit" color="accent" style="font-weight:400" label="编辑"
              @click="EditCourse()" />
          </q-td>
        </template>
      </q-table>
      <class-form v-if="isShowClassForm" :save-obj="classObjOption" @close="closeClassSaveForm"
        @success="refreshPage">
      </class-form>
    </div>
  </div>
</template>
<script>
//   import {
//     queryCoursePage,
//     queryCourseCategoryTree,
//   } from '../../api/course/index'
  import classForm from '../../components/course/class-form'
  export default {
    meta: {
      title: "班级管理"
    },
    components: {
      classForm
    },
    data() {
      return {
        columns: [{
            name: 'CourseId',
            label: '班级名称',
            field: 'CourseId',
            align: 'left'
          },
          {
            name: 'CourseName',
            required: true,
            label: '校区',
            align: 'left',
          },
          {
            name: 'CateName',
            label: '课程',
            field: 'CateName',
            align: 'left'
          },
          {
            name: 'CoverImg',
            label: '带班老师',
            field: 'CoverImg',
            align: 'left'
          },
          {
            name: 'CourseIntro',
            label: '招生/报名',
            field: 'CourseIntro',
            align: 'left'
          },
          {
            name: 'CreateByName',
            label: '开班时间',
            field: 'CreateByName',
            align: 'left'
          },
          {
            name: 'CreateTimeStr',
            label: '课程进度',
            field: 'CreateTimeStr',
            align: 'left'
          },
          {
            name: 'Status',
            label: '状态',
            align: 'left',
            field: 'Status'
          },
          {
            name: 'optioned',
            label: '操作',
            field: 'CourseId'
          }
        ],
        data: [],
        loading: false,
        isShowClassForm:false,
        msg: {
          pageIndex: 1,
          pageSize: 12,
          className:'', //班级名称
          classStatus:'', //班级状态
          teacher:'', //带班老师
          LearningCourses:'', //学习课程
          guanlianxiaoqu:0, //关联校区  
        },
        //班级状态
        classStatusList:[{
            Id:1,
            Name:'状态1'
        }],
        //关联校区
        schoolList:[{
            Id:1,
            Name:'清华大学'
        }],
        pageCount: 0,
        classObjOption:null,
      }
    },
    mounted() {
      this.getList();
    },
    methods: {
      //翻页
      changePage(val) {
        this.msg.pageIndex = val;
        this.getcourselist()
      },
      //获取菜单分页列表
      getList() {
        // this.loading = true;
        // queryCoursePage(this.msg).then(res => {
        //   this.loading = false
        //   this.data = res.Data.PageData
        //   this.pageCount = res.Data.PageCount
        // }).catch(() => {
        //   this.loading = false
        // })
      },
      //刷新页面
      refreshPage() {
        this.isShowClassForm = false;
        this.getcourselist();
      },
      //新增修改菜单
      EditCourse(obj) {
        // if (obj) {
        //   this.classObjOption = obj
        // } else {
        //   this.classObjOption = null
        // }
         this.isShowClassForm = true
      },
      //关闭弹窗
      closeClassSaveForm() {
        // this.isShowClassForm = false
      }
    }
  }

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

</style>
