import DropDownActions from '@/components/drop-down-actions'; import { DeleteOutlined, DownOutlined, PlusOutlined, SyncOutlined } from '@ant-design/icons'; import { useIntl } from '@umijs/max'; import { Button, Input, Space } from 'antd'; import React, { useMemo } from 'react'; import BaseSelect from '../seal-form/base/select'; import './index.less'; type PageToolsProps = { left?: React.ReactNode; right?: React.ReactNode; marginBottom?: number; marginTop?: number; style?: React.CSSProperties; }; const PageTools: React.FC = (props) => { const { left, right, marginBottom = 0, marginTop = 30, style: pageStyle } = props; const newStyle: React.CSSProperties = useMemo(() => { const style: React.CSSProperties = {}; style.marginBottom = `${marginBottom}px`; style.marginTop = `${marginTop}px`; if (pageStyle) { Object.assign(style, pageStyle); } return style; }, [marginBottom, marginTop, pageStyle]); return (
{left}
{right}
); }; interface ActionItem { label: string; locale: boolean; value: string; key: string; icon: React.ReactNode; } interface FilterBarProps { handleInputChange: (e: React.ChangeEvent) => void; handleSelectChange?: (value: any) => void; handleSearch: () => void; handleDeleteByBatch?: () => void; handleClickPrimary?: (item: any) => void; rowSelection?: any; actionItems?: ActionItem[]; selectOptions?: Global.BaseOption[]; showSelect?: boolean; buttonText: string; buttonIcon?: React.ReactNode; marginBottom?: number; marginTop?: number; inputHolder?: string; selectHolder?: string; actionType?: 'dropdown' | 'button'; showPrimaryButton?: boolean; showDeleteButton?: boolean; width?: { input?: number; select?: number; }; } export const FilterBar: React.FC = (props) => { const { handleInputChange, handleSelectChange, handleSearch, handleDeleteByBatch, handleClickPrimary, rowSelection, actionItems = [], selectOptions, showSelect, buttonText, buttonIcon, actionType = 'button', marginBottom = 10, marginTop = 10, inputHolder, selectHolder, showPrimaryButton = true, showDeleteButton = true, width } = props; const intl = useIntl(); const renderRight = useMemo(() => { if (!showPrimaryButton && !showDeleteButton) { return null; } return ( {showPrimaryButton ? ( actionType === 'dropdown' ? ( ) : ( ) ) : null} {showDeleteButton && ( )} ); }, [ actionItems, actionType, rowSelection?.selectedRowKeys, handleClickPrimary, intl ]); return ( {showSelect && ( )} } right={renderRight} > ); }; export default PageTools;