import DropDownActions from '@/components/drop-down-actions'; import { DeleteOutlined, DownOutlined, PlusOutlined, SearchOutlined, 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; right?: React.ReactNode; left?: React.ReactNode; width?: { input?: number; select?: number; }; } export const FilterBar: React.FC = (props) => { const { handleInputChange, handleSelectChange, handleSearch, handleDeleteByBatch = null, handleClickPrimary = null, rowSelection, actionItems = [], selectOptions, showSelect, buttonText, buttonIcon, actionType = 'button', marginBottom = 10, marginTop = 10, inputHolder, selectHolder, right, left, width } = props; const intl = useIntl(); const renderRight = useMemo(() => { if (!handleClickPrimary && !handleDeleteByBatch) { return null; } return ( {handleClickPrimary ? ( actionType === 'dropdown' ? ( ) : ( ) ) : null} {handleDeleteByBatch && ( )} ); }, [ actionItems, actionType, rowSelection?.selectedRowKeys, handleClickPrimary, intl ]); return ( } placeholder={ inputHolder || intl.formatMessage({ id: 'common.filter.name' }) } style={{ width: width?.input || 230 }} allowClear onChange={handleInputChange} > {showSelect && ( )} } right={right || renderRight} > ); }; export default PageTools;