import { Space, Popconfirm, Dropdown, DatePicker, Popover, Button, Radio } from 'antd'; import { FC, useState, useRef } from 'react'; import { PlaySquareOutlined, StopOutlined, CloudDownloadOutlined, DeleteOutlined, ExportOutlined, RocketOutlined, } from '@ant-design/icons'; export type BatchCtrlDropDownButtonProps = { onMenuClick?: (key: string) => void; onDownloadDateRangeChange?: (dateRange: string[], pickerType: string) => void; onDeleteConfirm?: () => void; downloadLoading?: boolean; disabledList?: string[]; hiddenList?: string[]; extenderList?: string[]; }; const { RangePicker } = DatePicker; const BatchCtrlDropDownButton: FC = ({ onMenuClick, onDownloadDateRangeChange, onDeleteConfirm, downloadLoading, disabledList = [], hiddenList = [], extenderList = [], }) => { const [popoverOpenState, setPopoverOpenState] = useState(false); const [pickerType, setPickerType] = useState('day'); const dateRangeRef = useRef([]); const extenderConfig: any = { exportTagButton: { key: 'exportTagButton', label: '导出为标签', icon: , disabled: disabledList?.includes('exportTagButton'), }, batchPublish: { key: 'batchPublish', label: '批量发布', icon: , disabled: disabledList?.includes('batchPublish'), }, batchUnPublish: { key: 'batchUnPublish', label: '批量下架', icon: , disabled: disabledList?.includes('batchUnPublish'), }, }; const extenderButtonList: any[] = extenderList.reduce((list: any[], key) => { const target = extenderConfig[key]; if (target) { list.push(target); } return list; }, []); const dropdownButtonItems: any[] = [ { key: 'batchStart', label: '批量启用', icon: , disabled: disabledList?.includes('batchStart'), }, { key: 'batchStop', label: '批量停用', icon: , disabled: disabledList?.includes('batchStop'), }, { key: 'batchDownload', label: ( { setPopoverOpenState(true); }} > 批量下载 ), icon: , disabled: disabledList?.includes('batchDownload'), }, ...extenderButtonList, { key: 'batchDelete', label: ( { onDeleteConfirm?.(); }} > 批量删除 ), icon: , disabled: disabledList?.includes('batchDelete'), }, ].filter((item) => { return !hiddenList.includes(item.key); }); const popoverConfig = { title: '选择下载区间', content: ( { setPickerType(e.target.value); }} > 按日 按周 按月 { dateRangeRef.current = date; return; }} picker={pickerType as any} allowClear={true} />
), }; return ( { setPopoverOpenState(open); }} > { onMenuClick?.(key); }, }} > 批量操作 ); }; export default BatchCtrlDropDownButton;