<template>
  <BasicTable @register="registerTable">
    <template #form-userLevle="{ model, field }">
      <a-select
        v-model:value="model[field]"
        placeholder="请选择"
        @change="change(model)"
        :fieldNames="{ label: 'text', value: 'value' }"
        :options="Options"
      ></a-select>
    </template>
    <template #tableTitle>
      <a-button type="primary" preIcon="ant-design:export-outlined" v-auth="'tbxx-hqjdjl-dc'" @click="onExportXls"> 导出</a-button>
    </template>
  </BasicTable>
</template>
<script setup lang="ts">
  import { BasicTable } from '@/components/Table';
  import { useListPage } from '/@/hooks/system/useListPage';

  import { HqgljlColumns, HqgljlsearchFormSchema, getUserLevel } from './data';
  import { dkhqjgjltj, dkhqjgjltjExcel } from './api';

  const { tableContext, onExportXls } = useListPage({
    tableProps: {
      title: '',
      api: dkhqjgjltj,
      columns: HqgljlColumns,
      canResize: false,
      rowSelection: { type: '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: HqgljlsearchFormSchema,
        autoSubmitOnEnter: true,
        showAdvancedButton: false,
      },
      actionColumn: {
        width: 120,
        fixed: 'right',
      },
    },
    exportConfig: {
      name: '地块后期监管记录统计',
      url: dkhqjgjltjExcel,
    },
  });
  const [registerTable, {}, {}] = tableContext;
  const Options = getUserLevel().data;
  function change(model) {
    model.cityCode = '';
  }
</script>
