Monitor.js 4.96 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 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';
9
import GridContent from '@/components/PageHeaderWrapper/GridContent';
jim's avatar
jim committed
10

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
  // Call resolve on behalf of passed
afc163's avatar
afc163 committed
21
  setTimeout(() => resolve(), 300);
jim's avatar
jim committed
22
});
afc163's avatar
afc163 committed
23

jim's avatar
jim committed
24
@Secured(havePermissionAsync)
Andreas Cederström's avatar
Andreas Cederström committed
25 26 27
@connect(({ monitor, loading }) => ({
  monitor,
  loading: loading.models.monitor,
28
}))
afc163's avatar
afc163 committed
29
class Monitor extends PureComponent {
30
  componentDidMount() {
陈帅's avatar
陈帅 committed
31 32
    const { dispatch } = this.props;
    dispatch({
33 34
      type: 'monitor/fetchTags',
    });
nikogu's avatar
nikogu committed
35
  }
nikogu's avatar
nikogu committed
36

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

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

export default Monitor;