Commit dee8abcf by Nakarin Luankla

UPDATE evaluation-cycle-manager

parent 0407d6c0
<ng-container *ngIf="!showFrom" >
<div class="w-full min-height-50px mb-10px justify-between items-center"> <div class="w-full min-height-50px mb-10px justify-between items-center">
<div class="flex justify-between"> <div class="flex justify-between">
<div class="flex pr-2"> <div class="flex pr-2">
<!-- <div class="flex">
<div class="flex items-center">
<input type="checkbox" class="ti-form-checkbox pointer-events-none" id="hs-default-checkbox"
[(ngModel)]="isDataListChecked">
<label for="hs-default-checkbox" class="text-sm text-gray-500 mx-2 pointer-events-none">
{{numDataListChecked}} Selected</label>
</div>
<div class="mx-1 flex items-center">
<button (click)="isDataListCheckedAll = !isDataListCheckedAll;dataListCheckAll()"
class="focus:ring-2 focus:ring-primary rounded-sm flex item-center">
<i class="fs-l transition-all duration-200"
[ngClass]="{'ri-checkbox-multiple-line text-gray-500': !isDataListCheckedAll, 'ri-checkbox-multiple-fill text-primary': isDataListCheckedAll}"></i>
</button>
<label class="text-sm text-gray-500 ml-2">Select All</label>
</div>
</div> -->
</div> </div>
<div class="flex justify-end"> <div class="flex justify-end">
<div class="px-1"> <div class="px-1">
...@@ -111,12 +96,12 @@ ...@@ -111,12 +96,12 @@
</td> </td>
<td class="flex justify-center items-center"> <td class="flex justify-center items-center">
<i *ngIf="item.statusCode.code !== '2'" class="ti ti-edit cursor-pointer i-gray fs-l px-1" <i *ngIf="item.statusCode.code !== '2'" class="ti ti-edit cursor-pointer i-gray fs-l px-1"
(click)="modalStatus='edit';onEdit()"></i> (click)="modalStatus='edit';onEdit(item)"></i>
<i *ngIf="item.statusCode.code !== '2'" class="ti ti-trash cursor-pointer i-gray fs-l px-1" <!-- <i *ngIf="item.statusCode.code !== '2'" class="ti ti-trash cursor-pointer i-gray fs-l px-1"
data-hs-overlay="#define-document-form-delete-modal"></i> data-hs-overlay="#define-document-form-delete-modal"></i> -->
<span *ngIf="item.statusCode.code !== '2'" class="badge text-white m-1 cursor-pointer bg-primary" <!-- <span *ngIf="item.statusCode.code !== '2'" class="badge text-white m-1 cursor-pointer bg-primary"
(click)="basicAlert3()">สร้างแบบฟอร์ม</span> (click)="basicAlert3()">สร้างแบบฟอร์ม</span> -->
</td> </td>
</tr> </tr>
...@@ -162,7 +147,7 @@ ...@@ -162,7 +147,7 @@
</ul> </ul>
</nav> </nav>
</div> </div>
</ng-container>
<div id="define-document-form-modal" class="hs-overlay hidden ti-modal "> <div id="define-document-form-modal" class="hs-overlay hidden ti-modal ">
<div class=" ti-modal-box ease-out modal-md"> <div class=" ti-modal-box ease-out modal-md">
...@@ -329,4 +314,7 @@ ...@@ -329,4 +314,7 @@
</div> </div>
</div> </div>
<ng-container *ngIf="showFrom" >
<app-edit-define-document-form [evaluationRound]="evaluationRound" (showFrom)="showFrom=$event"></app-edit-define-document-form>
</ng-container>
...@@ -26,8 +26,9 @@ export interface DataModel { ...@@ -26,8 +26,9 @@ export interface DataModel {
styleUrls: ['./define-document-form.component.scss'], styleUrls: ['./define-document-form.component.scss'],
}) })
export class DefineDocumentFormComponent { export class DefineDocumentFormComponent {
[x: string]: any;
@Output() sendGroupShow: EventEmitter<string> = new EventEmitter<string>(); @Output() sendGroupShow: EventEmitter<string> = new EventEmitter<string>();
// @Output() evaluationRound: EventEmitter<DataModel> = new EventEmitter<DataModel>();
currentPage = 1; currentPage = 1;
page = Array.from({ length: 1 }, (_, i) => i + 1); page = Array.from({ length: 1 }, (_, i) => i + 1);
search = ''; search = '';
...@@ -36,6 +37,8 @@ export class DefineDocumentFormComponent { ...@@ -36,6 +37,8 @@ export class DefineDocumentFormComponent {
isDataListCheckedAll = false; isDataListCheckedAll = false;
modalStatus: 'add' | 'edit' = 'add'; modalStatus: 'add' | 'edit' = 'add';
evaluation_cyclelist:DataModel[] = [] evaluation_cyclelist:DataModel[] = []
evaluationRound?:DataModel
showFrom = false
constructor( constructor(
private cdr: ChangeDetectorRef, private cdr: ChangeDetectorRef,
private swalService: SwalService, private swalService: SwalService,
...@@ -43,8 +46,9 @@ export class DefineDocumentFormComponent { ...@@ -43,8 +46,9 @@ export class DefineDocumentFormComponent {
private toastr: ToastrService private toastr: ToastrService
) {} ) {}
onEdit() { onEdit(evaluationRound:DataModel) {
this.sendGroupShow.emit('2'); this.evaluationRound = evaluationRound;
this.showFrom = true
} }
ngOnInit(): void { ngOnInit(): void {
this.getEvaluationCycleList(); this.getEvaluationCycleList();
......
import { Component, ElementRef, EventEmitter, Input, Output, ViewChild } from '@angular/core'; import { ChangeDetectorRef, Component, ElementRef, EventEmitter, Input, Output, ViewChild } from '@angular/core';
import { ToastrService } from 'ngx-toastr'; import { ToastrService } from 'ngx-toastr';
import { StatusCodeModel } from 'src/app/shared/model/status-code.model';
import { EvaluationAssessmentService } from 'src/app/shared/services/evaluation-assessment.service';
import { EvaluationCycleService } from 'src/app/shared/services/evaluation-cycle.service';
export interface DataModel {
evaluationRoundId: string;
tdesc: string;
edesc: string;
apsyear: string;
apsPeriodStart: string;
apsPeriodEnd: string;
statusCode: StatusCodeModel;
}
@Component({ @Component({
selector: 'app-edit-define-document-form', selector: 'app-edit-define-document-form',
templateUrl: './edit-define-document-form.component.html', templateUrl: './edit-define-document-form.component.html',
styleUrls: ['./edit-define-document-form.component.scss'] styleUrls: ['./edit-define-document-form.component.scss']
}) })
export class EditDefineDocumentFormComponent { export class EditDefineDocumentFormComponent {
@ViewChild('modalEdit') modalEdit!: ElementRef; @ViewChild('modalEdit') modalEdit!: ElementRef;
@Input() pathTitle = ['การประเมินสมรรถนะ', 'การจัดการสมรรถนะ', 'จัดกลุ่มสมรรถนะ']; @Input() evaluationRound?: DataModel;
@Output() sendPathTitle: EventEmitter<string[]> = new EventEmitter<string[]>(); @Output() showFrom: EventEmitter<boolean> = new EventEmitter<boolean>();
@Output() sendGroupShow: EventEmitter<string> = new EventEmitter<string>(); currentPage = 1;
activeTab: string = 'tab1'; // กำหนด tab เริ่มต้น page = Array.from({ length: 1 }, (_, i) => i + 1);
currentModal = "";
search = '';
assessmentList:any[]=[]
loadingAssess= false
evaluationRoundId = ""
apsassessy = ""
constructor(private toastr: ToastrService,
private evaluationAssessmentService: EvaluationAssessmentService,
private cdr: ChangeDetectorRef) {
}
ngOnInit(): void {
if(this.evaluationRound){
this.getEvaluationCycleList()
}
}
saveAssessmentList(){
let body = this.assessmentList.filter(x => x.active == true)
if(body.length > 0){
this.evaluationAssessmentService.postList(body).subscribe({
next: response => {
if (response.success) {
this.showAlert(response.message, 'success')
this.getEvaluationCycleList()
} else {
// ฟังก์ชันในการเปลี่ยนแท็บ
changeTab(tab: { id: string, text: string }) {
this.sendPathTitle.emit(['การประเมินสมรรถนะ', 'การจัดการสมรรถนะ', tab.text]);
this.activeTab = tab.id;
} }
}
})
}else{
this.showAlert('ไม่พบรายการ', 'error')
}
}
getApsassessy(){
this.loadingAssess = true
this.evaluationAssessmentService.getApsassessy(this.evaluationRoundId,this.apsassessy).subscribe({
next: response => {
this.loadingAssess = false
this.cdr.detectChanges();
},
error: err => {
this.loadingAssess = false
console.error('Error fetching evaluation cycles:', err);
}
})
}
searchChange() {
this.currentPage = 1
this.page = Array.from({ length: Math.ceil(this.assessmentListFilter().length / 10) }, (_, i) => i + 1);
}
getEvaluationCycleList() {
this.evaluationAssessmentService.getById(this.evaluationRound!.evaluationRoundId).subscribe({
next: response => {
this.assessmentList = response
this.cdr.detectChanges();
},
error: err => {
console.error('Error fetching evaluation cycles:', err);
}
});
}
assessmentListFilter(){
return this.assessmentList.filter(x =>
x.apsassessy.fname.toLowerCase().includes(this.search.toLowerCase()) ||
x.apsassessy.lname.toLowerCase().includes(this.search.toLowerCase()) ||
x.apsassessy.efname.toLowerCase().includes(this.search.toLowerCase()) ||
x.apsassessy.elname.toLowerCase().includes(this.search.toLowerCase()) ||
x.apsassessy.employeeId.toLowerCase().includes(this.search.toLowerCase())
)
}
onBack() { onBack() {
this.sendGroupShow.emit('1'); // เปลี่ยนกลับไปหน้า 1 this.showFrom.emit(false);
} }
// การจัดการการเปิดปิด modal // การจัดการการเปิดปิด modal
modalOptions: { modalOptions: {
...@@ -40,15 +122,35 @@ export class EditDefineDocumentFormComponent { ...@@ -40,15 +122,35 @@ export class EditDefineDocumentFormComponent {
backdropClose: true, backdropClose: true,
} }
}; };
openModalTest(id: string) {
document.getElementById(id)?.classList.add('open');
document.getElementById(id)?.classList.remove('hidden');
setTimeout(() => {
document.getElementById(id)?.setAttribute('aria-overlay', 'true')
document.getElementById(id)?.setAttribute('tabindex', '0')
}, 10);
console.log("🚀 ~ EditDefineDocumentFormComponent ~ openModalTest ~ document.getElementById(id):", document.getElementById(id))
}
openEdit() { openEdit(evaluationRoundId:string,apsassessy:string) {
if(evaluationRoundId&&apsassessy){
const modalElement = this.modalEdit.nativeElement; const modalElement = this.modalEdit.nativeElement;
setTimeout(() => { setTimeout(() => {
modalElement.setAttribute('aria-overlay', 'false'); modalElement.setAttribute('aria-overlay', 'false');
console.log("🚀 ~ EditDefineDocumentFormComponent ~ openEdit ~ modalElement:", modalElement)
}, 10); }, 10);
this.evaluationRoundId = evaluationRoundId
this.apsassessy = apsassessy
this.getApsassessy()
} }
}
dataListCheck(){
console.log( this.assessmentList);
}
openModal(name: string, size: string, closeOnBackdrop?: boolean) { openModal(name: string, size: string, closeOnBackdrop?: boolean) {
this.modalOptions[name].modalSize = size; this.modalOptions[name].modalSize = size;
this.modalOptions[name].backdropClose = closeOnBackdrop || false; this.modalOptions[name].backdropClose = closeOnBackdrop || false;
...@@ -79,10 +181,12 @@ export class EditDefineDocumentFormComponent { ...@@ -79,10 +181,12 @@ export class EditDefineDocumentFormComponent {
addUser() { addUser() {
} }
showAlert(text: string, type: 'success' | 'error') {
currentModal = ""; this.toastr[type](text, 'แจ้งเตือน', {
timeOut: 3000,
constructor(private toastr: ToastrService) { } positionClass: 'toast-top-right',
});
}
showSuccess() { showSuccess() {
this.toastr.success('บันทึกข้อมูลสำเร็จ', 'เเจ้งเตือน', { this.toastr.success('บันทึกข้อมูลสำเร็จ', 'เเจ้งเตือน', {
......
...@@ -28,10 +28,7 @@ ...@@ -28,10 +28,7 @@
</div> </div>
<div id="underline-2" role="tabpanel" aria-labelledby="underline-item-2" <div id="underline-2" role="tabpanel" aria-labelledby="underline-item-2"
*ngIf="activeTab === 'underline-2'"> *ngIf="activeTab === 'underline-2'">
<app-define-document-form *ngIf="groupShow=='1'" <app-define-document-form *ngIf="groupShow=='1'" (sendGroupShow)="groupShow=$event"></app-define-document-form>
(sendGroupShow)="groupShow=$event"></app-define-document-form>
<app-edit-define-document-form *ngIf="groupShow=='2'"
(sendGroupShow)="groupShow=$event"></app-edit-define-document-form>
</div> </div>
</div> </div>
......
import { Component, EventEmitter, Input, Output } from '@angular/core'; import { Component, EventEmitter, Input, Output } from '@angular/core';
import { StatusCodeModel } from 'src/app/shared/model/status-code.model';
@Component({ @Component({
selector: 'app-evaluation-cycle-manager', selector: 'app-evaluation-cycle-manager',
templateUrl: './evaluation-cycle-manager.component.html', templateUrl: './evaluation-cycle-manager.component.html',
styleUrls: ['./evaluation-cycle-manager.component.scss'] styleUrls: ['./evaluation-cycle-manager.component.scss']
}) })
export class EvaluationCycleManagerComponent { export class EvaluationCycleManagerComponent {
@Input() pathTitle = ['การประเมินสมรรถนะ', 'การจัดการรอบการประเมิน', 'รอบการประเมิน'] @Input() pathTitle = ['การประเมินสมรรถนะ', 'การจัดการรอบการประเมิน', 'รอบการประเมิน']
activeTab: string = 'underline-1'; // Tab แรกแสดงเป็นค่าเริ่มต้น activeTab: string = 'underline-2'; // Tab แรกแสดงเป็นค่าเริ่มต้น
groupShow = '1' groupShow = '1'
} }
\ No newline at end of file
...@@ -150,6 +150,7 @@ import { PmsGradeRegistrationComponent } from '../performance-management-evaluat ...@@ -150,6 +150,7 @@ import { PmsGradeRegistrationComponent } from '../performance-management-evaluat
import { PmsGradeManagementComponent } from '../performance-management-evaluation/pms-grade-registration/pms-grade-management/pms-grade-management.component'; import { PmsGradeManagementComponent } from '../performance-management-evaluation/pms-grade-registration/pms-grade-management/pms-grade-management.component';
import { PmsSubGradeRegistrationComponent } from '../performance-management-evaluation/pms-grade-registration/pms-grade-management/pms-sub-grade-registration/pms-sub-grade-registration.component'; import { PmsSubGradeRegistrationComponent } from '../performance-management-evaluation/pms-grade-registration/pms-grade-management/pms-sub-grade-registration/pms-sub-grade-registration.component';
import { PmsGroupGradeComponent } from '../performance-management-evaluation/pms-grade-registration/pms-grade-management/pms-group-grade/pms-group-grade.component'; import { PmsGroupGradeComponent } from '../performance-management-evaluation/pms-grade-registration/pms-grade-management/pms-group-grade/pms-group-grade.component';
import { EvaluationAssessmentService } from 'src/app/shared/services/evaluation-assessment.service';
export const MY_DATE_FORMATS = { export const MY_DATE_FORMATS = {
parse: { parse: {
...@@ -330,6 +331,7 @@ export class CustomDateAdapter extends NativeDateAdapter { ...@@ -330,6 +331,7 @@ export class CustomDateAdapter extends NativeDateAdapter {
PmsMasfromEvaluationCycleService, PmsMasfromEvaluationCycleService,
PmsGroupGradeService, PmsGroupGradeService,
PmsSettingAssessmentService, PmsSettingAssessmentService,
EvaluationAssessmentService,
{ {
provide: HTTP_INTERCEPTORS, provide: HTTP_INTERCEPTORS,
useClass: HttpRequestInterceptor, useClass: HttpRequestInterceptor,
......
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { environment } from 'src/environments/environment';
import { AlertModel } from '../model/alert.model';
import { EvaluationCycleModel } from '../model/evaluation-cycle.model';
@Injectable({
providedIn: 'root'
})
export class EvaluationAssessmentService {
api = "/evaluation-assessment"
urlApi = environment.baseUrl + this.api
constructor(private http: HttpClient) {
}
getList(): Observable<EvaluationCycleModel[]> {
return this.http.get<EvaluationCycleModel[]>(this.urlApi + "/lists")
}
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)
}
post(body: EvaluationCycleModel): Observable<AlertModel> {
return this.http.post<AlertModel>(this.urlApi, body)
}
postList(body:any[]): Observable<AlertModel> {
return this.http.post<AlertModel>(this.urlApi+"/create-list", body)
}
delete(body: EvaluationCycleModel | EvaluationCycleModel[]): Observable<AlertModel> {
const options = {
headers: new HttpHeaders({
"Content-Type": "application/json",
}),
body: body
};
return this.http.delete<AlertModel>(this.urlApi, options)
}
}
...@@ -19,6 +19,9 @@ export class EvaluationCycleService { ...@@ -19,6 +19,9 @@ export class EvaluationCycleService {
getById(evaluationRoundId: string): Observable<EvaluationCycleModel> { getById(evaluationRoundId: string): Observable<EvaluationCycleModel> {
return this.http.get<EvaluationCycleModel>(this.urlApi + "/" + evaluationRoundId) return this.http.get<EvaluationCycleModel>(this.urlApi + "/" + evaluationRoundId)
} }
getApsassessy(evaluationRoundId: string,apsassessy:string): Observable<EvaluationCycleModel> {
return this.http.get<EvaluationCycleModel>(this.urlApi + "/" + evaluationRoundId+"/"+apsassessy)
}
post(body: EvaluationCycleModel): Observable<AlertModel> { post(body: EvaluationCycleModel): Observable<AlertModel> {
return this.http.post<AlertModel>(this.urlApi, body) return this.http.post<AlertModel>(this.urlApi, body)
} }
......
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