SidevarItem copy.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  1. <template>
  2. <div class="box-item">
  3. <el-menu
  4. class="el-menu-vertical-demo"
  5. text-color="#fff"
  6. active-color="#000"
  7. :default-active="activeIndex"
  8. :collapse="menuClose"
  9. @select="handleSelect"
  10. >
  11. <!-- <div class="logo">logo</div> -->
  12. <div class="logo el-menu-item">
  13. <el-icon :size="20"
  14. ><img src="@/assets/logo.png" style="width: 30px; height: 24px"
  15. /></el-icon>
  16. </div>
  17. <el-menu-item :index="9">
  18. <img
  19. v-if="activeIndex == 9"
  20. src="@/assets/busqueryA.png"
  21. alt=""
  22. style="width: 22px; height: 22px; margin: 0 18px"
  23. />
  24. <img
  25. v-else
  26. src="@/assets/busquery.png "
  27. alt=""
  28. style="width: 22px; height: 22px; margin: 0 18px"
  29. />
  30. <span>车辆调度</span>
  31. </el-menu-item>
  32. <el-menu-item :index="1">
  33. <img v-if="activeIndex == 1" src="@/assets/statementA.png" alt="" />
  34. <img v-else src="@/assets/statement.png " alt="" />
  35. <span>报表统计</span>
  36. </el-menu-item>
  37. <el-menu-item :index="2">
  38. <img v-if="activeIndex == 2" src="@/assets/staffA.png" alt="" />
  39. <img v-else src="@/assets/staff.png" alt="" />
  40. <span>驾驶员管理</span>
  41. </el-menu-item>
  42. <el-menu-item :index="11">
  43. <img
  44. v-if="activeIndex == 11"
  45. style="width: 22px; height: 22px; margin: 0 20px 0 18px"
  46. src="@/assets/reportA.png"
  47. alt=""
  48. />
  49. <img
  50. v-else
  51. style="width: 22px; height: 22px; margin: 0 20px 0 18px"
  52. src="@/assets/report.png"
  53. alt=""
  54. />
  55. <span>报备管理</span>
  56. </el-menu-item>
  57. <el-menu-item :index="3">
  58. <img v-if="activeIndex == 3" src="@/assets/accountA.png" alt="" />
  59. <img v-else src="@/assets/account.png" alt="" />
  60. <span>账号管理</span>
  61. </el-menu-item>
  62. <el-menu-item :index="4">
  63. <img v-if="activeIndex == 4" src="@/assets/carA.png" alt="" />
  64. <img v-else src="@/assets/car.png" alt="" />
  65. <span>车辆管理</span>
  66. </el-menu-item>
  67. <el-menu-item :index="5">
  68. <img v-if="activeIndex == 5" src="@/assets/pathA.png" alt="" />
  69. <img v-else src="@/assets/path.png" alt="" />
  70. <span>路线管理</span>
  71. </el-menu-item>
  72. <el-menu-item :index="6">
  73. <img v-if="activeIndex == 6" src="@/assets/classesA.png" alt="" />
  74. <img v-else src="@/assets/classes.png" alt="" />
  75. <span>班次管理</span>
  76. </el-menu-item>
  77. <el-menu-item :index="7">
  78. <img v-if="activeIndex == 7" src="@/assets/blacklistA.png" alt="" />
  79. <img v-else src="@/assets/blacklist.png" alt="" />
  80. <span>黑名单管理</span>
  81. </el-menu-item>
  82. <el-menu-item :index="10">
  83. <img
  84. v-if="activeIndex == 10"
  85. src="@/assets/logA.png"
  86. alt=""
  87. style="width: 21px; height: 21px; margin: 0 20px"
  88. />
  89. <img
  90. v-else
  91. src="@/assets/log.png"
  92. alt=""
  93. style="width: 21px; height: 21px; margin: 0 20px"
  94. />
  95. <span>操作日志</span>
  96. </el-menu-item>
  97. <el-sub-menu index="1">
  98. <template #title>
  99. <el-icon style="font-size: 28px;"><location /></el-icon>
  100. <span>顺风车模块</span>
  101. </template>
  102. <el-sub-menu index="1-4">
  103. <template #title>顺风车司机</template>
  104. <el-menu-item index="1-4-1">司机思考</el-menu-item>
  105. <el-menu-item index="1-3">司机管理</el-menu-item>
  106. </el-sub-menu>
  107. <el-menu-item index="1-3">路线管理</el-menu-item>
  108. </el-sub-menu>
  109. <el-menu-item :index="8">
  110. <img
  111. v-if="activeIndex == 8"
  112. src="@/assets/systemA.png"
  113. alt=""
  114. style="width: 20px; height: 20px"
  115. />
  116. <img
  117. v-else
  118. src="@/assets/system.png"
  119. alt=""
  120. style="width: 20px; height: 20px"
  121. />
  122. <span>系统设置</span>
  123. </el-menu-item>
  124. </el-menu>
  125. </div>
  126. </template>
  127. <script setup>
  128. import { ref, onBeforeMount, onMounted, watch, reactive } from "vue";
  129. import { useStore } from "vuex";
  130. import { useRouter } from "vue-router";
  131. const store = useStore();
  132. const router = useRouter();
  133. const menuClose = ref(false);
  134. const activeIndex = ref(9);
  135. const acitveItems = reactive({ list: [] });
  136. watch(
  137. () => store.state.user.collapse,
  138. (newValue, oldValue) => {
  139. menuClose.value = newValue;
  140. }
  141. );
  142. watch(
  143. () => store.state.user.activeIndex,
  144. (newValue, oldValue) => {
  145. console.log(newValue);
  146. activeIndex.value = newValue;
  147. }
  148. );
  149. const handleSelect = (key) => {
  150. store.commit("indexUp", key);
  151. activeIndex.value = key;
  152. sessionStorage.setItem("sidevarItem", key);
  153. if (activeIndex.value == 1) {
  154. router.push({
  155. path: `/schoolBus/statement`,
  156. });
  157. }
  158. if (activeIndex.value == 2) {
  159. router.push({
  160. path: `/schoolBus/staff`,
  161. });
  162. }
  163. if (activeIndex.value == 3) {
  164. router.push({
  165. path: `/schoolBus/account`,
  166. });
  167. }
  168. if (activeIndex.value == 4) {
  169. router.push({
  170. path: `/schoolBus/bus`,
  171. });
  172. }
  173. if (activeIndex.value == 6) {
  174. router.push({
  175. path: `/schoolBus/classes`,
  176. });
  177. }
  178. if (activeIndex.value == 5) {
  179. router.push({
  180. path: `/schoolBus/buspath`,
  181. });
  182. }
  183. if (activeIndex.value == 8) {
  184. router.push({
  185. path: `/schoolBus/system`,
  186. });
  187. }
  188. if (activeIndex.value == 7) {
  189. router.push({
  190. path: `/schoolBus/blacklist`,
  191. });
  192. }
  193. if (activeIndex.value == 9) {
  194. router.push({
  195. path: `/schoolBus/busquery`,
  196. });
  197. }
  198. if (activeIndex.value == 10) {
  199. router.push({
  200. path: `/schoolBus/log`,
  201. });
  202. }
  203. if (activeIndex.value == 11) {
  204. router.push({
  205. path: `/schoolBus/report`,
  206. });
  207. }
  208. if (activeIndex.value == 0) {
  209. router.push({
  210. path: `/schoolBus/news`,
  211. });
  212. }
  213. };
  214. onBeforeMount(() => {
  215. activeIndex.value = Number(sessionStorage.getItem("sidevarItem"));
  216. store.commit("indexUp", Number(sessionStorage.getItem("sidevarItem")));
  217. });
  218. </script>
  219. <style lang="scss" scoped>
  220. .el-menu-vertical-demo:not(.el-menu--collapse) {
  221. width: 220px;
  222. // min-height: 400px;
  223. }
  224. .box-item {
  225. // width: 220px !important;
  226. height: calc(100vh);
  227. }
  228. .el-menu {
  229. width: 100%;
  230. height: 100%;
  231. overflow: auto;
  232. background: linear-gradient(
  233. 0deg,
  234. rgba(134, 132, 255, 1) 0%,
  235. rgba(60, 80, 232, 1) 100%
  236. );
  237. box-shadow: 0px 0px 20px 0px rgba(0, 0, 0, 0.16);
  238. .logo {
  239. height: 65px;
  240. color: rgb(255, 255, 255);
  241. cursor: default;
  242. display: flex;
  243. justify-content: space-around;
  244. align-items: center;
  245. }
  246. .logo:hover {
  247. background-color: transparent !important;
  248. }
  249. .el-menu-item {
  250. // border-left: 3px solid rgba(248, 220, 38);
  251. padding: 0 10px;
  252. }
  253. .el-menu-item:hover {
  254. background-color: rgba(255, 255, 255, 0.4);
  255. }
  256. .el-menu-item.is-active:hover {
  257. background-color: #fff;
  258. }
  259. .el-menu-item img {
  260. width: 18px;
  261. height: 18px;
  262. margin: 0 20px;
  263. }
  264. :deep(.el-sub-menu) {
  265. .el-sub-menu__title:hover{
  266. background-color: rgba(255, 255, 255, 0.4);
  267. }
  268. .el-sub-menu__title{
  269. display: flex;
  270. align-items: center;
  271. .el-icon{
  272. margin: 0 18px;
  273. }
  274. .el-sub-menu__icon-arrow{
  275. margin: 0 0 0 0px;
  276. top: 40%;
  277. }
  278. }
  279. .el-menu {
  280. background-color: transparent;
  281. }
  282. .el-menu--inline{
  283. .el-sub-menu{
  284. .el-sub-menu__title{
  285. padding-left: 40px;
  286. }
  287. }
  288. .el-menu-item{
  289. padding-left: 40px;
  290. }
  291. }
  292. }
  293. .el-sub-menu.is-active:hover {
  294. background-color: #fff;
  295. }
  296. }
  297. .el-menu--collapse{
  298. :deep(.el-sub-menu){
  299. display: flex;
  300. align-items: center;
  301. justify-content: center;
  302. .el-sub-menu__title{
  303. padding: 0;
  304. }
  305. }
  306. }
  307. .el-menu-item.is-active {
  308. box-sizing: border-box;
  309. background-color: #fff;
  310. color: #000;
  311. }
  312. </style>