Commit 92361e77 by Nattana Chaiyamat

รอบการประเมิน competency pms

parent a651bbec
...@@ -4,6 +4,8 @@ import { EvaluationCycleModel, MyEvaluationCycleModel } from 'src/app/shared/mod ...@@ -4,6 +4,8 @@ import { EvaluationCycleModel, MyEvaluationCycleModel } from 'src/app/shared/mod
import { EvaluationCycleService } from 'src/app/shared/services/evaluation-cycle.service'; import { EvaluationCycleService } from 'src/app/shared/services/evaluation-cycle.service';
import { MyStatusCodeModel, StatusCodeModel } from 'src/app/shared/model/status-code.model'; import { MyStatusCodeModel, StatusCodeModel } from 'src/app/shared/model/status-code.model';
import { EvaluationAssessmentService } from 'src/app/shared/services/evaluation-assessment.service'; import { EvaluationAssessmentService } from 'src/app/shared/services/evaluation-assessment.service';
import { PLService } from 'src/app/shared/services/pl.service';
import { MyPLModel, PLModel } from 'src/app/shared/model/pl.model';
export interface DataModel { export interface DataModel {
evaluationRoundId: string; evaluationRoundId: string;
...@@ -14,7 +16,11 @@ export interface DataModel { ...@@ -14,7 +16,11 @@ export interface DataModel {
apsPeriodEnd: string; apsPeriodEnd: string;
statusCode: StatusCodeModel; statusCode: StatusCodeModel;
} }
export interface DataModal {
search: string,
currentPage: number,
page: number[]
}
@Component({ @Component({
selector: 'app-evaluation-cycle', selector: 'app-evaluation-cycle',
templateUrl: './evaluation-cycle.component.html', templateUrl: './evaluation-cycle.component.html',
...@@ -40,26 +46,69 @@ export class EvaluationCycleComponent { ...@@ -40,26 +46,69 @@ export class EvaluationCycleComponent {
evaluationRoundId = '' evaluationRoundId = ''
private unlisten!: () => void; private unlisten!: () => void;
modal: DataModal = {
search: "",
currentPage: 1,
page: Array.from({ length: 1 }, (_, i) => i + 1)
}
pl: { loading: boolean, selectList: PLModel[], selectIndex: number, dataList: PLModel[] } = { loading: false, selectList: [new MyPLModel()], selectIndex: -1, dataList: [] }
constructor(private evaluationCycleService: EvaluationCycleService, constructor(private evaluationCycleService: EvaluationCycleService,
private toastr: ToastrService, private toastr: ToastrService,
private cdr: ChangeDetectorRef, private cdr: ChangeDetectorRef,
private renderer: Renderer2 private renderer: Renderer2,
private pLService: PLService
) { } ) { }
ngOnInit(): void { ngOnInit(): void {
this.getEvaluationCycleList() this.getEvaluationCycleList()
this.unlisten = this.renderer.listen('document', 'keydown', (event) => { this.unlisten = this.renderer.listen('document', 'keydown', (event) => {
if (event.key === 'Escape') { if (event.key === 'Escape') {
this.evaluationRoundId='' this.evaluationRoundId = ''
} }
}); });
this.getPlList()
} }
ngOnDestroy() { ngOnDestroy() {
if (this.unlisten) { if (this.unlisten) {
this.unlisten(); // เรียกใช้งานจริง ๆ เพื่อลบ event listener this.unlisten(); // เรียกใช้งานจริง ๆ เพื่อลบ event listener
} }
} }
getPlList() {
this.pl.loading = false
this.pLService.getList().subscribe({
next: response => {
this.pl.dataList = response.map((x: any) => new MyPLModel(x))
this.pl.loading = false
this.searchChange()
this.cdr.detectChanges()
}, error: error => {
this.pl.loading = false
this.cdr.detectChanges()
}
})
}
plListFilter() {
return this.pl.dataList.filter(x =>
(x.plId.toLowerCase().includes(this.modal.search.toLowerCase()) ||
x.tdesc.toLowerCase().includes(this.modal.search.toLowerCase()) ||
x.edesc.toLowerCase().includes(this.modal.search.toLowerCase())) &&
!this.pl.selectList.some(y => y.plId == x.plId)
);
}
selectPl(data?: PLModel) {
if (!data) {
this.pl.selectList.splice(this.pl.selectIndex, 1);
return;
}
this.pl.selectList[this.pl.selectIndex] = new MyPLModel(data);
if (this.pl.selectIndex === this.pl.selectList.length - 1) {
this.pl.selectList.push(new MyPLModel());
}
}
getEvaluationCycleList() { getEvaluationCycleList() {
this.dataLoading = true this.dataLoading = true
this.evaluationCycleService.getList().subscribe({ this.evaluationCycleService.getList().subscribe({
...@@ -185,23 +234,27 @@ export class EvaluationCycleComponent { ...@@ -185,23 +234,27 @@ export class EvaluationCycleComponent {
} else if (this.modalStatus == 'edit') { } else if (this.modalStatus == 'edit') {
this.setData(new MyEvaluationCycleModel({ evaluationRoundId: this.dataSelect.evaluationRoundId })) this.setData(new MyEvaluationCycleModel({ evaluationRoundId: this.dataSelect.evaluationRoundId }))
} }
this.pl.selectList = [new MyPLModel()]
} }
openModal(id: string,evaluationRoundId:string) { openModal(id: string, evaluationRoundId: string) {
this.evaluationRoundId = '' this.evaluationRoundId = ''
if(id == 'evaluation-cycle-person-modal'){ if (id == 'evaluation-cycle-person-modal') {
this.evaluationRoundId = evaluationRoundId this.evaluationRoundId = evaluationRoundId
this.evaluationRoundIdChange.emit(evaluationRoundId) this.evaluationRoundIdChange.emit(evaluationRoundId)
setTimeout(() => { setTimeout(() => {
document.getElementById(id)?.classList.add('open'); document.getElementById(id)?.classList.add('open');
document.getElementById(id)?.classList.remove('hidden'); document.getElementById(id)?.classList.remove('hidden');
document.getElementById(id)?.setAttribute('aria-overlay', 'false'); document.getElementById(id)?.setAttribute('aria-overlay', 'false');
}, 10); }, 10);
} }
} }
searchModalChange(dataList: any[]) {
this.modal.currentPage = 1
this.modal.page = Array.from({ length: Math.ceil(dataList.length / 10) }, (_, i) => i + 1);
}
} }
import { ChangeDetectorRef, Component, EventEmitter, Input, Output } from '@angular/core'; import { ChangeDetectorRef, Component, EventEmitter, Input, Output } from '@angular/core';
import { ToastrService } from 'ngx-toastr'; import { ToastrService } from 'ngx-toastr';
import { PLModel, MyPLModel } from 'src/app/shared/model/pl.model';
import { MyPmsMasfromEvaluationModel, PmsMasfromEvaluationModel } from 'src/app/shared/model/pms-masfrom-evaluation.model'; import { MyPmsMasfromEvaluationModel, PmsMasfromEvaluationModel } from 'src/app/shared/model/pms-masfrom-evaluation.model';
import { PLService } from 'src/app/shared/services/pl.service';
import { PmsMasfromEvaluationCycleService } from 'src/app/shared/services/pms-masfrom-evaluation.service'; import { PmsMasfromEvaluationCycleService } from 'src/app/shared/services/pms-masfrom-evaluation.service';
export interface DataModal {
search: string,
currentPage: number,
page: number[]
}
@Component({ @Component({
selector: 'app-management-evaluation-cycle', selector: 'app-management-evaluation-cycle',
templateUrl: './management-evaluation-cycle.component.html', templateUrl: './management-evaluation-cycle.component.html',
...@@ -25,13 +31,56 @@ export class ManagementCycleComponent { ...@@ -25,13 +31,56 @@ export class ManagementCycleComponent {
isDataListCheckedAll = false isDataListCheckedAll = false
numDataListChecked = 0 numDataListChecked = 0
modal: DataModal = {
search: "",
currentPage: 1,
page: Array.from({ length: 1 }, (_, i) => i + 1)
}
pl: { loading: boolean, selectList: PLModel[], selectIndex: number, dataList: PLModel[] } = { loading: false, selectList: [new MyPLModel()], selectIndex: -1, dataList: [] }
constructor(private pmsMasfromEvaluationCycleService: PmsMasfromEvaluationCycleService, constructor(private pmsMasfromEvaluationCycleService: PmsMasfromEvaluationCycleService,
private toastr: ToastrService, private toastr: ToastrService,
private cdr: ChangeDetectorRef private cdr: ChangeDetectorRef,
private pLService: PLService
) { } ) { }
ngOnInit(): void { ngOnInit(): void {
this.getPmsMasfromEvaluationCycleList() this.getPmsMasfromEvaluationCycleList()
this.getPlList()
}
getPlList() {
this.pl.loading = false
this.pLService.getList().subscribe({
next: response => {
this.pl.dataList = response.map((x: any) => new MyPLModel(x))
this.pl.loading = false
this.searchChange()
this.cdr.detectChanges()
}, error: error => {
this.pl.loading = false
this.cdr.detectChanges()
}
})
}
plListFilter() {
return this.pl.dataList.filter(x =>
(x.plId.toLowerCase().includes(this.modal.search.toLowerCase()) ||
x.tdesc.toLowerCase().includes(this.modal.search.toLowerCase()) ||
x.edesc.toLowerCase().includes(this.modal.search.toLowerCase())) &&
!this.pl.selectList.some(y => y.plId == x.plId)
);
}
selectPl(data?: PLModel) {
if (!data) {
this.pl.selectList.splice(this.pl.selectIndex, 1);
return;
}
this.pl.selectList[this.pl.selectIndex] = new MyPLModel(data);
if (this.pl.selectIndex === this.pl.selectList.length - 1) {
this.pl.selectList.push(new MyPLModel());
}
} }
getPmsMasfromEvaluationCycleList() { getPmsMasfromEvaluationCycleList() {
...@@ -142,6 +191,12 @@ export class ManagementCycleComponent { ...@@ -142,6 +191,12 @@ export class ManagementCycleComponent {
} else if (this.modalStatus == 'edit') { } else if (this.modalStatus == 'edit') {
this.setData(new MyPmsMasfromEvaluationModel({ pmsEvaluationRoundId: this.dataSelect.pmsEvaluationRoundId })) this.setData(new MyPmsMasfromEvaluationModel({ pmsEvaluationRoundId: this.dataSelect.pmsEvaluationRoundId }))
} }
this.pl.selectList = [new MyPLModel()]
}
searchModalChange(dataList: any[]) {
this.modal.currentPage = 1
this.modal.page = Array.from({ length: Math.ceil(dataList.length / 10) }, (_, i) => i + 1);
} }
} }
......
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