import React, { cloneElement, PureComponent } from 'react'; import { connect } from 'dva'; import { Card, Steps, Form } from 'antd'; import PageHeaderLayout from '../../../layouts/PageHeaderLayout'; import Step1 from './Step1'; import styles from '../style.less'; const Step = Steps.Step; @Form.create() class StepForm extends PureComponent { getCurrentStep() { const { routes } = this.props; switch (routes[routes.length - 1].path) { case 'step-form': return 0; case 'confirm': return 1; case 'result': return 2; default: return 0; } } render() { const { form, stepFormData, submitting, dispatch, children } = this.props; const formItemLayout = { labelCol: { span: 5, }, wrapperCol: { span: 19, }, }; return (
{children ? cloneElement(children, { form, formItemLayout, data: stepFormData, submitting, dispatch, }) : ( )}
); } } export default connect(state => ({ stepFormData: state.form.step, submitting: state.form.stepFormSubmitting, }))(StepForm);