Monitor.js 5.25 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';
陈帅's avatar
陈帅 committed
5
import Authorized 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
import styles from './Monitor.less';

陈帅's avatar
陈帅 committed
12 13
const { Secured } = Authorized;

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

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

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

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