import { LoadMoreFunction, SelectOption } from 'yc-pro-components/es/components/yc-select-v2'; import { Ref } from 'vue'; /** * 分页加载配置 */ export interface UseSelectWithPaginationConfig { /** API 调用函数 */ apiFn: (searchParams: Record, page: number, pageSize: number) => Promise; /** 搜索参数对象(固定参数,如 nodeType 等) */ searchParams?: Record; /** 每页数量 */ pageSize?: number; /** 数据转换函数,将 API 返回的数据转换为 SelectOption 格式 */ transform?: (item: unknown) => SelectOption; /** 响应数据路径(用于提取 result 和 total) */ dataPath?: { list?: string; total?: string; code?: string; }; /** 搜索字段名(用于 keyword 搜索,默认 'realShortName') */ searchField?: string; } /** * 使用分页选择器的返回值 */ export interface UseSelectWithPaginationReturn { /** 分页加载函数(供 YcSelectV2 使用) */ loadMore: LoadMoreFunction; /** 当前已加载的选项列表 */ options: Ref; /** 当前页码 */ currentPage: Ref; /** 是否还有更多数据 */ hasMore: Ref; /** 总数据量 */ total: Ref; /** 加载状态 */ loading: Ref; /** 重新加载数据(重置页码) */ reload: () => Promise; /** 清空数据 */ clear: () => void; } /** * 分页选择器 Hooks * @param config 配置项 * @returns 返回 loadMore 函数和相关状态 * * @example * ```ts * import { useSelectWithPagination } from 'yc-pro-components/es/hooks'; * import { getHousePage } from '@/api/fee-manage'; * * const { * loadMore, * options, * reload * } = useSelectWithPagination({ * apiFn: getHousePage, * searchParams: { nodeType: 1 }, * pageSize: 20, * transform: (item) => ({ * label: item.realShortName, * value: item.houseId * }) * }); * ``` */ export declare function useSelectWithPagination(config: UseSelectWithPaginationConfig): UseSelectWithPaginationReturn;