<template>
  <div>
    <el-table
      style="width: 100%"
      :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
      :data="tableList"
    >
      <el-table-column
        align="center"
        prop="id"
        label="课程编号"
      ></el-table-column>
      <el-table-column
        align="center"
        prop="name"
        label="服务课程"
      ></el-table-column>
      <el-table-column
        align="center"
        prop="groupType"
        label="课程类型"
      >
      <template slot-scope="scope">
        <div>
          {{scope.row.groupType | coursesType}}
        </div>
      </template>
      </el-table-column>
      <el-table-column
        align="center"
        prop="studentNum"
        label="学员数量"
      ></el-table-column>
      <el-table-column
        align="center"
        prop="subjectName"
        label="专业"
      ></el-table-column>
      <el-table-column
        align="center"
        prop="status"
        label="课程状态"
      >
      <template slot-scope="scope">
        <div>
          {{scope.row.status | coursesStatus}}
        </div>
      </template>
      </el-table-column>
      <el-table-column
        align="center"
        prop="homeworkExist"
        label="是否布置作业"
      >
      <template slot-scope="scope">
        <div>
          {{scope.row.homeworkExist?'是':'否'}}
        </div>
      </template>
      </el-table-column>
    </el-table>
    <pagination
      :total.sync="rules.total"
      :page.sync="rules.page"
      :limit.sync="rules.limit"
      :page-sizes="rules.page_size"
      @pagination="getList"
    />
  </div>
</template>
<script>
import pagination from "@/components/Pagination/index";
import { getTeacherServeHomeworkDetail } from "../api";
export default {
  components: { pagination },
  props: ["detail"],
  data() {
    return {
      tableList: [],
      rules: {
        // 分页规则
        limit: 10, // 限制显示条数
        page: 1, // 当前页
        total: 0, // 总条数
        page_size: [10, 20, 40, 50], // 选择限制显示条数
      },
    };
  },
  mounted() {
    // 获取分部

    this.init();
  },
  methods: {
    init() {
      this.getList();
    },
    async getList() {

      try {
      const dayjs = this.$helpers.dayjs
     const ruselt =  await getTeacherServeHomeworkDetail({
          page: this.rules.page,
          rows: this.rules.limit,
          monday: dayjs(this.detail.monday).format("YYYY-MM-DD"),
          sunday: dayjs(this.detail.sunday).format("YYYY-MM-DD"),
          teacherId:this.detail.teacherId
        });
        this.tableList = ruselt.data.rows
        this.rules.total = ruselt.data.total
      } catch (e) {
        console.log(e)
      }
    },
    search() {
      this.rules.page = 1;
      this.getList();
    },
    onReSet() {},
  },
};
</script>
<style lang="scss" scoped>
</style>
