Aside.vue 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <template>
  2. <el-menu
  3. :default-active="store.state.currentMenuItem"
  4. style="width: 220px; height: 100%"
  5. background-color="#141B29"
  6. text-color="#fff"
  7. active-text-color="#ffd04b"
  8. :router="true"
  9. >
  10. <el-sub-menu v-for="(item, index) in menu" :key="item" :index="index + ''">
  11. <template v-slot:title>
  12. <el-icon :size="18">
  13. <component :is="item.icon" />
  14. </el-icon>
  15. <span>{{ item.title }}</span>
  16. </template>
  17. <el-menu-item
  18. v-for="son in item.items"
  19. :index="son.path"
  20. :key="son"
  21. @click="changeIndex(son.path)"
  22. >
  23. {{ son.name }}
  24. </el-menu-item>
  25. </el-sub-menu>
  26. </el-menu>
  27. </template>
  28. <script setup>
  29. import { ref } from "vue";
  30. import store from "../store";
  31. let defaultActive = ref();
  32. function changeIndex(path) {
  33. defaultActive.value = path;
  34. }
  35. let menu = [
  36. {
  37. icon: "Fold",
  38. title: "首页",
  39. items: [
  40. {
  41. path: "/index",
  42. name: "首页",
  43. },
  44. ],
  45. },
  46. {
  47. icon: "Avatar",
  48. title: "船东管理",
  49. items: [
  50. {
  51. path: "/shipOwnerManage/shipOwnerList",
  52. name: "船东列表",
  53. },
  54. ],
  55. },
  56. {
  57. icon: "Ship",
  58. title: "船舶管理",
  59. items: [
  60. {
  61. path: "/shipManage/shipList",
  62. name: "船舶列表",
  63. },
  64. ],
  65. },
  66. {
  67. icon: "Document",
  68. title: "工作站",
  69. items: [
  70. {
  71. path: "/workStation/certsManage",
  72. name: "证书管理",
  73. },
  74. {
  75. path: "/workStation/insuranceManage",
  76. name: "保险管理",
  77. },
  78. ],
  79. },
  80. ];
  81. </script>
  82. <style scoped>
  83. .el-sub-menu__title i {
  84. height: 20px;
  85. margin-right: 10px;
  86. }
  87. </style>