<template>
  <PageWrapper dense>
    <BasicTable @register="registerTable">
      <template #toolbar>
        <a-button
          class="<sm:hidden"
          @click="downloadExcel(exportExcel, '请假信息', getForm().getFieldsValue())"
          v-auth="'workflow:leave:export'"
          >导出</a-button
        >

        <a-button type="primary" @click="handleAdd" v-auth="'workflow:leave:add'">新增</a-button>
      </template>
      <template #bodyCell="{ column, record }">
        <template v-if="column && record && column.key === 'action'"> </template>
      </template>
    </BasicTable>
  </PageWrapper>
</template>

<script setup lang="ts">
  import { PageWrapper } from '@/components/Page';
  import { BasicTable, useTable } from '@/components/Table';
  import { list, exportExcel } from './api';
  import { downloadExcel } from '@/utils/file/download';
  import { formSchemas, columns } from './data';
  import { useGo } from '@/hooks/web/usePage';
  import { PageEnum } from '@/enums/pageEnum';

  defineOptions({ name: 'OrderSend' });

  const [registerTable, { reload, getForm }] = useTable({
    rowSelection: {
      type: 'checkbox',
    },
    title: '工单派遣',
    api: list,
    showIndexColumn: true,
    rowKey: 'id',
    useSearchForm: true,
    formConfig: {
      schemas: formSchemas,
      name: 'patroling',
      baseColProps: {
        xs: 24,
        sm: 24,
        md: 24,
        lg: 6,
      },
    },
    columns: columns,
    actionColumn: {
      width: 200,
      title: '操作',
      key: 'action',
      fixed: 'right',
    },
  });

  function handleAdd() {
    go({ path: '/workflow/leaveEdit/index' as PageEnum, query: { type: 'add' } });
    reload();
  }

  // 前往审批记录页面
  const go = useGo();
</script>

<style scoped></style>
