List.js 1.79 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 7

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

Rayron Victor's avatar
Rayron Victor committed
26
  handleFormSubmit = value => {
27 28
    // eslint-disable-next-line
    console.log(value);
Rayron Victor's avatar
Rayron Victor committed
29
  };
偏右's avatar
偏右 committed
30 31

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

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

xiaohu's avatar
xiaohu committed
59
    const { match, children, location } = this.props;
偏右's avatar
偏右 committed
60 61

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

export default SearchList;