import { Component, OnInit,Output,EventEmitter } from '@angular/core'; import { HttpClient } from '@angular/common/http' import { Router,ActivatedRoute,NavigationEnd } from '@angular/router' import {CacheTokenService} from '../http-interceptors/cache-token.service'//引入服务 import { MatDialog } from '@angular/material/dialog'; import {ChangepasswordComponent} from '../ui/changepassword/changepassword.component' import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar'; import { filter } from 'rxjs/operators'; @Component({ selector: 'app-tabbar', templateUrl: './tabbar.component.html', styleUrls: ['./tabbar.component.scss'] }) export class TabbarComponent implements OnInit { theme: boolean = true; @Output() toggle = new EventEmitter(); @Output() toggleDarkTheme = new EventEmitter(); @Output() defaulttheme = new EventEmitter(); @Output() redtheme = new EventEmitter(); onChange(eventValue: boolean){ this.toggleDarkTheme.emit(eventValue); } constructor(private http:HttpClient,private router:Router,private route:ActivatedRoute,public token:CacheTokenService,public dialog: MatDialog, public snackBar: MatSnackBar) { } grade = null //单位完整度得分 title:any = "数字化预案编制管理平台" planName:any = null routerEventsListener //监测路由变化 integrityData:any ngOnInit() { this.routerEventsListener = this.router.events.pipe( filter(event => event instanceof NavigationEnd) ).subscribe((e) => { this.title = "数字化预案编制管理平台" this.planName = null this.grade = null }); this.getUserInfo() if(this.router.url.indexOf("editunitinfo") != -1 || this.router.url.indexOf("viewunitinfoplan") != -1){//如果url地址是从录入预案跳转 this.title = sessionStorage.getItem("companyName") this.planName = sessionStorage.getItem("planName") } if(this.router.url.indexOf("editplaninfo") != -1 || this.router.url.indexOf("viewunitinfo") != -1){//如果url地址是从重点单位跳转 this.title = sessionStorage.getItem("companyName") let obj = JSON.parse(sessionStorage.getItem(this.route.snapshot.queryParams.id)) this.grade = obj.zong this.integrityData = obj.details } } ngOnDestroy(){ this.routerEventsListener.unsubscribe() } integrityDetails(width,zong){ let style:any = {} style.width = (width/zong)*100 +'%'; return style } boxed(css){ const Element = document.body; Element.style.width = '1200px' } standard(){ const Element = document.body; Element.style.width = '100%' } isfullscreen:boolean = false; fullscreenToggle(){ const docElmWithBrowsersFullScreenFunctions = document.documentElement as HTMLElement & { mozRequestFullScreen(): Promise; webkitRequestFullscreen(): Promise; msRequestFullscreen(): Promise; }; if (docElmWithBrowsersFullScreenFunctions.requestFullscreen) { docElmWithBrowsersFullScreenFunctions.requestFullscreen(); } else if (docElmWithBrowsersFullScreenFunctions.mozRequestFullScreen) { /* Firefox */ docElmWithBrowsersFullScreenFunctions.mozRequestFullScreen(); } else if (docElmWithBrowsersFullScreenFunctions.webkitRequestFullscreen) { /* Chrome, Safari and Opera */ docElmWithBrowsersFullScreenFunctions.webkitRequestFullscreen(); } else if (docElmWithBrowsersFullScreenFunctions.msRequestFullscreen) { /* IE/Edge */ docElmWithBrowsersFullScreenFunctions.msRequestFullscreen(); } this.isfullscreen = true; } closefullscreen(){ const docWithBrowsersExitFunctions = document as Document & { mozCancelFullScreen(): Promise; webkitExitFullscreen(): Promise; msExitFullscreen(): Promise; }; if (docWithBrowsersExitFunctions.exitFullscreen) { docWithBrowsersExitFunctions.exitFullscreen(); } else if (docWithBrowsersExitFunctions.mozCancelFullScreen) { /* Firefox */ docWithBrowsersExitFunctions.mozCancelFullScreen(); } else if (docWithBrowsersExitFunctions.webkitExitFullscreen) { /* Chrome, Safari and Opera */ docWithBrowsersExitFunctions.webkitExitFullscreen(); } else if (docWithBrowsersExitFunctions.msExitFullscreen) { /* IE/Edge */ docWithBrowsersExitFunctions.msExitFullscreen(); } this.isfullscreen = false; } realName:any; //登录用户信息 //获取用户信息 getUserInfo () { this.http.get("/api/Account/Profiles").subscribe((data:any)=>{ this.realName = data.realName }) } //退出系统 signOut = () => { let out = confirm("您确定要退出吗") if(out) { this.http.post('/api/Account/SignOut',{}).subscribe( data=> { this.token.delete() sessionStorage.clear() window.localStorage.clear() this.router.navigate(['/login']) const config = new MatSnackBarConfig(); config.verticalPosition = 'bottom'; config.duration = 3000 this.snackBar.open('成功退出','确定',config); } ) } } //修改密码 changpsw() { let dialogRef = this.dialog.open(ChangepasswordComponent, {width:'348px'}); dialogRef.afterClosed().subscribe(); } }