Monitor.js 4.9 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';
niko's avatar
niko committed
4 5 6 7
import { Pie, WaterWave, Gauge, TagCloud } from 'components/Charts';
import NumberInfo from 'components/NumberInfo';
import CountDown from 'components/CountDown';
import ActiveChart from 'components/ActiveChart';
8
import numeral from 'numeral';
jim's avatar
jim committed
9
import GridContent from '../../layouts/GridContent';
jim's avatar
jim committed
10

陈帅's avatar
陈帅 committed
11
import Authorized from '../../utils/Authorized';
12 13
import styles from './Monitor.less';

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

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

jim's avatar
jim committed
18
// use permission as a parameter
jim's avatar
jim committed
19
const havePermissionAsync = new Promise(resolve => {
jim's avatar
jim committed
20 21 22 23
  // Call resolve on behalf of passed
  setTimeout(() => resolve(), 1000);
});
@Secured(havePermissionAsync)
Andreas Cederström's avatar
Andreas Cederström committed
24 25 26
@connect(({ monitor, loading }) => ({
  monitor,
  loading: loading.models.monitor,
27 28 29 30 31 32
}))
export default class Monitor extends PureComponent {
  componentDidMount() {
    this.props.dispatch({
      type: 'monitor/fetchTags',
    });
nikogu's avatar
nikogu committed
33
  }
nikogu's avatar
nikogu committed
34

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

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