e;
if (thisEvt.snapshot.routeConfig?.loadChildren) {
// 当前激活的路由
// const activatedRoutePath = thisEvt.snapshot.routeConfig?.path;
const activatedRoutePath = this.router.url;
- // console.log(activatedRoutePath);
const routeData = thisEvt.snapshot.queryParams;
let menuTitle = '新标签页';
if(routeData) {
diff --git a/src/app/pages/system/menu/menu.component.html b/src/app/pages/system/menu/menu.component.html
index 918b2a0..ad86257 100644
--- a/src/app/pages/system/menu/menu.component.html
+++ b/src/app/pages/system/menu/menu.component.html
@@ -2,9 +2,10 @@
+
0"
+ *ngIf="menuTree.length > 0 && treeView"
[nzData]="menuTree"
[nzShowLine]="true"
[nzExpandAll]="true"
@@ -25,7 +26,7 @@
{{menuDetail.menuName?menuDetail.menuName:'无'}}
{{menuDetail.menuType| menuType}}
{{menuDetail.menuUrl?menuDetail.menuUrl:'无'}}
- {{menuDetail.name?menuDetail.name:'无'}}
+ {{menuDetail.menuUrlImg?menuDetail.menuUrlImg:'无'}}
{{menuDetail.menuDesc?menuDetail.menuDesc:'无'}}
diff --git a/src/app/pages/system/menu/menu.component.ts b/src/app/pages/system/menu/menu.component.ts
index 43c1566..32c5fef 100644
--- a/src/app/pages/system/menu/menu.component.ts
+++ b/src/app/pages/system/menu/menu.component.ts
@@ -1,5 +1,5 @@
-import {Component, ViewChild} from '@angular/core';
-import {NzTreeComponent} from "ng-zorro-antd/tree";
+import {ChangeDetectorRef, Component, ViewChild} from '@angular/core';
+import {NzFormatEmitEvent, NzTreeComponent, NzTreeNode, NzTreeService} from "ng-zorro-antd/tree";
import {NgForOf, NgIf} from "@angular/common";
import {NzIconDirective} from "ng-zorro-antd/icon";
import {NzDropdownMenuComponent} from "ng-zorro-antd/dropdown";
@@ -23,7 +23,7 @@ import {NzFlexDirective} from "ng-zorro-antd/flex";
import {NzOptionComponent, NzSelectComponent} from "ng-zorro-antd/select";
import {NzInputNumberComponent} from "ng-zorro-antd/input-number";
import {NzMessageService} from "ng-zorro-antd/message";
-import {NzTreeNode} from "ng-zorro-antd/core/tree/nz-tree-base-node";
+import {NzSpinComponent} from "ng-zorro-antd/spin";
@Component({
selector: 'app-menu',
@@ -55,7 +55,8 @@ import {NzTreeNode} from "ng-zorro-antd/core/tree/nz-tree-base-node";
NzSelectComponent,
NzOptionComponent,
NgForOf,
- NzInputNumberComponent
+ NzInputNumberComponent,
+ NzSpinComponent
],
templateUrl: './menu.component.html',
styleUrl: './menu.component.less'
@@ -64,7 +65,7 @@ export class MenuComponent {
// 菜单数据
menuData: any = [];
// 菜单树形数据
- menuTree: any = [];
+ menuTree: any[] = [];
// 菜单详情
menuDetail: any = {};
// 编辑菜单弹出框
@@ -73,7 +74,9 @@ export class MenuComponent {
editMenuForm: FormGroup;
// 编辑菜单标题
editMenuTitle = '';
- @ViewChild('nzTreeComponent', { static: false }) nzTreeComponent!: NzTreeComponent;
+ // 树视图展示状态
+ treeView= false;
+
constructor(private menuService: MenuService,
private fb: NonNullableFormBuilder,
private modal: NzModalService,
@@ -98,6 +101,7 @@ export class MenuComponent {
queryMenuTree() {
this.menuService.queryRoleMenuTreeCustomized('', (data: any) => {
this.menuTree = data['return_data'];
+ this.treeView = true;
this.queryMenuData();
});
}
@@ -124,7 +128,6 @@ export class MenuComponent {
menuObj['parentMenu'] = this.menuData.find((o: any) => o.id == menuObj.menuPSid);
}
this.menuDetail = menuObj;
- console.log(this.menuDetail);
}
}
@@ -141,6 +144,14 @@ export class MenuComponent {
menuType: '1'
};
+ if (edit == false && this.menuDetail?.id == null) {
+ this.modal.confirm({
+ nzTitle: '提示',
+ nzContent: '请点击需要修改的菜单',
+ });
+ return;
+ }
+
if (this.menuDetail != null) {
if (edit) {
// 增加
@@ -165,6 +176,7 @@ export class MenuComponent {
*/
submitEditMenuForm() {
if (this.editMenuForm.valid) {
+ this.treeView = false;
this.menuService.editMenu(this.editMenuForm.value, (data: any) => {
if (data['return_code'] == '000000') {
// 刷新数据
@@ -213,14 +225,14 @@ export class MenuComponent {
const param = {
menuId: this.menuDetail.id
}
+ this.treeView = false;
this.menuService.delMenu(param, (data: any) => {
if (data['return_code'] == '000000') {
// 刷新数据
- const s = this.nzTreeComponent.getTreeNodeByKey(""+this.menuDetail.menuPSid)
-
-
+ this.queryMenuTree();
this.message.create('success', '操作成功');
} else {
+ this.treeView = true;
this.message.create('error', data['return_msg']);
}
});
diff --git a/src/app/servies/menu/menu.service.ts b/src/app/servies/menu/menu.service.ts
index cd51ceb..f95ad01 100644
--- a/src/app/servies/menu/menu.service.ts
+++ b/src/app/servies/menu/menu.service.ts
@@ -39,7 +39,7 @@ export class MenuService {
* @param callBack
*/
public queryMenuList(callBack:any) {
- this.http.get(environment.baseUrl + 'secMenu/queryMenuList').subscribe(data => {
+ this.http.post(environment.baseUrl + 'secMenu/queryMenuList', null).subscribe(data => {
callBack(data);
});
}
diff --git a/src/app/servies/role/role.service.ts b/src/app/servies/role/role.service.ts
new file mode 100644
index 0000000..17f6831
--- /dev/null
+++ b/src/app/servies/role/role.service.ts
@@ -0,0 +1,57 @@
+import { Injectable } from '@angular/core';
+import {HttpClient} from "@angular/common/http";
+import {environment} from "../../../environments/environment";
+import {ObjectData} from "../../utils/objectData.service";
+
+@Injectable({
+ providedIn: 'root'
+})
+export class RoleService {
+
+ constructor(private http: HttpClient) { }
+
+ /**
+ * 编辑角色
+ * @param params
+ * @param callBack
+ */
+ public editRole(params: object, callBack:any) {
+ this.http.post(environment.baseUrl + 'secRole/editRole', params).subscribe(data => {
+ callBack(data);
+ });
+ }
+
+ /**
+ * 删除角色
+ * @param params
+ * @param callBack
+ */
+ public delRole(params: object, callBack:any) {
+ this.http.post(environment.baseUrl + 'secRole/delRole', params).subscribe(data => {
+ callBack(data);
+ });
+ }
+
+ /**
+ * 查询详情
+ * @param roleId
+ * @param callBack
+ */
+ public queryDetail(roleId: number, callBack:any) {
+ this.http.get(environment.baseUrl + 'secRole/queryDetail?roleId='+roleId).subscribe(data => {
+ callBack(data);
+ });
+ }
+
+ /**
+ * 查询列表
+ * @param params
+ * @param callBack
+ */
+ public queryList(params: object, callBack:any) {
+ this.http.get(environment.baseUrl + 'secRole/queryList?'+ObjectData.objectByString(params)).subscribe(data => {
+ callBack(data);
+ });
+ }
+
+}