index.js 1.35 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 PageHeaderLayout from '@/layouts/PageHeaderLayout';
4 5
import styles from '../style.less';

xiaohu's avatar
xiaohu committed
6
// import { Route, Redirect, Switch } from 'dva/router';
7
// import { getRoutes } from '@/utils/utils';
xiaohu's avatar
xiaohu committed
8

afc163's avatar
afc163 committed
9
const { Step } = Steps;
10

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

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