提交 | 用户 | age
|
2407b3
|
1 |
import type { NamePath, RuleObject } from 'ant-design-vue/lib/form/interface'; |
2f6253
|
2 |
import type { VNode } from 'vue'; |
b5046f
|
3 |
import type { ButtonProps as AntdButtonProps } from '/@/components/Button'; |
2f6253
|
4 |
import type { FormItem } from './formItem'; |
陈 |
5 |
import type { ColEx, ComponentType } from './index'; |
73c8e0
|
6 |
import type { TableActionType } from '/@/components/Table/src/types/table'; |
4ff1c4
|
7 |
import type { CSSProperties } from 'vue'; |
785732
|
8 |
import type { RowProps } from 'ant-design-vue/lib/grid/Row'; |
2f6253
|
9 |
|
陈 |
10 |
export type FieldMapToTime = [string, [string, string], string?][]; |
|
11 |
|
1d4561
|
12 |
export type Rule = RuleObject & { |
V |
13 |
trigger?: 'blur' | 'change' | ['change', 'blur']; |
|
14 |
}; |
|
15 |
|
2f6253
|
16 |
export interface RenderCallbackParams { |
陈 |
17 |
schema: FormSchema; |
4ff1c4
|
18 |
values: Recordable; |
V |
19 |
model: Recordable; |
2f6253
|
20 |
field: string; |
陈 |
21 |
} |
a0c319
|
22 |
|
73c8e0
|
23 |
export interface ButtonProps extends AntdButtonProps { |
a0c319
|
24 |
text?: string; |
V |
25 |
} |
|
26 |
|
2407b3
|
27 |
export interface FormActionType { |
a0c319
|
28 |
submit: () => Promise<void>; |
4ff1c4
|
29 |
setFieldsValue: <T>(values: T) => Promise<void>; |
V |
30 |
resetFields: () => Promise<void>; |
|
31 |
getFieldsValue: () => Recordable; |
|
32 |
clearValidate: (name?: string | string[]) => Promise<void>; |
|
33 |
updateSchema: (data: Partial<FormSchema> | Partial<FormSchema>[]) => Promise<void>; |
c639e4
|
34 |
resetSchema: (data: Partial<FormSchema> | Partial<FormSchema>[]) => Promise<void>; |
4ff1c4
|
35 |
setProps: (formProps: Partial<FormProps>) => Promise<void>; |
V |
36 |
removeSchemaByFiled: (field: string | string[]) => Promise<void>; |
de5bf7
|
37 |
appendSchemaByField: ( |
V |
38 |
schema: FormSchema, |
|
39 |
prefixField: string | undefined, |
9edc28
|
40 |
first?: boolean | undefined |
de5bf7
|
41 |
) => Promise<void>; |
a0c319
|
42 |
validateFields: (nameList?: NamePath[]) => Promise<any>; |
V |
43 |
validate: (nameList?: NamePath[]) => Promise<any>; |
4ff1c4
|
44 |
scrollToField: (name: NamePath, options?: ScrollOptions) => Promise<void>; |
2f6253
|
45 |
} |
4ff1c4
|
46 |
|
2f6253
|
47 |
export type RegisterFn = (formInstance: FormActionType) => void; |
陈 |
48 |
|
|
49 |
export type UseFormReturnType = [RegisterFn, FormActionType]; |
|
50 |
|
|
51 |
export interface FormProps { |
785732
|
52 |
layout?: 'vertical' | 'inline' | 'horizontal'; |
46e087
|
53 |
// Form value |
4ff1c4
|
54 |
model?: Recordable; |
46e087
|
55 |
// The width of all items in the entire form |
2f6253
|
56 |
labelWidth?: number | string; |
785732
|
57 |
//alignment |
L |
58 |
labelAlign?: 'left' | 'right'; |
|
59 |
//Row configuration for the entire form |
|
60 |
rowProps?: RowProps; |
46e087
|
61 |
// Submit form on reset |
d09406
|
62 |
submitOnReset?: boolean; |
46e087
|
63 |
// Col configuration for the entire form |
2f6253
|
64 |
labelCol?: Partial<ColEx>; |
46e087
|
65 |
// Col configuration for the entire form |
2f6253
|
66 |
wrapperCol?: Partial<ColEx>; |
陈 |
67 |
|
b9d3d6
|
68 |
// General row style |
4ff1c4
|
69 |
baseRowStyle?: CSSProperties; |
b9d3d6
|
70 |
|
46e087
|
71 |
// General col configuration |
a0c319
|
72 |
baseColProps?: Partial<ColEx>; |
2f6253
|
73 |
|
46e087
|
74 |
// Form configuration rules |
2f6253
|
75 |
schemas?: FormSchema[]; |
46e087
|
76 |
// Function values used to merge into dynamic control form items |
4ff1c4
|
77 |
mergeDynamicData?: Recordable; |
46e087
|
78 |
// Compact mode for search forms |
2f6253
|
79 |
compact?: boolean; |
46e087
|
80 |
// Blank line span |
2f6253
|
81 |
emptySpan?: number | Partial<ColEx>; |
46e087
|
82 |
// Internal component size of the form |
5a6db8
|
83 |
size?: 'default' | 'small' | 'large'; |
46e087
|
84 |
// Whether to disable |
2f6253
|
85 |
disabled?: boolean; |
46e087
|
86 |
// Time interval fields are mapped into multiple |
2f6253
|
87 |
fieldMapToTime?: FieldMapToTime; |
46e087
|
88 |
// Placeholder is set automatically |
a0c319
|
89 |
autoSetPlaceHolder?: boolean; |
9b2d41
|
90 |
// Auto submit on press enter on input |
N |
91 |
autoSubmitOnEnter?: boolean; |
46e087
|
92 |
// Check whether the information is added to the label |
2f6253
|
93 |
rulesMessageJoinLabel?: boolean; |
46e087
|
94 |
// Whether to show collapse and expand buttons |
2f6253
|
95 |
showAdvancedButton?: boolean; |
ac1a36
|
96 |
// Whether to focus on the first input box, only works when the first form item is input |
V |
97 |
autoFocusFirstItem?: boolean; |
46e087
|
98 |
// Automatically collapse over the specified number of rows |
2f6253
|
99 |
autoAdvancedLine?: number; |
93f9a1
|
100 |
// Always show lines |
无 |
101 |
alwaysShowLines?: number; |
46e087
|
102 |
// Whether to show the operation button |
5a6db8
|
103 |
showActionButtonGroup?: boolean; |
2f6253
|
104 |
|
46e087
|
105 |
// Reset button configuration |
a0c319
|
106 |
resetButtonOptions?: Partial<ButtonProps>; |
2f6253
|
107 |
|
46e087
|
108 |
// Confirm button configuration |
a0c319
|
109 |
submitButtonOptions?: Partial<ButtonProps>; |
2f6253
|
110 |
|
46e087
|
111 |
// Operation column configuration |
5a6db8
|
112 |
actionColOptions?: Partial<ColEx>; |
2f6253
|
113 |
|
46e087
|
114 |
// Show reset button |
5a6db8
|
115 |
showResetButton?: boolean; |
46e087
|
116 |
// Show confirmation button |
5a6db8
|
117 |
showSubmitButton?: boolean; |
2f6253
|
118 |
|
5a6db8
|
119 |
resetFunc?: () => Promise<void>; |
V |
120 |
submitFunc?: () => Promise<void>; |
|
121 |
transformDateFunc?: (date: any) => string; |
2f6253
|
122 |
colon?: boolean; |
陈 |
123 |
} |
|
124 |
export interface FormSchema { |
46e087
|
125 |
// Field name |
2f6253
|
126 |
field: string; |
46e087
|
127 |
// Event name triggered by internal value change, default change |
2f6253
|
128 |
changeEvent?: string; |
46e087
|
129 |
// Variable name bound to v-model Default value |
1d4561
|
130 |
valueField?: string; |
46e087
|
131 |
// Label name |
2f6253
|
132 |
label: string; |
46e087
|
133 |
// Auxiliary text |
0b6110
|
134 |
subLabel?: string; |
46e087
|
135 |
// Help text on the right side of the text |
9b2d41
|
136 |
helpMessage?: |
N |
137 |
| string |
|
138 |
| string[] |
|
139 |
| ((renderCallbackParams: RenderCallbackParams) => string | string[]); |
46e087
|
140 |
// BaseHelp component props |
2f6253
|
141 |
helpComponentProps?: Partial<HelpComponentProps>; |
46e087
|
142 |
// Label width, if it is passed, the labelCol and WrapperCol configured by itemProps will be invalid |
2f6253
|
143 |
labelWidth?: string | number; |
46e087
|
144 |
// Disable the adjustment of labelWidth with global settings of formModel, and manually set labelCol and wrapperCol by yourself |
2f6253
|
145 |
disabledLabelWidth?: boolean; |
46e087
|
146 |
// render component |
2f6253
|
147 |
component: ComponentType; |
46e087
|
148 |
// Component parameters |
5832ee
|
149 |
componentProps?: |
1d4561
|
150 |
| ((opt: { |
V |
151 |
schema: FormSchema; |
|
152 |
tableAction: TableActionType; |
|
153 |
formActionType: FormActionType; |
4ff1c4
|
154 |
formModel: Recordable; |
V |
155 |
}) => Recordable) |
5832ee
|
156 |
| object; |
46e087
|
157 |
// Required |
765064
|
158 |
required?: boolean | ((renderCallbackParams: RenderCallbackParams) => boolean); |
2f6253
|
159 |
|
ac1a36
|
160 |
suffix?: string | number | ((values: RenderCallbackParams) => string | number); |
V |
161 |
|
46e087
|
162 |
// Validation rules |
1d4561
|
163 |
rules?: Rule[]; |
46e087
|
164 |
// Check whether the information is added to the label |
2f6253
|
165 |
rulesMessageJoinLabel?: boolean; |
陈 |
166 |
|
46e087
|
167 |
// Reference formModelItem |
2f6253
|
168 |
itemProps?: Partial<FormItem>; |
陈 |
169 |
|
46e087
|
170 |
// col configuration outside formModelItem |
2f6253
|
171 |
colProps?: Partial<ColEx>; |
陈 |
172 |
|
|
173 |
// 默认值 |
|
174 |
defaultValue?: any; |
|
175 |
isAdvanced?: boolean; |
|
176 |
|
46e087
|
177 |
// Matching details components |
2f6253
|
178 |
span?: number; |
陈 |
179 |
|
|
180 |
ifShow?: boolean | ((renderCallbackParams: RenderCallbackParams) => boolean); |
|
181 |
|
|
182 |
show?: boolean | ((renderCallbackParams: RenderCallbackParams) => boolean); |
|
183 |
|
46e087
|
184 |
// Render the content in the form-item tag |
2f6253
|
185 |
render?: (renderCallbackParams: RenderCallbackParams) => VNode | VNode[] | string; |
陈 |
186 |
|
46e087
|
187 |
// Rendering col content requires outer wrapper form-item |
a0c319
|
188 |
renderColContent?: (renderCallbackParams: RenderCallbackParams) => VNode | VNode[] | string; |
2f6253
|
189 |
|
1d4561
|
190 |
renderComponentContent?: |
V |
191 |
| ((renderCallbackParams: RenderCallbackParams) => any) |
|
192 |
| VNode |
|
193 |
| VNode[] |
|
194 |
| string; |
2f6253
|
195 |
|
46e087
|
196 |
// Custom slot, in from-item |
2f6253
|
197 |
slot?: string; |
陈 |
198 |
|
46e087
|
199 |
// Custom slot, similar to renderColContent |
2f6253
|
200 |
colSlot?: string; |
陈 |
201 |
|
|
202 |
dynamicDisabled?: boolean | ((renderCallbackParams: RenderCallbackParams) => boolean); |
|
203 |
|
1d4561
|
204 |
dynamicRules?: (renderCallbackParams: RenderCallbackParams) => Rule[]; |
2f6253
|
205 |
} |
陈 |
206 |
export interface HelpComponentProps { |
|
207 |
maxWidth: string; |
46e087
|
208 |
// Whether to display the serial number |
2f6253
|
209 |
showIndex: boolean; |
46e087
|
210 |
// Text list |
2f6253
|
211 |
text: any; |
46e087
|
212 |
// colour |
2f6253
|
213 |
color: string; |
46e087
|
214 |
// font size |
2f6253
|
215 |
fontSize: string; |
陈 |
216 |
icon: string; |
|
217 |
absolute: boolean; |
46e087
|
218 |
// Positioning |
2f6253
|
219 |
position: any; |
陈 |
220 |
} |