d7bd6af085fc3933a57d644915e6f7df8124ce6f.svn-base 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647
  1. <template>
  2. <div id="systemMenuBar" ref="systemMenuBar">
  3. <div
  4. class="systemMenuItem"
  5. v-for="(menuItem,index) in menuInfos"
  6. :key="index"
  7. v-if="menuItem.menuName !== '登录'">
  8. <p
  9. style="flex-basis: 90%;margin: 0px;line-height: 60px;"
  10. @mouseover="focusToMenuItem(menuItem,$event)"
  11. @mouseout="disAppearSubMenuLayerlazy()"
  12. @click="menuItemClick(menuItem)">
  13. <span :class="{systemMenuItemActive:focusMenuItem==menuItem,'light_back': themeName == 'light','dark_back': themeName == 'dark'}">{{menuItem.menuName}}</span>
  14. </p>
  15. </div>
  16. <div
  17. class="systemMenuItem moreMenu"
  18. key="newIndex"
  19. @mouseover="focusToMenuItem(moreMenuItem,$event)"
  20. @mouseout="popMoseOut()"
  21. v-if="menuMore.length>0">
  22. <p style="flex-basis: 90%;margin: 0px;line-height: 60px;">
  23. <el-popover
  24. placement="bottom"
  25. popper-class="menuPop"
  26. transition="el-zoom-in-top"
  27. trigger="hover">
  28. <div class="moreContent">
  29. <ul class="moreContentUl">
  30. <li v-for="(menuObj,index) in menuMore" @click="showSubMenu(menuObj,index)" :class="moreActive==index ? 'moreActive' : 'moreNormal'" >{{menuObj.menuName}}<i style="color:#434343;position: absolute;z-index: 500;top:10px;right:5px;" v-if="menuObj.menuList && menuObj.menuList.length>0" class="el-icon-caret-right"/></li>
  31. </ul>
  32. <div v-if="popVisible" class="subMain">
  33. <ul class="subMenuList">
  34. <li v-for="item in menuMoreObj.menuList">
  35. <span class="subMenuTitle"><em/>{{item.menuName}}</span>
  36. <div class="subMenuContent" v-for="item1 in item.menuList" :title="item1.menuName" @click="menuItemClick(item1)">{{item1.menuName}}</div>
  37. </li>
  38. </ul>
  39. </div>
  40. </div>
  41. <span slot="reference" :class="{systemMenuItemActive:focusMenuItem==moreMenuItem,'light_back': themeName == 'light','dark_back': themeName == 'dark'}"><i style="color:white !important;" class="el-icon-menu"/> {{moreMenuItem.menuLabel}}</span>
  42. </el-popover>
  43. </p>
  44. </div>
  45. <transition name="el-zoom-in-center">
  46. <div
  47. class="systemMenuItemDownLine"
  48. :style="{'margin-left':activeTriangleWidth+'px'}"
  49. v-show="showSubMenuLayer"
  50. @mouseover="keepMenuOpen()"
  51. ></div>
  52. </transition>
  53. <transition name="el-zoom-in-bottom">
  54. <div
  55. style="position: absolute;top:60px;width:100%;height:calc(100% - 60px);z-index:500;left:0px;"
  56. v-show="showSubMenuLayer"
  57. @mouseover="disAppearSubMenuLayer()"
  58. ></div>
  59. </transition>
  60. <transition name="el-zoom-in-top">
  61. <div
  62. class="systemSubMenuLayer"
  63. v-show="showSubMenuLayer"
  64. @mouseover="keepMenuOpen()"
  65. :style="{'left':activeTriangleWidth - 83 +'px'}"
  66. >
  67. <div
  68. class="systemSubMenuContainer"
  69. v-if="!focusMenuItem.href"
  70. v-for="(subMenu,index) in focusMenuItem.menuList"
  71. :key="subMenu.menuName+index"
  72. @mouseover="focusToMenuItem()"
  73. >
  74. <div class="systemSubMenuTitle" @click="menuItemClick(subMenu)">
  75. <p>
  76. <i v-if="subMenu.icon" class="icon iconfont" v-html="subMenu.icon"></i>
  77. <i class="icon iconfont watericon1-tongyongleiyelianjie" style="font-size: 16px !important;"></i>{{subMenu.menuName}}
  78. </p>
  79. </div>
  80. <div class="systemSubMenuContent">
  81. <div
  82. class="systemSubMenuLabel"
  83. v-if="!subMenu.href"
  84. v-for="(threeMenuItem,index) in subMenu.menuList"
  85. @click="menuItemClick(threeMenuItem)"
  86. :key="threeMenuItem.menuName+index"
  87. >
  88. <p :title="threeMenuItem.menuName">{{threeMenuItem.menuName}}</p>
  89. </div>
  90. </div>
  91. </div>
  92. </div>
  93. </transition>
  94. <div class="backToLeveLayer" v-show="showSubMenuLayer" @mouseover="disAppearSubMenuLayer()"></div>
  95. </div>
  96. </template>
  97. <script>
  98. /*
  99. to-do List:
  100. 1,样式适配问题 太小尺寸还是有问题
  101. */
  102. import theme from '../../store/theme'
  103. import request from '../../utils/gw_ajax_request.js';
  104. import {getCookie,setCookie} from '../../utils/gw_cookie.js'
  105. export default {
  106. name: "systemMenuBar",
  107. props:['changeSystem'],
  108. data() {
  109. return {
  110. showSubMenuLayer: false,
  111. keepMenuShow: false,
  112. focusMenuItem: {
  113. menuLabel: "首页",
  114. haveSubMenu: false,
  115. haveView: true,
  116. viewParamter: {}
  117. },
  118. moreMenuItem: {
  119. href:"more",
  120. menuLabel: "更多",
  121. haveSubMenu: false,
  122. haveView: true,
  123. viewParamter: {}
  124. },
  125. activeTriangleWidth: 0,
  126. menuInfo: {},
  127. menuInfos: [],
  128. menuMore:[],
  129. menuMoreObj:null,
  130. moreActive:null,
  131. themeName:'light',
  132. popVisible:false
  133. };
  134. },
  135. computed: {
  136. viewMenu: function() {
  137. console.log(this.$store.state.permission.routers);
  138. return this.$store.state.permission.routers;
  139. },
  140. isAdmin() {
  141. return localStorage.getItem("isAdmin") == 1 ? true : false;
  142. },
  143. userId(){
  144. return localStorage.getItem('userid') ? localStorage.getItem('userid') : ''
  145. },
  146. msg(){
  147. return theme.state.testMsg
  148. }
  149. },
  150. mounted() {
  151. this.getPrivData();
  152. },
  153. methods: {
  154. showSubMenu(menuItem,index){
  155. this.moreActive = index;
  156. this.menuMoreObj = menuItem;
  157. if(menuItem.menuList && menuItem.menuList.length>0){
  158. this.popVisible = true;
  159. }else{
  160. this.popVisible = false;
  161. if (menuItem.href) {
  162. this.$emit("addSystemMenuView", { viewItem: menuItem });
  163. }
  164. }
  165. },
  166. popMoseOut(){
  167. this.popVisible = false;
  168. this.moreActive = null;
  169. },
  170. popMoseOver(){
  171. this.popVisible = true;
  172. },
  173. focusToMenuItem: function(menuItem, event) {
  174. if (menuItem) {
  175. this.focusMenuItem = menuItem;
  176. if (!menuItem.href) {
  177. this.showSubMenuLayer = true;
  178. this.keepMenuShow = true;
  179. }
  180. }
  181. if (event) {
  182. var target = event.target;
  183. var elementLeft = target.offsetLeft - this.$refs.systemMenuBar.parentElement.scrollLeft + target.offsetWidth / 2 - 8;
  184. this.activeTriangleWidth = elementLeft;
  185. }
  186. },
  187. disAppearSubMenuLayer: function() {
  188. this.showSubMenuLayer = false;
  189. },
  190. keepMenuOpen: function() {
  191. this.keepMenuShow = true;
  192. },
  193. disAppearSubMenuLayerlazy: function() {
  194. let _self = this;
  195. this.keepMenuShow = false;
  196. setTimeout(() => {
  197. if (!_self.keepMenuShow) {
  198. _self.showSubMenuLayer = false;
  199. }
  200. }, 10);
  201. },
  202. menuItemClick: function(menuItem) {
  203. if (menuItem.href) {
  204. this.$emit("addSystemMenuView", { viewItem: menuItem });
  205. }
  206. },
  207. getPrivData() {
  208. let ownApp = localStorage.getItem('ownApp')
  209. let paramsObj = {
  210. userId: this.userId,
  211. ownApp: ownApp
  212. };
  213. request
  214. .post("sys/privs/getPrivByUserId", paramsObj)
  215. .then(res => {
  216. if (res.success) {
  217. this.menuInfos = []
  218. this.menuMore = []
  219. res.data.menu.forEach((item,index)=>{
  220. if(index<8){
  221. if(getCookie("sdUrl") && item.href && item.href=="/home"){
  222. item.menuName = "督查情况统计"
  223. }
  224. this.menuInfos.push(item);
  225. }
  226. if(index>=8){
  227. this.menuMore.push(item);
  228. }
  229. })
  230. // this.menuInfos = res.data.menu;
  231. this.$store.commit("privData", res.data.priv);
  232. console.log(this.$store.state.permission.privOfUser);
  233. sessionStorage.setItem(
  234. "privCollect",
  235. JSON.stringify(res.data.priv)
  236. );
  237. if(getCookie("sdUrl") && getCookie("sdUrl")=="/home"){
  238. this.$emit("addSystemMenuView", {
  239. viewItem: {
  240. menuName: "督查情况年度统计",
  241. name: "督查情况年度统计",
  242. id: 500,
  243. href: "/home",
  244. path: "/home",
  245. haveView: true
  246. }
  247. });
  248. return false;
  249. }
  250. if(getCookie("sdUrl") && getCookie("sdUrl")=="/planCheckYear"){
  251. this.$emit("addSystemMenuView", {
  252. viewItem: {
  253. menuName: "年度检查计划",
  254. name: "年度检查计划",
  255. id: 500,
  256. href: "/planCheckYear",
  257. path: "/planCheckYear",
  258. haveView: true
  259. }
  260. });
  261. return false;
  262. }
  263. let hasHomePage = false
  264. // this.menuInfos.forEach(ele=>{
  265. if(this.menuInfos[0].flagLeaf){
  266. this.$emit("addSystemMenuView", {
  267. viewItem: {
  268. menuName: this.menuInfos[0].menuName,
  269. name: this.menuInfos[0].menuName,
  270. id: 500,
  271. href: this.menuInfos[0].href,
  272. path: this.menuInfos[0].href,
  273. haveView: true
  274. }
  275. });
  276. }else{
  277. this.$emit("addSystemMenuView", {
  278. viewItem: {
  279. menuName: this.menuInfos[0].menuList[0].menuList[0].menuName,
  280. name: this.menuInfos[0].menuList[0].menuList[0].menuName,
  281. id: 500,
  282. href: this.menuInfos[0].menuList[0].menuList[0].href,
  283. path: this.menuInfos[0].menuList[0].menuList[0].href,
  284. haveView: true
  285. }
  286. });
  287. }
  288. // if( ele.flagLeaf && ele.menuName == '首页' ){
  289. // hasHomePage = true
  290. // this.$emit("addSystemMenuView", {
  291. // viewItem: {
  292. // menuName: "首页",
  293. // name: "首页",
  294. // id: 500,
  295. // href: "/home",
  296. // path: "/home",
  297. // haveView: true
  298. // }
  299. // });
  300. // }else if( ele.flagLeaf && ele.menuName == '稽察首页' ){
  301. // hasHomePage = true
  302. // this.$emit("addSystemMenuView", {
  303. // viewItem: {
  304. // menuName: "稽察首页",
  305. // name: "稽察首页",
  306. // id: 500,
  307. // href: "/jchome",
  308. // path: "/jchome",
  309. // haveView: true
  310. // }
  311. // });
  312. // }
  313. // if( hasHomePage ) return
  314. // if( ele.flagLeaf && ele.menuName == '综合展示' ){
  315. // this.$emit("addSystemMenuView", {
  316. // viewItem: {
  317. // menuName: "综合展示",
  318. // name: "综合展示",
  319. // id: 100,
  320. // href: "/zhxx",
  321. // path: "/zhxx",
  322. // haveView: true
  323. // }
  324. // });
  325. // }
  326. // })
  327. this.$emit('initFinish');
  328. }
  329. })
  330. // .catch(error => {
  331. // this.$message.error(error);
  332. // });
  333. },
  334. //格式化树形数据
  335. getTrees(list, pId) {
  336. let items = {};
  337. // 获取每个节点的直属子节点,*记住是直属,不是所有子节点
  338. for (let i = 0; i < list.length; i++) {
  339. let key = list[i].parentId;
  340. if (items[key]) {
  341. items[key].push(list[i]);
  342. } else {
  343. items[key] = [];
  344. items[key].push(list[i]);
  345. }
  346. }
  347. return this.formatTree(items, pId);
  348. },
  349. /**利用递归格式化每个节点**/
  350. formatTree(items, pId) {
  351. let result = [];
  352. if (!items[pId]) {
  353. return result;
  354. }
  355. for (let t of items[pId]) {
  356. t.children = this.formatTree(items, t.id);
  357. result.push(t);
  358. }
  359. return result;
  360. }
  361. },
  362. watch:{
  363. msg(n,o){
  364. if(n == 'dark'){
  365. this.themeName = 'dark';
  366. }else{
  367. this.themeName = 'light';
  368. }
  369. },
  370. changeSystem(){
  371. this.getPrivData()
  372. }
  373. }
  374. };
  375. </script>
  376. <style>
  377. @import url("/src/assets/iconsfont/iconfont.css");
  378. #systemMenuBar {
  379. height: 100%;
  380. width: 100%;
  381. display: flex;
  382. flex-direction: row;
  383. justify-content: center;
  384. align-items: center;
  385. z-index: 499;
  386. margin-left: 0px;
  387. }
  388. .moreMenuText{
  389. cursor: pointer;
  390. font-family: MicrosoftYaHei;
  391. font-weight: bold;
  392. font-size: 18px;
  393. color: rgba(255,255,255,1);
  394. padding: 8px;
  395. border-radius: 4px;
  396. }
  397. .moreContent{
  398. display: flex;
  399. overflow: auto;
  400. }
  401. .moreContent div.subMain{
  402. max-width: 300px;
  403. }
  404. .moreContentUl{
  405. width: 130px;
  406. list-style: none;
  407. }
  408. .moreContentUl li{
  409. position: relative;
  410. width: calc(100% - 7px);
  411. line-height: 35px;
  412. text-align: center;
  413. font-size: 17px;
  414. font-family:MicrosoftYaHei;
  415. letter-spacing: 3px;
  416. font-weight: bold;
  417. border-bottom: 1px solid #ece8e8;
  418. background: white;
  419. cursor: pointer;
  420. border-right: 3px solid #f7f7f7;
  421. border-top-left-radius: 30px;
  422. border-bottom-left-radius: 30px;
  423. margin-top: 10px;
  424. box-shadow: 0 2px 12px 0 rgb(0 0 0 / 10%);
  425. border: 1px solid transparent;
  426. transition: all .25s ease-in;
  427. }
  428. .moreContentUl li:hover{
  429. color: #2fa6ff;
  430. border-right: 5px solid #2fa6ff !important;
  431. border-top: 1px solid #2fa6ff !important;
  432. border-left: 1px solid #2fa6ff !important;
  433. border-bottom: 1px solid #2fa6ff !important;
  434. transform: translateY(-3px);
  435. }
  436. .moreContentUl li:hover i{
  437. color: #2fa6ff !important;
  438. }
  439. .subMenuList{
  440. list-style: none;
  441. padding: 0;
  442. display: flex;
  443. margin-bottom: 5px;
  444. }
  445. .subMenuList li{
  446. width: 130px;
  447. float:left;
  448. margin-left: 10px;
  449. box-shadow: 0 5px 12px 0 rgb(0 0 0 / 10%);
  450. text-indent: 10px;
  451. }
  452. .subMenuList li span{
  453. width: 100%;
  454. display: block;
  455. font-size: 15px;
  456. line-height: 25px;
  457. white-space:nowrap;
  458. overflow: hidden;
  459. text-overflow: ellipsis;
  460. border-bottom: 1px solid #1b75ff;
  461. }
  462. .subMenuList li span em{
  463. height:15px;
  464. background: #1b75ff;
  465. padding-right: 5px;
  466. margin-right: 5px;
  467. }
  468. .subMenuList li div{
  469. width: 100%;
  470. font-size: 13px;
  471. white-space:nowrap;
  472. overflow: hidden;
  473. text-overflow: ellipsis;
  474. line-height: 25px;
  475. cursor: pointer;
  476. transition: all .25s ease-in;
  477. }
  478. .subMenuList li div:hover{
  479. color: #1b75ff;
  480. transform: translateY(-2px);
  481. text-decoration: underline;
  482. }
  483. .moreActive{
  484. background: white !important;
  485. border-right: 5px solid #2fa6ff !important;
  486. border-top: 1px solid #2fa6ff !important;
  487. border-left: 1px solid #2fa6ff !important;
  488. border-bottom: 1px solid #2fa6ff !important;
  489. }
  490. .moreNormal{
  491. background: #f7f7f7;
  492. }
  493. .moreMenuText:hover{
  494. cursor: pointer;
  495. font-family: MicrosoftYaHei;
  496. font-weight: bold;
  497. color: rgba(255,255,255,1);
  498. background: #007ef6;
  499. }
  500. .systemMenuItem {
  501. min-width: 90px;
  502. height: 100%;
  503. flex-basis: 10%;
  504. display: flex;
  505. flex-direction: column;
  506. justify-content: center;
  507. align-items: center;
  508. z-index: 499;
  509. cursor: pointer;
  510. font-family:MicrosoftYaHei;
  511. font-weight:bold;
  512. font-size: 17px;
  513. color:rgba(255,255,255,1);
  514. }
  515. .systemMenuItemActive {
  516. color: rgb(255, 255, 255);
  517. padding: 8px;
  518. border-radius:4px;
  519. }
  520. .systemMenuItemActive.light_back{
  521. background:#007ef6;
  522. }
  523. .systemMenuItemActive.dark_back{
  524. background: #36A2FC;
  525. }
  526. .systemMenuItemDownLine {
  527. position: absolute;
  528. width: 0;
  529. height: 0;
  530. border: 10px solid transparent;
  531. border-bottom-color: #fff;
  532. z-index: 3000;
  533. top: 45px;
  534. left: 0;
  535. margin-top: -18px;
  536. }
  537. .systemSubMenuLayer {
  538. background-color: #fff;
  539. color: aliceblue;
  540. position: fixed;
  541. left: 240px;
  542. /* width: 100%; */
  543. min-height: 1px;
  544. top: 43px;
  545. z-index: 2001;
  546. display: flex;
  547. /* flex-direction: column; */
  548. justify-content: flex-start;
  549. box-shadow: 0px 5px 10px rgba(0, 0, 0, 0.3);
  550. padding: 5px;
  551. border-radius: 2px;
  552. max-height: 85%;
  553. max-width: 60%;
  554. overflow: auto;
  555. }
  556. .backToLeveLayer {
  557. margin-left: -5px;
  558. /* background-color: #d30505ad; */
  559. color: aliceblue;
  560. position: fixed;
  561. width: 100%;
  562. height: 100%;
  563. /* top: 100px; */
  564. z-index: 498;
  565. }
  566. .systemSubMenuContainer {
  567. min-width: 200px;
  568. padding: 5px;
  569. /* margin-left: 2%; */
  570. display: flex;
  571. flex-direction: column;
  572. justify-content: flex-start;
  573. width:200px;
  574. }
  575. .systemSubMenuContainer:first-of-type {
  576. /* margin-left: 7%; */
  577. }
  578. .systemSubMenuTitle {
  579. /* flex-basis: 11%; */
  580. }
  581. .systemSubMenuTitle p {
  582. display: inline-block;
  583. padding-bottom: 8px;
  584. border-bottom: solid 1px #5aaaff;
  585. margin-left: 6px;
  586. padding-right: 5px;
  587. padding-left: 2px;
  588. color: rgb(0, 110, 255);
  589. font-size: normal;
  590. font-weight: bold;
  591. text-align: left;
  592. cursor: pointer;
  593. }
  594. .systemSubMenuLabel {
  595. margin: 5px;
  596. }
  597. .systemSubMenuContent {
  598. display: flex;
  599. flex-direction: column;
  600. /* margin:5px; */
  601. }
  602. .systemSubMenuContent p {
  603. font-size: normal;
  604. font-weight: thin;
  605. /* color: rgb(104, 104, 104); */
  606. color: #333;
  607. font-weight: lighter;
  608. text-align: left;
  609. font-size: 13px;
  610. font-weight: 500;
  611. white-space: nowrap;
  612. overflow: hidden;
  613. text-overflow: ellipsis;
  614. }
  615. .systemSubMenuContent p:hover {
  616. color: rgb(0, 4, 255);
  617. cursor: pointer;
  618. text-decoration: underline;
  619. }
  620. .systemSubMenuLayer .iconfont {
  621. color: rgb(0, 110, 255) !important;
  622. font-size: 18px !important;
  623. margin-right: 5px;
  624. font-weight: 600;
  625. }
  626. @media screen and (max-width: 1679px) {
  627. .systemMenuItem {
  628. min-width: 90px;
  629. }
  630. }
  631. @media screen and (max-width: 1366px) {
  632. .systemMenuItem {
  633. min-width: 85px;
  634. }
  635. }
  636. </style>
  637. <style>
  638. .menuPop{
  639. width: auto !important;
  640. min-width: 120px !important;
  641. }
  642. </style>