vben
2020-11-18 ea24dfa384c9dc05e1b397c7c7dd4635dae87aef
提交 | 用户 | age
b6d5e5 1 import type { ButtonProps } from 'ant-design-vue/lib/button/buttonTypes';
2f6253 2 import type { CSSProperties, VNodeChild } from 'vue';
3 /**
4  * @description: 弹窗对外暴露的方法
5  */
6 export interface ModalMethods {
7   setModalProps: (props: Partial<ModalProps>) => void;
8 }
9
10 export type RegisterFn = (modalMethods: ModalMethods, uuid?: string) => void;
11 export interface ReturnMethods extends ModalMethods {
ea24df 12   openModal: <T = any>(props?: boolean, data?: T, openOnSet?: boolean) => void;
2f6253 13 }
14 export type UseModalReturnType = [RegisterFn, ReturnMethods];
15
16 export interface ReturnInnerMethods extends ModalMethods {
17   closeModal: () => void;
18   changeLoading: (loading: boolean) => void;
19   changeOkLoading: (loading: boolean) => void;
20 }
21 export type UseModalInnerReturnType = [RegisterFn, ReturnInnerMethods];
22
23 export interface ModalProps {
24   // 启用wrapper后 底部可以适当增加高度
25   wrapperFooterOffset?: number;
26   draggable?: boolean;
27
28   // 是否可以进行全屏
29   canFullscreen?: boolean;
30   visible?: boolean;
31   // 温馨提醒信息
32   helpMessage: string | string[];
33
34   // 是否使用modalWrapper
35   useWrapper: boolean;
36
37   loading: boolean;
38
39   wrapperProps: Omit<ModalWrapperProps, 'loading'>;
40
41   showOkBtn: boolean;
42   showCancelBtn: boolean;
43   closeFunc: () => Promise<any>;
44
45   /**
46    * Specify a function that will be called when modal is closed completely.
47    * @type Function
48    */
49   afterClose?: () => any;
50
51   /**
52    * Body style for modal body element. Such as height, padding etc.
53    * @default {}
54    * @type object
55    */
56   bodyStyle?: CSSProperties;
57
58   /**
59    * Text of the Cancel button
60    * @default 'cancel'
61    * @type string
62    */
63   cancelText?: string;
64
65   /**
66    * Centered Modal
67    * @default false
68    * @type boolean
69    */
70   centered?: boolean;
71
72   /**
73    * Whether a close (x) button is visible on top right of the modal dialog or not
74    * @default true
75    * @type boolean
76    */
77   closable?: boolean;
78   /**
79    * Whether a close (x) button is visible on top right of the modal dialog or not
80    */
81   closeIcon?: VNodeChild | JSX.Element;
82
83   /**
84    * Whether to apply loading visual effect for OK button or not
85    * @default false
86    * @type boolean
87    */
88   confirmLoading?: boolean;
89
90   /**
91    * Whether to unmount child components on onClose
92    * @default false
93    * @type boolean
94    */
95   destroyOnClose?: boolean;
96
97   /**
98    * Footer content, set as :footer="null" when you don't need default buttons
99    * @default OK and Cancel buttons
100    * @type any (string | slot)
101    */
102   footer?: VNodeChild | JSX.Element;
103
104   /**
105    * Return the mount node for Modal
106    * @default () => document.body
107    * @type Function
108    */
109   getContainer?: (instance: any) => HTMLElement;
110
111   /**
112    * Whether show mask or not.
113    * @default true
114    * @type boolean
115    */
116   mask?: boolean;
117
118   /**
119    * Whether to close the modal dialog when the mask (area outside the modal) is clicked
120    * @default true
121    * @type boolean
122    */
123   maskClosable?: boolean;
124
125   /**
126    * Style for modal's mask element.
127    * @default {}
128    * @type object
129    */
130   maskStyle?: CSSProperties;
131
132   /**
133    * Text of the OK button
134    * @default 'OK'
135    * @type string
136    */
137   okText?: string;
138
139   /**
140    * Button type of the OK button
141    * @default 'primary'
142    * @type string
143    */
144   okType?: 'primary' | 'danger' | 'dashed' | 'ghost' | 'default';
145
146   /**
147    * The ok button props, follow jsx rules
148    * @type object
149    */
150   okButtonProps?: ButtonProps;
151
152   /**
153    * The cancel button props, follow jsx rules
154    * @type object
155    */
156   cancelButtonProps?: ButtonProps;
157
158   /**
159    * The modal dialog's title
160    * @type any (string | slot)
161    */
162   title?: VNodeChild | JSX.Element;
163
164   /**
165    * Width of the modal dialog
166    * @default 520
167    * @type string | number
168    */
169   width?: string | number;
170
171   /**
172    * The class name of the container of the modal dialog
173    * @type string
174    */
175   wrapClassName?: string;
176
177   /**
178    * The z-index of the Modal
179    * @default 1000
180    * @type number
181    */
182   zIndex?: number;
183 }
184
185 export interface ModalWrapperProps {
186   footerOffset?: number;
187   loading: boolean;
188   modalHeaderHeight: number;
189   modalFooterHeight: number;
190   minHeight: number;
191   visible: boolean;
192   fullScreen: boolean;
193 }