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