This commit is contained in:
Taric Xin
2022-01-12 13:28:29 +08:00
parent e6724d3557
commit e4ab54e330
4 changed files with 14 additions and 11 deletions

View File

@ -97,29 +97,32 @@ export class MenuManagerComponentsIndexComponent implements OnInit {
nzTitle: '<i>删除确认</i>', nzTitle: '<i>删除确认</i>',
nzContent: `是否确认删除?`, nzContent: `是否确认删除?`,
nzOnOk: () => { 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 => { this.service.request(this.service.$api_get_one, { appId }, 'POST', false).subscribe(res => {
console.log(res); console.log(res);
if (res) { if (res) {
const menus = res.data; 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> { deleteMenuByAppID(arr: Array<any>) {
let ids: any[] = []; let ids: any[] = arr?.map(item => item.id) || [];
arr.forEach(item => { arr.forEach(item => {
if (item.children?.length > 0) { 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 => {});
} }
} }

View File

@ -15,7 +15,7 @@ export class MenuManagerService extends BaseService {
$api_get_one = `/api/mdc/cuc/functionInfo/getAllFunctionInfoByAppId?_allow_badcode=true`; $api_get_one = `/api/mdc/cuc/functionInfo/getAllFunctionInfoByAppId?_allow_badcode=true`;
// 删除多个菜单 // 删除多个菜单
$api_del_many = `/scm/cuc/cuc/functionInfo/deletebatchFunctionInfo`; $api_del_many = `/api/mdc/cuc/functionInfo/deletebatchFunctionInfo`;
constructor(public injector: Injector) { constructor(public injector: Injector) {
super(injector); super(injector);

View File

@ -3,7 +3,7 @@
"data": { "data": {
"menu": [ "menu": [
{ {
"text": "样例", "text": "主导航",
"hideInBreadcrumb": true, "hideInBreadcrumb": true,
"children": [ "children": [
{ {

View File

@ -1,7 +1,7 @@
{ {
"menu": [ "menu": [
{ {
"text": "样例", "text": "主导航",
"hideInBreadcrumb": true, "hideInBreadcrumb": true,
"children": [ "children": [
{ {