This commit is contained in:
zhigang.li 2018-05-30 18:40:43 +08:00
parent cbff5e3641
commit e549c92b1d
2 changed files with 77 additions and 11 deletions

View file

@ -80,23 +80,37 @@
let names = [...this.openedNames];
const index = names.indexOf(name);
if (index >= 0) {
names.splice(index, 1);
let currentSubmenu = null;
findComponentsDownward(this, 'Submenu').forEach(item => {
if (item.name === name) {
currentSubmenu = item;
item.opened = false;
}
});
findComponentsDownward(currentSubmenu, 'Submenu').forEach(item => {
item.opened = false;
});
} else {
if (this.accordion) {
if (this.mode === 'horizontal' && this.accordion) {
let currentSubmenu = null;
names = [];
findComponentsDownward(this, 'Submenu').forEach(item => {
if (item.name === name) currentSubmenu = item;
if (item.name === name) {
currentSubmenu = item;
item.opened = true;
}
});
findComponentsUpward(currentSubmenu, 'Submenu').forEach(item => {
names.push(item.name);
item.opened = true;
});
} else {
findComponentsDownward(this, 'Submenu').forEach(item => {
if (item.name === name) item.opened = true;
});
}
names.push(name);
}
this.openedNames = names;
this.updateOpened();
this.$emit('on-open-change', this.openedNames);
let openedNames = findComponentsDownward(this, 'Submenu').filter(item => item.opened).map(item => item.name);
this.openedNames = [...openedNames];
this.$emit('on-open-change', openedNames);
},
updateOpened () {
const items = findComponentsDownward(this, 'Submenu');