Skip to content

Commit 735f0cc

Browse files
authored
Merge pull request #141 from codingapi/dev
update from
2 parents 66efa8f + 5bfa0a1 commit 735f0cc

File tree

2 files changed

+307
-293
lines changed

2 files changed

+307
-293
lines changed

admin-ui/src/pages/form/index.tsx

Lines changed: 159 additions & 147 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +143,6 @@ const FooterButtons: React.FC<{ formInstance: FormInstance }> = ({formInstance})
143143
name: ['user', 'name'],
144144
label: '姓名',
145145
placeholder: '请输入姓名',
146-
validateFunction: async (content) => {
147-
const value = content.value;
148-
if (value) {
149-
return []
150-
}
151-
return ['姓名不能为空']
152-
}
153146
},
154147
type: 'input'
155148
}, 0);
@@ -172,13 +165,6 @@ const FormPage = () => {
172165
name: ['user', 'name'],
173166
label: '姓名',
174167
placeholder: '请输入姓名',
175-
validateFunction: async (content) => {
176-
const value = content.value;
177-
if (value) {
178-
return []
179-
}
180-
return ['姓名不能为空']
181-
}
182168
}
183169
},
184170
{
@@ -197,13 +183,6 @@ const FormPage = () => {
197183
name: ['user', 'password'],
198184
label: '银行卡密码',
199185
placeholder: '请输入银行卡密码',
200-
validateFunction: async (content) => {
201-
const value = content.value;
202-
if (value) {
203-
return []
204-
}
205-
return ['银行卡密码不能为空']
206-
}
207186
}
208187
},
209188
{
@@ -406,196 +385,229 @@ const FormPage = () => {
406385
/>
407386
)}
408387
>
409-
<FormInput
388+
<Form.Item
410389
required={true}
411390
name={["user", "name"]}
412391
label={"姓名"}
413-
placeholder={"请输入姓名"}
414-
validateFunction={async (content) => {
415-
const value = content.value;
416-
if (value) {
417-
return []
392+
rules={[
393+
{
394+
required: true,
395+
message: '姓名不能为空'
418396
}
419-
return ['姓名不能为空']
420-
}}
421-
/>
397+
]}
398+
>
399+
<FormInput
400+
placeholder={"请输入姓名"}
401+
/>
402+
</Form.Item>
422403

423-
<FormStepper
404+
<Form.Item
424405
required={true}
425406
name={["user", "age"]}
426407
label={"年龄"}
427-
placeholder={"请输入年龄"}
428-
/>
408+
>
409+
<FormStepper
410+
placeholder={"请输入年龄"}
411+
/>
412+
</Form.Item>
413+
429414

430-
<FormPassword
415+
<Form.Item
431416
required={true}
432417
name={["user", "password"]}
433418
label={"银行卡密码"}
434-
placeholder={"请输入银行卡密码"}
435-
validateFunction={async (content) => {
436-
const value = content.value;
437-
if (value) {
438-
return []
439-
}
440-
return ['银行卡密码不能为空']
441-
}}
442-
/>
419+
>
420+
<FormPassword/>
421+
</Form.Item>
443422

444-
<FormCaptcha
423+
<Form.Item
445424
required={true}
446425
name={["user", "code"]}
447426
label={"银行卡验证码"}
448-
placeholder={"请输入银行卡验证码"}
449-
onCaptchaRefresh={async () => {
450-
console.log('refresh captcha')
451-
return {
452-
url: '/captcha.jpeg',
453-
code: '123'
454-
}
455-
}}
456-
/>
427+
>
428+
<FormCaptcha
429+
placeholder={"请输入银行卡验证码"}
430+
onCaptchaRefresh={async () => {
431+
console.log('refresh captcha')
432+
return {
433+
url: '/captcha.jpeg',
434+
code: '123'
435+
}
436+
}}
437+
/>
438+
</Form.Item>
457439

458-
<FormCheckbox
440+
<Form.Item
459441
required={true}
460442
name={["user", "checkbox"]}
461443
label={"复选框"}
462-
options={[
463-
{label: '选项1', value: '1'},
464-
{label: '选项2', value: '2'},
465-
{label: '选项3', value: '3'},
466-
]}
467-
/>
444+
>
445+
<FormCheckbox
446+
options={[
447+
{label: '选项1', value: '1'},
448+
{label: '选项2', value: '2'},
449+
{label: '选项3', value: '3'},
450+
]}
451+
/>
452+
</Form.Item>
468453

469-
<FormRadio
454+
<Form.Item
470455
required={true}
471456
name={["user", "radio"]}
472457
label={"单选框"}
473-
options={[
474-
{label: '选项1', value: '1'},
475-
{label: '选项2', value: '2'},
476-
{label: '选项3', value: '3'},
477-
]}
478-
/>
458+
>
459+
<FormRadio
460+
options={[
461+
{label: '选项1', value: '1'},
462+
{label: '选项2', value: '2'},
463+
{label: '选项3', value: '3'},
464+
]}
465+
/>
466+
</Form.Item>
479467

480-
<FormRate
468+
<Form.Item
481469
required={true}
482470
name={["user", "rate"]}
483471
label={"评分"}
484-
/>
472+
>
473+
<FormRate/>
474+
</Form.Item>
485475

486-
<FormSlider
476+
<Form.Item
487477
required={true}
488478
name={["user", "slider"]}
489479
label={"滑块"}
490-
sliderPopover={true}
491-
/>
480+
>
481+
<FormSlider
482+
sliderPopover={true}
483+
/>
484+
</Form.Item>
492485

493-
<FormSwitch
486+
<Form.Item
494487
required={true}
495488
name={["user", "switch"]}
496489
label={"开关"}
497-
/>
490+
>
491+
<FormSwitch/>
492+
</Form.Item>
498493

499-
<FormTextArea
494+
<Form.Item
500495
required={true}
501496
name={["user", "textarea"]}
502497
label={"文本域"}
503-
/>
498+
>
499+
<FormTextArea/>
500+
</Form.Item>
504501

505-
<FormDate
502+
<Form.Item
506503
required={true}
507504
name={["user", "date"]}
508505
label={"日期"}
509-
/>
506+
>
507+
<FormDate/>
508+
</Form.Item>
510509

511-
<FormCascader
510+
<Form.Item
512511
required={true}
513512
name={["user", "cascader"]}
514513
label={"级联选择"}
515-
options={[
516-
{
517-
label: '选项1',
518-
value: '1',
519-
children: [
520-
{
521-
label: '选项1-1',
522-
value: '1-1',
523-
children: [
524-
{
525-
label: '选项1-1-1',
526-
value: '1-1-1',
527-
},
528-
{
529-
label: '选项1-1-2',
530-
value: '1-1-2',
531-
},
532-
]
533-
},
534-
{
535-
label: '选项1-2',
536-
value: '1-2',
537-
},
538-
]
539-
},
540-
{
541-
label: '选项2',
542-
value: '2',
543-
children: [
544-
{
545-
label: '选项2-1',
546-
value: '2-1',
547-
},
548-
{
549-
label: '选项2-2',
550-
value: '2-2',
551-
},
552-
]
553-
},
554-
]}
555-
/>
514+
>
515+
<FormCascader
516+
options={[
517+
{
518+
label: '选项1',
519+
value: '1',
520+
children: [
521+
{
522+
label: '选项1-1',
523+
value: '1-1',
524+
children: [
525+
{
526+
label: '选项1-1-1',
527+
value: '1-1-1',
528+
},
529+
{
530+
label: '选项1-1-2',
531+
value: '1-1-2',
532+
},
533+
]
534+
},
535+
{
536+
label: '选项1-2',
537+
value: '1-2',
538+
},
539+
]
540+
},
541+
{
542+
label: '选项2',
543+
value: '2',
544+
children: [
545+
{
546+
label: '选项2-1',
547+
value: '2-1',
548+
},
549+
{
550+
label: '选项2-2',
551+
value: '2-2',
552+
},
553+
]
554+
},
555+
]}
556+
/>
557+
</Form.Item>
556558

557-
<FormSelect
559+
<Form.Item
558560
required={true}
559561
name={["user", "select"]}
560562
label={"选择器"}
561-
selectMultiple={true}
562-
options={[
563-
{
564-
label: '选项1', value: '1',
565-
children: [
566-
{
567-
label: '选项1-1',
568-
value: '1-1',
569-
children: [
570-
{label: '选项1-1-1', value: '1-1-1'},
571-
{label: '选项1-1-2', value: '1-1-2'},
572-
]
573-
},
574-
{label: '选项1-2', value: '1-2'},
575-
]
576-
},
577-
{label: '选项2', value: '2'},
578-
{label: '选项3', value: '3'},
579-
]}
580-
/>
563+
>
564+
<FormSelect
565+
566+
selectMultiple={true}
567+
options={[
568+
{
569+
label: '选项1', value: '1',
570+
children: [
571+
{
572+
label: '选项1-1',
573+
value: '1-1',
574+
children: [
575+
{label: '选项1-1-1', value: '1-1-1'},
576+
{label: '选项1-1-2', value: '1-1-2'},
577+
]
578+
},
579+
{label: '选项1-2', value: '1-2'},
580+
]
581+
},
582+
{label: '选项2', value: '2'},
583+
{label: '选项3', value: '3'},
584+
]}
585+
/>
586+
</Form.Item>
581587

582-
<FormUploader
588+
<Form.Item
583589
required={true}
584590
name={["user", "avatar"]}
585591
label={"头像"}
586-
/>
592+
>
593+
<FormUploader/>
594+
</Form.Item>
587595

588-
<FormColor
596+
<Form.Item
589597
required={true}
590598
name={["user", "color"]}
591599
label={"颜色"}
592-
/>
600+
>
601+
<FormColor/>
602+
</Form.Item>
593603

594-
<FormCode
604+
<Form.Item
595605
required={true}
596606
name={["user", "ideCode"]}
597607
label={"代码"}
598-
/>
608+
>
609+
<FormCode/>
610+
</Form.Item>
599611
</Form>
600612
</Col>
601613

0 commit comments

Comments
 (0)