Monitor.js 5.46 KB
Newer Older
jim's avatar
jim committed
1
import React, { PureComponent } from 'react';
2
import { connect } from 'dva';
3
import { Row, Col, Card, Tooltip } from 'antd';
4
import numeral from 'numeral';
jim's avatar
jim committed
5
import GridContent from '../../layouts/GridContent';
陈帅's avatar
陈帅 committed
6
import Authorized from '../../utils/Authorized';
偏右's avatar
偏右 committed
7 8
import { Pie, WaterWave, Gauge, TagCloud } from '../../components/Charts';
import NumberInfo from '../../components/NumberInfo';
niko's avatar
niko committed
9
import CountDown from '../../components/CountDown';
nikogu's avatar
nikogu committed
10
import ActiveChart from '../../components/ActiveChart';
11 12
import styles from './Monitor.less';

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

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

jim's avatar
jim committed
17 18 19 20 21 22
// 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
23 24 25
@connect(({ monitor, loading }) => ({
  monitor,
  loading: loading.models.monitor,
26 27 28 29 30 31
}))
export default class Monitor extends PureComponent {
  componentDidMount() {
    this.props.dispatch({
      type: 'monitor/fetchTags',
    });
nikogu's avatar
nikogu committed
32
  }
nikogu's avatar
nikogu committed
33

34
  render() {
Andreas Cederström's avatar
Andreas Cederström committed
35
    const { monitor, loading } = this.props;
36 37 38
    const { tags } = monitor;

    return (
jim's avatar
jim committed
39
      <GridContent>
40
        <Row gutter={24}>
niko's avatar
niko committed
41
          <Col xl={18} lg={24} md={24} sm={24} xs={24} style={{ marginBottom: 24 }}>
42
            <Card title="活动实时交易情况" bordered={false}>
43
              <Row>
niko's avatar
niko committed
44
                <Col md={6} sm={12} xs={24}>
45 46
                  <NumberInfo
                    subTitle="今日交易总额"
niko's avatar
niko committed
47
                    suffix=""
48 49 50
                    total={numeral(124543233).format('0,0')}
                  />
                </Col>
niko's avatar
niko committed
51
                <Col md={6} sm={12} xs={24}>
ddcat1115's avatar
ddcat1115 committed
52 53 54 55
                  <NumberInfo
                    subTitle="销售目标完成率"
                    total="92%"
                  />
56
                </Col>
niko's avatar
niko committed
57
                <Col md={6} sm={12} xs={24}>
niko's avatar
niko committed
58
                  <NumberInfo subTitle="活动剩余时间" total={<CountDown target={targetTime} />} />
59
                </Col>
niko's avatar
niko committed
60
                <Col md={6} sm={12} xs={24}>
61 62
                  <NumberInfo
                    subTitle="每秒交易总额"
niko's avatar
niko committed
63
                    suffix=""
64 65 66 67 68
                    total={numeral(234).format('0,0')}
                  />
                </Col>
              </Row>
              <div className={styles.mapChart}>
69
                <Tooltip title="等待后期实现">
ddcat1115's avatar
ddcat1115 committed
70
                  <img src="https://gw.alipayobjects.com/zos/rmsportal/HBWnDEUXCnGnGrRfrpKa.png" alt="map" />
71
                </Tooltip>
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
            <Card
              title="各品类占比"
              bordered={false}
afc163's avatar
afc163 committed
112
              className={styles.pieCard}
113
            >
afc163's avatar
afc163 committed
114
              <Row style={{ padding: '16px 0' }}>
115 116
                <Col span={8}>
                  <Pie
nikogu's avatar
nikogu committed
117
                    animate={false}
118 119 120
                    percent={28}
                    subTitle="中式快餐"
                    total="28%"
偏右's avatar
偏右 committed
121
                    height={128}
afc163's avatar
afc163 committed
122
                    lineWidth={2}
123 124 125 126
                  />
                </Col>
                <Col span={8}>
                  <Pie
nikogu's avatar
nikogu committed
127
                    animate={false}
niko's avatar
niko committed
128
                    color="#5DDECF"
129 130 131
                    percent={22}
                    subTitle="西餐"
                    total="22%"
偏右's avatar
偏右 committed
132
                    height={128}
afc163's avatar
afc163 committed
133
                    lineWidth={2}
134 135 136 137
                  />
                </Col>
                <Col span={8}>
                  <Pie
nikogu's avatar
nikogu committed
138
                    animate={false}
niko's avatar
niko committed
139
                    color="#2FC25B"
140 141 142
                    percent={32}
                    subTitle="火锅"
                    total="32%"
偏右's avatar
偏右 committed
143
                    height={128}
afc163's avatar
afc163 committed
144
                    lineWidth={2}
145 146 147 148 149
                  />
                </Col>
              </Row>
            </Card>
          </Col>
150
          <Col xl={6} lg={12} sm={24} xs={24}>
Andreas Cederström's avatar
Andreas Cederström committed
151
            <Card title="热门搜索" loading={loading} bordered={false} bodyStyle={{ overflow: 'hidden' }}>
ddcat1115's avatar
ddcat1115 committed
152 153 154 155
              <TagCloud
                data={tags}
                height={161}
              />
156 157
            </Card>
          </Col>
158
          <Col xl={6} lg={12} sm={24} xs={24}>
ddcat1115's avatar
ddcat1115 committed
159 160 161 162 163 164
            <Card title="资源剩余" bodyStyle={{ textAlign: 'center', fontSize: 0 }} bordered={false}>
              <WaterWave
                height={161}
                title="补贴资金剩余"
                percent={34}
              />
165 166 167
            </Card>
          </Col>
        </Row>
jim's avatar
jim committed
168
      </GridContent>
169 170 171
    );
  }
}