Step1.js 4.2 KB

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