Monitor.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. import React, { PureComponent } from 'react';
  2. import { connect } from 'dva';
  3. import { Row, Col, Card } from 'antd';
  4. import numeral from 'numeral';
  5. import { NumberInfo, MiniArea, Pie, WaterWave, Gauge } from '../../components/Charts';
  6. import MapChart from '../../components/MapChart';
  7. import TagCloud from '../../components/TagCloud';
  8. import Countdown from '../../components/Countdown';
  9. import { fixedZero } from '../../utils/utils';
  10. import styles from './Monitor.less';
  11. const activeData = [];
  12. for (let i = 0; i < 24; i += 1) {
  13. activeData.push({
  14. x: `${fixedZero(i)}:00`,
  15. y: (i * 50) + (Math.floor(Math.random() * 200)),
  16. });
  17. }
  18. const MapData = [];
  19. for (let i = 0; i < 50; i += 1) {
  20. MapData.push({
  21. x: Math.floor(Math.random() * 600),
  22. y: Math.floor(Math.random() * 400),
  23. value: Math.floor(Math.random() * 1000) + 500,
  24. });
  25. }
  26. const targetTime = new Date().getTime() + 3900000;
  27. @connect(state => ({
  28. monitor: state.monitor,
  29. }))
  30. export default class Monitor extends PureComponent {
  31. componentDidMount() {
  32. this.props.dispatch({
  33. type: 'monitor/fetchTags',
  34. });
  35. }
  36. render() {
  37. const { monitor } = this.props;
  38. const { tags } = monitor;
  39. return (
  40. <div>
  41. <Row gutter={24}>
  42. <Col lg={16} md={24} sm={24} xs={24} style={{ marginBottom: 24 }}>
  43. <Card title="活动实时交易情况" bordered={false}>
  44. <Row>
  45. <Col sm={6} xs={12}>
  46. <NumberInfo
  47. subTitle="今日交易总额"
  48. total={numeral(124543233).format('0,0')}
  49. />
  50. </Col>
  51. <Col sm={6} xs={12}>
  52. <NumberInfo
  53. subTitle="销售目标完成率"
  54. total="92%"
  55. />
  56. </Col>
  57. <Col sm={6} xs={12}>
  58. <NumberInfo
  59. subTitle="活动剩余时间"
  60. total={<Countdown target={targetTime} />}
  61. />
  62. </Col>
  63. <Col sm={6} xs={12}>
  64. <NumberInfo
  65. subTitle="每秒交易总额"
  66. total={numeral(234).format('0,0')}
  67. />
  68. </Col>
  69. </Row>
  70. <div className={styles.mapChart}>
  71. <MapChart
  72. data={MapData}
  73. />
  74. </div>
  75. </Card>
  76. </Col>
  77. <Col lg={8} md={24} sm={24} xs={24}>
  78. <Card title="活动情况预测" style={{ marginBottom: 24 }} bordered={false}>
  79. <div className={styles.activeChart}>
  80. <NumberInfo
  81. subTitle="目标评估"
  82. total="有望达到预期"
  83. />
  84. <div style={{ marginTop: 32 }}>
  85. <MiniArea
  86. line
  87. color="#5DD1DD"
  88. height={84}
  89. yAxis={{
  90. tickCount: 3,
  91. tickLine: false,
  92. labels: false,
  93. title: false,
  94. line: false,
  95. }}
  96. data={activeData}
  97. />
  98. </div>
  99. {
  100. activeData && (
  101. <div className={styles.activeChartGrid}>
  102. <p>{[...activeData].sort()[activeData.length - 1].y + 200} 亿元</p>
  103. <p>{[...activeData].sort()[Math.floor(activeData.length / 2)].y} 亿元</p>
  104. </div>
  105. )
  106. }
  107. {
  108. activeData && (
  109. <div className={styles.activeChartLegend}>
  110. <span>00:00</span>
  111. <span>{activeData[Math.floor(activeData.length / 2)].x}</span>
  112. <span>{activeData[activeData.length - 1].x}</span>
  113. </div>
  114. )
  115. }
  116. </div>
  117. </Card>
  118. <Card
  119. title="券核效率"
  120. style={{ marginBottom: 24 }}
  121. bodyStyle={{ textAlign: 'center' }}
  122. bordered={false}
  123. >
  124. <Gauge
  125. title="跳出率"
  126. height={164}
  127. percent={87}
  128. />
  129. </Card>
  130. </Col>
  131. </Row>
  132. <Row gutter={24}>
  133. <Col sm={8} xs={24}>
  134. <Card
  135. title="各品类占比"
  136. style={{ marginBottom: 24 }}
  137. bordered={false}
  138. >
  139. <Row style={{ padding: '18px 0 19px 0' }}>
  140. <Col span={8}>
  141. <Pie
  142. percent={28}
  143. subTitle="中式快餐"
  144. total="28%"
  145. height={129}
  146. />
  147. </Col>
  148. <Col span={8}>
  149. <Pie
  150. color="#5DD1DD"
  151. percent={22}
  152. subTitle="西餐"
  153. total="22%"
  154. height={129}
  155. />
  156. </Col>
  157. <Col span={8}>
  158. <Pie
  159. color="#B5EDC9"
  160. percent={32}
  161. subTitle="火锅"
  162. total="32%"
  163. height={129}
  164. />
  165. </Col>
  166. </Row>
  167. </Card>
  168. </Col>
  169. <Col sm={8} xs={24} style={{ marginBottom: 24 }}>
  170. <Card title="热门搜索" bordered={false}>
  171. <TagCloud
  172. data={tags}
  173. height={161}
  174. />
  175. </Card>
  176. </Col>
  177. <Col sm={8} xs={24} style={{ marginBottom: 24 }}>
  178. <Card title="资源剩余" bodyStyle={{ textAlign: 'center' }} bordered={false}>
  179. <WaterWave
  180. height={161}
  181. title="补贴资金剩余"
  182. percent={34}
  183. />
  184. </Card>
  185. </Col>
  186. </Row>
  187. </div>
  188. );
  189. }
  190. }