cwg-sidebar.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <template>
  2. <view class="cwg-sidebar">
  3. <view class="menu-list">
  4. <view class="menu" v-for="(item, index) in menus" :key="item.path">
  5. <view class="menu-item" @click="handleClick(index)">
  6. <cwg-icon :name="item.icon" :size="20" color="#6c8595" />
  7. <view class="menu-label" v-t="item.label" />
  8. <view class="chevron-icon" :class="{ 'expanded': item.isOpenMenu }">
  9. <cwg-icon v-if="item.children && item.children.length" name="crm-chevron-down" :size="20"
  10. color="#6c8595" />
  11. </view>
  12. </view>
  13. <view :ref="(el) => setSubmenuRef(index, el)" class="submenu-box" :a="index" :key1="item.path + index"
  14. :b="item" :style="{
  15. height: !(item.children && item.children.length) ? '0px' : item.isOpenMenu ? item.submenuHeight + 'px' : '0px',
  16. transition: 'height 281ms cubic-bezier(0.4, 0, 0.2, 1)'
  17. }" :class="{ 'active': item.isOpenMenu }">
  18. <cwg-submenu v-if="item.children && item.children.length" :submenu-items="item.children"
  19. @submenu-click="handleSubmenuClick" />
  20. </view>
  21. </view>
  22. </view>
  23. <view class="menu fixed">
  24. <view class="menu-item ib-box" @click="setMode('ib')" v-if="mode !== 'ib'">
  25. <cwg-icon name="crm-ib" :size="20" color="#6c8595" />
  26. <view class="menu-label" v-t="'Home.msg.Ib'" />
  27. </view>
  28. <view class="menu-item ib-box" @click="setMode('customer')" v-if="mode !== 'customer'">
  29. <cwg-icon name="crm-trade" :size="20" color="#6c8595" />
  30. <view class="menu-label" v-t="'Home.msg.Custom'" />
  31. </view>
  32. </view>
  33. </view>
  34. </template>
  35. <script lang="ts" setup>
  36. import { useMenuSplit } from '@/composables/useMenuSplit'
  37. const { menus, setSubmenuRef, setMode, handleClick, handleSubmenuClick, mode } = useMenuSplit()
  38. </script>
  39. <style scoped lang="scss">
  40. @import "@/uni.scss";
  41. .cwg-sidebar {
  42. width: px2rpx(280);
  43. color: #6c8595;
  44. height: calc(100vh - 56px);
  45. overflow: auto;
  46. display: flex;
  47. flex-direction: column;
  48. align-items: center;
  49. padding: px2rpx(8);
  50. padding-top: px2rpx(20);
  51. box-sizing: border-box;
  52. gap: px2rpx(8);
  53. border-right: 1px solid rgba(108, 133, 149, 0.12);
  54. .logo {
  55. width: px2rpx(54);
  56. }
  57. .menu-list {
  58. flex: 1;
  59. width: 100%;
  60. overflow-y: auto;
  61. display: flex;
  62. flex-direction: column;
  63. gap: px2rpx(8);
  64. }
  65. .submenu-box {
  66. width: 100%;
  67. height: 0;
  68. overflow: hidden;
  69. }
  70. .menu {
  71. width: 100%;
  72. position: relative;
  73. display: flex;
  74. flex-direction: column;
  75. align-items: center;
  76. box-sizing: border-box;
  77. }
  78. .menu-item {
  79. width: 100%;
  80. height: px2rpx(40);
  81. cursor: pointer;
  82. display: flex;
  83. align-items: center;
  84. justify-content: space-between;
  85. gap: px2rpx(8);
  86. padding: px2rpx(10);
  87. box-sizing: border-box;
  88. font-size: 14px;
  89. .menu-label {
  90. flex: 1;
  91. }
  92. &:hover {
  93. background: rgba(108, 133, 149, 0.12) !important;
  94. border: 1px solid rgb(145, 163, 176) !important;
  95. border-radius: px2rpx(4);
  96. }
  97. .expanded .icon {
  98. transform: rotate(180deg);
  99. }
  100. }
  101. .ib-box {
  102. background: rgba(140, 69, 246, 0.08) !important;
  103. border: 1px solid rgba(140, 69, 246, 0.2) !important;
  104. font-size: px2rpx(18);
  105. font-weight: 600;
  106. color: #141d22;
  107. &:hover {
  108. background: rgba(140, 69, 246, 0.08) !important;
  109. border: 1px solid rgba(140, 69, 246, 0.2) !important;
  110. }
  111. }
  112. .zy-box {
  113. display: flex;
  114. align-items: center;
  115. justify-content: center;
  116. }
  117. .fixed {
  118. position: relative;
  119. width: 100%;
  120. display: flex;
  121. align-items: center;
  122. justify-content: center;
  123. gap: px2rpx(8);
  124. }
  125. }
  126. </style>