Skip to content

Commit

Permalink
feat: ✨ 完成基础表单与弹窗表单迁移
Browse files Browse the repository at this point in the history
  • Loading branch information
G committed Dec 11, 2023
1 parent 8f84807 commit 6c8a152
Show file tree
Hide file tree
Showing 42 changed files with 3,069 additions and 1,224 deletions.
105 changes: 105 additions & 0 deletions packages/gbeata/src/GDialogForm/g-dialog-form.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import { ModalProps } from 'antd/lib/modal';
import { ReactNode } from 'react';
import { Field } from '../GForm/g-form';
import {
ExtendField,
MwSearchTableField,
} from '../MwSearchTable/mw-search-table';
import { AnyKeyProps } from '../types/AnyKeyProps';

declare type ModeType = 'add' | 'update' | 'view' | 'custom' | string;

export interface GDialogFormProps extends ModalProps {
/** 弹窗标题 */
title?: string;
/** 用抽屉来展示 */
drawer?: boolean;
/** 表单项 */
fields?: Array<GDialogFormField | MwSearchTableField>;
/** form 的 span */
span?: number;
/** 新增 api */
addApi?(params?: AnyKeyProps): Promise<AnyKeyProps>;
/** 修改 api */
updateApi?(params?: AnyKeyProps): Promise<AnyKeyProps>;
/** 弹窗宽度 */
width?: number | string;
/** 表单名字 */
name?: string;
/** 提交前校验 */
beforeSubmit?(params?: AnyKeyProps, mode?: string): boolean | AnyKeyProps;
/** 表格其它属性扩展 */
dialogExtend?: AnyKeyProps;
/** 表单其它属性扩展 */
formExtend?: AnyKeyProps;
/** 是否只使用申明了 dialog 的 Field */
dialogOnly?: boolean;
/** 是否可见 */
visible?: boolean;
/** 打开弹窗后的默认值 */
initialValues?: AnyKeyProps;
/** 关闭弹窗监听 */
onClose?: () => void;
/** 关闭弹窗监听 */
onCancel?: () => void;
/** 模式 */
mode?: 'add' | 'update' | 'view';
/** 弹窗数据是否在加载中 */
spinning?: boolean;
/** 成功监听 */
onSuccess?: ({
data,
values,
params,
initParams,
closeDialog,
}: AnyKeyProps) => void;
/** 成功监听 */
onError?: ({
data,
values,
params,
initParams,
closeDialog,
}: AnyKeyProps) => void;
/** 成功后是否自动关闭 */
autoClose?: boolean;
children?: ReactNode;
stopLoading?: boolean;
}

export interface GDialogFormField extends Field {
/** 弹窗选项 */
dialog?: ExtendField;

/** table 参数 (写了也没用) */
table?: any;

/** search 参数 (写了也没用) */
search?: any;
}

export interface GDialogFormRef extends AnyKeyProps {
/**
* 弹窗新增模式
* @param params 初始表单数据
* @param title 弹窗标题,默认“新增”
*/
add(params?: AnyKeyProps, title?: ReactNode): Promise<any>;
/**
* 弹窗修改模式
* @param params 初始表单数据
* @param title 弹窗标题,默认“修改”
*/
update(params?: AnyKeyProps, title?: ReactNode): Promise<any>;
/**
* 弹窗详情模式
* @param params 初始表单数据
* @param title 弹窗标题,默认“详情”
*/
view(params?: AnyKeyProps, title?: ReactNode): void;
/**
* 关闭弹窗
*/
closeDialog(): void;
}
7 changes: 7 additions & 0 deletions packages/gbeata/src/GDialogForm/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { GDialogFormProps } from './g-dialog-form';

declare const MwDialogForm: React.ForwardRefExoticComponent<
GDialogFormProps & React.RefAttributes<HTMLDivElement>
>;

export default MwDialogForm;
Loading

0 comments on commit 6c8a152

Please sign in to comment.