onOpenChange(openKeys) {
const latestOpenKey = openKeys.find(
(key) => this.openKeys.indexOf(key) === -1
);
function getParent(data, id) {
var temp = [];
let originData = data;
function forFn(arr, id) {
arr.forEach((item) => {
if (item.menuId == id && item.parentId != 0) {
temp.push(item.menuId);
forFn(originData, item.parentId);
} else if (item.menuId == id && item.parentId == 0) {
temp.push(item.menuId);
return;
} else {
if (item.children) {
forFn(item.children, id);
}
}
});
}
forFn(data, id);
return temp;
}
if (latestOpenKey) {
this.openKeys = getParent(this.allId, latestOpenKey);
} else {
this.openKeys = openKeys;
}
},