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

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

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]) {
xiaohu's avatar
xiaohu committed
17
      case 'Step1':
jim's avatar
jim committed
18
        return 0;
xiaohu's avatar
xiaohu committed
19
      case 'Step2':
jim's avatar
jim committed
20
        return 1;
xiaohu's avatar
xiaohu committed
21
      case 'Step3':
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 44
            {children}
            {/* <Switch>
jim's avatar
jim committed
45 46 47 48 49 50 51 52
              {getRoutes(match.path, routerData).map(item => (
                <Route
                  key={item.key}
                  path={item.path}
                  component={item.component}
                  exact={item.exact}
                />
              ))}
WhatAKitty's avatar
WhatAKitty committed
53
              <Redirect exact from="/form/step-form" to="/form/step-form/info" />
陈帅's avatar
陈帅 committed
54
              <Redirect to="/exception/404" />
xiaohu's avatar
xiaohu committed
55
            </Switch> */}
陈帅's avatar
陈帅 committed
56
          </Fragment>
57 58 59 60 61
        </Card>
      </PageHeaderLayout>
    );
  }
}