<template>
  <BasicTable @register="registerTable" :rowSelection="rowSelection" :scroll="{ y: 450 }" />
</template>
<script lang="ts">
  import { BasicTable } from '/@/components/Table';
  import { useListPage } from '/@/hooks/system/useListPage';
  import { deviceList } from '/@/views/vent/monitorManager/windrectMonitor/windrect.api';
  import { getTableHeaderColumns } from '/@/hooks/web/useWebColumns';

  export default {
    name: 'ModalTable',
    components: { BasicTable },
    props: {
      deviceType: {
        type: String,
        required: true,
      },
    },
    setup(props) {
      const columns = getTableHeaderColumns(props.deviceType);

      // 列表页面公共参数、方法
      const { tableContext, onExportXls } = useListPage({
        designScope: 'windrect_list',
        tableProps: {
          title: '',
          api: deviceList.bind(null, { pageSize: 1000 }),
          columns: columns,
          size: 'small',
          actionColumn: {
            width: 180,
          },
          pagination: false,
          showActionColumn: false,
          showTableSetting: false,
          bordered: false,
          useSearchForm: false,
          autoCreateKey: true,
          beforeFetch: (params) => {
            return Object.assign({ column: 'createTime', order: 'desc' }, params);
          },
        },
      });

      //注册table数据
      const [registerTable, { clearSelectedRowKeys, setSelectedRowKeys }, { rowSelection, selectedRowKeys }] = tableContext;
      return {
        registerTable,
        onExportXls,
        clearSelectedRowKeys,
        setSelectedRowKeys,
        selectedRowKeys,
        rowSelection,
      };
    },
  };
</script>
