+
@@ -30,7 +30,6 @@
import GlobalLayout from '@/components/page/GlobalLayout'
import Contextmenu from '@/components/menu/Contextmenu'
import { mixin, mixinDevice } from '@/utils/mixin.js'
- import { topNavScrollToSelectItem } from '@/utils/util'
const indexKey = '/dashboard/analysis'
@@ -86,23 +85,20 @@
this.activePage = newRoute.fullPath
if (!this.multipage) {
this.linkList = [newRoute.fullPath]
- this.pageList = [newRoute]
+ this.pageList = [Object.assign({},newRoute)]
} else if (this.linkList.indexOf(newRoute.fullPath) < 0) {
this.linkList.push(newRoute.fullPath)
- this.pageList.push(newRoute)
+ this.pageList.push(Object.assign({},newRoute))
} else if (this.linkList.indexOf(newRoute.fullPath) >= 0) {
let oldIndex = this.linkList.indexOf(newRoute.fullPath)
- this.pageList.splice(oldIndex, 1, newRoute)
+ let oldPositionRoute = this.pageList[oldIndex]
+ this.pageList.splice(oldIndex, 1, Object.assign({},newRoute,{meta:oldPositionRoute.meta}))
}
},
'activePage': function(key) {
let index = this.linkList.lastIndexOf(key)
- var waitRouter = this.pageList[index]
- this.$router.push({
- path: waitRouter.path,
- name: waitRouter.name,
- params: waitRouter.params
- })
+ let waitRouter = this.pageList[index]
+ this.$router.push(Object.assign({},waitRouter));
},
'multipage': function(newVal) {
if (!newVal) {
@@ -114,12 +110,6 @@
methods: {
changePage(key) {
this.activePage = key
- // 只有当前模式是顶部菜单时才执行定位
- if (this.layoutMode === 'topmenu') {
- setTimeout(() => {
- topNavScrollToSelectItem(document)
- }, 100)
- }
},
editPage(key, action) {
this[action](key)
@@ -208,7 +198,17 @@
if (this.linkList.indexOf(this.activePage < 0)) {
this.activePage = this.linkList[this.linkList.length - 1]
}
+ },
+ //update-begin-author:taoyan date:20190430 for:动态路由title显示配置的菜单title而不是其对应路由的title
+ dynamicRouterShow(key,title){
+ let keyIndex = this.linkList.indexOf(key)
+ if(keyIndex>=0){
+ let currRouter = this.pageList[keyIndex]
+ let meta = Object.assign({},currRouter.meta,{title:title})
+ this.pageList.splice(keyIndex, 1, Object.assign({},currRouter,{meta:meta}))
+ }
}
+ //update-end-author:taoyan date:20190430 for:动态路由title显示配置的菜单title而不是其对应路由的title
}
}
diff --git a/ant-design-jeecg-vue/src/components/menu/SideMenu.vue b/ant-design-jeecg-vue/src/components/menu/SideMenu.vue
index 3fbcaf87..968f0448 100644
--- a/ant-design-jeecg-vue/src/components/menu/SideMenu.vue
+++ b/ant-design-jeecg-vue/src/components/menu/SideMenu.vue
@@ -3,7 +3,7 @@
:class="['sider', isDesktop() ? null : 'shadow', theme, fixSiderbar ? 'ant-fixed-sidemenu' : null ]"
width="200px"
:collapsible="collapsible"
- v-model="collapsed"
+ v-model="collapsed"
:trigger="null">
+ :style="smenuStyle">
+
@@ -53,10 +54,92 @@
required: true
}
},
+ computed:{
+ smenuStyle() {
+ let style = { 'padding': '0' }
+ if (this.fixSiderbar) {
+ style['height'] = 'calc(100% - 59px)'
+ style['overflow'] = 'auto'
+ style['overflow-x'] = 'hidden'
+ }
+ return style
+ }
+ },
methods: {
onSelect (obj) {
this.$emit('menuSelect', obj)
}
}
}
-
\ No newline at end of file
+
+
\ No newline at end of file
diff --git a/ant-design-jeecg-vue/src/components/menu/index.js b/ant-design-jeecg-vue/src/components/menu/index.js
index 59b0cf60..ecf7095c 100644
--- a/ant-design-jeecg-vue/src/components/menu/index.js
+++ b/ant-design-jeecg-vue/src/components/menu/index.js
@@ -34,149 +34,155 @@ export default {
}
},
computed: {
- rootSubmenuKeys: (vm) => {
- let keys = []
+ rootSubmenuKeys: vm => {
+ const keys = []
vm.menu.forEach(item => keys.push(item.path))
return keys
}
},
- created () {
+ mounted () {
this.updateMenu()
},
watch: {
collapsed (val) {
if (val) {
- this.cachedOpenKeys = this.openKeys
+ this.cachedOpenKeys = this.openKeys.concat()
this.openKeys = []
} else {
this.openKeys = this.cachedOpenKeys
}
},
- '$route': function () {
+ $route: function () {
this.updateMenu()
}
},
methods: {
- renderIcon: function (h, icon) {
- return icon === 'none' || icon === undefined ? null
- : h(Icon, { props: { type: icon !== undefined ? icon : '' } })
- },
- renderMenuItem: function (h, menu, pIndex, index) {
- // 判断是否带参数路由URL,是的话,采用path跳转方式
- if(menu.route && menu.route === '0'){
- return h(Item, { key: menu.path ? menu.path : 'item_' + pIndex + '_' + index },
- [
- h(
- 'router-link',
- //--update-begin----author:scott---date:20190320------for:改造菜单路由跳转规则,原来是跳转到组件,现在改造成跳转URL(为了支持参数URL菜单)------
- { attrs: { to: { path: menu.path } } },
- //--update-end----author:scott---date:20190320------for:改造菜单路由跳转规则,原来是跳转到组件,现在改造成跳转URL(为了支持参数URL菜单)------
- [
- this.renderIcon(h, menu.meta.icon),
- h('span', [ menu.meta.title ])
- ]
- )
- ]
- )
- }else{
- // 默认采用组件跳转方式
- return h(Item, { key: menu.path ? menu.path : 'item_' + pIndex + '_' + index },
- [
- h(
- 'router-link',
- { attrs: { to: { name: menu.name } } },
- [
- this.renderIcon(h, menu.meta.icon),
- h('span', [ menu.meta.title ])
- ]
- )
- ]
- )
- }
-
- },
- renderSubMenu: function (h, menu, pIndex, index) {
- const this2_ = this;
- let subItem = [ h('span',
- { slot: 'title' },
- [
- this.renderIcon(h, menu.meta.icon),
- h('span', [ menu.meta.title ])
- ]
- ) ]
- let itemArr = []
- let pIndex_ = pIndex + '_' + index
- if (!menu.alwaysShow) {
- menu.children.forEach(function (item, i) {
- itemArr.push(this2_.renderItem(h, item, pIndex_, i))
- })
- }
- return h(
- SubMenu,
- { key: menu.path ? menu.path : 'submenu_' + pIndex + '_' + index },
- subItem.concat(itemArr)
- )
- },
- renderItem: function (h, menu, pIndex, index) {
- if (!menu.hidden) {
- return menu.children && !menu.alwaysShow ? this.renderSubMenu(h, menu, pIndex, index) : this.renderMenuItem(h, menu, pIndex, index)
- }
- },
- renderMenu: function (h, menuTree) {
- const this2_ = this
- let menuArr = []
- menuTree.forEach(function (menu, i) {
- if (!menu.hidden) {
- menuArr.push(this2_.renderItem(h, menu, '0', i))
- }
- })
- return menuArr
- },
+ // select menu item
onOpenChange (openKeys) {
- const latestOpenKey = openKeys.find(key => this.openKeys.indexOf(key) === -1)
- if (this.rootSubmenuKeys.indexOf(latestOpenKey) === -1) {
+
+ // 在水平模式下时执行,并且不再执行后续
+ if (this.mode === 'horizontal') {
+ this.openKeys = openKeys
+ return
+ }
+ // 非水平模式时
+ const latestOpenKey = openKeys.find(key => !this.openKeys.includes(key))
+ if (!this.rootSubmenuKeys.includes(latestOpenKey)) {
this.openKeys = openKeys
} else {
- this.openKeys = latestOpenKey ? [ latestOpenKey ] : []
+ this.openKeys = latestOpenKey ? [latestOpenKey] : []
}
},
updateMenu () {
- let routes = this.$route.matched.concat()
- if (routes.length >= 4 && this.$route.meta.hidden) {
+ const routes = this.$route.matched.concat()
+ const { hidden } = this.$route.meta
+ if (routes.length >= 3 && hidden) {
routes.pop()
- this.selectedKeys = [ routes[2].path ]
+ this.selectedKeys = [routes[routes.length - 1].path]
} else {
- this.selectedKeys = [ routes.pop().path ]
+ this.selectedKeys = [routes.pop().path]
}
-
- let openKeys = []
+ const openKeys = []
if (this.mode === 'inline') {
- routes.forEach((item) => {
+ routes.forEach(item => {
openKeys.push(item.path)
})
}
+ //update-begin-author:taoyan date:20190510 for:online表单菜单点击展开的一级目录不对
+ if(!this.selectedKeys || this.selectedKeys[0].indexOf(":")<0){
+ this.collapsed ? (this.cachedOpenKeys = openKeys) : (this.openKeys = openKeys)
+ }
+ //update-end-author:taoyan date:20190510 for:online表单菜单点击展开的一级目录不对
+ },
- this.collapsed ? this.cachedOpenKeys = openKeys : this.openKeys = openKeys
+ // render
+ renderItem (menu) {
+ if (!menu.hidden) {
+ return menu.children && !menu.hideChildrenInMenu ? this.renderSubMenu(menu) : this.renderMenuItem(menu)
+ }
+ return null
+ },
+ renderMenuItem (menu) {
+ const target = menu.meta.target || null
+ const tag = target && 'a' || 'router-link'
+ let props = { to: { name: menu.name } }
+ if(menu.route && menu.route === '0'){
+ props = { to: { path: menu.path } }
+ }
+
+ const attrs = { href: menu.path, target: menu.meta.target }
+
+ if (menu.children && menu.hideChildrenInMenu) {
+ // 把有子菜单的 并且 父菜单是要隐藏子菜单的
+ // 都给子菜单增加一个 hidden 属性
+ // 用来给刷新页面时, selectedKeys 做控制用
+ menu.children.forEach(item => {
+ item.meta = Object.assign(item.meta, { hidden: true })
+ })
+ }
+
+ return (
+ -
+
+ {this.renderIcon(menu.meta.icon)}
+ {menu.meta.title}
+
+
+ )
+ },
+ renderSubMenu (menu) {
+ const itemArr = []
+ if (!menu.hideChildrenInMenu) {
+ menu.children.forEach(item => itemArr.push(this.renderItem(item)))
+ }
+ return (
+
+
+ {this.renderIcon(menu.meta.icon)}
+ {menu.meta.title}
+
+ {itemArr}
+
+ )
+ },
+ renderIcon (icon) {
+ if (icon === 'none' || icon === undefined) {
+ return null
+ }
+ const props = {}
+ typeof (icon) === 'object' ? props.component = icon : props.type = icon
+ return (
+
+ )
}
},
- render (h) {
- return h(
- Menu,
- {
- props: {
- theme: this.$props.theme,
- mode: this.$props.mode,
- openKeys: this.openKeys,
- selectedKeys: this.selectedKeys
- },
- on: {
- openChange: this.onOpenChange,
- select: (obj) => {
- this.selectedKeys = obj.selectedKeys
- this.$emit('select', obj)
- }
- }
- }, this.renderMenu(h, this.menu)
+
+ render () {
+ const { mode, theme, menu } = this
+ const props = {
+ mode: mode,
+ theme: theme,
+ openKeys: this.openKeys
+ }
+ const on = {
+ select: obj => {
+ this.selectedKeys = obj.selectedKeys
+ this.$emit('select', obj)
+ },
+ openChange: this.onOpenChange
+ }
+
+ const menuTree = menu.map(item => {
+ if (item.hidden) {
+ return null
+ }
+ return this.renderItem(item)
+ })
+ // {...{ props, on: on }}
+ return (
+
)
}
-}
\ No newline at end of file
+}
diff --git a/ant-design-jeecg-vue/src/components/page/GlobalHeader.vue b/ant-design-jeecg-vue/src/components/page/GlobalHeader.vue
index 926db82e..18c50d84 100644
--- a/ant-design-jeecg-vue/src/components/page/GlobalHeader.vue
+++ b/ant-design-jeecg-vue/src/components/page/GlobalHeader.vue
@@ -27,13 +27,11 @@