<template>
  <el-dialog
    class="student-log-detail-dialog"
    :visible.sync="modalIsShow"
    title="日志详情"
    width="1000px"
    top="94px"
    :close-on-click-modal="false"
    :close-on-press-escape="false"
    append-to-body
    @open="visibleChange"
  >
    <el-table ref="TableList" :data="dataList">
      <el-table-column prop="creatTime" label="发生时间"></el-table-column>
      <el-table-column prop="type" label="事件类型"></el-table-column>
      <el-table-column prop="remark" label="详情"></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>
    <div slot="footer"></div>
  </el-dialog>
</template>

<script>
import { studentLogDetail } from "@/api/invigilation";

export default {
  name: "student-log-detail-dialog",
  props: {
    detailId: {
      type: [String, Number],
      required: true,
    },
  },
  data() {
    return {
      modalIsShow: false,
      current: 1,
      total: 0,
      size: 10,
      dataList: [],
    };
  },
  methods: {
    visibleChange() {
      this.toPage(1);
    },
    async getList() {
      const datas = {
        examStudentId: this.detailId,
        pageNumber: this.current - 1,
        pageSize: this.size,
      };

      const res = await studentLogDetail(datas);

      this.dataList = res.data.data.records;
      this.total = res.data.data.total;
    },
    toPage(page) {
      this.current = page;
      this.getList();
    },
    cancel() {
      this.modalIsShow = false;
    },
    open() {
      this.modalIsShow = true;
    },
  },
};
</script>
