<template>
  <div class="part-box is-filter">
    <el-form inline>
      <el-form-item label="姓名">
        <el-input
          v-model.trim="searchModel.name"
          placeholder="请输入"
          clearable
          style="width: 120px"
        />
      </el-form-item>
      <el-form-item label="准考证号">
        <el-input
          v-model.trim="searchModel.examCardNo"
          placeholder="请输入"
          clearable
          style="width: 120px"
        />
      </el-form-item>
      <el-form-item label="学号">
        <el-input
          v-model.trim="searchModel.studentNo"
          placeholder="请输入"
          clearable
          style="width: 120px"
        />
      </el-form-item>
      <el-form-item label="科目">
        <select-subject v-model="searchModel.subject"></select-subject>
      </el-form-item>
    </el-form>
    <el-divider class="form-divider" />
    <div class="part-action">
      <el-space wrap>
        <el-button type="primary" @click="toPage(1)">查询</el-button>
        <el-button @click="exportData">导出</el-button>
        <el-button type="success" @click="startCheck">开始检查</el-button>
      </el-space>
    </div>
  </div>
  <div class="part-box">
    <el-table
      class="page-table"
      :data="dataList"
      :loading="loading"
      border
      stripe
    >
      <el-table-column type="index" label="序号" width="60" />
      <el-table-column property="examCardNo" label="准考证号" width="120" />
      <el-table-column property="name" label="姓名" min-width="100" />
      <el-table-column property="studentNo" label="学号" width="120" />
      <el-table-column property="subject" label="科目" min-width="100" />
      <el-table-column property="scanBatch" label="扫描批次" width="120" />
      <el-table-column property="uploadTime" label="上传时间" width="160" />
    </el-table>
    <el-pagination
      v-model:current-page="pagination.pageNumber"
      v-model:page-size="pagination.pageSize"
      :layout="pagination.layout"
      :total="pagination.total"
      @size-change="pageSizeChange"
      @current-change="toPage"
    />
  </div>
</template>

<script setup lang="ts">
  import { reactive } from 'vue';
  import { ElMessage } from 'element-plus';
  import { getImageCheckDataList } from '@/api/check';
  import type {
    ImageCheckDataListItem,
    ImageCheckDataListFilter,
  } from '@/api/types/check';
  import useTable from '@/hooks/table';

  defineOptions({
    name: 'ImageCheck',
  });

  const searchModel = reactive<ImageCheckDataListFilter>({
    name: '',
    examCardNo: '',
    studentNo: '',
    subject: null,
  });

  const { dataList, pagination, loading, toPage, pageSizeChange } =
    useTable<ImageCheckDataListItem>(getImageCheckDataList, searchModel, false);

  function exportData() {
    ElMessage.info('导出功能待实现');
  }

  function startCheck() {
    ElMessage.info('开始检查功能待实现');
  }
</script>
