Merge pull request #3764 from lison16/su
fixed https://github.com/iview/iview/issues/3733
This commit is contained in:
commit
b37deefb44
2 changed files with 77 additions and 11 deletions
|
@ -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');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue