index.jsx 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import React, { useState, useEffect } from 'react';
  2. import { Card, Steps } from 'antd';
  3. import { PageContainer } from '@ant-design/pro-layout';
  4. import { connect } from 'umi';
  5. import Step1 from './components/Step1';
  6. import Step2 from './components/Step2';
  7. import styles from './style.less';
  8. const { Step } = Steps;
  9. const getCurrentStepAndComponent = (current) => {
  10. switch (current) {
  11. case 'detail':
  12. return {
  13. step: 1,
  14. component: <Step2 />,
  15. };
  16. case 'info':
  17. default:
  18. return {
  19. step: 0,
  20. component: <Step1 />,
  21. };
  22. }
  23. };
  24. const EditReport = ({ current }) => {
  25. const [stepComponent, setStepComponent] = useState(<Step1 />);
  26. const [currentStep, setCurrentStep] = useState(0);
  27. useEffect(() => {
  28. const { step, component } = getCurrentStepAndComponent(current);
  29. setCurrentStep(step);
  30. setStepComponent(component);
  31. }, [current]);
  32. console.log(stepComponent)
  33. return (
  34. <Card bordered={false}>
  35. <>
  36. <Steps current={currentStep} className={styles.steps}>
  37. <Step title="基础信息" />
  38. <Step title="报告详情" />
  39. </Steps>
  40. {stepComponent}
  41. </>
  42. </Card>
  43. );
  44. };
  45. export default connect(({ editReport }) => ({
  46. current: editReport.current,
  47. }))(EditReport);