LeftWrap.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. <script setup>
  2. import { useRouter } from 'vue-router'
  3. import { useLayoutState } from '../hooks/index'
  4. import {apiSystemCommon} from '@/api/system'
  5. const router = useRouter()
  6. const { menuClose } = useLayoutState()
  7. const navList = ref([
  8. // {
  9. // name: '客户管理',
  10. // path: '/customer',
  11. // IsLevel: 2,
  12. // Children: [
  13. // {
  14. // name: '商家管理',
  15. // path: '/'
  16. // },
  17. // {
  18. // name: '用户管理',
  19. // path: '/customer/userList'
  20. // }
  21. // ]
  22. // },
  23. // {
  24. // name: 'ETA客户行为统计',
  25. // path: '/customer',
  26. // IsLevel: 1,
  27. // Children: [
  28. // {
  29. // name: 'ETA客户行为统计',
  30. // path: '/customer/userActionStatistic',
  31. // }
  32. // ]
  33. // },
  34. ])
  35. function getNavList() {
  36. apiSystemCommon.menuList().then(res=>{
  37. if(res.Ret===200){
  38. navList.value=res.Data.List||[]
  39. }
  40. })
  41. }
  42. getNavList()
  43. function handleClickMenu(path){
  44. router.push(path)
  45. }
  46. function getMenuIcon(item) {
  47. const iconMap = {
  48. '客户管理': 'menu/customer',
  49. 'ETA客户行为统计':'menu/menu02',
  50. 'ETA试用管理':'menu/menu03',
  51. 'ETA社区管理':'menu/menu04',
  52. 'ETA菜单配置':'menu/menu05',
  53. '培训管理':'menu/menu06',
  54. '个性化设置':'menu/menu07',
  55. '系统设置':'menu/menu08',
  56. '权限配置':'menu/menu09'
  57. }
  58. return iconMap[item] || 'menu/setting'
  59. }
  60. </script>
  61. <template>
  62. <div :class="['left-wrap', menuClose ? 'left-wrap__close' : '']">
  63. <t-menu
  64. class="menu-wrap"
  65. :value="$route.path"
  66. :collapsed="menuClose"
  67. :width="['200px', '80px']"
  68. >
  69. <template v-for="level1 in navList" :key="level1.MenuId">
  70. <t-menu-item :value="level1.children[0].path" v-if="level1.IsLevel === 1" @click="handleClickMenu(level1.children[0].path)">
  71. <svg-icon
  72. :name="getMenuIcon(level1.children[0].name)"
  73. :color="$route.path === level1.children[0].path ? '#086CE0' : '#333'"
  74. style="font-size: 20px;position: relative;top:5px"
  75. ></svg-icon>
  76. <span style="margin-left: 5px">{{ level1.children[0].name }}</span>
  77. </t-menu-item>
  78. <t-submenu :value="level1.MenuId" v-if="level1.IsLevel === 2">
  79. <template #title>
  80. <svg-icon
  81. :name="getMenuIcon(level1.name)"
  82. :color="$route.path === level1.path ? '#086CE0' : '#333'"
  83. style="font-size: 20px;position: relative;top:5px"
  84. ></svg-icon>
  85. <span style="margin-left: 5px">{{ level1.name }}</span>
  86. </template>
  87. <t-menu-item
  88. v-for="child in level1.children"
  89. :value="child.path"
  90. :key="child.path"
  91. @click="handleClickMenu(child.path)"
  92. >
  93. <span style="margin-left: 5px">{{ child.name }}</span>
  94. </t-menu-item>
  95. </t-submenu>
  96. </template>
  97. </t-menu>
  98. </div>
  99. </template>
  100. <style lang="scss" scoped>
  101. .left-wrap {
  102. width: 200px;
  103. z-index: 50;
  104. position: fixed;
  105. top: 67px;
  106. left: 0;
  107. bottom: 0;
  108. padding: 8px 0;
  109. background-color: #fff;
  110. display: flex;
  111. flex-direction: column;
  112. padding-bottom: 111px;
  113. transition: all 0.5s;
  114. .menu-wrap {
  115. flex: 1;
  116. height: 100%;
  117. border: none;
  118. .t-submenu {
  119. :deep(.t-menu-item) {
  120. padding-left: var(--t-menu-base-level-padding);
  121. }
  122. :deep(.t-submenu__icon-arrow) {
  123. transform: rotateZ(-90deg) !important;
  124. }
  125. &.is-opened {
  126. :deep(.t-submenu__icon-arrow) {
  127. transform: rotateZ(0deg) !important;
  128. border-radius: 4px;
  129. }
  130. }
  131. }
  132. :deep(.t-menu-item.is-active) {
  133. background-color: #f3f9ff;
  134. }
  135. }
  136. .user-box {
  137. background-color: var(--t-menu-hover-bg-color);
  138. color: #333;
  139. text-align: center;
  140. padding: 20px;
  141. .name-box {
  142. display: flex;
  143. justify-content: center;
  144. align-items: center;
  145. gap: 0 5px;
  146. }
  147. .opt {
  148. margin: 10px 0;
  149. cursor: pointer;
  150. }
  151. }
  152. }
  153. .left-wrap__close {
  154. width: 80px;
  155. }
  156. </style>