index.js 1.26 KB
Newer Older
陈帅's avatar
陈帅 committed
1
import React, { PureComponent, Fragment } from 'react';
WhatAKitty's avatar
WhatAKitty committed
2
import { Card, Steps } from 'antd';
3
import PageHeaderWrapper from '@/components/PageHeaderWrapper';
4 5
import styles from '../style.less';

afc163's avatar
afc163 committed
6
const { Step } = Steps;
7

WhatAKitty's avatar
WhatAKitty committed
8
export default class StepForm extends PureComponent {
9
  getCurrentStep() {
ddcat1115's avatar
ddcat1115 committed
10 11 12 13
    const { location } = this.props;
    const { pathname } = location;
    const pathList = pathname.split('/');
    switch (pathList[pathList.length - 1]) {
陈帅's avatar
陈帅 committed
14
      case 'info':
jim's avatar
jim committed
15
        return 0;
陈帅's avatar
陈帅 committed
16
      case 'confirm':
jim's avatar
jim committed
17
        return 1;
陈帅's avatar
陈帅 committed
18
      case 'result':
jim's avatar
jim committed
19 20 21
        return 2;
      default:
        return 0;
22 23
    }
  }
陈帅's avatar
陈帅 committed
24

25
  render() {
xiaohu's avatar
xiaohu committed
26
    const { location, children } = this.props;
27
    return (
28
      <PageHeaderWrapper
jim's avatar
jim committed
29
        title="分步表单"
jim's avatar
jim committed
30
        tabActiveKey={location.pathname}
jim's avatar
jim committed
31 32
        content="将一个冗长或用户不熟悉的表单任务分成多个步骤,指导用户完成。"
      >
33
        <Card bordered={false}>
陈帅's avatar
陈帅 committed
34
          <Fragment>
35 36 37 38 39
            <Steps current={this.getCurrentStep()} className={styles.steps}>
              <Step title="填写转账信息" />
              <Step title="确认转账信息" />
              <Step title="完成" />
            </Steps>
xiaohu's avatar
xiaohu committed
40
            {children}
陈帅's avatar
陈帅 committed
41
          </Fragment>
42
        </Card>
43
      </PageHeaderWrapper>
44 45 46
    );
  }
}