Step1.js 4.09 KB
Newer Older
陈帅's avatar
陈帅 committed
1
import React, { Fragment } from 'react';
WhatAKitty's avatar
WhatAKitty committed
2
import { connect } from 'dva';
3
import { Form, Input, Button, Select, Divider } from 'antd';
zinkey's avatar
zinkey committed
4
import router from 'umi/router';
5 6
import styles from './style.less';

afc163's avatar
afc163 committed
7
const { Option } = Select;
8

WhatAKitty's avatar
WhatAKitty committed
9 10 11 12 13 14 15 16 17
const formItemLayout = {
  labelCol: {
    span: 5,
  },
  wrapperCol: {
    span: 19,
  },
};

18 19 20
@connect(({ form }) => ({
  data: form.step,
}))
WhatAKitty's avatar
WhatAKitty committed
21
@Form.create()
afc163's avatar
afc163 committed
22
class Step1 extends React.PureComponent {
WhatAKitty's avatar
WhatAKitty committed
23 24 25 26 27 28 29 30 31 32
  render() {
    const { form, dispatch, data } = this.props;
    const { getFieldDecorator, validateFields } = form;
    const onValidateForm = () => {
      validateFields((err, values) => {
        if (!err) {
          dispatch({
            type: 'form/saveStepFormData',
            payload: values,
          });
zinkey's avatar
zinkey committed
33
          router.push('/form/step-form/confirm');
WhatAKitty's avatar
WhatAKitty committed
34 35 36 37
        }
      });
    };
    return (
陈帅's avatar
陈帅 committed
38
      <Fragment>
WhatAKitty's avatar
WhatAKitty committed
39
        <Form layout="horizontal" className={styles.stepForm} hideRequiredMark>
jim's avatar
jim committed
40
          <Form.Item {...formItemLayout} label="付款账户">
WhatAKitty's avatar
WhatAKitty committed
41 42 43 44 45 46 47 48 49
            {getFieldDecorator('payAccount', {
              initialValue: data.payAccount,
              rules: [{ required: true, message: '请选择付款账户' }],
            })(
              <Select placeholder="test@example.com">
                <Option value="ant-design@alipay.com">ant-design@alipay.com</Option>
              </Select>
            )}
          </Form.Item>
jim's avatar
jim committed
50
          <Form.Item {...formItemLayout} label="收款账户">
WhatAKitty's avatar
WhatAKitty committed
51 52 53 54 55 56 57 58 59 60 61
            <Input.Group compact>
              <Select defaultValue="alipay" style={{ width: 100 }}>
                <Option value="alipay">支付宝</Option>
                <Option value="bank">银行账户</Option>
              </Select>
              {getFieldDecorator('receiverAccount', {
                initialValue: data.receiverAccount,
                rules: [
                  { required: true, message: '请输入收款人账户' },
                  { type: 'email', message: '账户名应为邮箱格式' },
                ],
jim's avatar
jim committed
62
              })(<Input style={{ width: 'calc(100% - 100px)' }} placeholder="test@example.com" />)}
WhatAKitty's avatar
WhatAKitty committed
63 64
            </Input.Group>
          </Form.Item>
jim's avatar
jim committed
65
          <Form.Item {...formItemLayout} label="收款人姓名">
WhatAKitty's avatar
WhatAKitty committed
66 67 68
            {getFieldDecorator('receiverName', {
              initialValue: data.receiverName,
              rules: [{ required: true, message: '请输入收款人姓名' }],
jim's avatar
jim committed
69
            })(<Input placeholder="请输入收款人姓名" />)}
WhatAKitty's avatar
WhatAKitty committed
70
          </Form.Item>
jim's avatar
jim committed
71
          <Form.Item {...formItemLayout} label="转账金额">
WhatAKitty's avatar
WhatAKitty committed
72 73
            {getFieldDecorator('amount', {
              initialValue: data.amount,
74
              rules: [
WhatAKitty's avatar
WhatAKitty committed
75
                { required: true, message: '请输入转账金额' },
jim's avatar
jim committed
76 77 78 79
                {
                  pattern: /^(\d+)((?:\.\d+)?)$/,
                  message: '请输入合法金额数字',
                },
80
              ],
jim's avatar
jim committed
81
            })(<Input prefix="" placeholder="请输入金额" />)}
WhatAKitty's avatar
WhatAKitty committed
82 83 84 85
          </Form.Item>
          <Form.Item
            wrapperCol={{
              xs: { span: 24, offset: 0 },
jim's avatar
jim committed
86 87 88 89
              sm: {
                span: formItemLayout.wrapperCol.span,
                offset: formItemLayout.labelCol.span,
              },
WhatAKitty's avatar
WhatAKitty committed
90 91 92 93 94 95 96 97 98 99 100 101
            }}
            label=""
          >
            <Button type="primary" onClick={onValidateForm}>
              下一步
            </Button>
          </Form.Item>
        </Form>
        <Divider style={{ margin: '40px 0 24px' }} />
        <div className={styles.desc}>
          <h3>说明</h3>
          <h4>转账到支付宝账户</h4>
jim's avatar
jim committed
102 103 104
          <p>
            如果需要这里可以放一些关于产品的常见问题说明如果需要这里可以放一些关于产品的常见问题说明如果需要这里可以放一些关于产品的常见问题说明
          </p>
WhatAKitty's avatar
WhatAKitty committed
105
          <h4>转账到银行卡</h4>
jim's avatar
jim committed
106 107 108
          <p>
            如果需要这里可以放一些关于产品的常见问题说明如果需要这里可以放一些关于产品的常见问题说明如果需要这里可以放一些关于产品的常见问题说明
          </p>
WhatAKitty's avatar
WhatAKitty committed
109
        </div>
陈帅's avatar
陈帅 committed
110
      </Fragment>
WhatAKitty's avatar
WhatAKitty committed
111 112 113
    );
  }
}
lijiehua's avatar
lijiehua committed
114 115

export default Step1;