Commit 92361e77 by Nattana Chaiyamat

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

parent a651bbec
......@@ -4,6 +4,8 @@ import { EvaluationCycleModel, MyEvaluationCycleModel } from 'src/app/shared/mod
import { EvaluationCycleService } from 'src/app/shared/services/evaluation-cycle.service';
import { MyStatusCodeModel, StatusCodeModel } from 'src/app/shared/model/status-code.model';
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 {
evaluationRoundId: string;
......@@ -14,7 +16,11 @@ export interface DataModel {
apsPeriodEnd: string;
statusCode: StatusCodeModel;
}
export interface DataModal {
search: string,
currentPage: number,
page: number[]
}
@Component({
selector: 'app-evaluation-cycle',
templateUrl: './evaluation-cycle.component.html',
......@@ -40,26 +46,69 @@ export class EvaluationCycleComponent {
evaluationRoundId = ''
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,
private toastr: ToastrService,
private cdr: ChangeDetectorRef,
private renderer: Renderer2
private renderer: Renderer2,
private pLService: PLService
) { }
ngOnInit(): void {
this.getEvaluationCycleList()
this.unlisten = this.renderer.listen('document', 'keydown', (event) => {
if (event.key === 'Escape') {
this.evaluationRoundId=''
this.evaluationRoundId = ''
}
});
this.getPlList()
}
ngOnDestroy() {
if (this.unlisten) {
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() {
this.dataLoading = true
this.evaluationCycleService.getList().subscribe({
......@@ -185,23 +234,27 @@ export class EvaluationCycleComponent {
} else if (this.modalStatus == 'edit') {
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 = ''
if(id == 'evaluation-cycle-person-modal'){
if (id == 'evaluation-cycle-person-modal') {
this.evaluationRoundId = evaluationRoundId
this.evaluationRoundIdChange.emit(evaluationRoundId)
setTimeout(() => {
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');
}, 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 { 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 { PLService } from 'src/app/shared/services/pl.service';
import { PmsMasfromEvaluationCycleService } from 'src/app/shared/services/pms-masfrom-evaluation.service';
export interface DataModal {
search: string,
currentPage: number,
page: number[]
}
@Component({
selector: 'app-management-evaluation-cycle',
templateUrl: './management-evaluation-cycle.component.html',
......@@ -25,13 +31,56 @@ export class ManagementCycleComponent {
isDataListCheckedAll = false
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,
private toastr: ToastrService,
private cdr: ChangeDetectorRef
private cdr: ChangeDetectorRef,
private pLService: PLService
) { }
ngOnInit(): void {
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() {
......@@ -142,6 +191,12 @@ export class ManagementCycleComponent {
} else if (this.modalStatus == 'edit') {
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