menu.vue 7.2 KB

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