Step2.js 2.98 KB
Newer Older
1
import React from 'react';
WhatAKitty's avatar
WhatAKitty committed
2
import { connect } from 'dva';
3
import { Form, Input, Button, Alert, Divider } from 'antd';
zinkey's avatar
zinkey committed
4
import router from 'umi/router';
5
import { digitUppercase } from '@/utils/utils';
6 7
import styles from './style.less';

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

@Form.create()
class Step2 extends React.PureComponent {
  render() {
    const { form, data, dispatch, submitting } = this.props;
    const { getFieldDecorator, validateFields } = form;
    const onPrev = () => {
zinkey's avatar
zinkey committed
23
      router.push('/form/step-form/info');
WhatAKitty's avatar
WhatAKitty committed
24
    };
jim's avatar
jim committed
25
    const onValidateForm = e => {
WhatAKitty's avatar
WhatAKitty committed
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
      e.preventDefault();
      validateFields((err, values) => {
        if (!err) {
          dispatch({
            type: 'form/submitStepForm',
            payload: {
              ...data,
              ...values,
            },
          });
        }
      });
    };
    return (
      <Form layout="horizontal" className={styles.stepForm}>
        <Alert
          closable
          showIcon
          message="确认转账后,资金将直接打入对方账户,无法退回。"
          style={{ marginBottom: 24 }}
        />
jim's avatar
jim committed
47
        <Form.Item {...formItemLayout} className={styles.stepFormText} label="付款账户">
WhatAKitty's avatar
WhatAKitty committed
48 49
          {data.payAccount}
        </Form.Item>
jim's avatar
jim committed
50
        <Form.Item {...formItemLayout} className={styles.stepFormText} label="收款账户">
WhatAKitty's avatar
WhatAKitty committed
51 52
          {data.receiverAccount}
        </Form.Item>
jim's avatar
jim committed
53
        <Form.Item {...formItemLayout} className={styles.stepFormText} label="收款人姓名">
WhatAKitty's avatar
WhatAKitty committed
54 55
          {data.receiverName}
        </Form.Item>
jim's avatar
jim committed
56
        <Form.Item {...formItemLayout} className={styles.stepFormText} label="转账金额">
WhatAKitty's avatar
WhatAKitty committed
57
          <span className={styles.money}>{data.amount}</span>
58
          <span className={styles.uppercase}>{digitUppercase(data.amount)}</span>
WhatAKitty's avatar
WhatAKitty committed
59 60
        </Form.Item>
        <Divider style={{ margin: '24px 0' }} />
jim's avatar
jim committed
61
        <Form.Item {...formItemLayout} label="支付密码" required={false}>
WhatAKitty's avatar
WhatAKitty committed
62 63
          {getFieldDecorator('password', {
            initialValue: '123456',
jim's avatar
jim committed
64 65 66 67 68 69 70
            rules: [
              {
                required: true,
                message: '需要支付密码才能进行支付',
              },
            ],
          })(<Input type="password" autoComplete="off" style={{ width: '80%' }} />)}
WhatAKitty's avatar
WhatAKitty committed
71 72 73 74 75
        </Form.Item>
        <Form.Item
          style={{ marginBottom: 8 }}
          wrapperCol={{
            xs: { span: 24, offset: 0 },
jim's avatar
jim committed
76 77 78 79
            sm: {
              span: formItemLayout.wrapperCol.span,
              offset: formItemLayout.labelCol.span,
            },
WhatAKitty's avatar
WhatAKitty committed
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
          }}
          label=""
        >
          <Button type="primary" onClick={onValidateForm} loading={submitting}>
            提交
          </Button>
          <Button onClick={onPrev} style={{ marginLeft: 8 }}>
            上一步
          </Button>
        </Form.Item>
      </Form>
    );
  }
}

Andreas Cederström's avatar
Andreas Cederström committed
95 96
export default connect(({ form, loading }) => ({
  submitting: loading.effects['form/submitStepForm'],
WhatAKitty's avatar
WhatAKitty committed
97 98
  data: form.step,
}))(Step2);