List.js 1.74 KB
Newer Older
偏右's avatar
偏右 committed
1
import React, { Component } from 'react';
xiaohu's avatar
xiaohu committed
2
import { routerRedux } from 'dva/router';
偏右's avatar
偏右 committed
3 4
import { connect } from 'dva';
import { Input } from 'antd';
愚道's avatar
愚道 committed
5
import PageHeaderLayout from '../layouts/PageHeaderLayout';
偏右's avatar
偏右 committed
6 7 8

@connect()
export default class SearchList extends Component {
jim's avatar
jim committed
9
  handleTabChange = key => {
偏右's avatar
偏右 committed
10 11
    const { dispatch, match } = this.props;
    switch (key) {
xiaohu's avatar
xiaohu committed
12 13
      case 'Articles':
        dispatch(routerRedux.push(`${match.url}/Articles`));
偏右's avatar
偏右 committed
14
        break;
xiaohu's avatar
xiaohu committed
15 16
      case 'Applications':
        dispatch(routerRedux.push(`${match.url}/Applications`));
偏右's avatar
偏右 committed
17
        break;
xiaohu's avatar
xiaohu committed
18 19
      case 'Projects':
        dispatch(routerRedux.push(`${match.url}/Projects`));
偏右's avatar
偏右 committed
20 21 22 23
        break;
      default:
        break;
    }
jim's avatar
jim committed
24
  };
偏右's avatar
偏右 committed
25 26

  render() {
jim's avatar
jim committed
27 28
    const tabList = [
      {
xiaohu's avatar
xiaohu committed
29
        key: 'Articles',
jim's avatar
jim committed
30 31 32
        tab: '文章',
      },
      {
xiaohu's avatar
xiaohu committed
33
        key: 'Applications',
jim's avatar
jim committed
34 35 36
        tab: '应用',
      },
      {
xiaohu's avatar
xiaohu committed
37
        key: 'Projects',
jim's avatar
jim committed
38 39 40
        tab: '项目',
      },
    ];
偏右's avatar
偏右 committed
41 42 43 44 45 46 47 48 49 50 51 52 53

    const mainSearch = (
      <div style={{ textAlign: 'center' }}>
        <Input.Search
          placeholder="请输入"
          enterButton="搜索"
          size="large"
          onSearch={this.handleFormSubmit}
          style={{ width: 522 }}
        />
      </div>
    );

xiaohu's avatar
xiaohu committed
54
    const { match, children, location } = this.props;
偏右's avatar
偏右 committed
55 56 57 58 59 60

    return (
      <PageHeaderLayout
        title="搜索列表"
        content={mainSearch}
        tabList={tabList}
ddcat1115's avatar
ddcat1115 committed
61
        tabActiveKey={location.pathname.replace(`${match.path}/`, '')}
偏右's avatar
偏右 committed
62 63
        onTabChange={this.handleTabChange}
      >
xiaohu's avatar
xiaohu committed
64 65
        {children}
        {/* <Switch>
jim's avatar
jim committed
66 67 68
          {routes.map(item => (
            <Route key={item.key} path={item.path} component={item.component} exact={item.exact} />
          ))}
xiaohu's avatar
xiaohu committed
69
        </Switch> */}
偏右's avatar
偏右 committed
70 71 72 73
      </PageHeaderLayout>
    );
  }
}