naive-ui-table
Version:
基于naive-ui封装的表格组件
54 lines (53 loc) • 1.9 kB
TypeScript
import type { ComputedRef, Ref } from 'vue';
import type { DataTableColumn, DataTableRowKey } from 'naive-ui';
import type { Props as FormProps, FormInstance } from 'naive-ui-form';
export type { FormProps, FormInstance };
export type Recordable<T = any> = Record<string, T>;
type CustomColumn<T> = {
vif?: boolean | (() => boolean) | Ref<boolean>;
children?: DataTableColumn<T>[];
};
export type TableColumn<T = Recordable> = DataTableColumn<T> & CustomColumn<T>;
export type TableColumns<T = Recordable> = TableColumn<T>[];
export type Column<T = Recordable> = TableColumn<T>;
export type Columns<T = Recordable> = TableColumns<T>;
export interface TableProps {
columns: TableColumns<any>;
searchProps?: FormProps;
requestApi?: (params: any) => Promise<any>;
requestAuto?: boolean;
pagination?: boolean | object;
isPageApi?: boolean;
size?: 'small' | 'medium' | 'large';
remote?: boolean;
maxHeight?: number | string;
scrollX?: number | string;
resizeHeightOffset?: number;
toolButton?: ('refresh' | 'size' | 'setting')[] | boolean;
initParams?: Recordable;
dataCallback?: (data: Recordable) => Recordable;
requestError?: (params: any) => void;
showOrderColumn?: boolean;
}
export interface TableInstance {
basicForm: FormInstance | null;
tableRef: any;
tableColumns: ComputedRef<any[]>;
refresh(): Promise<any>;
resetState(): void;
openDrawer(bool: boolean): void;
height: ComputedRef<number>;
scrollWidth: ComputedRef<number>;
clearCheck(): void;
getCheckValue(): {
keys: DataTableRowKey[];
rows: object[];
};
getTableValue(): any;
getPageValue(): any;
setLoading(loading: boolean): void;
reset: FormInstance['reset'];
getValue: FormInstance['getValue'];
setValue: FormInstance['setValue'];
getFieldValue: FormInstance['getFieldValue'];
}