edit
This commit is contained in:
@ -97,29 +97,32 @@ export class MenuManagerComponentsIndexComponent implements OnInit {
|
||||
nzTitle: '<i>删除确认</i>',
|
||||
nzContent: `是否确认删除?`,
|
||||
nzOnOk: () => {
|
||||
this.deleteMenuByAppID(type === 0 ? 'A48F72F0A304427F921794BAD86B3522' : this.envSrv.env.appId);
|
||||
this.getMenuByAppID(type === 0 ? 'A48F72F0A304427F921794BAD86B3522' : this.envSrv.env.appId);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
deleteMenuByAppID(appId: string) {
|
||||
getMenuByAppID(appId: string) {
|
||||
this.service.request(this.service.$api_get_one, { appId }, 'POST', false).subscribe(res => {
|
||||
console.log(res);
|
||||
if (res) {
|
||||
const menus = res.data;
|
||||
console.log(this.getIds(res.data));
|
||||
|
||||
if (res.data?.length > 0) {
|
||||
this.deleteMenuByAppID(res.data);
|
||||
} else {
|
||||
this.service.msgSrv.success('菜单已清空');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
getIds(arr: Array<any>): Array<string> {
|
||||
let ids: any[] = [];
|
||||
deleteMenuByAppID(arr: Array<any>) {
|
||||
let ids: any[] = arr?.map(item => item.id) || [];
|
||||
arr.forEach(item => {
|
||||
if (item.children?.length > 0) {
|
||||
ids = [...ids, this.getIds(item.children)];
|
||||
this.deleteMenuByAppID(item.children);
|
||||
}
|
||||
});
|
||||
return ids;
|
||||
this.service.request(this.service.$api_del_many, ids).subscribe(res => {});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user