index.jsx 8.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. import React, { useCallback, useEffect, useRef, useState } from 'react';
  2. import { history, Link } from 'umi';
  3. import classNames from 'classnames';
  4. import ScreenHeader from '@/components/ScreenBox/ScreenHeader';
  5. import GeoMap from '@/components/GeoMap';
  6. import StatisCard from '@/components/ScreenBox/StatisCard';
  7. import SquareBox from '@/components/ScreenBox/SquareBox';
  8. import getWeather from '@/components/AMap/weather';
  9. import { useParticlesJs } from './hook';
  10. import MachineryType from './components/MachineryType';
  11. import MachineryStatus from './components/MachineryStatus';
  12. import WorkArea from './components/WorkArea';
  13. import List from './components/List';
  14. import ColorFont from './components/ColorFont';
  15. import WorkData from './components/WorkData';
  16. import Styles from './style.less';
  17. export default (props) => {
  18. const screenRef = useRef();
  19. const [weather, setWeather] = useState('暂无天气信息');
  20. const [machineryTypeData, setMachineryTypeData] = useState([
  21. { name: '收割机', value: 200 },
  22. { name: '播种机', value: 100 },
  23. { name: '农药机', value: 50 },
  24. ]);
  25. const [machineryStatusData, setMachineryStatusData] = useState([
  26. { name: '预约', value: 350 },
  27. { name: '作业', value: 900 },
  28. { name: '闲置', value: 650 },
  29. { name: '离线', value: 180 },
  30. { name: '维修', value: 380 },
  31. ]);
  32. const [workData, setWorkData] = useState([
  33. { name: '收割机', value: 35 },
  34. { name: '播种机', value: 35 },
  35. { name: '农药机', value: 30 },
  36. { name: '其他', value: 180 },
  37. ]);
  38. const [workAreaData, setWorkAreaData] = useState([
  39. { name: '收割机', value: 350 },
  40. { name: '播种机', value: 900 },
  41. { name: '农药机', value: 650 },
  42. { name: '其他', value: 180 },
  43. ]);
  44. const [machineTypeList, setMachineTypeList] = useState([
  45. { id: 't0', name: '合作社' },
  46. { id: 't1', name: '收割机' },
  47. { id: 't2', name: '播种机' },
  48. { id: 't3', name: '农药机' },
  49. ]);
  50. const [orgList, setOrgList] = useState([
  51. {
  52. orgId: 1,
  53. name: '合作社1',
  54. address: '合作社地址1',
  55. phone: '13823838438',
  56. machineNum: 12,
  57. lnglat: [111.888505, 32.854667],
  58. },
  59. {
  60. orgId: 2,
  61. name: '合作社2',
  62. address: '合作社地址2',
  63. phone: '13823838438',
  64. machineNum: 68,
  65. lnglat: [111.921464, 32.467361],
  66. },
  67. {
  68. orgId: 3,
  69. name: '合作社3',
  70. address: '合作社地址3',
  71. phone: '13823838438',
  72. machineNum: 3,
  73. lnglat: [112.367784, 32.815435],
  74. },
  75. {
  76. orgId: 4,
  77. name: '合作社4',
  78. address: '合作社地址4',
  79. phone: '13823838438',
  80. machineNum: 42,
  81. lnglat: [112.311479, 32.580836],
  82. },
  83. ]);
  84. const [machineList, setMachineList] = useState([
  85. {
  86. machineryId: 'm1',
  87. name: '农机1',
  88. typeId: 't1',
  89. orgName: '合作社1',
  90. lnglat: [111.867906, 32.799276],
  91. },
  92. {
  93. machineryId: 'm2',
  94. name: '农机2',
  95. typeId: 't2',
  96. orgName: '合作社1',
  97. lnglat: [112.087632, 32.66527],
  98. },
  99. {
  100. machineryId: 'm3',
  101. name: '农机3',
  102. typeId: 't1',
  103. orgName: '合作社2',
  104. lnglat: [112.237321, 32.631737],
  105. },
  106. {
  107. machineryId: 'm4',
  108. name: '农机4',
  109. typeId: 't3',
  110. orgName: '合作社2',
  111. lnglat: [112.002488, 32.563476],
  112. },
  113. {
  114. machineryId: 'm5',
  115. name: '农机5',
  116. typeId: 't3',
  117. orgName: '合作社3',
  118. lnglat: [112.105485, 32.791195],
  119. },
  120. ]);
  121. useEffect(() => {
  122. getWeather('邓州市').then((res) => {
  123. if (res && res.length) {
  124. const { casts } = res[0];
  125. const { dayweather, nighttemp, daytemp } = casts[0];
  126. const [min, max] =
  127. parseInt(nighttemp) > parseInt(daytemp) ? [daytemp, nighttemp] : [nighttemp, daytemp];
  128. setWeather(`${dayweather} ${min}-${max} °C`);
  129. } else {
  130. setWeather('暂无天气信息');
  131. }
  132. });
  133. }, []);
  134. useParticlesJs(Styles['particles-js']);
  135. return (
  136. <div className={classNames(Styles['screen-page'], Styles['pd-lr-40'])} ref={screenRef}>
  137. <div id={Styles['particles-js']} />
  138. <div className={Styles['grail-layout']}>
  139. <div className={Styles['grail-header']}>
  140. <ScreenHeader weather={weather} />
  141. </div>
  142. <div className={classNames(Styles['grail-container'], Styles['mg-tp-30'])}>
  143. <div className={Styles['grail-left']}>
  144. <div className="flex flex-column full-height">
  145. <div className="flex-0" style={{ minHeight: '37%' }}>
  146. <MachineryType source={machineryTypeData} />
  147. </div>
  148. <div className="flex-1" style={{ marginTop: '30px' }}>
  149. <MachineryStatus source={machineryStatusData} />
  150. </div>
  151. </div>
  152. </div>
  153. <div className={classNames(Styles['grail-content'], Styles['pd-lr-40'])}>
  154. <div className={Styles['statis-container']}>
  155. <StatisCard color="#23E8AE" icon="icon1" value={2346} title="农机总数(台)" />
  156. <StatisCard color="#0BDAFF" icon="icon2" value={528} title="农机使用数(台)" />
  157. <StatisCard color="#F5CC5C" icon="icon3" value={168} title="总预约数(台)" />
  158. <StatisCard color="#C579FF" icon="icon4" value={1568} title="总服务数(台)" />
  159. </div>
  160. <GeoMap machineTypeList={machineTypeList} orgList={orgList} machineList={machineList} />
  161. </div>
  162. <div className={Styles['grail-right']}>
  163. <div className="flex flex-column full-height">
  164. <div className="flex-0" style={{ minHeight: '46%' }}>
  165. <WorkData source={workData} />
  166. </div>
  167. <div className="flex-1" style={{ marginTop: '30px' }}>
  168. <WorkArea source={workAreaData} />
  169. </div>
  170. </div>
  171. </div>
  172. </div>
  173. <div className={classNames(Styles['grail-footer'], Styles['mg-tp-30'])}>
  174. <SquareBox>
  175. <div className="flex" style={{ padding: '20px 0' }}>
  176. <div className="flex-1">
  177. <List title="预约订单">
  178. <div>
  179. <ColorFont color="#F5CC5C">[快乐每一天]</ColorFont> 32s前预约了一台收割机,
  180. <ColorFont color="#44F68B">[收割机001]</ColorFont> 接到了此订单!
  181. </div>
  182. <div>
  183. <ColorFont color="#F5CC5C">[幸福人生]</ColorFont> 58分钟前预约了一台收割机,
  184. <ColorFont color="#44F68B">[播种机008]</ColorFont> 接到了此订单!尽快赶到!
  185. </div>
  186. <div>
  187. <ColorFont color="#F5CC5C">[灿烂人生]</ColorFont> 2个小时前预约了一台收割机,
  188. <ColorFont color="#44F68B">[收割机007]</ColorFont>{' '}
  189. 接到了此订单!正在赶往目的地!
  190. </div>
  191. <div>
  192. <ColorFont color="#F5CC5C">[快乐每一天]</ColorFont> 32s前预约了一台收割机,
  193. <ColorFont color="#44F68B">[收割机001]</ColorFont> 接到了此订单!
  194. </div>
  195. <div>
  196. <ColorFont color="#F5CC5C">[幸福人生]</ColorFont> 58分钟前预约了一台收割机,
  197. <ColorFont color="#44F68B">[播种机008]</ColorFont> 接到了此订单!尽快赶到!
  198. </div>
  199. <div>
  200. <ColorFont color="#F5CC5C">[灿烂人生]</ColorFont> 2个小时前预约了一台收割机,
  201. <ColorFont color="#44F68B">[收割机007]</ColorFont>{' '}
  202. 接到了此订单!正在赶往目的地!
  203. </div>
  204. </List>
  205. </div>
  206. <div className={classNames('flex-0', Styles['footer-middle'])} />
  207. <div className="flex-1">
  208. <List title="作业订单" color="green">
  209. <div>
  210. <ColorFont color="#44F68B">[收割机001]</ColorFont>
  211. 32s前接到了一个订单,距离目的地还有3.2公里,请农户耐心等待!
  212. </div>
  213. <div>
  214. <ColorFont color="#44F68B">[播种机008]</ColorFont>{' '}
  215. 2分钟前接到一个订单,距离目的地还有3.8公里,请农户耐心等待!
  216. </div>
  217. <div>
  218. <ColorFont color="#44F68B">[收割机007]</ColorFont>{' '}
  219. 2个小时前接到一个订单,距离目的地还有3.8公里,请农户耐心等待!
  220. </div>
  221. </List>
  222. </div>
  223. </div>
  224. </SquareBox>
  225. </div>
  226. </div>
  227. </div>
  228. );
  229. };