Elizabeth's proactive approach involves introducing urinal toilet attachment , an ingenious concept that optimizes space and functionality.

SidebarItem.vue 7.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. <template>
  2. <div v-if="!item.hidden && item.children" class="menu-wrapper">
  3. <div v-if="item.other">
  4. <a :href="item.src" target="_blank">
  5. <el-menu-item
  6. :index="resolvePath(item.src)"
  7. :class="{ 'submenu-title-noDropdown': !isNest }"
  8. >
  9. <i v-if="item.name == 'slow'" class="icon iconfont icon-manbing-xuanzhong" style="margin-right:4px"></i>
  10. <i v-if="item.name == 'scrm'" class="icon iconfont icon-pengyou" style="margin-right:4px"></i>
  11. <i v-if="item.name == 'shop'" class="icon iconfont icon-service_fill" style="margin-right:4px"></i>
  12. <span slot="title">{{ generateTitle(item.name) }}</span>
  13. </el-menu-item>
  14. </a>
  15. </div>
  16. <div v-else>
  17. <div
  18. v-if="
  19. hasOneShowingChild(item.children) &&
  20. !onlyOneChild.children &&
  21. !item.alwaysShow
  22. "
  23. @click="onClick(item)"
  24. >
  25. <router-link :to="resolvePath(onlyOneChild.path)">
  26. <el-menu-item
  27. :index="resolvePath(onlyOneChild.path)"
  28. :class="{ 'submenu-title-noDropdown': !isNest }"
  29. >
  30. <svg-icon
  31. v-if="onlyOneChild.meta && onlyOneChild.meta.icon"
  32. :icon-class="onlyOneChild.meta.icon"
  33. ></svg-icon>
  34. <span
  35. v-if="onlyOneChild.meta && onlyOneChild.meta.title"
  36. slot="title"
  37. >{{ generateTitle(onlyOneChild.meta.title) }}</span>
  38. </el-menu-item>
  39. </router-link>
  40. </div>
  41. <div v-else>
  42. <el-submenu v-if="item.meta.isChild" id="mySubmenu" :index="item.name || item.path">
  43. <template slot="title">
  44. <svg-icon v-if="item.meta && item.meta.icon" :icon-class="item.meta.icon"></svg-icon>
  45. <span v-if="item.meta && item.meta.title" slot="title">
  46. {{
  47. generateTitle(item.meta.title)
  48. }}
  49. </span>
  50. </template>
  51. <template v-for="child in item.children" v-if="!child.hidden">
  52. <router-link
  53. :to="resolvePath(child.path)"
  54. v-if="child.meta.isChild != true"
  55. :key="child.name"
  56. >
  57. <el-menu-item @click="onClick(item)" :index="resolvePath(child.path)">
  58. <svg-icon v-if="child.meta && child.meta.icon" :icon-class="child.meta.icon"></svg-icon>
  59. <span v-if="child.meta && child.meta.title" slot="title">
  60. {{
  61. generateTitle(child.meta.title)
  62. }}
  63. </span>
  64. </el-menu-item>
  65. </router-link>
  66. <router-link v-else :to="child.path" :key="child.name">
  67. <el-menu-item @click="onClick(item,child.parentNum)" :index="resolvePath(child.path)">
  68. <svg-icon v-if="child.meta && child.meta.icon" :icon-class="child.meta.icon"></svg-icon>
  69. <span v-if="child.meta && child.meta.title" slot="title">
  70. {{
  71. generateTitle(child.meta.title)
  72. }}
  73. </span>
  74. </el-menu-item>
  75. </router-link>
  76. </template>
  77. </el-submenu>
  78. <div v-else @click="onClick(item)">
  79. <router-link :to="resolvePath(item.children[0].path)">
  80. <el-menu-item :index="item.name || item.path">
  81. <template slot="title">
  82. <svg-icon v-if="item.meta && item.meta.icon" :icon-class="item.meta.icon"></svg-icon>
  83. <span v-if="item.meta && item.meta.title" slot="title">
  84. {{
  85. generateTitle(item.meta.title)
  86. }}
  87. </span>
  88. </template>
  89. <!-- <template v-for="child in item.children" v-if="!child.hidden">
  90. <sidebar-item
  91. :is-nest="true"
  92. class="nest-menu"
  93. v-if="child.children && child.children.length > 0"
  94. :item="child"
  95. :key="child.path"
  96. :base-path="resolvePath(child.path)"
  97. ></sidebar-item>
  98. <router-link v-else :to="resolvePath(child.path)" :key="child.name">
  99. <el-menu-item :index="resolvePath(child.path)">
  100. <svg-icon
  101. v-if="child.meta && child.meta.icon"
  102. :icon-class="child.meta.icon"
  103. ></svg-icon>
  104. <span v-if="child.meta && child.meta.title" slot="title">{{
  105. generateTitle(child.meta.title)
  106. }}</span>
  107. </el-menu-item>
  108. </router-link>
  109. </template>-->
  110. </el-menu-item>
  111. </router-link>
  112. </div>
  113. </div>
  114. </div>
  115. </div>
  116. </template>
  117. <script>
  118. import path from "path";
  119. import { generateTitle } from "@/utils/i18n";
  120. import { mapGetters } from "vuex";
  121. export default {
  122. name: "SidebarItem",
  123. props: {
  124. // route object
  125. item: {
  126. type: Object,
  127. required: true
  128. },
  129. isNest: {
  130. type: Boolean,
  131. default: false
  132. },
  133. basePath: {
  134. type: String,
  135. default: ""
  136. },
  137. index: {
  138. type: Number
  139. }
  140. },
  141. computed: {
  142. ...mapGetters(["permission_routers"])
  143. },
  144. data() {
  145. return {
  146. onlyOneChild: null
  147. };
  148. },
  149. methods: {
  150. hasOneShowingChild(children) {
  151. const showingChildren = children.filter(item => {
  152. if (item.hidden) {
  153. return false;
  154. } else {
  155. // temp set(will be used if only has one showing child )
  156. this.onlyOneChild = item;
  157. return true;
  158. }
  159. });
  160. if (showingChildren.length === 1) {
  161. return true;
  162. }
  163. return false;
  164. },
  165. resolvePath(...paths) {
  166. return path.resolve(this.basePath, ...paths);
  167. },
  168. generateTitle,
  169. onClick(index, num) {
  170. this.permission_routers.map((item, i) => {
  171. if (this.isObjectValueEqual(item, index)) {
  172. if (num) {
  173. this.$emit("a", i, num);
  174. } else {
  175. this.$emit("a", i, 999);
  176. }
  177. }
  178. });
  179. },
  180. isObjectValueEqual(a, b) {
  181. var aProps = Object.getOwnPropertyNames(a);
  182. var bProps = Object.getOwnPropertyNames(b);
  183. if (aProps.length != bProps.length) {
  184. return false;
  185. }
  186. for (var i = 0; i < aProps.length; i++) {
  187. var propName = aProps[i];
  188. if (a[propName] !== b[propName]) {
  189. return false;
  190. }
  191. }
  192. return true;
  193. }
  194. },
  195. created() {}
  196. };
  197. </script>
  198. <style lang="scss">
  199. #mySubmenu {
  200. .el-menu {
  201. display: flex;
  202. flex-wrap: wrap;
  203. > a {
  204. width: 50% !important;
  205. }
  206. .el-menu-item {
  207. min-width: 0;
  208. padding: 0 5px !important;
  209. font-size: 12px;
  210. background-color:#1F2D3D !important;
  211. }
  212. }
  213. }
  214. .menu-wrapper{
  215. .el-menu-item{
  216. background-color:#1F2D3D !important;
  217. color: #fff !important;
  218. }
  219. .el-menu{
  220. background-color:#1F2D3D !important;
  221. }
  222. .el-submenu__title{
  223. background-color:#1F2D3D !important;
  224. color: #fff !important;
  225. height: 32px !important;
  226. line-height: 32px !important;
  227. }
  228. .router-link-exact-active{
  229. color: rgb(64, 158, 255) !important;
  230. .el-menu-item{
  231. color: rgb(64, 158, 255) !important;
  232. }
  233. }
  234. }
  235. </style>