Commit 13c2c8ba by Nakarin Luankla

UPDATE การจัดการรอบการประเมิน

parent d3b60370
......@@ -358,7 +358,7 @@
เเก้ไขเเบบฟอร์มตามรอบการประเมิน
</h3>
<div class="flex justify-end">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger" (click)="evaluationRoundId=''"
data-hs-overlay="#evaluation-cycle-person-modal">
<span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i>
......
import { ChangeDetectorRef, Component, EventEmitter, Output } from '@angular/core';
import { ChangeDetectorRef, Component, EventEmitter, Output, Renderer2 } from '@angular/core';
import { ToastrService } from 'ngx-toastr';
import { EvaluationCycleModel, MyEvaluationCycleModel } from 'src/app/shared/model/evaluation-cycle.model';
import { EvaluationCycleService } from 'src/app/shared/services/evaluation-cycle.service';
......@@ -38,15 +38,28 @@ export class EvaluationCycleComponent {
isDataListCheckedAll = false
numDataListChecked = 0
evaluationRoundId = ''
private unlisten!: () => void;
constructor(private evaluationCycleService: EvaluationCycleService,
private toastr: ToastrService,
private cdr: ChangeDetectorRef,
private renderer: Renderer2
) { }
ngOnInit(): void {
this.getEvaluationCycleList()
this.unlisten = this.renderer.listen('document', 'keydown', (event) => {
if (event.key === 'Escape') {
this.evaluationRoundId=''
}
});
}
ngOnDestroy() {
if (this.unlisten) {
this.unlisten(); // เรียกใช้งานจริง ๆ เพื่อลบ event listener
}
}
getEvaluationCycleList() {
this.dataLoading = true
this.evaluationCycleService.getList().subscribe({
......
import { ChangeDetectorRef, Component, EventEmitter, Input, Output } from '@angular/core';
import { ToastrService } from 'ngx-toastr';
import { AppraisalRoundModel, MyAppraisalRoundModel } from 'src/app/shared/model/appraisal-aps.model';
import { AppraisalFormModel } from 'src/app/shared/model/appraisal-form.model';
import { AppraisalModel } from 'src/app/shared/model/appraisal.model';
import { AppraisalModel, MyAppraisalModel } from 'src/app/shared/model/appraisal.model';
import { EvaluationCycleModel, MyEvaluationCycleModel } from 'src/app/shared/model/evaluation-cycle.model';
import { EvaluationAssessmentService } from 'src/app/shared/services/evaluation-assessment.service';
import { EvaluationCycleService } from 'src/app/shared/services/evaluation-cycle.service';
......@@ -29,6 +30,20 @@ export class EditEvaluationFormComponent {
isChecked: boolean = false;
apsassessy = ""
empassessmentList: AppraisalModel[] = []
searchEmp = ""
empassessmentRoundList: AppraisalRoundModel[] = []
empassessmentRoundListCheckbox: {checkbox: boolean, item: AppraisalRoundModel}[] = []
currentPageRound = 1
pageRound = Array.from({ length: 1 }, (_, i) => i + 1);
searchRound = ""
selectEmp:AppraisalModel = new MyAppraisalModel()
numDataListChecked = 0
msg = ""
typeForm = ""
selectData: AppraisalRoundModel = new MyAppraisalRoundModel()
constructor(private toastr: ToastrService,
private cdr: ChangeDetectorRef,
private evaluationAssessmentService: EvaluationAssessmentService,
......@@ -41,6 +56,11 @@ export class EditEvaluationFormComponent {
}
ngOnChanges(): void {
setTimeout(() => {
document.getElementById('form-pm-emp')?.classList.add("hidden")
document.getElementById('form-assessment')?.classList.add("hidden")
document.getElementById('modal-alert')?.classList.add("hidden")
}, 10);
if (this.evaluationRoundId) {
this.getAssessmentId();
this.getAssessmentList();
......@@ -86,19 +106,33 @@ export class EditEvaluationFormComponent {
this.page = Array.from({ length: Math.ceil(filteredData.length / 10) }, (_, i) => i + 1);
}
openModalClass(id: string) {
document.getElementById(id)?.classList.add('open');
document.getElementById(id)?.classList.remove('hidden');
setTimeout(() => {
document.getElementById(id)?.setAttribute('aria-overlay', 'true')
}, 10);
openModalClass(id: string,type?:string) {
this.typeForm = type??""
if(id == 'modal-alert'){
if(type == 'deleteForm'){
this.msg = 'ยืนยันการลบรายการ'
}else if(type == 'addForm'){
this.msg = 'ยืนยันการบันทึกรายการ'
}
}
if(id){
document.getElementById(id)?.classList.add('open');
document.getElementById(id)?.classList.remove('hidden');
setTimeout(() => {
document.getElementById(id)?.setAttribute('aria-overlay', 'false')
}, 10);
}
this.isChecked = false;
this.numDataListChecked = 0;
}
closeModalClass(id: string) {
const modal = document.getElementById(id);
if (modal) {
modal.classList.add("hidden"); // ซ่อน Modal
console.log("🚀 ~ EditEvaluationFormComponent ~ closeModalClass ~ modal:", modal)
if (id) {
modal?.classList.add("hidden"); // ซ่อน Modal
}
}
......@@ -121,17 +155,19 @@ export class EditEvaluationFormComponent {
}
}
openAddRoundModel(evaluationRoundId:string,apsassessy:string,model:string) {
openAddRoundModel(evaluationRoundId:string,apsassessy:string,item:AppraisalModel,model:string) {
this.selectEmp = item
this.openModalClass(model);
this.evaluationRoundId = evaluationRoundId
this.apsassessy = apsassessy
this.getApsassessy()
this.getApsassessyMini();
}
getApsassessy(){
this.evaluationAssessmentService.getApsassessy(this.evaluationRoundId,this.apsassessy).subscribe({
next: response => {
console.log("🚀 ~ EditEvaluationFormComponent ~ this.evaluationAssessmentService.getApsassessy ~ response:", response)
this.empassessmentList = response
this.cdr.detectChanges();
},
error: err => {
......@@ -139,6 +175,65 @@ export class EditEvaluationFormComponent {
}
})
}
getApsassessyMini(){
this.evaluationAssessmentService.getApsassessyMini(this.evaluationRoundId,this.apsassessy).subscribe({
next: response => {
this.empassessmentRoundList = response
this.empassessmentRoundListCheckbox = this.empassessmentRoundList.map(item => ({checkbox: false, item}))
this.cdr.detectChanges();
},
error: err => {
console.error('Error fetching evaluation cycles:', err);
}
})
}
empassessmentListFilter() {
return this.empassessmentRoundListCheckbox.filter(x =>
x.item.groupAssessment1?.competencyIndicatorsCourses1Mini?.competencyIndicatorsCourses0?.competencyTopic?.tdesc?.toLowerCase()?.includes(this.searchRound?.toLowerCase() ?? "")||
x.item.groupAssessment1?.competencyIndicatorsCourses1Mini?.competencyIndicatorsCourses0?.competencyTopic?.edesc?.toLowerCase()?.includes(this.searchRound?.toLowerCase() ?? "") ||
x.item.groupAssessment1?.competencyIndicatorsCourses1Mini?.competencyIndicatorsCourses0?.competencyTopic?.competencyTopicId?.toLowerCase()?.includes(this.searchRound?.toLowerCase() ?? ""))
}
searchEmpassessmentListFilterChange() {
this.currentPageRound = 1;
const filteredData = this.empassessmentListFilter();
this.pageRound = Array.from({ length: Math.ceil(filteredData.length / 10) }, (_, i) => i + 1);
}
toggleCheckbox() {
this.isChecked = !this.isChecked; // สลับสถานะ
this.empassessmentRoundListCheckbox.map(item => item.checkbox = this.isChecked);
this.checkempassessmentRoundListCheckbox();
}
checkempassessmentRoundListCheckbox(){
this.numDataListChecked = this.empassessmentRoundListCheckbox.filter(x => x.checkbox).length
this.isChecked = this.numDataListChecked ? true : false
}
deleteFormOne(item:AppraisalRoundModel){
this.selectData = item
}
deleteAssessment() {
let body = this.empassessmentRoundListCheckbox.filter(x => x.checkbox).map(x => x.item)
if(this.typeForm=='deleteFormOne'){
body = [this.selectData]
}
if( body.length == 0){
this.showAlert('กรุณาเลือกรายการ', 'error')
return
}
this.evaluationAssessmentService.deletemMini(body,this.selectEmp.apsassessy.employeeId,this.selectEmp.masfromEvaluationRound.evaluationRoundId).subscribe({
next: response => {
if (response.success) {
this.showAlert(response.message, 'success')
this.getApsassessyMini();
} else {
this.showAlert(response.message, 'error')
}
}
})
}
showAlert(text: string, type: 'success' | 'error') {
this.toastr[type](text, 'แจ้งเตือน', {
timeOut: 3000,
......@@ -148,13 +243,7 @@ export class EditEvaluationFormComponent {
toggleCheckbox() {
this.isChecked = !this.isChecked; // สลับสถานะ
}
addUser() {
}
......
......@@ -354,7 +354,7 @@
<div id="management-evaluation-cycle-person-modal" class="hs-overlay hidden ti-modal">
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out lg:!max-w-4xl lg:w-full m-3 lg:!mx-auto">
<div class="max-h-full overflow-hidden ti-modal-content w-full">
<div class="max-h-full overflow-hidden ti-modal-content w-full rounded-sm shadow-sm">
<div class="ti-modal-header">
<h3 class="text-xxl font-bold text-primary">
เเก้ไขเเบบฟอร์มตามรอบการประเมิน
......
export interface AppraisalRoundModel {
runNo: number;
companyId: string;
groupAssessment1: GroupAssessment1;
}
export interface GroupAssessment1 {
personalLevelModel: PersonalLevelModel;
competencyIndicatorsCourses1Mini: CompetencyIndicatorsCourses1Mini;
companyId: string;
groupAssessmentMini: GroupAssessmentMini;
}
export interface PersonalLevelModel {
plId: string;
tdesc: any;
edesc: any;
companyId: any;
}
export interface CompetencyIndicatorsCourses1Mini {
competencyIndicatorsCourses0: CompetencyIndicatorsCourses0;
lineNo: number;
companyId: string;
competencyCourseId: string;
behavioralIndicatorsList: BehavioralIndicatorsList[];
}
export interface CompetencyIndicatorsCourses0 {
competencyTopic: CompetencyTopic;
companyId: string;
edesc: string;
tdesc: string;
indicatorsCourseDetailTh: string;
indicatorsCourseDetailEn: string;
expectation: any;
}
export interface CompetencyTopic {
competencyTopicId: string;
competencyType: any;
companyId: any;
edesc: any;
tdesc: any;
competencyDetail: any;
competencyFiles: any;
lineNo: any;
}
export interface BehavioralIndicatorsList {
competencyIndicators1: CompetencyIndicators1;
runNo: number;
companyId: string;
assessmentId: string;
behavioralIndicators: string;
competencyBehavioral: CompetencyBehavioral;
}
export interface CompetencyIndicators1 {
competencyIndicatorsCourses0: CompetencyIndicatorsCourses02;
lineNo: number;
companyId: string;
competencyCourseId: string;
}
export interface CompetencyIndicatorsCourses02 {
competencyTopic: CompetencyTopic;
companyId: string;
edesc: string;
tdesc: string;
indicatorsCourseDetailTh: string;
indicatorsCourseDetailEn: string;
}
export interface CompetencyBehavioral {
scoreTopicExpectation: number;
companyId: string;
}
export interface GroupAssessmentMini {
personalLevel: PersonalLevel;
competencyIndicatorsCourses1Mini: any;
companyId: string;
edesc: any;
tdesc: any;
}
export interface PersonalLevel {
plId: string;
tdesc: any;
edesc: any;
companyId: any;
}
// ------------------------- Class Implementation -------------------------
export class MyAppraisalRoundModel implements AppraisalRoundModel {
runNo: number;
companyId: string;
groupAssessment1: GroupAssessment1;
constructor(data?: Partial<AppraisalRoundModel>) {
this.runNo = data?.runNo ?? 0;
this.companyId = data?.companyId || "";
this.groupAssessment1 = new MyGroupAssessment1(data?.groupAssessment1);
}
}
export class MyGroupAssessment1 implements GroupAssessment1 {
personalLevelModel: PersonalLevelModel;
competencyIndicatorsCourses1Mini: CompetencyIndicatorsCourses1Mini;
companyId: string;
groupAssessmentMini: GroupAssessmentMini;
constructor(data?: Partial<GroupAssessment1>) {
this.personalLevelModel = new MyPersonalLevelModel(data?.personalLevelModel);
this.competencyIndicatorsCourses1Mini = new MyCompetencyIndicatorsCourses1Mini(data?.competencyIndicatorsCourses1Mini);
this.companyId = data?.companyId || "";
this.groupAssessmentMini = new MyGroupAssessmentMini(data?.groupAssessmentMini);
}
}
export class MyPersonalLevelModel implements PersonalLevelModel {
plId: string;
tdesc: any;
edesc: any;
companyId: any;
constructor(data?: Partial<PersonalLevelModel>) {
this.plId = data?.plId || "";
this.tdesc = data?.tdesc ?? null;
this.edesc = data?.edesc ?? null;
this.companyId = data?.companyId ?? null;
}
}
export class MyCompetencyIndicatorsCourses1Mini implements CompetencyIndicatorsCourses1Mini {
competencyIndicatorsCourses0: CompetencyIndicatorsCourses0;
lineNo: number;
companyId: string;
competencyCourseId: string;
behavioralIndicatorsList: BehavioralIndicatorsList[];
constructor(data?: Partial<CompetencyIndicatorsCourses1Mini>) {
this.competencyIndicatorsCourses0 = new MyCompetencyIndicatorsCourses0(data?.competencyIndicatorsCourses0);
this.lineNo = data?.lineNo ?? 0;
this.companyId = data?.companyId || "";
this.competencyCourseId = data?.competencyCourseId || "";
this.behavioralIndicatorsList = data?.behavioralIndicatorsList?.map(item => new MyBehavioralIndicatorsList(item)) || [];
}
}
export class MyCompetencyIndicatorsCourses0 implements CompetencyIndicatorsCourses0 {
competencyTopic: CompetencyTopic;
companyId: string;
edesc: string;
tdesc: string;
indicatorsCourseDetailTh: string;
indicatorsCourseDetailEn: string;
expectation: any;
constructor(data?: Partial<CompetencyIndicatorsCourses0>) {
this.competencyTopic = new CompetencyTopicModel(data?.competencyTopic);
this.companyId = data?.companyId || "";
this.edesc = data?.edesc || "";
this.tdesc = data?.tdesc || "";
this.indicatorsCourseDetailTh = data?.indicatorsCourseDetailTh || "";
this.indicatorsCourseDetailEn = data?.indicatorsCourseDetailEn || "";
this.expectation = data?.expectation ?? null;
}
}
export class MyBehavioralIndicatorsList implements BehavioralIndicatorsList {
competencyIndicators1: CompetencyIndicators1;
runNo: number;
companyId: string;
assessmentId: string;
behavioralIndicators: string;
competencyBehavioral: CompetencyBehavioral;
constructor(data?: Partial<BehavioralIndicatorsList>) {
this.competencyIndicators1 = new MyCompetencyIndicators1(data?.competencyIndicators1);
this.runNo = data?.runNo ?? 0;
this.companyId = data?.companyId || "";
this.assessmentId = data?.assessmentId || "";
this.behavioralIndicators = data?.behavioralIndicators || "";
this.competencyBehavioral = new MyCompetencyBehavioral(data?.competencyBehavioral);
}
}
export class MyCompetencyIndicators1 implements CompetencyIndicators1 {
competencyIndicatorsCourses0: CompetencyIndicatorsCourses02;
lineNo: number;
companyId: string;
competencyCourseId: string;
constructor(data?: Partial<CompetencyIndicators1>) {
this.competencyIndicatorsCourses0 = new MyCompetencyIndicatorsCourses0(data?.competencyIndicatorsCourses0);
this.lineNo = data?.lineNo ?? 0;
this.companyId = data?.companyId || "";
this.competencyCourseId = data?.competencyCourseId || "";
}
}
export class MyCompetencyBehavioral implements CompetencyBehavioral {
scoreTopicExpectation: number;
companyId: string;
constructor(data?: Partial<CompetencyBehavioral>) {
this.scoreTopicExpectation = data?.scoreTopicExpectation ?? 0;
this.companyId = data?.companyId || "";
}
}
export class MyGroupAssessmentMini implements GroupAssessmentMini {
personalLevel: PersonalLevel;
competencyIndicatorsCourses1Mini: any;
companyId: string;
edesc: any;
tdesc: any;
constructor(data?: Partial<GroupAssessmentMini>) {
this.personalLevel = new MyPersonalLevel(data?.personalLevel);
this.competencyIndicatorsCourses1Mini = data?.competencyIndicatorsCourses1Mini ?? null;
this.companyId = data?.companyId || "";
this.edesc = data?.edesc ?? null;
this.tdesc = data?.tdesc ?? null;
}
}
export class MyPersonalLevel implements PersonalLevel {
plId: string;
tdesc: any;
edesc: any;
companyId: any;
constructor(data?: Partial<PersonalLevel>) {
this.plId = data?.plId || "";
this.tdesc = data?.tdesc ?? null;
this.edesc = data?.edesc ?? null;
this.companyId = data?.companyId ?? null;
}
}
export class CompetencyTopicModel implements CompetencyTopic {
competencyTopicId: string;
competencyType: any;
companyId: any;
edesc: any;
tdesc: any;
competencyDetail: any;
competencyFiles: any;
lineNo: any;
constructor(data: Partial<CompetencyTopic> = {}) {
this.competencyTopicId = data.competencyTopicId || "";
this.competencyType = data.competencyType ?? null;
this.companyId = data.companyId ?? null;
this.edesc = data.edesc ?? null;
this.tdesc = data.tdesc ?? null;
this.competencyDetail = data.competencyDetail ?? null;
this.competencyFiles = data.competencyFiles ?? null;
this.lineNo = data.lineNo ?? null;
}
}
\ No newline at end of file
......@@ -4,6 +4,8 @@ import { Observable } from 'rxjs';
import { environment } from 'src/environments/environment';
import { AlertModel } from '../model/alert.model';
import { EvaluationCycleModel } from '../model/evaluation-cycle.model';
import { AppraisalModel } from '../model/appraisal.model';
import { AppraisalRoundModel } from '../model/appraisal-aps.model';
@Injectable({
providedIn: 'root'
......@@ -19,8 +21,11 @@ export class EvaluationAssessmentService {
getById(evaluationRoundId: string): Observable<any[]> {
return this.http.get<any[]>(this.urlApi + "/" + evaluationRoundId)
}
getApsassessy(evaluationRoundId: string,apsassessy:string): Observable<EvaluationCycleModel> {
return this.http.get<EvaluationCycleModel>(this.urlApi + "/" + evaluationRoundId+"/"+apsassessy)
getApsassessy(evaluationRoundId: string,apsassessy:string): Observable<AppraisalModel[]> {
return this.http.get<AppraisalModel[]>(this.urlApi + "/" + evaluationRoundId+"/"+apsassessy)
}
getApsassessyMini(evaluationRoundId: string,apsassessy:string): Observable<AppraisalRoundModel[]> {
return this.http.get<AppraisalRoundModel[]>(this.urlApi + "/mini/" + evaluationRoundId+"/"+apsassessy)
}
post(body: EvaluationCycleModel): Observable<AlertModel> {
return this.http.post<AlertModel>(this.urlApi, body)
......@@ -37,4 +42,14 @@ export class EvaluationAssessmentService {
};
return this.http.delete<AlertModel>(this.urlApi, options)
}
deletemMini(body: AppraisalRoundModel[],apsassessy:string,evaluationRoundId:string): Observable<AlertModel> {
const options = {
headers: new HttpHeaders({
"Content-Type": "application/json",
}),
body: body
};
return this.http.delete<AlertModel>(this.urlApi+'/delete-mini'+"/"+apsassessy+"/"+evaluationRoundId, options)
}
}
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