import { Button, Input, Space, Popover } from 'antd' import { ReloadOutlined, FilterOutlined } from '@ant-design/icons' import './ListActionBar.css' const { Search } = Input /** * 列表操作栏组件 * @param {Object} props * @param {Array} props.actions - 左侧操作按钮配置数组 * @param {Array} props.batchActions - 批量操作按钮配置数组(仅在有选中项时显示) * @param {Object} props.selectionInfo - 选中信息 { count: 选中数量, total: 总数量, isAllPagesSelected: 是否跨页全选 } * @param {Function} props.onSelectAllPages - 选择所有页回调 * @param {Function} props.onClearSelection - 清除选择回调 * @param {Object} props.search - 搜索配置 * @param {Object} props.filter - 高级筛选配置(可选) * @param {boolean} props.showRefresh - 是否显示刷新按钮 * @param {Function} props.onRefresh - 刷新回调 */ function ListActionBar({ actions = [], batchActions = [], selectionInfo, onSelectAllPages, onClearSelection, search, filter, showRefresh = false, onRefresh, }) { // 是否有选中项 const hasSelection = selectionInfo && selectionInfo.count > 0 return (
{/* 左侧操作按钮区 */}
{/* 常规操作按钮(无选中时显示) */} {!hasSelection && actions.map((action) => ( ))} {/* 批量操作区域(有选中时显示) */} {hasSelection && ( {/* 选中信息 */}
已选择 {selectionInfo.count} 项 {selectionInfo.isAllPagesSelected && ( (全部页) )} {!selectionInfo.isAllPagesSelected && selectionInfo.total > selectionInfo.count && ( 选择全部 {selectionInfo.total} 项 )} 清除
{/* 批量操作按钮 */} {batchActions.map((action) => ( ))}
)}
{/* 右侧搜索筛选区 */}
search?.onChange?.(e.target.value)} value={search?.value} /> {filter && ( {filter.title || '高级筛选'}
} trigger="click" open={filter.visible} onOpenChange={filter.onVisibleChange} placement="bottomRight" overlayClassName="filter-popover" > )} {showRefresh && ( )}
) } export default ListActionBar