import { Component, Input, OnInit } from '@angular/core'; import { RhStorageService } from 'rh-base/core'; import { EmployeeInfoQueryDto, FactoryInfoDto, FullEmployeeInfoDto, RhLoginedUserDto, UserAccountInfo, UserAccountQueryDto, WithNil } from 'rh-base/model'; import { AppService } from '../../../app.service'; @Component({ selector: 'app-user-information', templateUrl: './user-information.component.html', styleUrls: ['./user-information.component.less'] }) export class UserInformationComponent implements OnInit { //当前登录人的工厂信息 @Input() rhCurrentUserFactory!: FactoryInfoDto; //当前登录人 @Input() rhCurrentUser!: RhLoginedUserDto; //当前登录人的员工信息 currentEmployee!: FullEmployeeInfoDto; //当前登录人的用户信息 currentUserAccount!: UserAccountInfo; //获取当前登录人 currentUser: WithNil; // transPipe(value: string) { // switch (value) { // case 'OnTheJob': // return '在职'; // case 'Departure': // return '离职'; // case 'male': // return '男'; // case 'female': // return '女'; // default: // return value; // } // } constructor(private operator: AppService, private storage: RhStorageService) { this.currentUser = this.storage.getUserSession()?.User; // } ngOnInit(): void { this.currentUserAccount = UserAccountInfo.create(); this.currentEmployee = FullEmployeeInfoDto.create(); this.getEmployeeInfo(); setTimeout(() => { this.getUserInfo(); }, 20); } // 员工信息 getEmployeeInfo() { const queryDto = EmployeeInfoQueryDto.create(); queryDto.EmployeeCode = this.rhCurrentUser.UserName; queryDto.FactoryCode = this.rhCurrentUser.FactoryCode; // // const OrderByFields = (queryDto.Options.OrderByFields = {}); // queryDto.Options = { OrderByFields: {} }; // queryDto.Mode = 8; // queryDto.OpSign = 1; this.operator.GetEmployeeInfoDatas(queryDto).subscribe((result) => { if (result && result.Success) { // if (result.Attach.length === 1) this.currentEmployee = result.Attach[0]; } }); } //用户信息 getUserInfo() { const queryDto = UserAccountQueryDto.create(); queryDto.UserName = this.rhCurrentUser.UserName; queryDto.FactoryCode = this.rhCurrentUser.FactoryCode; queryDto.IsActive = true; queryDto.SkipCount = 0; this.operator.GetUserAccounts(queryDto).subscribe((result) => { if (result && result.Success) { this.currentUserAccount = result.Attach[0]; } }); } }