home.jsx 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. import "./home.scss";
  2. import {Avatar, Menu, Popconfirm} from 'antd';
  3. import {useEffect, useState} from "react";
  4. import {AreaChartOutlined, DesktopOutlined, FileDoneOutlined, SettingOutlined, UserOutlined} from '@ant-design/icons';
  5. import {Outlet, useLocation, useNavigate} from 'react-router-dom';
  6. import axios from "@/utils/axios.js";
  7. import {useDispatch} from 'react-redux';
  8. import {setDictData} from '@/store/reducer.js';
  9. export default function Home() {
  10. const navagate = useNavigate()
  11. const [current, setCurrent] = useState('mail')
  12. // 菜单数据
  13. const items = [{
  14. label: '首页配置', key: 'basicInfomation', icon: <DesktopOutlined/>, children: [{
  15. label: '汇总统计数据', key: 'statisticsData', icon: <AreaChartOutlined/>,
  16. }, {
  17. label: '消费占比', key: 'consumptionProportion', icon: <AreaChartOutlined/>,
  18. }, {
  19. label: '客流排名', key: 'flowRanking', icon: <AreaChartOutlined/>,
  20. }, {
  21. label: '线路客流排名', key: 'lineFlowRanking', icon: <AreaChartOutlined/>,
  22. }, {
  23. label: '舆情统计数据', key: 'publicOpinion', icon: <AreaChartOutlined/>,
  24. }, {
  25. label: '站场设备统计', key: 'stationEquipment', icon: <AreaChartOutlined/>,
  26. }, {
  27. label: '客运量数据', key: 'passengerVolumeData', icon: <AreaChartOutlined/>,
  28. }, {
  29. label: '班次完成率', key: 'classCompletionRate', icon: <AreaChartOutlined/>,
  30. }, {
  31. label: '班次准点率', key: 'classPunctualitRate', icon: <AreaChartOutlined/>,
  32. }, {
  33. label: '发车准点率', key: 'carCompletionRate', icon: <AreaChartOutlined/>,
  34. }]
  35. }, {
  36. label: '线路运营配置', key: 'lineConfiguration', icon: <SettingOutlined/>, children: [{
  37. label: '线路基本情况', key: 'basicInfomationOfTheLine', icon: <AreaChartOutlined/>,
  38. }, {
  39. label: '线路发班情况', key: 'lineDispatch', icon: <AreaChartOutlined/>,
  40. }, {
  41. label: '乘客类型', key: 'passengerType', icon: <AreaChartOutlined/>,
  42. }, {
  43. label: '汇总数据', key: 'summaryData', icon: <AreaChartOutlined/>,
  44. }, {
  45. label: '驾驶员数量', key: 'numberOfDrivers', icon: <AreaChartOutlined/>,
  46. }, {
  47. label: '车辆数量占比', key: 'numberOfTransit', icon: <AreaChartOutlined/>,
  48. }, {
  49. label: '车辆监控', key: 'vehicleMonitoring', icon: <AreaChartOutlined/>,
  50. }, {
  51. label: '车辆状态', key: 'vehicleStatus', icon: <AreaChartOutlined/>,
  52. }]
  53. }, {
  54. label: '客流分析', key: 'passengerFlowAnalysis', icon: <SettingOutlined/>, children: [{
  55. label: '底部信息', key: 'passengerInfomation', icon: <FileDoneOutlined/>,
  56. }, {
  57. label: '区域客流', key: 'regionalPassengerFlow', icon: <FileDoneOutlined/>,
  58. }, {
  59. label: '通勤时间', key: 'commutingTime', icon: <FileDoneOutlined/>,
  60. }, {
  61. label: '消费类型', key: 'consumptionType', icon: <FileDoneOutlined/>,
  62. }, {
  63. label: '乘距分布', key: 'distribution', icon: <FileDoneOutlined/>,
  64. }, {
  65. label: '换乘次数', key: 'replacementFrequency', icon: <FileDoneOutlined/>,
  66. }, {
  67. label: '客流线路分布', key: 'passengerFlowRoutes', icon: <FileDoneOutlined/>,
  68. }, {
  69. label: '客运量排名', key: 'rankingOfPassengerVolume', icon: <FileDoneOutlined/>,
  70. }]
  71. }, {
  72. label: '维保动态', key: 'maintenanceDynamics', icon: <SettingOutlined/>, children: [{
  73. label: '体检问题情况', key: 'physicalExaminationIssues', icon: <FileDoneOutlined/>,
  74. }, {
  75. label: '维修保养统计', key: 'maintenanceStatistics', icon: <FileDoneOutlined/>,
  76. }, {
  77. label: '乘距分布', key: 'distance', icon: <FileDoneOutlined/>,
  78. }, {
  79. label: '客流线路分布', key: 'distributionOfPassengerFlowRoutes', icon: <FileDoneOutlined/>,
  80. }, {
  81. label: '维保基本信息', key: 'basicMaintenanceInfomation', icon: <FileDoneOutlined/>,
  82. }, {
  83. label: '维保执行占比', key: 'maintenanceExecution', icon: <FileDoneOutlined/>,
  84. }, {
  85. label: '车辆运营状态', key: 'statusClassification', icon: <FileDoneOutlined/>,
  86. }, {
  87. label: '车辆维保状态', key: 'maintenanceStatus', icon: <FileDoneOutlined/>,
  88. }, {
  89. label: '消费类型', key: 'mainConsumPtionType', icon: <FileDoneOutlined/>,
  90. }, {
  91. label: '维保明细', key: 'maintenanceDetails', icon: <FileDoneOutlined/>,
  92. },]
  93. }, {
  94. label: '设施管理', key: 'facilityManagementChild', icon: <DesktopOutlined/>, children: [{
  95. label: '车载部件', key: 'vehiclesComponents', icon: <AreaChartOutlined/>,
  96. }, {
  97. label: '充电站', key: 'chargingStation', icon: <AreaChartOutlined/>,
  98. }, {
  99. label: '设施基础信息', key: 'informationOfFacilities', icon: <AreaChartOutlined/>,
  100. }, {
  101. label: '电子站牌', key: 'electronicLicensePlate', icon: <AreaChartOutlined/>,
  102. }, {
  103. label: '车型展示', key: 'vehiclesModelDisplay', icon: <AreaChartOutlined/>,
  104. }, {
  105. label: '洗车机', key: 'carWasher', icon: <AreaChartOutlined/>,
  106. },]
  107. },
  108. {
  109. label: '站场管理信息', key: 'stationManagementInformation', icon: <DesktopOutlined/>, children: [{
  110. label: '站场基本信息', key: 'stationBasicInformation', icon: <AreaChartOutlined/>,
  111. }, {
  112. label: '面积分布', key: 'areaDistrbution', icon: <AreaChartOutlined/>,
  113. }, {
  114. label: '场地建设时间', key: 'siteConstructionTime', icon: <AreaChartOutlined/>,
  115. }, {
  116. label: '场地权属情况', key: 'siteOwnership', icon: <AreaChartOutlined/>,
  117. }, {
  118. label: '区域分布', key: 'regionalDistribution', icon: <AreaChartOutlined/>,
  119. }, {
  120. label: '类型分布', key: 'typeDistribution', icon: <AreaChartOutlined/>,
  121. }, {
  122. label: '使用情况', key: 'usage', icon: <AreaChartOutlined/>,
  123. },]
  124. }, {
  125. label: '基础信息配置', key: 'setting', icon: <SettingOutlined/>, children: [{
  126. label: '用户管理', key: 'user', icon: <UserOutlined/>,
  127. }, {
  128. label: '字典管理', key: 'dict', icon: <FileDoneOutlined/>,
  129. }]
  130. }]
  131. /**
  132. * 电机左边弹框跳转页面
  133. * @param e 电机的数据
  134. */
  135. const onClick = (e) => {
  136. setCurrent(e.key);
  137. navagate("/" + e.key)
  138. };
  139. /**
  140. * 退出登录
  141. * @returns {Promise<void>}
  142. */
  143. async function logOut() {
  144. let {code} = await axios.post('/sys/logout')
  145. if (code === 200) {
  146. localStorage.removeItem('user')
  147. navagate('/login')
  148. }
  149. }
  150. // reduce状态
  151. const dispatch = useDispatch();
  152. /**
  153. * 全局存储字典
  154. * @returns {Promise<void>}
  155. */
  156. async function getDict() {
  157. let {data} = await axios.get("/dict/selectKey");
  158. dispatch(setDictData(data))
  159. }
  160. const location = useLocation();
  161. // 让页面无法跳转
  162. function jumpToPage() {
  163. if (location.pathname === '/') {
  164. navagate('/statisticsData')
  165. }
  166. }
  167. useEffect(() => {
  168. jumpToPage()
  169. getDict()
  170. }, [])
  171. return (<div className="home">
  172. <div className="head">
  173. <h2>车站管理系统</h2>
  174. <Popconfirm
  175. title="登出"
  176. description="是否登出此账号"
  177. onConfirm={logOut}
  178. okText="确认"
  179. cancelText="取消"
  180. >
  181. <div className="ava">
  182. <Avatar size={30} icon={<UserOutlined/>}></Avatar>
  183. <p>{JSON.parse(localStorage.getItem('user'))?.name}</p>
  184. </div>
  185. </Popconfirm>
  186. </div>
  187. <div className="body">
  188. <div className="menu">
  189. <Menu onClick={onClick} selectedKeys={[current]} mode="inline" items={items}/>
  190. </div>
  191. <div className="contetn">
  192. <Outlet></Outlet>
  193. </div>
  194. </div>
  195. </div>);
  196. }