TopSearch.js 3.35 KB
Newer Older
陈帅's avatar
陈帅 committed
1 2
import React, { memo } from 'react';
import { Row, Col, Table, Tooltip, Card, Icon } from 'antd';
陈帅's avatar
陈帅 committed
3
import { FormattedMessage } from 'umi-plugin-react/locale';
4
import { Trend, NumberInfo, Charts } from 'ant-design-pro';
陈帅's avatar
陈帅 committed
5
import numeral from 'numeral';
6 7 8
import styles from '../style.less';

const { MiniArea } = Charts;
陈帅's avatar
陈帅 committed
9 10 11

const columns = [
  {
12
    title: <FormattedMessage id="BLOCK_NAME.table.rank" defaultMessage="Rank" />,
陈帅's avatar
陈帅 committed
13 14 15 16 17
    dataIndex: 'index',
    key: 'index',
  },
  {
    title: (
18
      <FormattedMessage id="BLOCK_NAME.table.search-keyword" defaultMessage="Search keyword" />
陈帅's avatar
陈帅 committed
19 20 21 22 23 24
    ),
    dataIndex: 'keyword',
    key: 'keyword',
    render: text => <a href="/">{text}</a>,
  },
  {
25
    title: <FormattedMessage id="BLOCK_NAME.table.users" defaultMessage="Users" />,
陈帅's avatar
陈帅 committed
26 27 28 29 30 31
    dataIndex: 'count',
    key: 'count',
    sorter: (a, b) => a.count - b.count,
    className: styles.alignRight,
  },
  {
32
    title: <FormattedMessage id="BLOCK_NAME.table.weekly-range" defaultMessage="Weekly Range" />,
陈帅's avatar
陈帅 committed
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
    dataIndex: 'range',
    key: 'range',
    sorter: (a, b) => a.range - b.range,
    render: (text, record) => (
      <Trend flag={record.status === 1 ? 'down' : 'up'}>
        <span style={{ marginRight: 4 }}>{text}%</span>
      </Trend>
    ),
    align: 'right',
  },
];

const TopSearch = memo(({ loading, visitData2, searchData, dropdownGroup }) => (
  <Card
    loading={loading}
    bordered={false}
    title={
xiaohuoni's avatar
xiaohuoni committed
50 51 52 53
      <FormattedMessage
        id="BLOCK_NAME.analysis.online-top-search"
        defaultMessage="Online Top Search"
      />
陈帅's avatar
陈帅 committed
54 55 56 57 58 59 60 61 62
    }
    extra={dropdownGroup}
    style={{ marginTop: 24 }}
  >
    <Row gutter={68}>
      <Col sm={12} xs={24} style={{ marginBottom: 24 }}>
        <NumberInfo
          subTitle={
            <span>
xiaohuoni's avatar
xiaohuoni committed
63 64 65 66
              <FormattedMessage
                id="BLOCK_NAME.analysis.search-users"
                defaultMessage="search users"
              />
陈帅's avatar
陈帅 committed
67
              <Tooltip
xiaohuoni's avatar
xiaohuoni committed
68 69 70
                title={
                  <FormattedMessage id="BLOCK_NAME.analysis.introduce" defaultMessage="introduce" />
                }
陈帅's avatar
陈帅 committed
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
              >
                <Icon style={{ marginLeft: 8 }} type="info-circle-o" />
              </Tooltip>
            </span>
          }
          gap={8}
          total={numeral(12321).format('0,0')}
          status="up"
          subTotal={17.1}
        />
        <MiniArea line height={45} data={visitData2} />
      </Col>
      <Col sm={12} xs={24} style={{ marginBottom: 24 }}>
        <NumberInfo
          subTitle={
            <span>
              <FormattedMessage
88
                id="BLOCK_NAME.analysis.per-capita-search"
陈帅's avatar
陈帅 committed
89 90 91
                defaultMessage="Per Capita Search"
              />
              <Tooltip
xiaohuoni's avatar
xiaohuoni committed
92 93 94
                title={
                  <FormattedMessage id="BLOCK_NAME.analysis.introduce" defaultMessage="introduce" />
                }
陈帅's avatar
陈帅 committed
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
              >
                <Icon style={{ marginLeft: 8 }} type="info-circle-o" />
              </Tooltip>
            </span>
          }
          total={2.7}
          status="down"
          subTotal={26.2}
          gap={8}
        />
        <MiniArea line height={45} data={visitData2} />
      </Col>
    </Row>
    <Table
      rowKey={record => record.index}
      size="small"
      columns={columns}
      dataSource={searchData}
      pagination={{
        style: { marginBottom: 0 },
        pageSize: 5,
      }}
    />
  </Card>
));

export default TopSearch;