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

jim's avatar
jim committed
16 17 18 19 20 21
// use permission as a parameter
const havePermissionAsync = new Promise((resolve) => {
  // Call resolve on behalf of passed
  setTimeout(() => resolve(), 1000);
});
@Secured(havePermissionAsync)
Andreas Cederström's avatar
Andreas Cederström committed
22 23 24
@connect(({ monitor, loading }) => ({
  monitor,
  loading: loading.models.monitor,
25 26 27 28 29 30
}))
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
  render() {
Andreas Cederström's avatar
Andreas Cederström committed
34
    const { monitor, loading } = this.props;
35 36 37
    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}>
ddcat1115's avatar
ddcat1115 committed
51 52 53 54
                  <NumberInfo
                    subTitle="销售目标完成率"
                    total="92%"
                  />
55
                </Col>
niko's avatar
niko committed
56
                <Col md={6} sm={12} xs={24}>
niko's avatar
niko committed
57
                  <NumberInfo subTitle="活动剩余时间" total={<CountDown target={targetTime} />} />
58
                </Col>
niko's avatar
niko committed
59
                <Col md={6} sm={12} xs={24}>
60 61
                  <NumberInfo
                    subTitle="每秒交易总额"
niko's avatar
niko committed
62
                    suffix=""
63 64 65 66 67
                    total={numeral(234).format('0,0')}
                  />
                </Col>
              </Row>
              <div className={styles.mapChart}>
68
                <Tooltip title="等待后期实现">
ddcat1115's avatar
ddcat1115 committed
69
                  <img src="https://gw.alipayobjects.com/zos/rmsportal/HBWnDEUXCnGnGrRfrpKa.png" alt="map" />
70
                </Tooltip>
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}>
afc163's avatar
afc163 committed
107
          <Col xl={12} lg={24} sm={24} xs={24}>
108 109 110
            <Card
              title="各品类占比"
              bordered={false}
afc163's avatar
afc163 committed
111
              className={styles.pieCard}
112
            >
afc163's avatar
afc163 committed
113
              <Row style={{ padding: '16px 0' }}>
114 115
                <Col span={8}>
                  <Pie
nikogu's avatar
nikogu committed
116
                    animate={false}
117 118 119
                    percent={28}
                    subTitle="中式快餐"
                    total="28%"
偏右's avatar
偏右 committed
120
                    height={128}
afc163's avatar
afc163 committed
121
                    lineWidth={2}
122 123 124 125
                  />
                </Col>
                <Col span={8}>
                  <Pie
nikogu's avatar
nikogu committed
126
                    animate={false}
niko's avatar
niko committed
127
                    color="#5DDECF"
128 129 130
                    percent={22}
                    subTitle="西餐"
                    total="22%"
偏右's avatar
偏右 committed
131
                    height={128}
afc163's avatar
afc163 committed
132
                    lineWidth={2}
133 134 135 136
                  />
                </Col>
                <Col span={8}>
                  <Pie
nikogu's avatar
nikogu committed
137
                    animate={false}
niko's avatar
niko committed
138
                    color="#2FC25B"
139 140 141
                    percent={32}
                    subTitle="火锅"
                    total="32%"
偏右's avatar
偏右 committed
142
                    height={128}
afc163's avatar
afc163 committed
143
                    lineWidth={2}
144 145 146 147 148
                  />
                </Col>
              </Row>
            </Card>
          </Col>
149
          <Col xl={6} lg={12} sm={24} xs={24}>
Andreas Cederström's avatar
Andreas Cederström committed
150
            <Card title="热门搜索" loading={loading} bordered={false} bodyStyle={{ overflow: 'hidden' }}>
ddcat1115's avatar
ddcat1115 committed
151 152 153 154
              <TagCloud
                data={tags}
                height={161}
              />
155 156
            </Card>
          </Col>
157
          <Col xl={6} lg={12} sm={24} xs={24}>
ddcat1115's avatar
ddcat1115 committed
158 159 160 161 162 163
            <Card title="资源剩余" bodyStyle={{ textAlign: 'center', fontSize: 0 }} bordered={false}>
              <WaterWave
                height={161}
                title="补贴资金剩余"
                percent={34}
              />
164 165 166
            </Card>
          </Col>
        </Row>
167
      </div>
168 169 170
    );
  }
}