menu.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. <template>
  2. <div class="door_menu">
  3. <div class="menu">
  4. <div :class="$router.path=='/workbench'?'active item':'item'" @click="$router.push('/workbench')">工作台</div>
  5. <div v-for="menu in menusShow" :key="menu.id" :class="currMenuId===menu.id?'active item':'item'" @click="menuSelect(menu)">{{ menu.name }}</div>
  6. </div>
  7. <el-popover
  8. v-if="menusPop.length>0"
  9. placement="bottom-end"
  10. trigger="click"
  11. width="88"
  12. popper-class="menuPopper"
  13. @hide="popoverImg=false"
  14. @show="popoverImg=true"
  15. >
  16. <div class="list">
  17. <div v-for="menu in menusPop" :key="menu.id" :class="currMenuId===menu.id?'active item':'item'" @mouseover="menuMouseOver(menu)">{{ menu.name }}</div>
  18. </div>
  19. <img
  20. slot="reference"
  21. :src="popoverImg?require('./image/menu_1.png'):require('./image/menu.png')"
  22. alt=""
  23. style="vertical-align: middle;cursor: pointer"
  24. >
  25. </el-popover>
  26. <el-popover
  27. placement="bottom-end"
  28. popper-class="menuPopper"
  29. trigger="click"
  30. width="200"
  31. >
  32. <div class="list">
  33. <div :class="menuPopId==10?'active':''" class="item" @click="openUpdate" @mouseover="mouseoverFun(10)">密码修改</div>
  34. <div :class="menuPopId==11?'active':''" class="item" @mouseover="mouseoverFun(11)">版本:V1.0</div>
  35. <div :class="menuPopId==12?'active':''" class="item" @click="logOut" @mouseover="mouseoverFun(12)">退出系统</div>
  36. </div>
  37. <div slot="reference" class="user_info">
  38. <img alt="" class="head" src="./image/head.png">
  39. <div class="user_name">欢迎你,{{ user.truename }}!</div>
  40. <img alt="" src="./image/arrow.png">
  41. </div>
  42. </el-popover>
  43. <el-dialog
  44. :append-to-body="true"
  45. :close-on-click-modal="false"
  46. :close-on-press-escape="false"
  47. :modal-append-to-body="true"
  48. :visible.sync="dialogPWDVisible"
  49. title="修改密码"
  50. top="60px"
  51. class="statistic_base"
  52. width="600px"
  53. >
  54. <update-password @closeUpdate="dialogPWDVisible = false" />
  55. </el-dialog>
  56. </div>
  57. </template>
  58. <script>
  59. import UpdatePassword from '@/views/components/updatePassword'
  60. import { mapGetters } from 'vuex'
  61. export default {
  62. name: 'Door',
  63. components: {
  64. UpdatePassword
  65. },
  66. data() {
  67. return {
  68. dialogPWDVisible: false,
  69. user: this.$common.currUser() ? this.$common.currUser() : '',
  70. popoverImg: false,
  71. menuPopId: 0,
  72. menusShow: [],
  73. menusPop: [],
  74. menuShowNum: 7,
  75. currMenuId: ''
  76. }
  77. },
  78. computed: {
  79. ...mapGetters(['permission_menus'])
  80. },
  81. watch: {},
  82. mounted() {
  83. // console.log('user',this.user)
  84. this.$nextTick(() => {
  85. this.initMenus(this.permission_menus)
  86. })
  87. },
  88. methods: {
  89. initMenus: function(_menu) {
  90. this.menusShow = _menu.slice(0, this.menuShowNum)
  91. this.menusPop = _menu.slice(this.menuShowNum, _menu.length)
  92. var num = this.$route.query.menuIndex ? this.$route.query.menuIndex : 1
  93. var pass = 0
  94. for (var i = 0; i < this.menusShow.length; i++) {
  95. if (num == this.menusShow[i].id) {
  96. num = i
  97. pass = 1
  98. }
  99. }
  100. for (var i = 0; i < this.menusPop.length; i++) {
  101. if (num == this.menusPop[i].id) {
  102. num = i
  103. pass = 2
  104. }
  105. }
  106. if (pass == 1) {
  107. if (this.menusShow.length > 1) {
  108. this.menuSelect(this.menusShow[num])
  109. }
  110. } else if (pass == 2) {
  111. this.menuSelect(this.menusPop[num])
  112. }
  113. },
  114. openUpdate: function() {
  115. this.dialogPWDVisible = true
  116. },
  117. closeUpdate: function() {
  118. this.dialogPWDVisible = false
  119. },
  120. logOut() {
  121. this.$router.push('/login')
  122. },
  123. mouseoverFun(num) {
  124. this.menuPopId = num
  125. },
  126. menuMouseOver(_menu) {
  127. if (_menu) {
  128. this.currMenuId = _menu.id
  129. }
  130. },
  131. menuSelect: function(_menu) {
  132. console.log(_menu)
  133. if (_menu) {
  134. this.currMenuId = _menu.id
  135. if (_menu.name === '首页') {
  136. this.$router.push({ path: _menu.children[0].path })
  137. } else {
  138. if (!_menu.children) {
  139. this.$router.push({ path: _menu.page })
  140. } else {
  141. var num = this.$route.query.subMenu ? this.$route.query.subMenu : 0
  142. for (var i = 0; i < _menu.children.length; i++) {
  143. if (_menu.children[i].id == num) {
  144. num = i
  145. }
  146. }
  147. this.$emit('menuSelect', _menu, num)
  148. }
  149. }
  150. }
  151. }
  152. }
  153. }
  154. </script>
  155. <style lang="scss">
  156. .door_menu {
  157. > div {
  158. display: inline-block;
  159. vertical-align: middle;
  160. }
  161. > img {
  162. vertical-align: middle;
  163. }
  164. // min-width: 1200px;
  165. .menu {
  166. margin-right: 10px;
  167. .item {
  168. display: inline-block;
  169. font-size: 16px;
  170. color: rgba(255, 255, 255, 0.8);
  171. line-height: 24px;
  172. padding: 0 10px 11px;
  173. cursor: pointer;
  174. }
  175. .item.active {
  176. color: #EC8F29;
  177. border-bottom: 2px solid #EC8F29;
  178. background: transparent !important;
  179. }
  180. }
  181. .search {
  182. width: 285px;
  183. height: 32px;
  184. border-radius: 4px 4px 4px 4px;
  185. opacity: 1;
  186. border: 1px solid #FFFFFF;
  187. line-height: 32px;
  188. // position: relative;
  189. // top: 20px;
  190. margin-right: 52px;
  191. img {
  192. margin-left: 15px;
  193. margin-right: 8px;
  194. vertical-align: middle;
  195. position: relative;
  196. top: -2px;
  197. }
  198. .el-input {
  199. width: 80%;
  200. font-size: 16px;
  201. .el-input__inner {
  202. height: 30px;
  203. line-height: 30px;
  204. border: 0;
  205. background-color: inherit;
  206. padding: 0;
  207. }
  208. }
  209. }
  210. .user_info {
  211. height: 40px;
  212. background: rgba(255, 255, 255, 0.23);
  213. border-radius: 20px 20px 20px 20px;
  214. opacity: 1;
  215. border: 1px solid #FFFFFF;
  216. padding: 8px 16px;
  217. line-height: 1;
  218. cursor: pointer;
  219. margin-left: 10px;
  220. width: fit-content;
  221. display: inline-block;
  222. > div {
  223. display: inline-block;
  224. vertical-align: middle;
  225. }
  226. > img {
  227. vertical-align: middle;
  228. }
  229. .head {
  230. width: 25px;
  231. height: 25px;
  232. margin-right: 8px;
  233. }
  234. .user_name {
  235. font-size: 13px;
  236. color: #FFFFFF;
  237. line-height: 20px;
  238. }
  239. .user_role {
  240. font-size: 12px;
  241. color: rgba(255, 255, 255, 0.8);
  242. line-height: 14px;
  243. }
  244. }
  245. .logout {
  246. cursor: pointer;
  247. }
  248. .container {
  249. width: 1440px;
  250. margin: 0 auto;
  251. position: relative;
  252. }
  253. }
  254. .menuPopper {
  255. min-width: 0 !important;
  256. background: white !important;
  257. margin-top: 12px !important;
  258. .popper__arrow {
  259. display: block !important;
  260. }
  261. .list {
  262. .item {
  263. color: #666666 !important;
  264. font-size: 14px !important;
  265. padding: 5px 0 !important;
  266. cursor: pointer !important;
  267. }
  268. .active .el-upload--text,
  269. .active {
  270. color: #1F6AFF !important;
  271. text-decoration: underline !important;
  272. }
  273. }
  274. }
  275. </style>