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