diff --git a/src/app/system-management/role/addrole/addrole.component.html b/src/app/system-management/role/addrole/addrole.component.html index a986b7b..94f160e 100644 --- a/src/app/system-management/role/addrole/addrole.component.html +++ b/src/app/system-management/role/addrole/addrole.component.html @@ -19,20 +19,21 @@ - + \ No newline at end of file diff --git a/src/app/system-management/role/addrole/addrole.component.ts b/src/app/system-management/role/addrole/addrole.component.ts index f2ff54e..e65d39c 100644 --- a/src/app/system-management/role/addrole/addrole.component.ts +++ b/src/app/system-management/role/addrole/addrole.component.ts @@ -1,18 +1,21 @@ -import { Component, OnInit, Input } from '@angular/core'; +import { Component, OnInit, Input,ViewChild } from '@angular/core'; import { NzModalRef } from 'ng-zorro-antd/modal'; -import { FormBuilder, FormGroup, Validators } from '@angular/forms'; +import { FormBuilder, FormGroup, Validators, } from '@angular/forms'; import { HttpClient } from '@angular/common/http'; import { TreeService } from 'src/app/service/tree.service'; +import { NzTreeComponent } from 'ng-zorro-antd/tree'; @Component({ selector: 'app-addrole', templateUrl: './addrole.component.html', styleUrls: ['./addrole.component.scss'] }) export class AddroleComponent implements OnInit { - + @ViewChild('nzTreeComponent', { static: false }) nzTreeComponent!: NzTreeComponent; + @Input() data?: any; + @Input() nodes?: any; @Input() title?: string; @Input() subtitle?: string; - @Input() nodes?: any; + validateForm!: FormGroup; constructor(private modal: NzModalRef, private fb: FormBuilder, private http: HttpClient, private toTree: TreeService) { } @@ -23,10 +26,10 @@ export class AddroleComponent implements OnInit { this.validateForm = this.fb.group({ name: [null, [Validators.required]], power: [null, [Validators.required]], - // menus: [null] + menus: [null] }); } - + totalCount getAllMenus() { let params = { diff --git a/src/app/system-management/role/editrole/editrole.component.html b/src/app/system-management/role/editrole/editrole.component.html index b6b040b..38539e9 100644 --- a/src/app/system-management/role/editrole/editrole.component.html +++ b/src/app/system-management/role/editrole/editrole.component.html @@ -16,21 +16,21 @@ - + + \ No newline at end of file diff --git a/src/app/system-management/role/editrole/editrole.component.ts b/src/app/system-management/role/editrole/editrole.component.ts index a215613..3f9b4ee 100644 --- a/src/app/system-management/role/editrole/editrole.component.ts +++ b/src/app/system-management/role/editrole/editrole.component.ts @@ -20,15 +20,33 @@ export class EditroleComponent implements OnInit { ngOnInit(): void { this.nodes.length != 0 ? null : this.getAllMenus() this.multipleValue = this.data.grantedPermissions + this.getMenus() this.validateForm = this.fb.group({ name: [null, [Validators.required]], power: [null, [Validators.required]], - // menus: [null] + menus: [null] }); if (this.optionList.length == 0) { this.loadMore() } } + getMenus() { + let params = { + Id: this.data.id, + } + this.http.get('/api/services/app/Role/Get', { + params: params + }).subscribe((data: any) => { + // console.log(666, data) + let arr = [] + data.result.menus.forEach(element => { + arr.push(element.id) + }); + this.validateForm.patchValue({ + menus: arr + }); + }) + } totalCount getAllMenus() { let params = { diff --git a/src/app/system-management/role/role.component.html b/src/app/system-management/role/role.component.html index ef1935f..722f951 100644 --- a/src/app/system-management/role/role.component.html +++ b/src/app/system-management/role/role.component.html @@ -29,7 +29,7 @@