index.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import React, { Component } from 'react';
  2. import { Redirect, Route, Switch, routerRedux } from 'dva/router';
  3. import { connect } from 'dva';
  4. import PageHeaderLayout from '../../../layouts/PageHeaderLayout';
  5. import { getRoutes } from '../../../utils/utils';
  6. @connect()
  7. export default class AccountsPage extends Component {
  8. handleTabChange = (key) => {
  9. const { dispatch, match } = this.props;
  10. switch (key) {
  11. // 终端课程包
  12. case 'terminals':
  13. dispatch(routerRedux.push(`${match.url}/terminals`));
  14. break;
  15. // 校区列表
  16. case 'campus':
  17. dispatch(routerRedux.push(`${match.url}/campus`));
  18. break;
  19. // 即将逾期
  20. case 'overdue':
  21. dispatch(routerRedux.push(`${match.url}/overdue`));
  22. break;
  23. // 总统计表
  24. case 'totalList':
  25. dispatch(routerRedux.push(`${match.url}/totalList`));
  26. break;
  27. // 已配置标签终端信息表
  28. case 'didLabelList':
  29. dispatch(routerRedux.push(`${match.url}/didLabelList`));
  30. break;
  31. default:
  32. break;
  33. }
  34. };
  35. render() {
  36. const tabList = [
  37. {
  38. key: 'terminals',
  39. tab: '已开通账号',
  40. },
  41. {
  42. key: 'campus',
  43. tab: '已开通校区',
  44. },
  45. {
  46. key: 'overdue',
  47. tab: '即将到期(30天)',
  48. },
  49. {
  50. key: 'didLabelList',
  51. tab: '已配置标签终端信息表',
  52. },
  53. {
  54. key: 'totalList',
  55. tab: '总统计表',
  56. },
  57. ];
  58. const { match, routerData, location } = this.props;
  59. const routes = getRoutes(match.path, routerData);
  60. return (
  61. <PageHeaderLayout
  62. tabList={tabList}
  63. tabActiveKey={location.pathname.replace(`${match.path}/`, '')}
  64. onTabChange={this.handleTabChange}
  65. >
  66. <Switch>
  67. {routes.map(item => (
  68. <Route key={item.key} path={item.path} component={item.component} exact={item.exact} />
  69. ))}
  70. <Redirect exact from="/dashboard/accounts" to="/dashboard/accounts/terminals" />
  71. </Switch>
  72. </PageHeaderLayout>
  73. );
  74. }
  75. }