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

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

import styles from './Monitor.less';

const MapData = [];
for (let i = 0; i < 50; i += 1) {
  MapData.push({
    x: Math.floor(Math.random() * 600),
    y: Math.floor(Math.random() * 400),
    value: Math.floor(Math.random() * 1000) + 500,
  });
}
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
30
  }
nikogu's avatar
nikogu committed
31

32 33 34 35 36
  render() {
    const { monitor } = this.props;
    const { tags } = monitor;

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