<template>
  <PageWrapper dense>
    <BasicTable @register="registerTable">
      <template #bodyCell="{ column, record }">
        <template v-if="column && record && column.key === 'action'">
          <a-popconfirm
            title="确定要删除吗?"
            ok-text="是"
            cancel-text="否"
            @confirm="handleDelete(record.id)"
          >
            <a-button type="link">删除</a-button>
          </a-popconfirm>
        </template>
      </template>
    </BasicTable>
  </PageWrapper>
</template>

<script setup lang="ts">
  import { PageWrapper } from '@/components/Page';
  import { BasicTable, useTable } from '@/components/Table';
  import { list, removeByIds } from './api';
  import { formSchemas, columns } from './data';
  import {getHangzhouRegions} from '@/api/common/index'
  defineOptions({ name: 'register' });

  const [registerTable, { reload }] = useTable({
    title: '签到管理',
    api: list,
    showIndexColumn: true,
    rowKey: 'id',
    useSearchForm: true,
    formConfig: {
      schemas: formSchemas,
      name: 'register',
      baseColProps: {
        xs: 24,
        sm: 24,
        md: 24,
        lg: 6,
      },
    },
    immediate: true,
    columns: columns,
    // actionColumn: {
    //   width: 300,
    //   title: '操作',
    //   key: 'action',
    //   fixed: 'right',
    // },
  });
  //新增编辑删除
  const handleDelete = async (id: any) => {
    await removeByIds([id]);
    reload();
  };
  
  //详情，跳转
  //下拉框
  const getHangzhouOptions =async()=>{
   const res = await getHangzhouRegions()
   formSchemas[0].componentProps.options = res
  }
  getHangzhouOptions()

</script>

<style scoped></style>
