11<template >
22 <div >
3- <a-form style =" max-width : 500px ; margin : 40px auto 0 ;" >
3+ <a-form :form = " form " style =" max-width : 500px ; margin : 40px auto 0 ;" >
44 <a-form-item
55 label =" 付款账户"
66 :labelCol =" labelCol"
77 :wrapperCol =" wrapperCol"
88 >
9- <a-select value =" 1" placeholder =" ant-design@alipay.com" >
9+ <a-select
10+ placeholder =" ant-design@alipay.com"
11+ v-decorator =" ['paymentUser', { rules: [{required: true, message: '付款账户必须填写'}] }]" >
1012 <a-select-option value =" 1" >ant-design@alipay.com</a-select-option >
1113 </a-select >
1214 </a-form-item >
1517 :labelCol =" labelCol"
1618 :wrapperCol =" wrapperCol"
1719 >
18- <a-input-group :compact =" true" style =" display : inline-block ; vertical-align : middle " >
20+ <a-input-group
21+ style =" display : inline-block ; vertical-align : middle "
22+ :compact =" true"
23+ >
1924 <a-select defaultValue =" alipay" style =" width : 100px " >
2025 <a-select-option value =" alipay" >支付宝</a-select-option >
2126 <a-select-option value =" wexinpay" >微信</a-select-option >
2227 </a-select >
23- <a-input :style =" {width: 'calc(100% - 100px)'}" value =" test@example.com" />
28+ <a-input
29+ :style =" {width: 'calc(100% - 100px)'}"
30+ v-decorator =" ['payType', { initialValue: 'test@example.com', rules: [{required: true, message: '收款账户必须填写'}]}]"
31+ />
2432 </a-input-group >
2533 </a-form-item >
2634 <a-form-item
2735 label =" 收款人姓名"
2836 :labelCol =" labelCol"
2937 :wrapperCol =" wrapperCol"
3038 >
31- <a-input value = " Alex" />
39+ <a-input v-decorator = " ['name', { initialValue: ' Alex', rules: [{required: true, message: '收款人名称必须核对'}] }] " />
3240 </a-form-item >
3341 <a-form-item
3442 label =" 转账金额"
3543 :labelCol =" labelCol"
3644 :wrapperCol =" wrapperCol"
3745 >
38- <a-input prefix =" ¥" value = " 5000" />
46+ <a-input prefix =" ¥" v-decorator = " ['momey', { initialValue: ' 5000', rules: [{required: true, message: '转账金额必须填写'}] }] " />
3947 </a-form-item >
4048 <a-form-item :wrapperCol =" {span: 19, offset: 5}" >
4149 <a-button type =" primary" @click =" nextStep" >下一步</a-button >
@@ -58,12 +66,19 @@ export default {
5866 data () {
5967 return {
6068 labelCol: { lg: { span: 5 }, sm: { span: 5 } },
61- wrapperCol: { lg: { span: 19 }, sm: { span: 19 } }
69+ wrapperCol: { lg: { span: 19 }, sm: { span: 19 } },
70+ form: this .$form .createForm (this )
6271 }
6372 },
6473 methods: {
6574 nextStep () {
66- this .$emit (' nextStep' )
75+ const { form: { validateFields } } = this
76+ // 先校验,通过表单校验后,才进入下一步
77+ validateFields ((err , values ) => {
78+ if (! err) {
79+ this .$emit (' nextStep' )
80+ }
81+ })
6782 }
6883 }
6984}
0 commit comments