<template>
  <BasicTable @register="registerTable">
    <template #tableTitle>
      <a-button type="primary" preIcon="ant-design:export-outlined" v-auth="'fxpgzt-dc'" @click="onExportXls"> 导出</a-button>
    </template>
  </BasicTable>
</template>
<script setup lang="ts">
  import { BasicTable } from '@/components/Table';
  import { useListPage } from '/@/hooks/system/useListPage';
  import { FxpgztColumns, FxpgztseachFormSchema } from './data';
  import { fxpgzt, fxpgztExcel } from './api';

  const { tableContext, onExportXls } = useListPage({
    tableProps: {
      title: '',
      api: fxpgzt,
      columns: FxpgztColumns,

      canResize: false,
      //定义rowSelection的类型，默认是checkbox多选，可以设置成radio单选
      rowKey: 'wrdkid',
      clickToRowSelect: true,
      showActionColumn: false,
      beforeFetch(params: any) {
        if (params.data) {
          const arry = params.data.split(',');
          params.startTime = arry[0];
          params.endTime = arry[1];
        }
      },
      formConfig: {
        labelWidth: 120,
        schemas: FxpgztseachFormSchema,
        autoSubmitOnEnter: true,
        showAdvancedButton: false,
      },
      actionColumn: {
        width: 120,
        fixed: 'right',
      },
    },
    exportConfig: {
      name: '风险评估专题',
      url: fxpgztExcel,
    },
  });
  const [registerTable, {}, {}] = tableContext;
</script>
