import { Button, Dropdown, MenuProps } from 'antd';

export const MyExport = (props: any) => {
  const items: MenuProps['items'] = [
    {
      key: '1',
      label: '当前页(含查询条件)',
      onClick: () =>
        props?.keyParams
          ? props?.download?.({ download_type: 'page', ...props?.item })
          : props?.download?.Export?.({
              download_type: 'page',
              ...props?.item,
            }),
    },
    {
      key: '2',
      label: '所有页(含查询条件)',
      onClick: () =>
        props?.keyParams
          ? props?.download?.({ download_type: 'query', ...props?.item })
          : props?.download?.Export?.({
              download_type: 'query',
              ...props?.item,
            }),
    },
    {
      key: '3',
      label: '所有记录',
      onClick: () =>
        props?.keyParams
          ? props?.download?.({ download_type: 'all', ...props?.item })
          : props?.download?.Export?.({
              download_type: 'all',
              ...props?.item,
            }),
    },
  ];

  return (
    <Dropdown menu={{ items }} placement="bottomLeft">
      <Button type="primary">{props?.title || '导出'}</Button>
    </Dropdown>
  );
};
