<template>
  <div class="part-box is-filter">
    <el-form inline>
      <el-form-item label="确认类型">
        <select-option v-model="searchModel.type" type="manualConfirmType">
        </select-option>
      </el-form-item>
      <el-form-item label="科目">
        <select-subject v-model="searchModel.subjectCode"></select-subject>
      </el-form-item>
      <el-form-item label="考点">
        <el-input
          v-model.trim="searchModel.examSite"
          placeholder="请选择"
          clearable
          style="width: 120px"
        />
      </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="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 prop="examNumber" label="准考证号" width="120" />
      <el-table-column prop="name" label="姓名" min-width="100" />
      <el-table-column prop="studentCode" label="学号" width="120" />
      <el-table-column prop="subjectName" label="科目" min-width="100" />
      <el-table-column prop="examSite" label="考点" width="120" />
      <el-table-column prop="batchCode" label="扫描批次" width="120" />
      <el-table-column prop="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 { getManualConfirmDataList } from '@/api/check';
  import type {
    ManualConfirmDataListItem,
    ManualConfirmDataListFilter,
  } from '@/api/types/check';
  import useTable from '@/hooks/table';
  import ls from '@/utils/storage';

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

  const searchModel = reactive<ManualConfirmDataListFilter>({
    type: '',
    subjectCode: '',
    examSite: '',
  });

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

  function startCheck() {
    ls.set('manual-confirm', searchModel);
    // TODO:开始处理
  }
</script>
