@aplus-frontend/ui
Version:
87 lines (86 loc) • 3.22 kB
TypeScript
import { StyleValue, VNode, VNodeChild } from 'vue';
import { ApTableProps } from '../../ap-table';
import { ModalProps, TableProps } from '@aplus-frontend/antdv';
/** table-modal的props类型 */
export interface ApTableModalProps<TableRowType = any> extends Omit<ModalProps, 'onOk' | 'open' | 'close' | 'visible'> {
columns: ApTableProps['columns'];
getRowKey?: (record: TableRowType) => string | number;
api?: (params: any) => Promise<{
records: TableRowType[];
total: number;
}>;
/** 支持ApTable组件的props */
apTableProps?: Omit<ApTableProps, 'columns' | 'getRowKey' | 'request'>;
maxCount?: number;
/** 是否渲染modal-title-suffix
* @default true
*/
isRenderModalTitleSuffix?: boolean;
/** 渲染table-modal的后缀函数 */
renderModalTitleSuffix?: ModalTitleSlots['default'];
/** 禁用选项 */
disabledCheckbox?: boolean | ((record: TableRowType, selectRows: TableRowType[]) => boolean);
/** 其他row-selection选项 */
rowSelection?: TableProps['rowSelection'];
/** 表格布局配置 */
tableLayoutConfig?: TableLayoutConfig;
/** 渲染头部信息 */
renderHeader?: () => VNodeChild;
/** 弹框ok事件回调 */
onOk?: (data: OpenReturnType<TableRowType>) => Promise<boolean> | void;
}
/** useCreateTableModal参数类型 */
export interface UseCreateTableModalProps extends ApTableModalProps {
/** 组件卸载时销毁modal */
destroyOnUnmounted?: boolean;
}
/** useTableSelectModal参数类型 */
export interface UseTableSelectModalProps<TableRowType> extends ApTableModalProps<TableRowType> {
/**
* 确认选择数据后回调函数
* @description 不要直接改变回调函数的传入的数据,因为传入的数据是是引用类型,会影响异步返回的数据
* */
finishCallback?: (data: OpenReturnType<TableRowType>) => void;
}
/** open打开方法返回的值的类型 */
export interface OpenReturnType<RowType> {
keys: number[] | string[];
rows: RowType[];
}
/** table-modal实例open方法接收的配置类型 */
export interface OpenOptions {
extraParams?: any;
/** 弹框刷新方式 */
refreshMode?: 'reset' | 'submit' | 'none';
/** 修改apTable的数据 */
apTableDataSources?: any[];
}
/** 等待异步打开modal错误情况 */
export declare enum AsyncOpenResultError {
/** 弹框关闭 */
ModalCancel = "ModalCancel",
/** 超出最大选择数量 */
ExceedMaxCount = "ExceedMaxCount",
/** 没有getRowKey */
NotFineGetRowKey = "NotFineGetRowKey"
}
/** modal-title slots */
export interface ModalTitleSlots {
default: (props: {
maxCount: number;
count: number;
}) => VNodeChild;
}
/** table-layout Props */
export interface TableLayoutConfig {
/** 左侧标题 */
leftTitle?: string | VNodeChild;
/** 右侧标题 */
rightTitle?: (selectedCount: number) => string | VNodeChild;
/** 右侧内容样式 */
rightContentStyle?: StyleValue;
/** 已经选择item渲染, renderSelectedItem有值才为复杂布局 */
renderSelectedItem?: (record: any, actions: {
deleteItem: (record: any) => void;
}) => VNode;
}