diff --git a/src/app/pages/audit/audit-nav/audit-nav.component.html b/src/app/pages/audit/audit-nav/audit-nav.component.html index 58a8928..ab98133 100644 --- a/src/app/pages/audit/audit-nav/audit-nav.component.html +++ b/src/app/pages/audit/audit-nav/audit-nav.component.html @@ -13,10 +13,10 @@
- - - - + + + +
\ No newline at end of file diff --git a/src/app/pages/home/home.component.html b/src/app/pages/home/home.component.html index 4c3cbad..f1b69bc 100644 --- a/src/app/pages/home/home.component.html +++ b/src/app/pages/home/home.component.html @@ -7,7 +7,7 @@
-
  • {{item.name}}
  • @@ -19,7 +19,7 @@ -
  • {{item.name}}
  • diff --git a/src/app/pages/home/home.component.ts b/src/app/pages/home/home.component.ts index fe9bc0c..59cc89e 100644 --- a/src/app/pages/home/home.component.ts +++ b/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( diff --git a/src/app/pages/license/nav-bar/nav-bar.component.html b/src/app/pages/license/nav-bar/nav-bar.component.html index 790c47c..a2e48a5 100644 --- a/src/app/pages/license/nav-bar/nav-bar.component.html +++ b/src/app/pages/license/nav-bar/nav-bar.component.html @@ -4,7 +4,7 @@ diff --git a/src/app/pages/license/nav-bar/nav-bar.component.ts b/src/app/pages/license/nav-bar/nav-bar.component.ts index 502afc5..b14e2e2 100644 --- a/src/app/pages/license/nav-bar/nav-bar.component.ts +++ b/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] + } } diff --git a/src/app/pages/login/login.component.ts b/src/app/pages/login/login.component.ts index ec9282d..a8afc1a 100644 --- a/src/app/pages/login/login.component.ts +++ b/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))