From e4ab54e330261724709f5cef16983d535913dd00 Mon Sep 17 00:00:00 2001 From: Taric Xin Date: Wed, 12 Jan 2022 13:28:29 +0800 Subject: [PATCH] edit --- .../components/index/index.component.ts | 19 +++++++++++-------- .../services/menu-manager.service.ts | 2 +- src/assets/mocks/menu-data.json | 2 +- src/assets/mocks/platform/tms-obc-web.json | 2 +- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/app/routes/menu-manager/components/index/index.component.ts b/src/app/routes/menu-manager/components/index/index.component.ts index ac124451..5c41d4fb 100644 --- a/src/app/routes/menu-manager/components/index/index.component.ts +++ b/src/app/routes/menu-manager/components/index/index.component.ts @@ -97,29 +97,32 @@ export class MenuManagerComponentsIndexComponent implements OnInit { nzTitle: '删除确认', 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): Array { - let ids: any[] = []; + deleteMenuByAppID(arr: Array) { + 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 => {}); } } diff --git a/src/app/routes/menu-manager/services/menu-manager.service.ts b/src/app/routes/menu-manager/services/menu-manager.service.ts index 3e23c3dd..e1a9a85e 100644 --- a/src/app/routes/menu-manager/services/menu-manager.service.ts +++ b/src/app/routes/menu-manager/services/menu-manager.service.ts @@ -15,7 +15,7 @@ export class MenuManagerService extends BaseService { $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) { super(injector); diff --git a/src/assets/mocks/menu-data.json b/src/assets/mocks/menu-data.json index 89329db4..4c7e0fcf 100644 --- a/src/assets/mocks/menu-data.json +++ b/src/assets/mocks/menu-data.json @@ -3,7 +3,7 @@ "data": { "menu": [ { - "text": "样例", + "text": "主导航", "hideInBreadcrumb": true, "children": [ { diff --git a/src/assets/mocks/platform/tms-obc-web.json b/src/assets/mocks/platform/tms-obc-web.json index c533d478..cc63fb4a 100644 --- a/src/assets/mocks/platform/tms-obc-web.json +++ b/src/assets/mocks/platform/tms-obc-web.json @@ -1,7 +1,7 @@ { "menu": [ { - "text": "样例", + "text": "主导航", "hideInBreadcrumb": true, "children": [ {