import { FactoryInfoDto, RhProjectConfigDto } from 'rh-base/model'; import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; import { Router } from '@angular/router'; import { UntypedFormGroup } from '@angular/forms'; import { RhLoginedUserDto, RhUpdatePasswordDto } from 'rh-base/model'; import { RhStorageService } from 'rh-base/core'; import { RhRouteReuseStrategy } from 'rh-base/core'; import { RhAppConfigService, MsgHelper } from 'rh-base/core'; import { AppService } from '../../../app.service'; @Component({ selector: 'app-header-user', templateUrl: './header-user.component.html', styleUrls: ['./header-user.component.less'] }) export class HeaderUserComponent implements OnInit { user!: RhLoginedUserDto; // 当前登录人 @Output() rhUserChange = new EventEmitter(); //当前登录人的工厂信息 @Input() rhCurrentUserFactory!: FactoryInfoDto; // *************** 密码 ******************** isShowPasswd = false; updatePasswordDto!: RhUpdatePasswordDto; updatePasswordForm!: UntypedFormGroup; //*************** 个人资料 ******************** isShowUserInformationModal = false; get projectConfig(): RhProjectConfigDto { return this.operator.projectConfig; } constructor(public router: Router, public storage: RhStorageService, private operator: AppService) {} ngOnInit() { this.user = this.operator.getUser()!; this.rhUserChange.emit(this.user); } logout() { // 清空localStorage和路由列表 this.storage.cleanLoggedInStorage(); this.router.navigate([this.projectConfig.LoginPath]).then((flag) => { if (flag) { RhRouteReuseStrategy.resetHandlers(); } }); } openPasswdModal() { this.isShowPasswd = true; } closePassedModal() { this.isShowPasswd = false; } openUserInformationModal() { this.isShowUserInformationModal = true; } closeUserInformationModal() { this.isShowUserInformationModal = false; } onClickRefreshButton() { MsgHelper.ShowConfirmModal( '选择刷新方式', '请选择刷新方式,强制刷新同时会清除缓存!', () => { window.location.reload(/* false */); }, () => { window.location.reload(/* true */); }, 'primary', '刷新', '强制刷新' ); } refreshPage() { // window.document.location.reload(false); document.execCommand('Refresh'); } forceRefresh() { // window.location = window.location.href+'?eraseCache=true'; } }