<!--  -->
<template>
  <div class="m-container">
    <h2>
      <div class="squrt"></div>
      课表列表
    </h2>
    <div class="m-core">
      <save-form
        :inline="true"
        :model="searchForm"
        @submit="search"
        @reset="onReSet"
        ref="searchForm"
      >
        <!-- <el-form-item prop="organId">
          <el-select
            class="multiple"
            v-model.trim="searchForm.organId"
            filterable
            clearable
            placeholder="请选择分部"
          >
            <el-option
              v-for="(item, index) in selects.branchs"
              :key="index"
              :label="item.name"
              :value="item.id"
            ></el-option>
          </el-select>
        </el-form-item> -->

        <el-form-item prop="teacherIdList">
          <remote-search
            :commit="'setTeachers'"
            v-model="searchForm.teacherIdList"
            :demissionFlag="true"
            :isForzenWithQueryCondition="true"
          />
        </el-form-item>
        <el-form-item prop="courseStatus">
          <el-select
            v-model.trim="searchForm.courseStatus"
            clearable
            filterable
            placeholder="课程状态"
          >
            <el-option label="未开始" value="NOT_START"></el-option>
            <el-option label="进行中" value="UNDERWAY"></el-option>
            <el-option label="已结束" value="OVER"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item  prop="teachMode">
          <el-select
            style="width: 180px !important"
            v-model.trim="searchForm.teachMode"
            clearable
            filterable
            placeholder="教学模式"
          >
            <el-option label="线上课" value="ONLINE"></el-option>
            <el-option label="线下课" value="OFFLINE"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item prop="timer">
          <el-date-picker
            v-model.trim="searchForm.timer"
            type="daterange"
            value-format="yyyy-MM-dd"
            range-separator="-"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            :picker-options="{
              firstDayOfWeek: 1,
            }"
          ></el-date-picker>
        </el-form-item>
        <el-form-item>
          <el-button native-type="submit" type="primary">搜索</el-button>
          <el-button native-type="reset" type="danger">重置</el-button>
        </el-form-item>
      </save-form>
      <div class="tableWrap">
        <el-table
          style="width: 100%"
          :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
          :data="tableList"
        >
          <el-table-column
            align="center"
            prop="id"
            label="课程名称"
          >
            <template slot-scope="scope">
              <copy-text>{{ scope.row.courseName }}</copy-text>
            </template>
          </el-table-column>
          <!-- <el-table-column
            align="center"
            prop="organName"
            label="分部"
          >
            <template slot-scope="scope">
              <copy-text>{{ scope.row.organName }}</copy-text>
            </template>
          </el-table-column> -->
          <el-table-column
            align="center"
            prop="teacherName"
            label="老师姓名"
          >
            <template slot-scope="scope">
              <copy-text>{{ scope.row.teacherName }}</copy-text>
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="courseType"
            label="课程类型"
          >
            <template slot-scope="scope">
              <copy-text>{{ scope.row.courseType | coursesType }}</copy-text>
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="phone"
            label="教学模式"
          >
            <template slot-scope="scope">
              {{ scope.row.teachMode | teachMode }}
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="courseStatus"
            label="课程状态"
          >
          <template slot-scope="scope">
              {{ scope.row.courseStatus  | coursesStatus }}
            </template>
          </el-table-column>
          <el-table-column
            align="center"
            prop="studentId"
            label="课程时间"
          >
           <template slot-scope="scope">
            <div>
              {{ scope.row.classDate|formatTimer}} {{scope.row.classTime}}
            </div>
          </template>
          </el-table-column>
        </el-table>
        <pagination
          sync
          :total.sync="pageInfo.total"
          :page.sync="pageInfo.page"
          :limit.sync="pageInfo.limit"
          :page-sizes="pageInfo.page_size"
          @pagination="getList"
        />
      </div>
    </div>
  </div>
</template>

<script>
import axios from "axios";
import { getToken } from "@/utils/auth";
import pagination from "@/components/Pagination/index";
import { getCourseSchedule } from "@/api/businessManager";
import { getInstrument } from "@/api/buildTeam";
import {  getTimes } from "@/utils";
import load from "@/utils/loading";
export default {
  components: { pagination },
  data() {
    return {
      searchForm: {
        search: null,
        organId:'',
        teacherIdList:'',
        timer:[],
        courseStatus:'',
        teachMode:''
      },
      soundLists: [],
      organList: [],
      tableList:[],
      pageInfo: {
        // 分页规则
        limit: 10, // 限制显示条数
        page: 1, // 当前页
        total: 0, // 总条数
        page_size: [10, 20, 40, 50], // 选择限制显示条数
      },
      categoryList:[]
    };
  },
  //生命周期 - 创建完成（可以访问当前this实例）
  created() {},
  //生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {
    // 获取分部
    this.$store.dispatch("setBranchs");
    this.init();
    this.getList()
  },
  methods: {
    init() {
    },
   search() {
      this.pageInfo.page = 1;
      this.getList()
    },
    onReSet() {
      this.pageInfo.page = 1;
    this.searchForm= {
        search: null,
        organId:'',
        teacherIdList:'',
        timer:[],
        courseStatus:'',
        teachMode:''
      }
      this.getList()
    },
    async getList() {
     try{
      const {  timer, ...rest } = this.searchForm;
      let obj = {
        page: this.pageInfo.page,
        rows: this.pageInfo.limit,
        ...rest,
        ...getTimes(timer, ["createStartDate", "createEndDate"]),
      }
       const res = await getCourseSchedule(obj)
        this.tableList = res.data.rows
        this.pageInfo.total = res.data.total
     }catch(e){
      console.log(e)
     }

    },
    lookRepair(row){
      this.$router.push({path:'/otherManager/repairList',query:{hasExemptionAmount:'1',studentInstrumentId:row.id}})
    }
  },
};
</script>
<style lang='scss' scoped>
</style>
