沈斌
2017-12-15 f9b157566af34b8dc28ba10b34d025ac04f3168b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { Component } from '@angular/core';
import { ACLService } from '@delon/acl';
import { MenuService } from '@delon/theme';
 
@Component({
    selector: 'app-acl',
    templateUrl: './acl.component.html'
})
export class ACLComponent {
 
    full = true;
    roleA = '';
    roleB = '';
 
    constructor(
        private aclService: ACLService,
        private menuSrv: MenuService) { }
 
    private reMenu() {
        this.menuSrv.resume((item) => {
            item.hide = item.acl && !this.aclService.can(item.acl);
        });
    }
 
    toggleFull() {
        this.full = !this.full;
        this.aclService.setFull(this.full);
        this.reMenu();
    }
 
    toggleRoleA() {
        this.full = false;
        this.roleA = this.roleA.length > 0 ? '' : 'role-a';
        this.aclService.setFull(this.full);
        this.aclService.setRole([this.roleA]);
        this.reMenu();
    }
 
    toggleRoleB() {
        this.full = false;
        this.roleB = this.roleB.length > 0 ? '' : 'role-b';
        this.aclService.setFull(this.full);
        this.aclService.setRole([this.roleB]);
        this.reMenu();
    }
}