Monitor.js 5.34 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';

偏右'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 23 24 25 26 27 28 29 30

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
31
  }
nikogu's avatar
nikogu committed
32

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

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