/** * 动态表格增删 */ import { CommonProps, TableProps, ButtonProps, TableColumnProps } from '@wakeadmin/element-adapter'; import Sortable from 'sortablejs'; import { LooseMessageBoxOptions } from '../utils'; import { FatFormItemProps, FatFormGroupSlots, FatFormGroupProps, FatFormMethods } from './types'; export interface FatFormTableMethods { /** * 上移 * @param item */ moveUp(item: any): void; /** * 当前值 */ getValue(): any; /** * 设置值 */ setValue(value: any[]): void; /** * 下移 * @param item */ moveDown(item: any): void; /** * 删除 */ remove(item: any): void; /** * 创建新的子项 */ create(): void; } export interface FatFormTableSlots extends Omit, 'renderDefault'> { renderDefault?: (inst: FatFormTableMethods) => any; /** * 自定义列 */ renderColumns?: (inst: FatFormTableMethods) => any; /** * 自定义操作栏,可以在这里使用 el-table-column */ renderActions?: (inst: FatFormTableMethods) => any; } export declare function useFatFormTableRef(): import("@wakeadmin/demi").Ref | undefined>; export interface FatFormTableColumnMethods { form: FatFormMethods; table: FatFormTableMethods; itemProps: FatFormItemProps; /** * 当前行的数据 */ row: any; /** * 当前字段的数据 */ value: any; /** * 父级的 prop */ parentProp: string; prop: string; index: number; } export interface FatFormTableColumn extends CommonProps, Omit, 'renderLabel' | 'renderTooltip'> { /** * el-table-column 的 props */ tableColumnProps?: TableColumnProps; renderColumn?: (inst: FatFormTableColumnMethods) => any; renderLabel?: (inst: FatFormTableMethods) => any; renderTooltip?: (inst: FatFormTableMethods) => any; } export declare const FatFormTableDropGuide: { Prevent: boolean; InsertBefore: number; InsertAfter: number; Ok: boolean; }; /** * 排序的方式 */ export declare enum FatFormTableSortType { ByDrag = "by-drag", ByAction = "by-action" } export interface FatFormTableSortableOptions { /** * 排序的方式,默认是 FatFormTableSortType.ByAction */ type?: FatFormTableSortType; /** * 确定行是否可以被排序 * @returns */ rowSortable?: (params: { row: Store; index: number; list: Store[]; }) => boolean; /** * 拖拽块选择器 * 默认整行可以进行拖拽 * @note 只有拖拽排序的方式支持该方法 */ handle?: string; /** * 判断是否可以放置 * @note 只有拖拽排序的方式支持该方法 * @returns 可以使用 FatFormTableDropGuide * return false; — for cancel * return -1; — insert before target * return 1; — insert after target * return true; — keep default insertion point based on the direction * return void; — keep default insertion point based on the direction */ canDrop?: (params: { /** * sortable 原始 move 事件类型 */ nativeMoveEvent: Sortable.MoveEvent; nativeEvent: Event; /** * 当前正在拖拽的子项 */ dragged: Store; /** * dragged 对应的索引 */ draggedIndex: number; /** * 即将释放的参考元素 */ related: Store; /** * related 对应的索引 */ relatedIndex: number; /** * 是否插入到 related 之前 */ willInsertAfter?: boolean; /** * 完整的列表 */ list: Store[]; }) => false | -1 | 1 | true | void; /** * 是否忽略 form mode,默认 false * 默认情况下,mode === preview 时不允许拖拽 */ ignoreMode?: boolean; } export interface FatFormTableProps extends Omit, keyof FatFormGroupSlots>, FatFormTableSlots { /** * 透传给 el-table 的属性 */ tableProps?: TableProps & CommonProps; /** * 子项 key */ rowKey?: string | symbol | ((row: any) => string | number); /** * 字段路径。例如 a.b.c、b[0] */ prop: string; /** * 表单项 */ columns: FatFormTableColumn[]; /** * 子项大小限制,默认不限制 */ max?: number; /** * 表单 column 对齐方式, 默认 left */ columnAlign?: 'left' | 'right' | 'center'; /** * 表单 columnHeader 对齐方式,默认 left */ columnHeaderAlign?: 'left' | 'right' | 'center'; /** * 是否可排序, 默认 false */ sortable?: boolean; /** * 排序配置 */ sortableProps?: FatFormTableSortableOptions; /** * 是否支持创建, 默认 true */ enableCreate?: boolean; /** * 创建文本, 默认为 ’新增‘ */ createText?: any; /** * 创建按钮的自定义属性 */ createProps?: ButtonProps; /** * 上移文本,默认为 ’上移‘ */ moveUpText?: string; /** * 下移文本,默认为 ’下移‘ */ moveDownText?: string; /** * 删除文本,默认为 '删除' */ removeText?: string; /** * 操作文本,默认为 '操作' */ actionText?: string; /** * 操作列的宽度, 默认 180px */ actionWidth?: number; /** * 是否开启操作栏,默认 true */ enableActions?: boolean; /** * 删除确认配置, 默认为 确认删除? */ removeConfirm?: LooseMessageBoxOptions<{ instance: FatFormTableMethods; }>; /** * 是否支持删除 * @param params * @returns */ removable?: (params: { item: any; index: number; list: any[]; }) => boolean; /** * 自定义创建逻辑 * 可以抛出异常来终止创建 * 如果返回一个对象,将作为新子项插入到队列尾部 * * 如果要自定义复杂的创建逻辑,比如插入到队列前面,可以关闭 enableCreate, 并自己实现 */ beforeCreate?: () => any; /** * 删除前触发,可以返回 false 或抛出异常 阻止提交 * @param item * @returns */ beforeRemove?: (item: any) => Promise; } export declare const FatFormTable: import("@wakeadmin/h").DefineComponent, {}, {}, { default: (scope: FatFormTableMethods) => any; columns: (scope: FatFormTableMethods) => any; actions: (scope: FatFormTableMethods) => any; label: (scope: FatFormMethods) => any; tooltip: (scope: FatFormMethods) => any; message: (scope: FatFormMethods) => any; }>; //# sourceMappingURL=fat-form-table.d.ts.map