Monitor.js 5.31 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')
Andreas Cederström's avatar
Andreas Cederström committed
17 18 19
@connect(({ monitor, loading }) => ({
  monitor,
  loading: loading.models.monitor,
20 21 22 23 24 25
}))
export default class Monitor extends PureComponent {
  componentDidMount() {
    this.props.dispatch({
      type: 'monitor/fetchTags',
    });
nikogu's avatar
nikogu committed
26
  }
nikogu's avatar
nikogu committed
27

28
  render() {
Andreas Cederström's avatar
Andreas Cederström committed
29
    const { monitor, loading } = this.props;
30 31 32
    const { tags } = monitor;

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