TopSearch.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. import React, { memo } from 'react';
  2. import { Row, Col, Table, Tooltip, Card, Icon } from 'antd';
  3. import { FormattedMessage } from 'umi/locale';
  4. import Trend from '@/components/Trend';
  5. import numeral from 'numeral';
  6. import styles from './Analysis.less';
  7. import NumberInfo from '@/components/NumberInfo';
  8. import { MiniArea } from '@/components/Charts';
  9. const columns = [
  10. {
  11. title: <FormattedMessage id="app.analysis.table.rank" defaultMessage="Rank" />,
  12. dataIndex: 'index',
  13. key: 'index',
  14. },
  15. {
  16. title: (
  17. <FormattedMessage id="app.analysis.table.search-keyword" defaultMessage="Search keyword" />
  18. ),
  19. dataIndex: 'keyword',
  20. key: 'keyword',
  21. render: text => <a href="/">{text}</a>,
  22. },
  23. {
  24. title: <FormattedMessage id="app.analysis.table.users" defaultMessage="Users" />,
  25. dataIndex: 'count',
  26. key: 'count',
  27. sorter: (a, b) => a.count - b.count,
  28. className: styles.alignRight,
  29. },
  30. {
  31. title: <FormattedMessage id="app.analysis.table.weekly-range" defaultMessage="Weekly Range" />,
  32. dataIndex: 'range',
  33. key: 'range',
  34. sorter: (a, b) => a.range - b.range,
  35. render: (text, record) => (
  36. <Trend flag={record.status === 1 ? 'down' : 'up'}>
  37. <span style={{ marginRight: 4 }}>{text}%</span>
  38. </Trend>
  39. ),
  40. align: 'right',
  41. },
  42. ];
  43. const TopSearch = memo(({ loading, visitData2, searchData, dropdownGroup }) => (
  44. <Card
  45. loading={loading}
  46. bordered={false}
  47. title={
  48. <FormattedMessage id="app.analysis.online-top-search" defaultMessage="Online Top Search" />
  49. }
  50. extra={dropdownGroup}
  51. style={{ marginTop: 24 }}
  52. >
  53. <Row gutter={68}>
  54. <Col sm={12} xs={24} style={{ marginBottom: 24 }}>
  55. <NumberInfo
  56. subTitle={
  57. <span>
  58. <FormattedMessage id="app.analysis.search-users" defaultMessage="search users" />
  59. <Tooltip
  60. title={<FormattedMessage id="app.analysis.introduce" defaultMessage="introduce" />}
  61. >
  62. <Icon style={{ marginLeft: 8 }} type="info-circle-o" />
  63. </Tooltip>
  64. </span>
  65. }
  66. gap={8}
  67. total={numeral(12321).format('0,0')}
  68. status="up"
  69. subTotal={17.1}
  70. />
  71. <MiniArea line height={45} data={visitData2} />
  72. </Col>
  73. <Col sm={12} xs={24} style={{ marginBottom: 24 }}>
  74. <NumberInfo
  75. subTitle={
  76. <span>
  77. <FormattedMessage
  78. id="app.analysis.per-capita-search"
  79. defaultMessage="Per Capita Search"
  80. />
  81. <Tooltip
  82. title={<FormattedMessage id="app.analysis.introduce" defaultMessage="introduce" />}
  83. >
  84. <Icon style={{ marginLeft: 8 }} type="info-circle-o" />
  85. </Tooltip>
  86. </span>
  87. }
  88. total={2.7}
  89. status="down"
  90. subTotal={26.2}
  91. gap={8}
  92. />
  93. <MiniArea line height={45} data={visitData2} />
  94. </Col>
  95. </Row>
  96. <Table
  97. rowKey={record => record.index}
  98. size="small"
  99. columns={columns}
  100. dataSource={searchData}
  101. pagination={{
  102. style: { marginBottom: 0 },
  103. pageSize: 5,
  104. }}
  105. />
  106. </Card>
  107. ));
  108. export default TopSearch;