Browse Source

[完善]完善角色分配菜单

beijing
邵佳豪 2 years ago
parent
commit
a484afad66
  1. 25
      src/app/system-management/menu/editmenu/editmenu.component.spec.ts
  2. 25
      src/app/system-management/menu/menu.component.spec.ts
  3. 2
      src/app/system-management/menu/menu.component.ts
  4. 2
      src/app/system-management/role/menus/menus.component.html
  5. 54
      src/app/system-management/role/role.component.ts

25
src/app/system-management/menu/editmenu/editmenu.component.spec.ts

@ -1,25 +0,0 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { EditmenuComponent } from './editmenu.component';
describe('EditmenuComponent', () => {
let component: EditmenuComponent;
let fixture: ComponentFixture<EditmenuComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ EditmenuComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(EditmenuComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

25
src/app/system-management/menu/menu.component.spec.ts

@ -1,25 +0,0 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { MenuComponent } from './menu.component';
describe('MenuComponent', () => {
let component: MenuComponent;
let fixture: ComponentFixture<MenuComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ MenuComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(MenuComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

2
src/app/system-management/menu/menu.component.ts

@ -114,7 +114,7 @@ export class MenuComponent implements OnInit {
editOr(node) {
console.log(node)
const modal = this.modal.create({
nzTitle: '编辑组织机构',
nzTitle: '编辑菜单',
nzContent: EditmenuComponent,
nzViewContainerRef: this.viewContainerRef,
nzWidth: 288,

2
src/app/system-management/role/menus/menus.component.html

@ -3,7 +3,7 @@
<nz-form-item>
<nz-form-label [nzSm]="6" [nzXs]="24" nzFor="菜单">菜单</nz-form-label>
<nz-form-control>
<nz-tree-select #nzTreeComponent formControlName="menus" [nzNodes]="nodes" nzShowSearch nzCheckable nzPlaceHolder="请选择菜单"
<nz-tree-select [nzCheckStrictly]="true" #nzTreeComponent formControlName="menus" [nzNodes]="nodes" nzShowSearch nzCheckable nzPlaceHolder="请选择菜单"
[nzExpandedIcon]="multiExpandedIconTpl">
</nz-tree-select>
</nz-form-control>

54
src/app/system-management/role/role.component.ts

@ -165,38 +165,32 @@ export class RoleComponent implements OnInit {
nzOnOk: async () => {
await new Promise(resolve => {
console.log('表单信息', instance.validateForm)
console.log('tree', instance.nzTreeComponent.getCheckedNodeList())
let arr = []
let treeData = instance.nzTreeComponent.getCheckedNodeList()
treeData.forEach(element => {
arr.push(element.key)
if (element.origin.children.length != 0) {
element.origin.children.forEach(ele => {
arr.push(ele.key)
})
}
if (element.parentNode) {
arr.push(element.parentNode.key)
}
});
console.log(99999999999, arr)
console.log(777777777777)
return false
// let body = instance.validateForm.value.menus
// this.http.post('/api/services/app/Role/SetRoleMenus', body, {
// params: {
// roleId: item.id
// let arr = []
// let treeData = instance.nzTreeComponent.getCheckedNodeList()
// console.log('tree', treeData)
// treeData.forEach(element => {
// arr.push(element.key)
// if (element.origin.children && element.origin.children.length != 0) {
// element.origin.children.forEach(ele => {
// arr.push(ele.key)
// })
// }
// if (element.parentNode) {
// arr.push(element.parentNode.key)
// }
// }).subscribe(data => {
// resolve(data)
// this.message.create('success', '分配成功!');
// this.getAllRoles()
// return true
// })
// });
let body = instance.validateForm.value.menus
this.http.post('/api/services/app/Role/SetRoleMenus', body, {
params: {
roleId: item.id
}
}).subscribe(data => {
resolve(data)
this.message.create('success', '分配成功!');
this.getAllRoles()
return true
})
})
}
});

Loading…
Cancel
Save