@aplus-frontend/ui
Version:
102 lines (101 loc) • 2.72 kB
TypeScript
import { TableRowSelection } from '@aplus-frontend/antdv/lib/table/interface';
import { ComputedRef, Ref } from 'vue';
import { ApTableProps } from '../../ap-table';
import { Recordable } from '../../type';
import { ApGridRowSelection } from '../interface';
export interface RowSelectionReturnType<RecordType = any> {
rowSelection: ComputedRef<TableRowSelection<RecordType>>;
selectedRows: Ref<Partial<RecordType>[]>;
/**
* 选中某行
* @param item
* @returns
*/
select: (item: RecordType) => void;
/**
* 取消选中某行
* @param item
* @returns
*/
unSelect: (item: RecordType) => void;
/**
* 某行是否被选中
* @param item
* @returns
*/
isSelected: (item: RecordType) => boolean;
/**
* 选中当前所有数据
* @returns
*/
selectAll: () => void;
/**
* 取消选中当前所有数据
* @returns
*/
unSelectAll: () => void;
/**
* 清空所有选中
* @returns
*/
clearAll: () => void;
/**
* 切换某行的选中状态
* @param item
* @returns
*/
toggleSelect: (item: RecordType) => void;
/**
* 多项选中
* @param items
* @returns
*/
selectMulti: (items: RecordType[]) => void;
/**
* 多项反选
* @param items
* @returns
*/
unSelectMulti: (items: RecordType[]) => void;
/**
* VxeTable 表格checkbox-change事件
* @param select
* @param selectedRows
* @param reserveSelectedRows
* @returns
*/
selectChange: (select: boolean, selectedRows: RecordType[], reserveSelectedRows: RecordType[]) => void;
/**
* VxeTable 表格checkbox-all事件
* @param item
* @param select
* @param partRowData
* @returns
*/
selectAllChange: (select: boolean, partRowData: RecordType[]) => void;
/**
* VxeTable 表格checkbox-range-change事件
* @param selected
* @param partRowData
* @returns
*/
selectRangeChange: (selected: RecordType[], partRowData: RecordType[]) => void;
/**
* 通过key勾选多条数据
* @param keys
* @returns
*/
selectMultiByKeys: (keys: (string | number)[]) => void;
}
type RowSelectionParams<T> = ApGridRowSelection<T> & {
/**
* 数据源(如果是后端分页,则表示当页数据,否则是全量数据)
*/
dataSource: Ref<T[]>;
/**
* 同Table的rowkey
*/
rowKey: ApTableProps['rowKey'];
};
declare const useTableRowSelection: <RecordType = Recordable>(props: RowSelectionParams<RecordType>) => RowSelectionReturnType<RecordType>;
export default useTableRowSelection;