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="flex justify-between">
<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 class="flex justify-end">
<div class="px-1">
......@@ -111,12 +96,12 @@
</td>
<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"
(click)="modalStatus='edit';onEdit()"></i>
<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>
(click)="modalStatus='edit';onEdit(item)"></i>
<!-- <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> -->
<span *ngIf="item.statusCode.code !== '2'" class="badge text-white m-1 cursor-pointer bg-primary"
(click)="basicAlert3()">สร้างแบบฟอร์ม</span>
<!-- <span *ngIf="item.statusCode.code !== '2'" class="badge text-white m-1 cursor-pointer bg-primary"
(click)="basicAlert3()">สร้างแบบฟอร์ม</span> -->
</td>
</tr>
......@@ -162,7 +147,7 @@
</ul>
</nav>
</div>
</ng-container>
<div id="define-document-form-modal" class="hs-overlay hidden ti-modal ">
<div class=" ti-modal-box ease-out modal-md">
......@@ -329,4 +314,7 @@
</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 {
styleUrls: ['./define-document-form.component.scss'],
})
export class DefineDocumentFormComponent {
[x: string]: any;
@Output() sendGroupShow: EventEmitter<string> = new EventEmitter<string>();
// @Output() evaluationRound: EventEmitter<DataModel> = new EventEmitter<DataModel>();
currentPage = 1;
page = Array.from({ length: 1 }, (_, i) => i + 1);
search = '';
......@@ -36,6 +37,8 @@ export class DefineDocumentFormComponent {
isDataListCheckedAll = false;
modalStatus: 'add' | 'edit' = 'add';
evaluation_cyclelist:DataModel[] = []
evaluationRound?:DataModel
showFrom = false
constructor(
private cdr: ChangeDetectorRef,
private swalService: SwalService,
......@@ -43,8 +46,9 @@ export class DefineDocumentFormComponent {
private toastr: ToastrService
) {}
onEdit() {
this.sendGroupShow.emit('2');
onEdit(evaluationRound:DataModel) {
this.evaluationRound = evaluationRound;
this.showFrom = true
}
ngOnInit(): void {
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 { 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({
selector: 'app-edit-define-document-form',
templateUrl: './edit-define-document-form.component.html',
styleUrls: ['./edit-define-document-form.component.scss']
})
export class EditDefineDocumentFormComponent {
@ViewChild('modalEdit') modalEdit!: ElementRef;
@Input() pathTitle = ['การประเมินสมรรถนะ', 'การจัดการสมรรถนะ', 'จัดกลุ่มสมรรถนะ'];
@Output() sendPathTitle: EventEmitter<string[]> = new EventEmitter<string[]>();
@Output() sendGroupShow: EventEmitter<string> = new EventEmitter<string>();
activeTab: string = 'tab1'; // กำหนด tab เริ่มต้น
@Input() evaluationRound?: DataModel;
@Output() showFrom: EventEmitter<boolean> = new EventEmitter<boolean>();
currentPage = 1;
page = Array.from({ length: 1 }, (_, i) => i + 1);
currentModal = "";
search = '';
assessmentList:any[]=[]
loadingAssess= false
// ฟังก์ชันในการเปลี่ยนแท็บ
changeTab(tab: { id: string, text: string }) {
this.sendPathTitle.emit(['การประเมินสมรรถนะ', 'การจัดการสมรรถนะ', tab.text]);
this.activeTab = tab.id;
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 {
}
}
})
}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() {
this.sendGroupShow.emit('1'); // เปลี่ยนกลับไปหน้า 1
this.showFrom.emit(false);
}
// การจัดการการเปิดปิด modal
modalOptions: {
......@@ -40,15 +122,35 @@ export class EditDefineDocumentFormComponent {
backdropClose: true,
}
};
openEdit() {
const modalElement = this.modalEdit.nativeElement;
openModalTest(id: string) {
document.getElementById(id)?.classList.add('open');
document.getElementById(id)?.classList.remove('hidden');
setTimeout(() => {
modalElement.setAttribute('aria-overlay', 'false');
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(evaluationRoundId:string,apsassessy:string) {
if(evaluationRoundId&&apsassessy){
const modalElement = this.modalEdit.nativeElement;
setTimeout(() => {
modalElement.setAttribute('aria-overlay', 'false');
console.log("🚀 ~ EditDefineDocumentFormComponent ~ openEdit ~ modalElement:", modalElement)
}, 10);
this.evaluationRoundId = evaluationRoundId
this.apsassessy = apsassessy
this.getApsassessy()
}
}
dataListCheck(){
console.log( this.assessmentList);
}
openModal(name: string, size: string, closeOnBackdrop?: boolean) {
this.modalOptions[name].modalSize = size;
this.modalOptions[name].backdropClose = closeOnBackdrop || false;
......@@ -79,10 +181,12 @@ export class EditDefineDocumentFormComponent {
addUser() {
}
currentModal = "";
constructor(private toastr: ToastrService) { }
showAlert(text: string, type: 'success' | 'error') {
this.toastr[type](text, 'แจ้งเตือน', {
timeOut: 3000,
positionClass: 'toast-top-right',
});
}
showSuccess() {
this.toastr.success('บันทึกข้อมูลสำเร็จ', 'เเจ้งเตือน', {
......
......@@ -28,10 +28,7 @@
</div>
<div id="underline-2" role="tabpanel" aria-labelledby="underline-item-2"
*ngIf="activeTab === 'underline-2'">
<app-define-document-form *ngIf="groupShow=='1'"
(sendGroupShow)="groupShow=$event"></app-define-document-form>
<app-edit-define-document-form *ngIf="groupShow=='2'"
(sendGroupShow)="groupShow=$event"></app-edit-define-document-form>
<app-define-document-form *ngIf="groupShow=='1'" (sendGroupShow)="groupShow=$event"></app-define-document-form>
</div>
</div>
......
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { StatusCodeModel } from 'src/app/shared/model/status-code.model';
@Component({
selector: 'app-evaluation-cycle-manager',
templateUrl: './evaluation-cycle-manager.component.html',
styleUrls: ['./evaluation-cycle-manager.component.scss']
})
export class EvaluationCycleManagerComponent {
@Input() pathTitle = ['การประเมินสมรรถนะ', 'การจัดการรอบการประเมิน', 'รอบการประเมิน']
activeTab: string = 'underline-1'; // Tab แรกแสดงเป็นค่าเริ่มต้น
activeTab: string = 'underline-2'; // Tab แรกแสดงเป็นค่าเริ่มต้น
groupShow = '1'
}
\ No newline at end of file
......@@ -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 { 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 { EvaluationAssessmentService } from 'src/app/shared/services/evaluation-assessment.service';
export const MY_DATE_FORMATS = {
parse: {
......@@ -330,6 +331,7 @@ export class CustomDateAdapter extends NativeDateAdapter {
PmsMasfromEvaluationCycleService,
PmsGroupGradeService,
PmsSettingAssessmentService,
EvaluationAssessmentService,
{
provide: HTTP_INTERCEPTORS,
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 {
getById(evaluationRoundId: string): Observable<EvaluationCycleModel> {
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> {
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