Monitor.js 5.22 KB
Newer Older
1 2
import React, { PureComponent } from 'react';
import { connect } from 'dva';
3
import { Row, Col, Card, Tooltip } from 'antd';
4
import numeral from 'numeral';
ddcat1115's avatar
ddcat1115 committed
5
import { Secured } from '../../utils/Authorized';
偏右'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

import styles from './Monitor.less';

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

ddcat1115's avatar
ddcat1115 committed
15
@Secured('admin')
16 17 18 19 20 21 22 23
@connect(state => ({
  monitor: state.monitor,
}))
export default class Monitor extends PureComponent {
  componentDidMount() {
    this.props.dispatch({
      type: 'monitor/fetchTags',
    });
nikogu's avatar
nikogu committed
24
  }
nikogu's avatar
nikogu committed
25

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

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