Monitor.js 5.07 KB
Newer Older
1 2
import React, { PureComponent } from 'react';
import { connect } from 'dva';
3
import { Row, Col, Card, Tooltip } from 'antd';
4 5
import numeral from 'numeral';

偏右's avatar
偏右 committed
6 7
import { Pie, WaterWave, Gauge, TagCloud } from '../../components/Charts';
import NumberInfo from '../../components/NumberInfo';
niko's avatar
niko committed
8
import CountDown from '../../components/CountDown';
nikogu's avatar
nikogu committed
9
import ActiveChart from '../../components/ActiveChart';
10 11 12 13 14 15 16 17 18 19 20 21 22

import styles from './Monitor.less';

const targetTime = new Date().getTime() + 3900000;

@connect(state => ({
  monitor: state.monitor,
}))
export default class Monitor extends PureComponent {
  componentDidMount() {
    this.props.dispatch({
      type: 'monitor/fetchTags',
    });
nikogu's avatar
nikogu committed
23
  }
nikogu's avatar
nikogu committed
24

25 26 27 28 29
  render() {
    const { monitor } = this.props;
    const { tags } = monitor;

    return (
30
      <div>
31
        <Row gutter={24}>
niko's avatar
niko committed
32
          <Col xl={18} lg={24} md={24} sm={24} xs={24} style={{ marginBottom: 24 }}>
33
            <Card title="活动实时交易情况" bordered={false}>
34
              <Row>
niko's avatar
niko committed
35
                <Col md={6} sm={12} xs={24}>
36 37
                  <NumberInfo
                    subTitle="今日交易总额"
niko's avatar
niko committed
38
                    suffix=""
39 40 41
                    total={numeral(124543233).format('0,0')}
                  />
                </Col>
niko's avatar
niko committed
42
                <Col md={6} sm={12} xs={24}>
niko's avatar
niko committed
43
                  <NumberInfo subTitle="销售目标完成率" total="92%" />
44
                </Col>
niko's avatar
niko committed
45
                <Col md={6} sm={12} xs={24}>
niko's avatar
niko committed
46
                  <NumberInfo subTitle="活动剩余时间" total={<CountDown target={targetTime} />} />
47
                </Col>
niko's avatar
niko committed
48
                <Col md={6} sm={12} xs={24}>
49 50
                  <NumberInfo
                    subTitle="每秒交易总额"
niko's avatar
niko committed
51
                    suffix=""
52 53 54 55 56
                    total={numeral(234).format('0,0')}
                  />
                </Col>
              </Row>
              <div className={styles.mapChart}>
57
                <Tooltip title="等待后期实现">
niko's avatar
niko committed
58 59 60 61
                  <img
                    src="https://gw.alipayobjects.com/zos/rmsportal/HBWnDEUXCnGnGrRfrpKa.png"
                    alt="map"
                  />
62
                </Tooltip>
63 64 65
              </div>
            </Card>
          </Col>
niko's avatar
niko committed
66
          <Col xl={6} lg={24} md={24} sm={24} xs={24}>
67
            <Card title="活动情况预测" style={{ marginBottom: 24 }} bordered={false}>
nikogu's avatar
nikogu committed
68
              <ActiveChart />
69
            </Card>
70 71 72 73 74 75
            <Card
              title="券核效率"
              style={{ marginBottom: 24 }}
              bodyStyle={{ textAlign: 'center' }}
              bordered={false}
            >
76
              <Gauge
niko's avatar
niko committed
77
                format={(val) => {
niko's avatar
niko committed
78
                  switch (parseInt(val, 10)) {
niko's avatar
niko committed
79 80 81 82 83
                    case 20:
                      return '';
                    case 40:
                      return '';
                    case 60:
niko's avatar
niko committed
84
                      return '';
niko's avatar
niko committed
85 86 87 88 89 90
                    case 80:
                      return '';
                    default:
                      return '';
                  }
                }}
niko's avatar
niko committed
91
                title="跳出率"
niko's avatar
niko committed
92
                height={180}
93 94 95 96 97 98
                percent={87}
              />
            </Card>
          </Col>
        </Row>
        <Row gutter={24}>
afc163's avatar
afc163 committed
99
          <Col xl={12} lg={24} sm={24} xs={24}>
100 101 102 103
            <Card
              title="各品类占比"
              style={{ marginBottom: 24 }}
              bordered={false}
afc163's avatar
afc163 committed
104
              className={styles.pieCard}
105
            >
afc163's avatar
afc163 committed
106
              <Row style={{ padding: '16px 0' }}>
107 108
                <Col span={8}>
                  <Pie
nikogu's avatar
nikogu committed
109
                    animate={false}
110 111 112
                    percent={28}
                    subTitle="中式快餐"
                    total="28%"
偏右's avatar
偏右 committed
113
                    height={128}
afc163's avatar
afc163 committed
114
                    lineWidth={2}
115 116 117 118
                  />
                </Col>
                <Col span={8}>
                  <Pie
nikogu's avatar
nikogu committed
119
                    animate={false}
niko's avatar
niko committed
120
                    color="#5DDECF"
121 122 123
                    percent={22}
                    subTitle="西餐"
                    total="22%"
偏右's avatar
偏右 committed
124
                    height={128}
afc163's avatar
afc163 committed
125
                    lineWidth={2}
126 127 128 129
                  />
                </Col>
                <Col span={8}>
                  <Pie
nikogu's avatar
nikogu committed
130
                    animate={false}
niko's avatar
niko committed
131
                    color="#2FC25B"
132 133 134
                    percent={32}
                    subTitle="火锅"
                    total="32%"
偏右's avatar
偏右 committed
135
                    height={128}
afc163's avatar
afc163 committed
136
                    lineWidth={2}
137 138 139 140 141
                  />
                </Col>
              </Row>
            </Card>
          </Col>
afc163's avatar
afc163 committed
142
          <Col xl={6} lg={12} sm={24} xs={24} style={{ marginBottom: 24 }}>
niko's avatar
niko committed
143 144
            <Card title="热门搜索" bordered={false}>
              <TagCloud data={tags} height={161} />
145 146
            </Card>
          </Col>
afc163's avatar
afc163 committed
147
          <Col xl={6} lg={12} sm={24} xs={24} style={{ marginBottom: 24 }}>
niko's avatar
niko committed
148 149 150 151 152 153
            <Card
              title="资源剩余"
              bodyStyle={{ textAlign: 'center', fontSize: 0 }}
              bordered={false}
            >
              <WaterWave height={161} title="补贴资金剩余" percent={34} />
154 155 156
            </Card>
          </Col>
        </Row>
157
      </div>
158 159 160
    );
  }
}