List.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import React, { Component } from 'react';
  2. import { routerRedux } from 'dva/router';
  3. import { connect } from 'dva';
  4. import { Input } from 'antd';
  5. import PageHeaderLayout from '../layouts/PageHeaderLayout';
  6. @connect()
  7. export default class SearchList extends Component {
  8. handleTabChange = key => {
  9. const { dispatch, match } = this.props;
  10. switch (key) {
  11. case 'Articles':
  12. dispatch(routerRedux.push(`${match.url}/Articles`));
  13. break;
  14. case 'Applications':
  15. dispatch(routerRedux.push(`${match.url}/Applications`));
  16. break;
  17. case 'Projects':
  18. dispatch(routerRedux.push(`${match.url}/Projects`));
  19. break;
  20. default:
  21. break;
  22. }
  23. };
  24. render() {
  25. const tabList = [
  26. {
  27. key: 'Articles',
  28. tab: '文章',
  29. },
  30. {
  31. key: 'projects',
  32. tab: '项目',
  33. },
  34. {
  35. key: 'applications',
  36. tab: '应用',
  37. },
  38. ];
  39. const mainSearch = (
  40. <div style={{ textAlign: 'center' }}>
  41. <Input.Search
  42. placeholder="请输入"
  43. enterButton="搜索"
  44. size="large"
  45. onSearch={this.handleFormSubmit}
  46. style={{ width: 522 }}
  47. />
  48. </div>
  49. );
  50. const { match, children, location } = this.props;
  51. return (
  52. <PageHeaderLayout
  53. title="搜索列表"
  54. content={mainSearch}
  55. tabList={tabList}
  56. tabActiveKey={location.pathname.replace(`${match.path}/`, '')}
  57. onTabChange={this.handleTabChange}
  58. >
  59. {children}
  60. {/* <Switch>
  61. {routes.map(item => (
  62. <Route key={item.key} path={item.path} component={item.component} exact={item.exact} />
  63. ))}
  64. </Switch> */}
  65. </PageHeaderLayout>
  66. );
  67. }
  68. }