Commit 76e5e020 by liimin

优化

1 parent c0dc17a3
...@@ -8,9 +8,11 @@ ...@@ -8,9 +8,11 @@
<script> <script>
import { mapActions, mapGetters } from 'vuex' import { mapActions, mapGetters } from 'vuex'
// import { utils } from 'glsx-common' // import { utils } from 'glsx-common'
import { currentId } from './mixins/index'
export default { export default {
name: 'LeftSideMenuLv1Item', name: 'LeftSideMenuLv1Item',
inject: ['bus'], inject: ['bus'],
mixins: [currentId],
props: { props: {
menuData: { menuData: {
type: Object, type: Object,
...@@ -28,14 +30,16 @@ export default { ...@@ -28,14 +30,16 @@ export default {
}, },
methods: { methods: {
mouseenter: function () { mouseenter: function () {
if (this.menu.hoverId === this.menu.id) return
this.setHoverId(this.menuData.id) this.setHoverId(this.menuData.id)
this.menu.isCollapse && this.bus.$emit('mouseenter', this.$refs['bt' + this.menuData.id], () => this.bus.$emit('menuChanged', { menus: this.menuData.children.noHidden() })) this.menu.isCollapse && this.bus.$emit('mouseenter', this.$refs['bt' + this.menuData.id], this.emitter)
}, },
mouseleave: function () { mouseleave: function () {
this.setHoverId('') this.setHoverId('')
}, },
handleClick() { handleClick() {
!this.menu.isCollapse && this.emitter()
},
emitter() {
this.bus.$emit('menuChanged', { menus: this.menuData.children.noHidden() }) this.bus.$emit('menuChanged', { menus: this.menuData.children.noHidden() })
}, },
...mapActions('menu', ['setHoverId']) ...mapActions('menu', ['setHoverId'])
......
...@@ -46,7 +46,7 @@ export default { ...@@ -46,7 +46,7 @@ export default {
}, },
mounted() { mounted() {
this.bus.$on('menuChanged', this.handleMenuChanged) this.bus.$on('menuChanged', this.handleMenuChanged)
this.reload() !this.menu.isCollapse && this.reload()
}, },
beforeDestroy() { beforeDestroy() {
this.bus.$off('menuChanged', this.handleMenuChanged) this.bus.$off('menuChanged', this.handleMenuChanged)
...@@ -59,18 +59,18 @@ export default { ...@@ -59,18 +59,18 @@ export default {
return children.noHidden().length == 0 return children.noHidden().length == 0
}, },
handleMenuChanged({ menus = [], isReload = false }) { handleMenuChanged({ menus = [], isReload = false }) {
const pid1 = this.menus[0]?.id?.split('-')
const pid2 = menus[0]?.id?.split('-')
if (pid1 == pid2) return
if (isReload) { if (isReload) {
this.reload() this.reload()
return return
} }
// console.log('待修改:'+menus[0]?.title , '当前,'+this.menus[0]?.title);
this.menus = menus this.menus = menus
this.bus.$emit('menuOpenedsChanged', { menus }) this.bus.$emit('menuOpenedsChanged', { menus })
}, },
reload() { reload() {
const { lv1 } = this.current const { lv1 } = this.current
const [pid] = this.menus[0]?.id.split('-') || []
if (lv1 == pid) return
const menus = this.app.menuList.find(({ id }) => id == lv1).children.noHidden() const menus = this.app.menuList.find(({ id }) => id == lv1).children.noHidden()
this.handleMenuChanged({ menus }) this.handleMenuChanged({ menus })
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!