Monitor.js 4.9 KB
Newer Older
J
jim 已提交
1
import React, { PureComponent } from 'react';
2
import { connect } from 'dva';
3
import { Row, Col, Card, Tooltip } from 'antd';
N
niko 已提交
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 '@/layouts/GridContent';
J
jim 已提交
10

11
import Authorized from '@/utils/Authorized';
12 13
import styles from './Monitor.less';

陈帅 已提交
14 15
const { Secured } = Authorized;

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

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

36
  render() {
A
Andreas Cederström 已提交
37
    const { monitor, loading } = this.props;
38 39 40
    const { tags } = monitor;

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