<template>
  <div class="part-box is-border">
    <el-form inline>
      <el-form-item label="签到表编号">
        <el-input
          v-model.trim="searchModel.signPaperNo"
          placeholder="请选择"
          clearable
          style="width: 120px"
        >
        </el-input>
      </el-form-item>
      <el-form-item label="状态">
        <el-select
          v-model="searchModel.status"
          placeholder="请选择"
          clearable
          style="width: 120px"
        >
          <el-option label="请选择" value="" />
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-space wrap>
          <el-button type="primary" @click="toPage(1)">查询</el-button>
          <el-button @click="exportData">总数 --</el-button>
        </el-space>
      </el-form-item>
    </el-form>
    <el-divider class="form-divider" />
    <el-table
      class="page-table"
      :data="dataList"
      :loading="loading"
      border
      stripe
    >
      <el-table-column property="signPaperNo" label="签到表编号" sortable />
      <el-table-column property="imageCount" label="图片数量" sortable />
      <el-table-column label="操作" width="100" fixed="right">
        <template #default="scope">
          <el-button size="small" link @click="onView(scope.row)">
            查看
          </el-button>
        </template>
      </el-table-column>
    </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 { getSignPaperStatList } from '@/api/scan';
  import { SignPaperStatItem, SignPaperStatListFilter } from '@/api/types/scan';
  import useTable from '@/hooks/table';

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

  const searchModel = reactive<SignPaperStatListFilter>({
    signPaperNo: '',
    status: '',
  });

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

  function onView(row: SignPaperStatItem) {
    // TODO: 实现查看功能
    console.log('查看签到表:', row);
  }

  function exportData() {
    // TODO: 实现导出功能
  }
</script>
