1
0

index.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <template>
  2. <div class="shortcut" :style="{ height: moreStatus ? 'auto' : '50px' }" @mouseleave="moreClose">
  3. <div class="tags" @mouseenter="moreOpen">
  4. <router-link v-for="item in shortcutMenuList" :key="item.menuId" :to="'/' + item.path + '/'" class="tag">
  5. <span class="font_name">{{ item.menuName }}</span>
  6. <i class="el-icon-error" v-show="delStatus" @click.prevent="deleteShortcutMenu(item)"></i>
  7. </router-link>
  8. </div>
  9. <div class="btns">
  10. <a href="javascript:void(0);" title="删除" @click="delStatus = !delStatus">
  11. <i class="el-icon-delete"></i>
  12. </a>
  13. </div>
  14. </div>
  15. </template>
  16. <script>
  17. import { getUserShortcutMenuList, deleteUserShortcutMenu, addUserShortcutMenu } from '@/api/system/menu'
  18. import EventBus from '@/utils/eventBus'
  19. export default {
  20. data() {
  21. return {
  22. moreStatus: false,
  23. delStatus: false,
  24. shortcutMenuList: [], // 快捷菜单列表
  25. userId: '' // 用户ID
  26. }
  27. },
  28. computed: {
  29. theme() {
  30. return this.$store.state.settings.theme
  31. }
  32. },
  33. mounted() {
  34. this.$nextTick(() => {
  35. EventBus.$on('addShortcutMenu', obj => {
  36. let param = {
  37. menuId: obj.menuId,
  38. userId: this.userId
  39. }
  40. addUserShortcutMenu(param).then(res => {
  41. if (res.code === 200) {
  42. this.getUserShortcutMenuList()
  43. }
  44. })
  45. })
  46. })
  47. },
  48. created() {
  49. this.getUserShortcutMenuList()
  50. },
  51. methods: {
  52. // 快捷菜单列表
  53. getUserShortcutMenuList() {
  54. this.userId = this.$store.state.user.userId
  55. getUserShortcutMenuList(this.userId).then(res => {
  56. this.shortcutMenuList = res.data
  57. console.log(this.shortcutMenuList)
  58. })
  59. },
  60. // 删除快捷菜单
  61. deleteShortcutMenu(menu) {
  62. let obj = {
  63. menuId: menu.menuId,
  64. userId: this.userId
  65. }
  66. this.$modal
  67. .confirm('是否确认删除菜单名称为"' + menu.menuName + '"的数据项?')
  68. .then(function () {
  69. return deleteUserShortcutMenu(obj)
  70. })
  71. .then(res => {
  72. console.log(res)
  73. this.getUserShortcutMenuList()
  74. this.$modal.msgSuccess('删除成功')
  75. })
  76. .catch(() => {})
  77. },
  78. isActive(route) {
  79. return route.path === this.$route.path
  80. },
  81. activeStyle(tag) {
  82. if (!this.isActive(tag)) return {}
  83. return {
  84. 'background-color': this.theme,
  85. 'border-color': this.theme
  86. }
  87. },
  88. moreOpen() {
  89. this.moreStatus = true
  90. },
  91. moreClose() {
  92. this.moreStatus = false
  93. }
  94. }
  95. }
  96. </script>
  97. <style scoped lang="scss">
  98. .shortcut {
  99. height: 40px;
  100. line-height: 40px;
  101. padding: 0 10px;
  102. overflow: hidden;
  103. display: flex;
  104. justify-content: space-between;
  105. .tags {
  106. flex: 1;
  107. .tag {
  108. font-size: 14px;
  109. color: #fff;
  110. margin-right: 5px;
  111. display: inline-block;
  112. position: relative;
  113. background: #4c9898;
  114. border: #4c9898 1px solid;
  115. border-radius: 5px;
  116. margin-top: 7px;
  117. padding: 0 15px;
  118. i {
  119. position: absolute;
  120. top: 20%;
  121. right: -10px;
  122. }
  123. }
  124. }
  125. .btns {
  126. height: 50px;
  127. display: flex;
  128. align-items: center;
  129. i {
  130. font-size: 18px;
  131. color: #fff;
  132. }
  133. // .more-open i {
  134. // transform: rotate(-90deg);
  135. // -webkit-transform: rotate(-90deg);
  136. // -moz-transform: rotate(-90deg);
  137. // -o-transform: rotate(-90deg);
  138. // -mz-transform: rotate(-90deg);
  139. // }
  140. // .more-close i {
  141. // transform: rotate(90deg);
  142. // -webkit-transform: rotate(90deg);
  143. // -moz-transform: rotate(90deg);
  144. // -o-transform: rotate(90deg);
  145. // -mz-transform: rotate(90deg);
  146. // }
  147. }
  148. }
  149. </style>