Skip to content

Commit f2ec2ca

Browse files
authored
feat: 添加更多配置项 (vbenjs#2607)
1 parent b66a83c commit f2ec2ca

File tree

1 file changed

+152
-40
lines changed

1 file changed

+152
-40
lines changed

src/views/demo/form/UseForm.vue

+152-40
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,17 @@
4949
{ value: 'default', label: 'defualt' },
5050
];
5151
52+
const layoutList = [
53+
{ value: 'vertical', label: 'vertical' },
54+
{ value: 'inline', label: 'inline' },
55+
{ value: 'horizontal', label: 'horizontal' },
56+
];
57+
58+
const labelAlignList = [
59+
{ value: 'left', label: 'left' },
60+
{ value: 'right', label: 'right' },
61+
];
62+
5263
const schemas: FormSchema[] = [
5364
{
5465
field: 'field1',
@@ -157,26 +168,49 @@
157168
},
158169
},
159170
];
160-
161171
const formSchemas: FormSchema[] = [
162172
{
163-
field: '',
173+
field: 'd1',
164174
component: 'Divider',
165175
label: '基础属性',
166176
colProps: { span: 24 },
167177
componentProps: {
168178
orientation: 'center',
169179
},
170180
},
181+
{
182+
field: 'name',
183+
defaultValue: 'useForm',
184+
component: 'Input',
185+
label: 'name',
186+
colProps: { span: 24 },
187+
},
188+
{
189+
field: 'layout',
190+
defaultValue: 'horizontal',
191+
component: 'RadioButtonGroup',
192+
label: 'layout',
193+
colProps: { span: 24 },
194+
componentProps: {
195+
options: layoutList,
196+
},
197+
},
198+
{
199+
field: 'labelAlign',
200+
defaultValue: 'right',
201+
component: 'RadioButtonGroup',
202+
label: 'labelAlign',
203+
colProps: { span: 24 },
204+
componentProps: {
205+
options: labelAlignList,
206+
},
207+
},
171208
{
172209
field: 'labelWidth',
173210
defaultValue: 120,
174211
component: 'InputNumber',
175212
label: 'labelWidth',
176213
colProps: { span: 24 },
177-
componentProps: {
178-
size: 'small',
179-
},
180214
},
181215
{
182216
field: 'size',
@@ -186,51 +220,121 @@
186220
colProps: { span: 24 },
187221
componentProps: {
188222
options: sizeList,
189-
size: 'small',
190223
},
191224
},
225+
{
226+
field: 'colon',
227+
defaultValue: false,
228+
component: 'Switch',
229+
label: 'colon',
230+
colProps: { span: 24 },
231+
},
192232
{
193233
field: 'disabled',
194234
defaultValue: false,
195235
component: 'Switch',
196236
label: 'disabled',
197237
colProps: { span: 24 },
198-
componentProps: {
199-
size: 'small',
200-
},
201238
},
202239
{
203240
field: 'compact',
204241
defaultValue: false,
205242
component: 'Switch',
206243
label: 'compact',
207244
colProps: { span: 24 },
208-
componentProps: {
209-
size: 'small',
210-
},
211245
},
212246
{
213-
field: '',
247+
field: 'autoSetPlaceHolder',
248+
defaultValue: true,
249+
component: 'Switch',
250+
label: 'autoSetPlaceHolder',
251+
colProps: { span: 24 },
252+
},
253+
{
254+
field: 'autoSubmitOnEnter',
255+
defaultValue: false,
256+
component: 'Switch',
257+
label: 'autoSubmitOnEnter',
258+
colProps: { span: 24 },
259+
},
260+
{
261+
field: 'showAdvancedButton',
262+
defaultValue: false,
263+
component: 'Switch',
264+
label: 'showAdvancedButton',
265+
colProps: { span: 24 },
266+
},
267+
268+
{
269+
field: 'd2',
214270
component: 'Divider',
215-
label: '网格布局',
271+
label: '网格布局(rowProps)',
216272
colProps: { span: 24 },
217273
componentProps: {
218274
orientation: 'center',
219275
},
220276
},
221277
{
222-
field: 'actionColOptions.span',
223-
component: 'Slider',
224-
defaultValue: 24,
225-
label: 'span',
278+
field: 'rowProps.gutter.0',
279+
component: 'InputNumber',
280+
defaultValue: 0,
281+
label: 'Horizontal Gutter',
226282
colProps: { span: 24 },
227283
componentProps: {
228-
min: 1,
229-
max: 24,
284+
addonAfter: 'px',
230285
},
231286
},
232287
{
233-
field: '',
288+
field: 'rowProps.gutter.1',
289+
component: 'InputNumber',
290+
defaultValue: 0,
291+
label: 'Vertical Gutter',
292+
colProps: { span: 24 },
293+
componentProps: {
294+
addonAfter: 'px',
295+
},
296+
},
297+
{
298+
field: 'rowProps.align',
299+
defaultValue: 'top',
300+
component: 'Select',
301+
label: 'align',
302+
colProps: { span: 24 },
303+
componentProps: {
304+
options: [
305+
{ value: 'stretch', label: 'stretch' },
306+
{ value: 'bottom', label: 'bottom' },
307+
{ value: 'top', label: 'top' },
308+
{ value: 'middle', label: 'middle' },
309+
],
310+
},
311+
},
312+
{
313+
field: 'rowProps.justify',
314+
defaultValue: 'start',
315+
component: 'Select',
316+
label: 'justify',
317+
colProps: { span: 24 },
318+
componentProps: {
319+
options: [
320+
{ value: 'space-around', label: 'space-around' },
321+
{ value: 'space-between', label: 'space-between' },
322+
{ value: 'center', label: 'center' },
323+
{ value: 'end', label: 'end' },
324+
{ value: 'start', label: 'start' },
325+
],
326+
},
327+
},
328+
{
329+
field: 'wrap',
330+
defaultValue: true,
331+
component: 'Switch',
332+
label: 'wrap',
333+
colProps: { span: 24 },
334+
},
335+
336+
{
337+
field: 'd3',
234338
component: 'Divider',
235339
label: '操作按钮',
236340
colProps: { span: 24 },
@@ -242,18 +346,21 @@
242346
field: 'showActionButtonGroup',
243347
defaultValue: true,
244348
component: 'Switch',
245-
label: '操作按钮',
349+
label: 'showActionButtonGroup',
246350
colProps: { span: 24 },
247351
componentProps: ({ formActionType }) => {
248352
return {
249-
size: 'small',
250353
onChange: async (val: boolean) => {
251354
formActionType.updateSchema([
252355
{ field: 'showResetButton', componentProps: { disabled: !val } },
253356
{
254357
field: 'showSubmitButton',
255358
componentProps: { disabled: !val },
256359
},
360+
{
361+
field: 'actionColOptions.span',
362+
componentProps: { disabled: !val },
363+
},
257364
]);
258365
},
259366
};
@@ -263,24 +370,36 @@
263370
field: 'showResetButton',
264371
defaultValue: true,
265372
component: 'Switch',
266-
label: '重置按钮',
373+
label: 'showResetButton',
267374
colProps: { span: 24 },
268-
componentProps: {
269-
size: 'small',
270-
},
271375
},
272376
{
273377
field: 'showSubmitButton',
274378
defaultValue: true,
275379
component: 'Switch',
276-
label: '提交按钮',
380+
label: 'showSubmitButton',
381+
colProps: { span: 24 },
382+
},
383+
384+
{
385+
field: 'd4',
386+
component: 'Divider',
387+
label: '操作按钮网格布局(actionColOptions)',
277388
colProps: { span: 24 },
278389
componentProps: {
279-
size: 'small',
390+
orientation: 'center',
280391
},
281392
},
282393
{
283-
field: '',
394+
field: 'actionColOptions.span',
395+
component: 'Slider',
396+
defaultValue: 24,
397+
label: 'span',
398+
colProps: { span: 24 },
399+
componentProps: { min: 0, max: 24 },
400+
},
401+
{
402+
field: 'd5',
284403
component: 'Divider',
285404
label: '其他事件',
286405
colProps: { span: 24 },
@@ -309,32 +428,29 @@
309428
const visible = ref<boolean>(false);
310429
const settingFormRef = ref();
311430
const [registerSetting] = useForm({
312-
labelWidth: 80,
431+
size: 'small',
313432
schemas: formSchemas,
314433
compact: true,
315434
actionColOptions: { span: 24 },
316435
showActionButtonGroup: false,
317436
});
318-
319437
const resetSettings = async () => {
320438
setProps({ resetButtonOptions: { disabled: false, text: '重置' } });
321439
setProps({ submitButtonOptions: { disabled: false, loading: false } });
322440
await setFieldsValue({ field9: [] });
323441
await settingFormRef.value?.resetFields();
324442
};
325-
326443
const handleSubmitSetting = async (values: Recordable) => {
444+
console.log(values);
327445
await setProps(values);
328446
visible.value = false;
329447
};
330-
331448
const [register, { setProps, setFieldsValue, updateSchema }] = useForm({
332449
labelWidth: 120,
333450
schemas,
334451
actionColOptions: { span: 24 },
335452
fieldMapToTime: [['fieldTime', ['startTime', 'endTime'], 'YYYY-MM']],
336453
});
337-
338454
async function handleLoad() {
339455
const promiseFn = function () {
340456
return new Promise((resolve) => {
@@ -348,9 +464,7 @@
348464
}, 1000);
349465
});
350466
};
351-
352467
const item = await promiseFn();
353-
354468
const { field9, province, city, district } = item as any;
355469
await updateSchema({
356470
field: 'field9',
@@ -359,16 +473,14 @@
359473
},
360474
});
361475
await setFieldsValue({ field9 });
476+
visible.value = false;
362477
}
363-
364478
const showDrawer = () => {
365479
visible.value = true;
366480
};
367-
368481
const onSettings = () => {
369482
settingFormRef.value?.submit();
370483
};
371-
372484
const withClose = (formProps: Partial<FormProps>) => {
373485
setProps(formProps);
374486
visible.value = false;

0 commit comments

Comments
 (0)