HomeView.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. <script lang="ts" setup>
  2. import {apiauthlogout} from '../request/api.js'
  3. import { ElMessage } from 'element-plus'
  4. import { RouterView,useRoute,useRouter } from 'vue-router'
  5. const route = useRoute();
  6. const router = useRouter();
  7. import {usenowrouteStore} from '../stores/nowroute.ts'
  8. const routerStore=usenowrouteStore()
  9. let {routename,setroute}=routerStore
  10. import {ref,watch,computed } from 'vue'
  11. import {
  12. BellFilled,
  13. ArrowRightBold,
  14. Menu as IconMenu,
  15. Location,
  16. Setting,
  17. Search
  18. } from '@element-plus/icons-vue'
  19. let searchWord=ref('')
  20. const handleOpen = (key: string, keyPath: string[]) => {
  21. //setroute(key.path)
  22. }
  23. let filterName=computed(()=>{
  24. let res=''
  25. switch(routerStore.routename){
  26. case '/userman':
  27. res='用户管理'
  28. break;
  29. case '/areaman':
  30. res='区域管理'
  31. break;
  32. case '/stationman':
  33. res='站点管理'
  34. break;
  35. case '/carman':
  36. res='车辆管理'
  37. break;
  38. case '/routeman':
  39. res='路线管理'
  40. break;
  41. case '/carplanman':
  42. res='车辆排班'
  43. break;
  44. case '/orderman':
  45. res='订单管理'
  46. break;
  47. case '/passengerstation':
  48. res='客运站管理'
  49. break;
  50. case '/bannerman':
  51. res='小程序宣传图管理'
  52. break;
  53. }
  54. return res
  55. })
  56. const handleClose = (key: string, keyPath: string[]) => {
  57. }
  58. const clickUser=(type: string)=>{
  59. switch(type){
  60. case 'logout':
  61. apiauthlogout({}).then(res=>{
  62. ElMessage({
  63. message: '成功退出',
  64. type: 'success',
  65. duration: 3 * 1000
  66. });
  67. router.replace({
  68. path:'/login'
  69. })
  70. }).catch(err=>{
  71. console.log(err)
  72. })
  73. break;
  74. }
  75. console.log(type)
  76. }
  77. // 使用 watch 监听路由对象的变化
  78. watch(() => route, (newRoute, oldRoute) => {
  79. console.log(newRoute)
  80. setroute(newRoute.path)
  81. // 在这里执行你想要的逻辑
  82. }, { deep: true });
  83. </script>
  84. <template>
  85. <div class="common-layout">
  86. <el-container>
  87. <el-aside width="200px" style="background:#fff">
  88. <div class="reset-ipt">
  89. <!-- <el-input
  90. v-model="searchWord"
  91. style="width: 100%"
  92. placeholder="搜索菜单..."
  93. :suffix-icon="Search"
  94. /> -->
  95. 车辆调度管理系统
  96. </div>
  97. <el-menu
  98. active-text-color="#ffd04b"
  99. background-color="#000000"
  100. class="el-menu-vertical-demo"
  101. default-active="1"
  102. router
  103. text-color="#fff"
  104. @open="handleOpen"
  105. @close="handleClose"
  106. >
  107. <el-menu-item index="userman">
  108. <div class="ima-icon">
  109. <img style="width:20px;height:auto" src="../../public/imgs/userman.png" alt="">
  110. </div>
  111. <span style="flex:1">用户管理</span>
  112. <div class="next-img">
  113. <el-icon><ArrowRightBold /></el-icon>
  114. </div>
  115. </el-menu-item>
  116. <el-menu-item index="areaman">
  117. <div class="ima-icon">
  118. <img style="width:18px;height:auto" src="../../public/imgs/areaman.png" alt="">
  119. </div>
  120. <span style="flex:1">区域管理</span>
  121. <div class="next-img">
  122. <el-icon><ArrowRightBold /></el-icon>
  123. </div>
  124. </el-menu-item>
  125. <el-menu-item index="stationman">
  126. <div class="ima-icon">
  127. <img style="width:9px;height:auto" src="../../public/imgs/stationman.png" alt="">
  128. </div>
  129. <span style="flex:1">站点管理</span>
  130. <div class="next-img">
  131. <el-icon><ArrowRightBold /></el-icon>
  132. </div>
  133. </el-menu-item>
  134. <el-menu-item index="carman">
  135. <div class="ima-icon">
  136. <img style="width:16px;height:auto" src="../../public/imgs/carman.png" alt="">
  137. </div>
  138. <span style="flex:1">车辆管理</span>
  139. <div class="next-img">
  140. <el-icon><ArrowRightBold /></el-icon>
  141. </div>
  142. </el-menu-item>
  143. <el-menu-item index="routeman">
  144. <div class="ima-icon">
  145. <img style="width:16px;height:auto" src="../../public/imgs/routeman.png" alt="">
  146. </div>
  147. <span style="flex:1">路线管理</span>
  148. <div class="next-img">
  149. <el-icon><ArrowRightBold /></el-icon>
  150. </div>
  151. </el-menu-item>
  152. <el-menu-item index="carplanman">
  153. <div class="ima-icon">
  154. <img style="width:14px;height:auto" src="../../public/imgs/carman.png" alt="">
  155. </div>
  156. <span style="flex:1">车辆排班</span>
  157. <div class="next-img">
  158. <el-icon><ArrowRightBold /></el-icon>
  159. </div>
  160. </el-menu-item>
  161. <el-menu-item index="orderman">
  162. <div class="ima-icon">
  163. <img style="width:12px;height:auto" src="../../public/imgs/orderman.png" alt="">
  164. </div>
  165. <span style="flex:1">订单管理</span>
  166. <div class="next-img">
  167. <el-icon><ArrowRightBold /></el-icon>
  168. </div>
  169. </el-menu-item>
  170. <el-menu-item index="passengerstation">
  171. <div class="ima-icon">
  172. <img style="width:12px;height:auto" src="../../public/imgs/orderman.png" alt="">
  173. </div>
  174. <span style="flex:1">客运站管理</span>
  175. <div class="next-img">
  176. <el-icon><ArrowRightBold /></el-icon>
  177. </div>
  178. </el-menu-item>
  179. <el-menu-item index="bannerman">
  180. <div class="ima-icon">
  181. <img style="width:12px;height:auto" src="../../public/imgs/orderman.png" alt="">
  182. </div>
  183. <span style="flex:1">banner管理</span>
  184. <div class="next-img">
  185. <el-icon><ArrowRightBold /></el-icon>
  186. </div>
  187. </el-menu-item>
  188. </el-menu>
  189. </el-aside>
  190. <el-container>
  191. <el-header>
  192. <div class="left-part">
  193. <el-breadcrumb separator="/">
  194. <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
  195. <el-breadcrumb-item v-if="routerStore.routename">{{ filterName }}</el-breadcrumb-item>
  196. </el-breadcrumb>
  197. </div>
  198. <div class="right-part">
  199. <el-icon :size="22"><BellFilled /></el-icon>
  200. <el-dropdown @command="clickUser">
  201. <div style="display:flex;align-items:center">
  202. <div class="person-photo" style="cursor:pointer"></div>
  203. <div style="margin-right:24px;padding-left:6px;cursor:pointer">
  204. 管理员
  205. </div>
  206. <el-icon class="el-icon--right">
  207. <arrow-down />
  208. </el-icon>
  209. </div>
  210. <template #dropdown>
  211. <el-dropdown-menu>
  212. <el-dropdown-item command="logout">退出登录</el-dropdown-item>
  213. </el-dropdown-menu>
  214. </template>
  215. </el-dropdown>
  216. </div>
  217. </el-header>
  218. <el-main>
  219. <RouterView />
  220. </el-main>
  221. </el-container>
  222. </el-container>
  223. </div>
  224. </template>
  225. <style lang="scss">
  226. .reset-ipt{
  227. box-sizing: border-box;
  228. color:#fff;
  229. background:#000;
  230. padding:12px 16px;
  231. .el-input__wrapper{
  232. box-shadow: none;
  233. background:#374151;
  234. }
  235. }
  236. </style>
  237. <style lang="scss" scoped>
  238. .el-menu{
  239. height:calc(100% - 56px);
  240. }
  241. .common-layout{
  242. height:100%;
  243. .el-container{
  244. .el-menu-item{
  245. display:flex;
  246. align-items: center;
  247. justify-content: space-between;
  248. }
  249. .ima-icon{
  250. margin-right:8px;
  251. display:flex;
  252. align-items: center;
  253. justify-content: center;
  254. }
  255. height:100%;
  256. .el-header{
  257. background:#fff;
  258. height:72px;
  259. display:flex;
  260. justify-content: space-between;
  261. align-items: center;
  262. .right-part{
  263. display:flex;
  264. align-items: center;
  265. .person-photo{
  266. margin-left:24px;
  267. height:42px;
  268. width:42px;
  269. background:url(/imgs/userphoto.png) no-repeat;
  270. background-size:100% 100%;
  271. border-radius: 50%;
  272. }
  273. }
  274. }
  275. .el-main{
  276. background:#f3f4f6;
  277. }
  278. }
  279. }
  280. </style>