SidevarItem.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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="3">
  43. <img v-if="activeIndex == 3" src="@/assets/accountA.png" alt="" />
  44. <img v-else src="@/assets/account.png" alt="" />
  45. <span>账号管理</span>
  46. </el-menu-item>
  47. <el-menu-item :index="4">
  48. <img v-if="activeIndex == 4" src="@/assets/carA.png" alt="" />
  49. <img v-else src="@/assets/car.png" alt="" />
  50. <span>车辆管理</span>
  51. </el-menu-item>
  52. <el-menu-item :index="5">
  53. <img v-if="activeIndex == 5" src="@/assets/pathA.png" alt="" />
  54. <img v-else src="@/assets/path.png" alt="" />
  55. <span>路线管理</span>
  56. </el-menu-item>
  57. <el-menu-item :index="6">
  58. <img v-if="activeIndex == 6" src="@/assets/classesA.png" alt="" />
  59. <img v-else src="@/assets/classes.png" alt="" />
  60. <span>班次管理</span>
  61. </el-menu-item>
  62. <el-menu-item :index="7">
  63. <img v-if="activeIndex == 7" src="@/assets/blacklistA.png" alt="" />
  64. <img v-else src="@/assets/blacklist.png" alt="" />
  65. <span>黑名单管理</span>
  66. </el-menu-item>
  67. <el-menu-item :index="8">
  68. <img
  69. v-if="activeIndex == 8"
  70. src="@/assets/systemA.png"
  71. alt=""
  72. style="width: 20px; height: 20px"
  73. />
  74. <img
  75. v-else
  76. src="@/assets/system.png"
  77. alt=""
  78. style="width: 20px; height: 20px"
  79. />
  80. <span>系统设置</span>
  81. </el-menu-item>
  82. </el-menu>
  83. </div>
  84. </template>
  85. <script setup>
  86. import { ref, onBeforeMount, onMounted, watch, reactive } from "vue";
  87. import { useStore } from "vuex";
  88. import { useRouter } from "vue-router";
  89. const store = useStore();
  90. const router = useRouter();
  91. const menuClose = ref(false);
  92. const activeIndex = ref(9);
  93. const acitveItems = reactive({ list: [] });
  94. watch(
  95. () => store.state.user.collapse,
  96. (newValue, oldValue) => {
  97. menuClose.value = newValue;
  98. }
  99. );
  100. watch(
  101. () => store.state.user.activeIndex,
  102. (newValue, oldValue) => {
  103. activeIndex.value = newValue;
  104. }
  105. );
  106. const handleSelect = (key, keyPath) => {
  107. // console.log(key, keyPath);
  108. store.commit("indexUp", key);
  109. activeIndex.value = key;
  110. sessionStorage.setItem("sidevarItem", key);
  111. if (activeIndex.value == 1) {
  112. router.push({
  113. path: `/schoolBus/statement`,
  114. });
  115. }
  116. if (activeIndex.value == 2) {
  117. router.push({
  118. path: `/schoolBus/staff`,
  119. });
  120. }
  121. if (activeIndex.value == 3) {
  122. router.push({
  123. path: `/schoolBus/account`,
  124. });
  125. }
  126. if (activeIndex.value == 4) {
  127. router.push({
  128. path: `/schoolBus/bus`,
  129. });
  130. }
  131. if (activeIndex.value == 6) {
  132. router.push({
  133. path: `/schoolBus/classes`,
  134. });
  135. }
  136. if (activeIndex.value == 5) {
  137. router.push({
  138. path: `/schoolBus/buspath`,
  139. });
  140. }
  141. if (activeIndex.value == 8) {
  142. router.push({
  143. path: `/schoolBus/waiting`,
  144. });
  145. }
  146. if (activeIndex.value == 7) {
  147. router.push({
  148. path: `/schoolBus/blacklist`,
  149. });
  150. }
  151. if (activeIndex.value == 9) {
  152. router.push({
  153. path: `/schoolBus/busquery`,
  154. });
  155. }
  156. if (activeIndex.value == 0) {
  157. router.push({
  158. path: `/schoolBus/news`,
  159. });
  160. }
  161. };
  162. onBeforeMount(() => {
  163. // console.log("切换", Number(sessionStorage.getItem("sidevarItem")));
  164. store.commit("indexUp", Number(sessionStorage.getItem("sidevarItem")));
  165. });
  166. </script>
  167. <style lang="scss" scoped>
  168. .box-item {
  169. // width: 160px;
  170. }
  171. .el-menu-vertical-demo:not(.el-menu--collapse) {
  172. width: 200px;
  173. // min-height: 400px;
  174. }
  175. .el-menu {
  176. width: 100%;
  177. height: 100%;
  178. background: linear-gradient(
  179. 0deg,
  180. rgba(134, 132, 255, 1) 0%,
  181. rgba(60, 80, 232, 1) 100%
  182. );
  183. box-shadow: 0px 0px 20px 0px rgba(0, 0, 0, 0.16);
  184. .logo {
  185. height: 65px;
  186. color: rgb(255, 255, 255);
  187. cursor: default;
  188. display: flex;
  189. justify-content: space-around;
  190. align-items: center;
  191. }
  192. .logo:hover {
  193. background-color: transparent !important;
  194. }
  195. .el-menu-item {
  196. // border-left: 3px solid rgba(248, 220, 38);
  197. padding: 0 10px;
  198. }
  199. .el-menu-item:hover {
  200. background-color: rgba(255, 255, 255, 0.4);
  201. }
  202. .el-menu-item.is-active:hover {
  203. background-color: #fff;
  204. }
  205. .el-menu-item img {
  206. width: 18px;
  207. height: 18px;
  208. margin: 0 20px;
  209. }
  210. }
  211. .el-menu-item.is-active {
  212. box-sizing: border-box;
  213. background-color: #fff;
  214. color: #000;
  215. }
  216. </style>