tav-ui
Version:
36 lines (35 loc) • 2.13 kB
TypeScript
import type { ComputedRef, Ref } from 'vue';
import type { PaginationProps } from '../types/pagination';
import type { BasicTableProps, FetchParams, SorterResult, TableEmitType } from '../types/table';
declare type Recordable<T = any> = Record<string, T>;
interface ComponentElRef<T extends HTMLElement = HTMLDivElement> {
$el: T;
}
declare type ComponentRef<T extends HTMLElement = HTMLDivElement> = ComponentElRef<T> | null;
interface ActionType {
getPaginationInfo: ComputedRef<boolean | PaginationProps>;
setPagination: (info: Partial<PaginationProps>) => void;
setLoading: (loading: boolean) => void;
getFieldsValue: () => Recordable;
clearSelectedRowKeys: () => void;
tableData: Ref<Recordable[]>;
}
export declare function useDataSource(tableElRef: Ref<ComponentRef>, propsRef: ComputedRef<BasicTableProps>, { getPaginationInfo, setPagination, setLoading, getFieldsValue, clearSelectedRowKeys, tableData, }: ActionType, emit: TableEmitType, filterRef: any): {
getDataSourceRef: ComputedRef<Recordable<any>[]>;
getDataSource: <T = Recordable<any>>() => T[];
getRawDataSource: <T_1 = Recordable<any>>() => T_1;
getRowKey: ComputedRef<string | ((record: {
[x: string]: any;
}) => string) | undefined>;
setTableData: <T_2 = Recordable<any>>(values: T_2[]) => void;
getAutoCreateKey: ComputedRef<boolean | undefined>;
fetch: (opt?: FetchParams | undefined) => Promise<Recordable<any>[] | undefined>;
reload: (opt?: FetchParams | undefined) => Promise<Recordable<any>[] | undefined>;
updateTableData: (index: number, key: string, value: any) => Promise<Recordable<any>>;
updateTableDataRecord: (rowKey: string | number, record: Recordable) => Recordable | undefined;
deleteTableDataRecord: (rowKey: string | number | string[] | number[]) => void;
insertTableDataRecord: (record: Recordable, index?: number | undefined) => Recordable | undefined;
findTableDataRecord: (rowKey: string | number) => any;
handleTableChange: (pagination: PaginationProps, filters: Partial<Recordable<string[]>>, sorter: SorterResult) => void;
};
export {};