List.js 1.68 KB
Newer Older
偏右's avatar
偏右 committed
1
import React, { Component } from 'react';
zinkey's avatar
zinkey committed
2
import router from 'umi/router';
偏右's avatar
偏右 committed
3 4
import { connect } from 'dva';
import { Input } from 'antd';
5
import PageHeaderWrapper from '@/components/PageHeaderWrapper';
偏右's avatar
偏右 committed
6

afc163's avatar
afc163 committed
7
export default
偏右's avatar
偏右 committed
8
@connect()
afc163's avatar
afc163 committed
9
class SearchList extends Component {
jim's avatar
jim committed
10
  handleTabChange = key => {
zinkey's avatar
zinkey committed
11
    const { match } = this.props;
偏右's avatar
偏右 committed
12
    switch (key) {
13
      case 'articles':
zinkey's avatar
zinkey committed
14
        router.push(`${match.url}/articles`);
偏右's avatar
偏右 committed
15
        break;
16
      case 'applications':
zinkey's avatar
zinkey committed
17
        router.push(`${match.url}/applications`);
偏右's avatar
偏右 committed
18
        break;
19
      case 'projects':
zinkey's avatar
zinkey committed
20
        router.push(`${match.url}/projects`);
偏右's avatar
偏右 committed
21 22 23 24
        break;
      default:
        break;
    }
jim's avatar
jim committed
25
  };
偏右's avatar
偏右 committed
26 27

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

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

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

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