Commit b0834f40 by Nattana Chaiyamat

แบบประเมิน

parent 57da5b5f
import { ChangeDetectorRef, Component, EventEmitter, HostListener, Input, Output } from '@angular/core';
import { Router } from '@angular/router';
import { th } from 'date-fns/locale';
import { CompetencyModel } from 'src/app/shared/model/competency.model';
import { EmployeeModel, MyEmployeeModel } from 'src/app/shared/model/employee.model';
import { AppraisalService } from 'src/app/shared/services/appraisal.service';
import { EmployeeService } from 'src/app/shared/services/employee.service';
import { TokenService } from 'src/app/shared/services/token.service';
import Swal from 'sweetalert2';
@Component({
......@@ -187,7 +187,7 @@ export class PmsFormEmployeeComponent {
hasPushedState = false;
companyId = ""
handleBack = (event: PopStateEvent) => {
this.returnPath()
this.router.navigate(['/supervisor-evaluation']);
......@@ -197,8 +197,10 @@ export class PmsFormEmployeeComponent {
private router: Router,
private employeeService: EmployeeService,
private appraisalService: AppraisalService,
private cdr: ChangeDetectorRef
) { }
private cdr: ChangeDetectorRef,
private tokenService: TokenService
) {
}
ngOnDestroy() {
window.removeEventListener('popstate', this.handleBack);
......@@ -206,6 +208,7 @@ export class PmsFormEmployeeComponent {
}
ngOnInit() {
this.companyId = this.tokenService.getUser()?.companyid || ""
this.dateIso = this.currentDate.toISOString();
this.getEvaluatee()
this.getCompentencyAll()
......@@ -239,6 +242,7 @@ export class PmsFormEmployeeComponent {
selectDataList(data: CompetencyModel) {
this.compentency.data = data
this.compentency.data.commentAll.sort((a, b) => new Date(b.commentDate).getTime() - new Date(a.commentDate).getTime());
this.canSave = this.compentency.data.statusType == "pending" || this.compentency.data.statusType == "evaluating"
this.canDraft = +this.compentency.data.currentStep <= 1 && (this.compentency.data.statusType == "pending" || this.compentency.data.statusType == "evaluating")
this.canEdit = +this.compentency.data.currentStep <= 1 && (this.compentency.data.statusType == "pending" || this.compentency.data.statusType == "evaluating")
......@@ -383,12 +387,13 @@ export class PmsFormEmployeeComponent {
type StepKey = 'apsassessy' | 'apsapprove1' | 'apsapprove2' | 'apsapprove3' | 'apsapprove4' | 'apsapprove5';
const steps: StepKey[] = ['apsassessy', 'apsapprove1', 'apsapprove2', 'apsapprove3', 'apsapprove4', 'apsapprove5'];
const stepIndex = parseInt(this.compentency.data.currentStep, 10);
const updatedData = { ...this.compentency.data };
const updatedData = JSON.parse(JSON.stringify(this.compentency.data));
if (approveStatus === '3' && stepIndex >= 2) {
const prevKey: StepKey = steps[stepIndex - 1];
updatedData[prevKey] = {
...updatedData[prevKey],
status: '0',
stepReturn: stepIndex
};
}
const currentKey: StepKey = steps[stepIndex];
......@@ -403,11 +408,21 @@ export class PmsFormEmployeeComponent {
statusType = "evaluating"
} else if (approveStatus === "2") {
statusType = "completed"
for (let i = stepIndex + 1; i < steps.length; i++) {
const nextKey: StepKey = steps[i];
if (updatedData[nextKey]?.status === '3') {
updatedData[nextKey] = {
...updatedData[nextKey],
status: '0',
};
}
}
} else if (approveStatus === "3") {
statusType = "rejected"
}
updatedData.commentAll.push({
commentDate: this.dateIso,
companyId: this.companyId,
currentStep: this.compentency.data.currentStep,
statusType: statusType,
comment: this.comment,
......
......@@ -108,7 +108,7 @@
<div class="flex justify-center">
<button type="button" class="ti-btn rounded-sm "
*ngFor="let type of item.typeList"
[class]="statusButtonClass(item.statusPms.statusType)"
[class]="statusButtonClass(type.statusType)"
style="height: 15px; width: 45px; font-size: 12px; display: flex; align-items: center; justify-content: center;margin-left:4px;"
(click)="selectSubordinate(item,type.competencyTypeId,subordinate.select?.evaluationRoundId);pageEvalution=type.shortName">
{{type.shortName}}
......@@ -118,7 +118,7 @@
<td class="text-center">
<div class="flex justify-center">
<button type="button" class="ti-btn rounded-sm"
[class]="statusButtonClass(item.statusPms.statusType)"
[class]="statusButtonClass(item.statusIdp.statusType)"
style="height: 15px; width: 45px; font-size: 12px; display: flex; align-items: center; justify-content: center;margin-left:4px;"
(click)="selectSubordinate(item,'',subordinate.select?.evaluationRoundId,item.statusIdp.statusType);pageEvalution='idp'">
IDP
......
......@@ -25,6 +25,7 @@ export interface ApsEmp {
}
export interface CommentAll {
commentDate: string
companyId: string
currentStep: string
statusType: string
comment: string
......
......@@ -20,7 +20,7 @@ export class AppraisalService {
return this.http.get<CompetencyModel[]>(this.urlApi + "/competencyAll/emp?apsassessy=" + apsassessy + (bossId ? "&bossId=" + bossId : ''))
}
postCompentencyAll(body: CompetencyModel): Observable<AlertModel> {
return this.http.post<AlertModel>(this.urlApi + "/appraisalcompetencyAll/emp", body)
return this.http.post<AlertModel>(this.urlApi + "/competencyAll/emp", body)
}
getFormCompentencyById(evaluationRoundId: string, apsassessy: string, typeId: string): Observable<AppraisalCompentencyModel2> {
return this.http.get<AppraisalCompentencyModel2>(this.urlApi + "/competency/" + evaluationRoundId + "/" + apsassessy + "/" + typeId)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment