<template>
  <div>
    <el-table
      style="width: 100%"
      :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
      :data="tableList"
    >
      <el-table-column align="center" prop="studentId" label="事项"
        ><template>
          <div>下校巡查</div>
        </template></el-table-column
      >
      <el-table-column align="center" prop="studentId" label="时间">
        <template slot-scope="scope">
          <div>
            {{ scope.row.planStart }}-{{
              scope.row.planEnd | dayjsFormatMinute
            }}
          </div>
        </template>
      </el-table-column>
      <el-table-column
        align="center"
        prop="cooperationName"
        label="合作单位"
      ></el-table-column>
      <el-table-column
        align="center"
        prop="musicGroupName"
        label="乐团"
      ></el-table-column>
      <el-table-column align="center" prop="studentId" label="是否完成">
        <template slot-scope="scope">
          <div>
            {{ scope.row.status > 0 ? "已完成" : "未完成" }}
          </div>
        </template>
      </el-table-column>
      <el-table-column align="center" prop="studentId" label="操作">
        <template slot-scope="scope">
          <auth :auths="['inspectionItemPlan/update']">
            <div>
              <el-button type="text" :disabled="!!scope.row.status" @click="resetList(scope.row)"
                >修改日程</el-button
              >
            </div>
          </auth>
        </template>
      </el-table-column>
    </el-table>
    <pagination
      save-key="teamSchedule-taskList"
      sync
      :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 { getInspectionItemPlan } from "../../api";
export default {
  components: { pagination },
  data() {
    return {
      tableList: [],
      rangeStart: "",
      rangeEnd: "",
      rules: {
        // 分页规则
        limit: 10, // 限制显示条数
        page: 1, // 当前页
        total: 0, // 总条数
        page_size: [10, 20, 40, 50], // 选择限制显示条数
      },
    };
  },
  mounted() {
    this.rangeStart = this.$route.query.startTime;
    this.rangeEnd = this.$route.query.endTime;
    this.userId = this.$route.query.teacher;
    this.getList();
  },
  methods: {
    async getList() {
      try {
        const result = await getInspectionItemPlan({
          startTime: this.rangeStart,
          endTime: this.rangeEnd,
          userId: this.userId,
          page: this.rules.page,
          rows: this.rules.limit,
        });
        this.tableList = result.data.rows;
        this.rules.total = result.data.total;
        this.$emit('getTotal', result.data.total)
      } catch (e) {
        console.log(e);
      }
    },
    resetList(row){
      this.$emit('resetSchedule',row)
    }
  },
};
</script>
<style lang="scss" scoped>
</style>
