From e14f624b860452419e5f90e58baa80cc82020512 Mon Sep 17 00:00:00 2001 From: java110 <928255095@qq.com> Date: Sat, 26 Feb 2022 16:59:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E5=AE=8C=E6=88=90=20?= =?UTF-8?q?=E9=A6=96=E9=A1=B5=20=E5=B8=83=E5=B1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dev/addMenuCatalog/addMenuCatalog.js | 2 +- .../components/frame/breadcrumb/breadcrumb.js | 43 ++++-------- public/components/frame/menu/menu.html | 6 +- public/components/frame/menu/menu.js | 43 +++++------- public/components/frame/nav/nav.html | 38 ++-------- public/components/frame/nav/nav.js | 69 +++++++++++++++---- .../menuCatalogManage/menuCatalogManage.html | 2 +- public/vcCore/vcFramework.js | 10 +-- 8 files changed, 103 insertions(+), 110 deletions(-) diff --git a/public/components/dev/addMenuCatalog/addMenuCatalog.js b/public/components/dev/addMenuCatalog/addMenuCatalog.js index 0cada4423..a40fae6cb 100644 --- a/public/components/dev/addMenuCatalog/addMenuCatalog.js +++ b/public/components/dev/addMenuCatalog/addMenuCatalog.js @@ -12,7 +12,7 @@ icon: '', seq: '', storeType: '', - url: '', + url: '#', isShow: '', } diff --git a/public/components/frame/breadcrumb/breadcrumb.js b/public/components/frame/breadcrumb/breadcrumb.js index 691a2cb5f..f141a3994 100755 --- a/public/components/frame/breadcrumb/breadcrumb.js +++ b/public/components/frame/breadcrumb/breadcrumb.js @@ -20,42 +20,24 @@ _freshBreadCrumbByUrl: function() { let tabs = vc.getTabFromLocal(); - - let _tmpMenus = vc.getMenus(); - - if (_tmpMenus == null || _tmpMenus == undefined) { - return; - } let _curPath = location.hash; if (_curPath.indexOf('?') != -1) { _curPath = _curPath.substring(0, _curPath.indexOf('?')); } - tabs.forEach(item => { - let _path = item; + let _path = item.url; if (_path.indexOf('?') != -1) { _path = _path.substring(0, _path.indexOf('?')); } - let _url = vc.getUrl() + _path; - - _tmpMenus.forEach(_menu => { - _menu.childs.forEach(child => { - //console.log(_url, child.href) - if (_url != child.href) { - return; - } - _tmpBreadCrumbInf = { - href: item, - pageName: child.name, - active: '0' - }; - if (_path == _curPath) { - _tmpBreadCrumbInf.active = '1' - } - this.breadCrumbs.push(_tmpBreadCrumbInf); - }) - }) - + _tmpBreadCrumbInf = { + href: item.url, + pageName: item.name, + active: '0' + }; + if (_path == _curPath) { + _tmpBreadCrumbInf.active = '1' + } + this.breadCrumbs.push(_tmpBreadCrumbInf); }); }, @@ -70,7 +52,8 @@ }, _deleteSmallTab: function(_item) { let _tabs = vc.getTabFromLocal(); - vc.deleteTabToLocal(_item.href); + _item.url = _item.href; + vc.deleteTabToLocal(_item); vm.breadCrumbs = []; if (_item.active == '0') { vm._freshBreadCrumbByUrl(); @@ -80,7 +63,7 @@ vc.jumpToPage("/"); return; } - vc.jumpToPage(vc.getUrl() + _tabs[_tabs.length - 2]); + vc.jumpToPage(vc.getUrl() + _tabs[_tabs.length - 2].url); } }, diff --git a/public/components/frame/menu/menu.html b/public/components/frame/menu/menu.html index 4385ca39d..5f1d2e8c2 100755 --- a/public/components/frame/menu/menu.html +++ b/public/components/frame/menu/menu.html @@ -12,7 +12,7 @@ -
  • +
  • {{vc.i18n(menu.name)}} @@ -21,10 +21,10 @@ - + {{vc.i18n(menu.name)}} diff --git a/public/components/frame/menu/menu.js b/public/components/frame/menu/menu.js index 2bebc9e38..83bbfac53 100755 --- a/public/components/frame/menu/menu.js +++ b/public/components/frame/menu/menu.js @@ -10,7 +10,11 @@ }, mounted: function() { this._initSysInfo(); - this.getMenus(); + + //监听 菜单目录改变 + document.body.addEventListener('loadMenu', function(_param) { + vm.getMenus(_param.detail); + }, false); let _menuDiv = document.getElementById('menu-nav'); vcFramework.eleResize.on(_menuDiv, function() { //console.log('resize', '大小修改了'); @@ -35,31 +39,21 @@ _gotoIndex: function() { vc.jumpToPage("/") }, - getMenus: function() { - - let _tmpMenus = vc.getMenus(); - //浏览器缓存中能获取到 - if (_tmpMenus != null && _tmpMenus != undefined) { - this.miniMenu(); - this.menus = _tmpMenus; - // 子菜单默认选中 - var _currentHref = window.location.pathname + window.location.hash; - this._setSelectedMenusChild(_currentHref); - return; - } - - let param = { + getMenus: function(_catalog) { + let _param = { params: { - msg: this.message + caId: _catalog.caId } - } //发送get请求 - vc.http.get('menu', - 'getMenus', - param, + vc.http.apiGet('/menu.listCatalogMenus', + _param, function(json, res) { - let _menus = JSON.parse(json); + let _menuData = JSON.parse(json); + if (_menuData.code != 0) { + return; + } + let _menus = _menuData.data; if (_menus == null || _menus.length == 0) { return; } @@ -77,7 +71,6 @@ ); }, refreshMenuActive: function(jsonArray, _id) { - console.log(jsonArray); for (var menuIndex = 0; menuIndex < jsonArray.length; menuIndex++) { if (jsonArray[menuIndex].hasOwnProperty('childs')) { @@ -124,13 +117,13 @@ $("body").toggleClass("mini-navbar"); vc.setMenuState('OFF'); }, - _gotoPage: function(_href) { + _gotoPage: function(_href, _tabName) { // 子菜单默认选中 this._setSelectedMenusChild(_href); if (_href.indexOf('?') > -1) { - _href += "&tab=on" + _href += ("&tab=" + _tabName) } else { - _href += "?tab=on" + _href += ("?tab=" + _tabName) } vc.jumpToPage(_href); }, diff --git a/public/components/frame/nav/nav.html b/public/components/frame/nav/nav.html index 5d40029cd..891022204 100755 --- a/public/components/frame/nav/nav.html +++ b/public/components/frame/nav/nav.html @@ -3,39 +3,9 @@
  • - {{userName}} + {{userName}}