<template>
  <el-dialog
    class="print-task-students"
    :visible.sync="modalIsShow"
    title="考生明细"
    top="10vh"
    width="700px"
    :close-on-click-modal="false"
    :close-on-press-escape="false"
    append-to-body
    @open="visibleChange"
  >
    <el-table border ref="TableList" :data="dataList">
      <el-table-column
        type="index"
        label="序号"
        width="70"
        :index="indexMethod"
      ></el-table-column>
      <el-table-column prop="studentName" label="姓名"></el-table-column>
      <el-table-column prop="studentCode" label="学号"></el-table-column>
      <el-table-column prop="clazz" label="班级"></el-table-column>
    </el-table>
    <div class="part-page">
      <el-pagination
        v-if="dataList.length"
        background
        layout="total,prev, pager, next"
        :current-page="current"
        :total="total"
        :page-size="size"
        @current-change="toPage"
      >
      </el-pagination>
    </div>

    <div slot="footer"></div>
  </el-dialog>
</template>

<script>
import { listTaskPrintStudent } from "../api";

export default {
  name: "print-task-students",
  props: {
    classId: {
      type: String,
      default: ""
    }
  },
  data() {
    return {
      modalIsShow: false,
      isSubmit: false,
      params: "",
      dataList: [],
      current: 1,
      size: this.GLOBAL.pageSize,
      total: 0
    };
  },
  methods: {
    visibleChange() {
      this.toPage(1);
    },
    async getList() {
      const data = await listTaskPrintStudent({
        classId: this.classId,
        pageNumber: this.current,
        pageSize: this.size
      });
      this.dataList = data.records;
      this.total = data.total;
    },
    toPage(page) {
      this.current = page;
      this.getList();
    },
    cancel() {
      this.modalIsShow = false;
    },
    open() {
      this.modalIsShow = true;
    }
  }
};
</script>
