<template>
  <div class="report-exception">
    <el-table ref="TableList" :data="dataList">
      <el-table-column type="index" label="排序"></el-table-column>
      <el-table-column prop="examName" label="批次名称（ID）"></el-table-column>
      <el-table-column prop="examActivityId" label="场次ID"></el-table-column>
      <el-table-column prop="examroom" label="考场名称（代码）">
        <span slot-scope="scope"
          >{{ scope.row.roomName }}({{ scope.row.roomCode }})</span
        >
      </el-table-column>
      <el-table-column prop="identity" label="证件号"></el-table-column>
      <el-table-column prop="name" label="姓名"></el-table-column>
      <el-table-column prop="courseCode" label="科目名称（代码）">
        <span slot-scope="scope"
          >{{ scope.row.courseName }}({{ scope.row.courseCode }})</span
        ></el-table-column
      >
      <el-table-column prop="exceptionCount" label="次数"></el-table-column>
      <el-table-column
        prop="exceptionTotalTime"
        label="累积持续时长（单位：分钟）"
      ></el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button
            class="btn-table-icon"
            type="primary"
            icon="icon icon-view"
            @click="toDetail(scope.row)"
            >详情</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <div class="part-page">
      <el-pagination
        background
        layout="prev, pager, next,total,sizes,jumper"
        :current-page="current"
        :total="total"
        :page-size="size"
        @size-change="toPage(1)"
        @current-change="toPage"
      >
      </el-pagination>
    </div>

    <exception-detail-dialog
      :detail-id="detailId"
      ref="ExceptionDetailDialog"
    ></exception-detail-dialog>
  </div>
</template>

<script>
import { reportExceptionData } from "@/api/invigilation";
import ExceptionDetailDialog from "./ExceptionDetailDialog";

export default {
  name: "report-exception",
  components: { ExceptionDetailDialog },
  props: {
    filter: {
      type: Object,
      default() {
        return {};
      },
    },
  },
  data() {
    return {
      current: 1,
      total: 0,
      size: 10,
      dataList: [],
      detailId: "",
    };
  },
  mounted() {
    this.getData();
  },
  methods: {
    async getList() {
      const datas = {
        ...this.filter,
        pageNumber: this.current - 1,
        pageSize: this.size,
      };

      const res = await reportExceptionData(datas);

      this.dataList = res.data.data.records;
      this.total = res.data.data.total;
    },
    toPage(page) {
      this.current = page;
      this.getList();
    },
    getData() {
      this.toPage(1);
    },
    toDetail(row) {
      this.detailId = row.examStudentId;
      this.$refs.ExceptionDetailDialog.open();
    },
  },
};
</script>
