Browse Source

菜单管理

beijing
陈鹏飞 2 years ago
parent
commit
3b24dbff66
  1. 8
      src/app/pages/audit/audit-nav/audit-nav.component.html
  2. 4
      src/app/pages/home/home.component.html
  3. 30
      src/app/pages/home/home.component.ts
  4. 2
      src/app/pages/license/nav-bar/nav-bar.component.html
  5. 32
      src/app/pages/license/nav-bar/nav-bar.component.ts
  6. 6
      src/app/pages/login/login.component.ts

8
src/app/pages/audit/audit-nav/audit-nav.component.html

@ -13,10 +13,10 @@
</div>
</div>
<div class="content">
<app-update-license-list *ngIf="selectedItem == menu[0]" #child2></app-update-license-list>
<app-file-license-list *ngIf="selectedItem == menu[1]" #child3></app-file-license-list>
<app-audit-ing *ngIf="selectedItem == menu[2]"></app-audit-ing>
<app-audit-record *ngIf="selectedItem == menu[3]"></app-audit-record>
<app-update-license-list *ngIf="selectedItem == navList[0]" #child2></app-update-license-list>
<app-file-license-list *ngIf="selectedItem == navList[1]" #child3></app-file-license-list>
<app-audit-ing *ngIf="selectedItem == navList[2]"></app-audit-ing>
<app-audit-record *ngIf="selectedItem == navList[3]"></app-audit-record>
<app-audit-inform-time *ngIf="selectedItem == '预警规则'"></app-audit-inform-time>
</div>
</div>

4
src/app/pages/home/home.component.html

@ -7,7 +7,7 @@
<img src="../../../assets/images/logo2.png" alt="">
</div>
<div class="libox" *ngIf="!isGasStationNav">
<li *ngFor="let item of menu1" (click)="routerChange(item)"
<li *ngFor="let item of menuList1" (click)="routerChange(item)"
[ngClass]="{'router-link-active': item.name == selectedItem}">
{{item.name}}
</li>
@ -19,7 +19,7 @@
</li>
</ng-container>
<ng-template #elseTemplate>
<li *ngFor="let item of menu2" (click)="routerChange(item)"
<li *ngFor="let item of menuList2" (click)="routerChange(item)"
[ngClass]="{'router-link-active': item.name == selectedItem}">
{{item.name}}
</li>

30
src/app/pages/home/home.component.ts

@ -58,7 +58,10 @@ export class HomeComponent implements OnInit {
{ name: '预警记录', url: '/records_nav/petrolStation' },
{ name: '证照管理', url: '/license/petrolStation' },
]
userMenu=[]
tap=[]
menuList1=[]
menuList2=[]
selectedItem
routerChange(item) {
if (item.name == this.selectedItem) {
@ -70,7 +73,13 @@ export class HomeComponent implements OnInit {
}
ngOnInit(): void {
let a= sessionStorage.getItem('userdata')
this.userMenu=JSON.parse(a).menus
for (let index = 0; index < this.userMenu.length; index++) {
let a=this.userMenu[index].name
this.tap.push(a)
}
if (sessionStorage.getItem('selectedMenu')) {
this.selectedItem = sessionStorage.getItem('selectedMenu')
}
@ -79,9 +88,26 @@ export class HomeComponent implements OnInit {
//初始化登陆 如果是油站用户
if (this.isGasStation) {
this.isGasStationNav = true
for (let index = 0; index < this.menu2.length; index++) {
for (let k = 0; k < this.tap.length; k++) {
if (this.tap[k]==this.menu2[index].name) {
this.menuList2.push(this.menu2[index])
}
}
}
console.log( this.menuList2);
} else {//初始化登陆 如果是管理者用户
this.isGasStationNav = false
this.isGasStationBack = false
for (let index = 0; index < this.menu1.length; index++) {
for (let k = 0; k < this.tap.length; k++) {
if (this.tap[k]==this.menu1[index].name) {
this.menuList1.push(this.menu1[index])
}
}
}
}
this.router.events.pipe(

2
src/app/pages/license/nav-bar/nav-bar.component.html

@ -4,7 +4,7 @@
<img src="../../../assets/images/logosm.png" alt="">
<div class="nav">
<div class="navitem">
<span *ngFor="let item of navList" [ngClass]="{'grey': selectedItem != item}"
<span *ngFor="let item of menu" [ngClass]="{'grey': selectedItem != item}"
(click)="selectNav(item)">{{item}}</span>
</div>
</div>

32
src/app/pages/license/nav-bar/nav-bar.component.ts

@ -10,11 +10,41 @@ export class NavBarComponent implements OnInit {
constructor() { }
navList = ['通知','经营类证照','资产类证照','历史纪录']
selectedItem = '通知'
tap=[]
userMenu = []
menu=[]
selectedItem
selectNav(item){
this.selectedItem = item
}
ngOnInit(): void {
let a= sessionStorage.getItem('userdata')
this.userMenu=JSON.parse(a).menus
console.log(this.userMenu);
for (let index = 0; index < this.userMenu.length; index++) {
let a=this.userMenu[index].name
this.tap.push(a)
}
console.log(this.tap);
if (this.userMenu.length==0) {
this.menu=this.navList
}else{
for (let index = 0; index < this.navList.length; index++) {
for (let k = 0; k < this.tap.length; k++) {
if (this.tap[k]==this.navList[index]) {
this.menu.push(this.tap[k])
console.log( this.menu);
}
}
}
}
this.selectedItem = this.menu[0]
}
}

6
src/app/pages/login/login.component.ts

@ -112,6 +112,12 @@ export class LoginComponent implements OnInit {
console.log('token', data.result)
this.http.get('/api/services/app/Session/GetCurrentLoginInformations').subscribe((data: any) => {
console.log('GetCurrentLoginInformations', data.result)
if(data.result.user.menus.length==0){
this.message.create('error', `当前用户未分配菜单`);
this.isLoading=false
return
}
sessionStorage.setItem('userdata', JSON.stringify(data.result.user))
sessionStorage.setItem('userdataOfgasstation', JSON.stringify(data.result.user))
sessionStorage.setItem('isDefaultPassword', JSON.stringify(data.result.user.isDefaultPassword))

Loading…
Cancel
Save