123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- import React, { useState, useEffect } from 'react';
- import { Card, Steps } from 'antd';
- import { PageContainer } from '@ant-design/pro-layout';
- import { connect } from 'umi';
- import Step1 from './components/Step1';
- import Step2 from './components/Step2';
- import styles from './style.less';
- const { Step } = Steps;
- const getCurrentStepAndComponent = (current) => {
- switch (current) {
- case 'detail':
- return {
- step: 1,
- component: <Step2 />,
- };
- case 'info':
- default:
- return {
- step: 0,
- component: <Step1 />,
- };
- }
- };
- const EditReport = ({ current }) => {
- const [stepComponent, setStepComponent] = useState(<Step1 />);
- const [currentStep, setCurrentStep] = useState(0);
- useEffect(() => {
- const { step, component } = getCurrentStepAndComponent(current);
- setCurrentStep(step);
- setStepComponent(component);
- }, [current]);
- console.log(stepComponent)
- return (
- <Card bordered={false}>
- <>
- <Steps current={currentStep} className={styles.steps}>
- <Step title="基础信息" />
- <Step title="报告详情" />
- </Steps>
- {stepComponent}
- </>
- </Card>
- );
- };
- export default connect(({ editReport }) => ({
- current: editReport.current,
- }))(EditReport);
|