การประเมินสมรรถนะ>การจัดรอบการประเมิน เเละ การประเมินสมรรถนะ>การตั้งค่า

parent 4e8508bd
import { ChangeDetectorRef, Component, EventEmitter, Input, Output } from '@angular/core'; import { ChangeDetectorRef, Component} from '@angular/core';
import { ToastrService } from 'ngx-toastr'; 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';
import { MyStatusCodeModel, StatusCodeModel } from 'src/app/shared/model/status-code.model';
export interface DataModel { export interface DataModel {
check: boolean, evaluationRoundId: string;
code: string, tdesc: string;
period: string, edesc: string;
year: string, apsyear: string;
startDate: string, apsPeriodStart: string;
endDate: string, apsPeriodEnd: string;
status: string statusCode: StatusCodeModel;
} }
@Component({ @Component({
...@@ -17,94 +20,133 @@ export interface DataModel { ...@@ -17,94 +20,133 @@ export interface DataModel {
styleUrls: ['./evaluation-cycle.component.scss'] styleUrls: ['./evaluation-cycle.component.scss']
}) })
export class EvaluationCycleComponent { export class EvaluationCycleComponent {
currentPage = 1 apsPeriodStart: string = '';
page = Array.from({ length: 1 }, (_, i) => i + 1); apsPeriodEnd: string = '';
search = ""
numDataListChecked = 0
isDataListChecked = false
isDataListCheckedAll = false
dataList: DataModel[] = [
{
check: false,
code: "Y67P2",
period: "ช่วงเวลาที่ 2",
year: "2567",
startDate: "01-07-2567",
endDate: "31-12-2567",
status: "1"
},
{
check: false,
code: "Y68P1",
period: "ช่วงเวลาที่ 1",
year: "2568",
startDate: "01-01-2568",
endDate: "30-06-2568",
status: "2"
},
{
check: false,
code: "Y67P1",
period: "ช่วงเวลาที่ 1",
year: "2567",
startDate: "01-01-2567",
endDate: "30-06-2567",
status: "3"
},
]
dataSelect: DataModel = {
check: false,
code: "",
period: "",
year: "",
startDate: "",
endDate: "",
status: "",
}
modalStatus: "add" | "edit" = "add"
constructor(private cdr: ChangeDetectorRef) {
}
dataListSelect(data?: DataModel) { currentPage = 1
this.dataSelect = data || { page = Array.from({ length: 1 }, (_, i) => i + 1);
check: false, search = ""
code: "", modalStatus = 'add'
period: "", evaluation_cyclelist: { check: boolean, data: DataModel }[] = []
year: "", evaluation_cycle: EvaluationCycleModel = new MyEvaluationCycleModel({})
startDate: "", dataLoading = false
endDate: "", dataSelect: DataModel = { evaluationRoundId: "", tdesc: "", edesc: "", apsyear: "", apsPeriodStart: "", apsPeriodEnd: "", statusCode: new MyStatusCodeModel({})}
status: "", itemToDelete: EvaluationCycleModel | null = null;
} isDataListChecked = false
this.cdr.detectChanges() isDataListCheckedAll = false
} numDataListChecked = 0
dataListFilter() { constructor(private evaluationCycleService: EvaluationCycleService,
return this.dataList.filter(x => { private toastr: ToastrService,
const match = x.code.includes(this.search) || x.period.includes(this.search); private cdr: ChangeDetectorRef
if (!match) x.check = false; ) { }
return match;
}); ngOnInit(): void {
} this.getEvaluationCycleList()
}
dataListCheck() { getEvaluationCycleList() {
const dataCheck = this.dataListFilter(); this.evaluationCycleService.getList().subscribe({
this.isDataListChecked = dataCheck.some(x => x.check); next: response => {
this.isDataListCheckedAll = dataCheck.length ? dataCheck.every(x => x.check) : false; console.log('API response:', response);
this.numDataListChecked = dataCheck.filter(x => x.check).length; this.evaluation_cyclelist = response.map(x => ({
} check: false,
data: {
evaluationRoundId: x.evaluationRoundId,
tdesc: x.tdesc,
edesc: x.edesc,
apsyear: x.apsyear,
apsPeriodStart: x.apsPeriodStart,
apsPeriodEnd: x.apsPeriodEnd,
statusCode: new MyStatusCodeModel(x.statusCode || {})
}
}));
this.searchChange();
this.cdr.detectChanges();
},
error: err => {
console.error('Error fetching evaluation cycles:', err);
}
});
}
dataListCheck() {
const dataCheck = this.evaluation_cycleListFilter();
this.isDataListChecked = dataCheck.some(x => x.check);
this.isDataListCheckedAll = dataCheck.length ? dataCheck.every(x => x.check) : false;
this.numDataListChecked = dataCheck.filter(x => x.check).length;
}
dataListCheckAll() {
const selectAll = this.isDataListCheckedAll;
this.evaluation_cyclelist.forEach(x => x.check = selectAll);
this.dataListCheck();
}
dataListCheckAll() { searchChange() {
const selectAll = this.isDataListCheckedAll; this.currentPage = 1
this.dataList.forEach(x => x.check = selectAll); this.page = Array.from({ length: Math.ceil(this.evaluation_cycleListFilter().length / 10) }, (_, i) => i + 1);
this.dataListCheck(); }
} evaluation_cycleListFilter() {
return this.evaluation_cyclelist.filter(x => {
const data = x.data
const match = data.evaluationRoundId.includes(this.search) || data.tdesc.includes(this.search) || data.edesc.includes(this.search);
return match;
});
}
setData(data?: DataModel) {
this.dataSelect = JSON.parse(JSON.stringify(data || {
evaluationRoundId: "",
tdesc: "",
edesc: "",
apsyear: "",
apsPeriodStart: "",
apsPeriodEnd: "",
statusCode: new MyStatusCodeModel({})
}));
}
addevaluation_cycle() {
const body = new MyEvaluationCycleModel({ evaluationRoundId: this.dataSelect.evaluationRoundId, tdesc: this.dataSelect.tdesc, edesc: this.dataSelect.edesc, apsyear: this.dataSelect.apsyear, apsPeriodStart: this.dataSelect.apsPeriodStart, apsPeriodEnd: this.dataSelect.apsPeriodEnd, statusCode: this.dataSelect.statusCode })
this.evaluationCycleService.post(body).subscribe({
next: response => {
if (response.success) {
this.showAlert(response.message, 'success')
this.getEvaluationCycleList()
} else {
this.showAlert(response.message, 'error')
}
}, error: error => {
this.showAlert(error.message, 'error')
}
})
}
searchChange() { deleteevaluation_cycle() {
this.currentPage = 1; let body: EvaluationCycleModel | EvaluationCycleModel[] = []
const filteredData = this.dataListFilter(); if (this.dataSelect.evaluationRoundId) {
this.page = Array.from({ length: Math.ceil(filteredData.length / 10) }, (_, i) => i + 1); body = new MyEvaluationCycleModel({ evaluationRoundId: this.dataSelect.evaluationRoundId, tdesc: this.dataSelect.tdesc, edesc: this.dataSelect.edesc, apsyear: this.dataSelect.apsyear, apsPeriodStart: this.dataSelect.apsPeriodStart, apsPeriodEnd: this.dataSelect.apsPeriodEnd, statusCode: this.dataSelect.statusCode })
this.dataListCheck(); } else {
body = this.evaluation_cyclelist.filter(x => x.check).map(x => new MyEvaluationCycleModel({ evaluationRoundId: x.data.evaluationRoundId, tdesc: x.data.tdesc, edesc: x.data.edesc, apsyear: x.data.apsyear, apsPeriodStart: x.data.apsPeriodStart, apsPeriodEnd: x.data.apsPeriodEnd, statusCode: x.data.statusCode }))
} }
this.evaluationCycleService.delete(body).subscribe({
next: response => {
if (response.success) {
this.showAlert(response.message, 'success')
this.getEvaluationCycleList()
} else {
this.showAlert(response.message, 'error')
}
}, error: error => {
this.showAlert(error.message, 'error')
}
})
}
showAlert(text: string, type: 'success' | 'error') {
this.toastr[type](text, 'แจ้งเตือน', {
timeOut: 3000,
positionClass: 'toast-top-right',
});
}
} }
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
</div> </div>
<div class="grid grid-cols-3 gap-6"> <div class="grid grid-cols-3 gap-6">
<div class="col-span-1"> <div class="col-span-1">
<input type="text" id="input-label" class="ti-form-input w-2/3 pr-10" value="2567"> <input type="text" id="input-label" class="ti-form-input w-2/3 pr-10" value="{{ setting.apsyear }}">
</div> </div>
</div> </div>
<div class="grid grid-cols-3 gap-6 mt-10"> <div class="grid grid-cols-3 gap-6 mt-10">
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
</div> </div>
<div class="grid grid-cols-3 gap-6"> <div class="grid grid-cols-3 gap-6">
<div class="col-span-1"> <div class="col-span-1">
<input type="text" id="input-label" class="ti-form-input w-2/3 pr-10" value="8"> <input type="text" id="input-label" class="ti-form-input w-2/3 pr-10" value="{{ setting.expectationLevel }}">
</div> </div>
</div> </div>
<label for="hs-trailing-button-add-on-with-icon" class="ti-form-label mt-10">จัดการสมรรถนะกับกลุ่ม *</label> <label for="hs-trailing-button-add-on-with-icon" class="ti-form-label mt-10">จัดการสมรรถนะกับกลุ่ม *</label>
...@@ -43,13 +43,13 @@ ...@@ -43,13 +43,13 @@
<div class="grid grid-cols-6 flex gap-x-6"> <div class="grid grid-cols-6 flex gap-x-6">
<div class="flex col-span-1 mt-5"> <div class="flex col-span-1 mt-5">
<input type="radio" name="hs-radio-group" class="ti-form-radio" id="hs-radio-group-1" checked> <input type="radio" name="hs-radio-group" class="ti-form-radio" id="hs-radio-group-1" checked>
<label for="hs-radio-group-1" class="text-sm text-gray-500 ltr:ml-5 rtl:mr-2 dark:text-white/70">ระดับพนักงาน (PL)</label> <label for="hs-radio-group-1" class="text-sm text-gray-500 ltr:ml-5 rtl:mr-2 dark:text-white/70">{{ setting.companyId }}</label>
</div> </div>
<div class="flex col-span-2 mt-5 ml-4rem"> <!-- <div class="flex col-span-2 mt-5 ml-4rem">
<input type="radio" name="hs-radio-group" class="ti-form-radio" id="hs-radio-group-2"> <input type="radio" name="hs-radio-group" class="ti-form-radio" id="hs-radio-group-2">
<label for="hs-radio-group-2" class="text-sm text-gray-500 ltr:ml-5 rtl:mr-2 dark:text-white/70">ลักษณะงาน ( JD)</label> <label for="hs-radio-group-2" class="text-sm text-gray-500 ltr:ml-5 rtl:mr-2 dark:text-white/70">ลักษณะงาน ( JD)</label>
</div> </div> -->
</div> </div>
</div> </div>
...@@ -69,11 +69,11 @@ ...@@ -69,11 +69,11 @@
<tbody> <tbody>
<tr> <tr>
<td>น้ำหนัก</td> <td>น้ำหนัก</td>
<td><span>1</span></td> <td><span>{{ setting.settingScore5 }}</span></td>
<td><span>0.8</span></td> <td><span>{{ setting.settingScore4 }}</span></td>
<td><span>0.6</span></td> <td><span>{{ setting.settingScore3 }}</span></td>
<td><span>0.4</span></td> <td><span>{{ setting.settingScore2 }}</span></td>
<td><span>0.2</span></td> <td><span>{{ setting.settingScore1 }}</span></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
......
import { 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 { MySettingAssessmentModel, SettingAssessmentModel } from 'src/app/shared/model/setting-assessment.model';
import { SettingAssessmentService } from 'src/app/shared/services/setting-assessment.service';
@Component({ @Component({
selector: 'app-competency-configuration', selector: 'app-competency-configuration',
...@@ -11,8 +13,63 @@ export class CompetencyConfigurationComponent { ...@@ -11,8 +13,63 @@ export class CompetencyConfigurationComponent {
@Output() sendPathTitle: EventEmitter<string[]> = new EventEmitter<string[]>(); @Output() sendPathTitle: EventEmitter<string[]> = new EventEmitter<string[]>();
activeTab: string = 'tab1'; // กำหนด tab เริ่มต้น activeTab: string = 'tab1'; // กำหนด tab เริ่มต้น
isChecked: boolean = false; isChecked: boolean = false;
settingList: SettingAssessmentModel[] = []
settingListLoading = false
setting: SettingAssessmentModel = new MySettingAssessmentModel({})
search = ""
constructor(private settingAssessmentService: SettingAssessmentService,
private toastr: ToastrService,
private cdr: ChangeDetectorRef
) { }
ngOnInit(): void {
this.getSettingList()
}
getSettingList() {
this.settingListLoading = true
this.settingAssessmentService.getList().subscribe({
next: response => {
this.settingList = response
this.settingListLoading = false
this.cdr.detectChanges()
}, error: error => {
this.settingListLoading = false
this.cdr.detectChanges()
}
})
}
selectsetting(setting?: SettingAssessmentModel) {
this.setting = new MySettingAssessmentModel(setting || {})
}
// showSuccessAdd() {
// this.toastr.success('บันทึกข้อมูลสำเร็จ', 'แจ้งเตือน', {
// timeOut: 3000,
// positionClass: 'toast-top-right',
// });
// }
// showSuccessDelete() {
// this.toastr.success('ลบข้อมูลสำเร็จ', 'แจ้งเตือน', {
// timeOut: 3000,
// positionClass: 'toast-top-right',
// });
// }
// addsetting() {
// this.settingAssessmentService.post(this.setting).subscribe((response: any) => {
// if (response.success) {
// this.showSuccessAdd()
// this.getSettingList()
// }
// })
// }
// deletesetting() {
// this.settingAssessmentService.delete(this.setting).subscribe((response: any) => {
// if (response.success) {
// this.showSuccessDelete()
// this.getSettingList()
// }
// })
// }
// ฟังก์ชันในการเปลี่ยนแท็บ
changeTab(tab: { id: string, text: string }) { changeTab(tab: { id: string, text: string }) {
this.sendPathTitle.emit(['การประเมินสมรรถนะ', 'การตั้งค่า', tab.text]); this.sendPathTitle.emit(['การประเมินสมรรถนะ', 'การตั้งค่า', tab.text]);
this.activeTab = tab.id; this.activeTab = tab.id;
...@@ -22,69 +79,5 @@ export class CompetencyConfigurationComponent { ...@@ -22,69 +79,5 @@ export class CompetencyConfigurationComponent {
this.isChecked = !this.isChecked; this.isChecked = !this.isChecked;
} }
// การจัดการการเปิดปิด modal
modalOptions: {
[nameModal: string]: {
isModalOpen: boolean;
modalSize: string;
backdropClose: boolean;
};
} = {
"add": {
isModalOpen: false,
modalSize: 'm',
backdropClose: true,
},
"edit": {
isModalOpen: false,
modalSize: 'm',
backdropClose: true,
}
};
openModal(name: string, size: string, closeOnBackdrop?: boolean) {
this.modalOptions[name].modalSize = size;
this.modalOptions[name].backdropClose = closeOnBackdrop || false;
this.modalOptions[name].isModalOpen = true;
this.currentModal = name; // ตั้งค่าค่าของ currentModal เป็น 'add' หรือ 'edit'
document.body.style.overflow = 'hidden';
}
closeModal(name: string) {
this.modalOptions[name].isModalOpen = false;
if (!this.isAnyModalOpen()) {
document.body.style.overflow = ''; // คืนค่าการ Scroll เฉพาะเมื่อ Modal ทั้งหมดปิดแล้ว
}
}
isAnyModalOpen(): boolean {
return Object.values(this.modalOptions).some(modal => modal.isModalOpen); // ตรวจสอบว่า modal อื่นยังเปิดอยู่หรือไม่
}
// ฟังก์ชันสำหรับการเพิ่ม ลบ หรือแก้ไข ข้อมูล
addUser() {
}
currentModal = ""
constructor(private toastr: ToastrService) { }
showSuccess() {
this.toastr.success('บันทึกข้อมูลสำเร็จ', 'เเจ้งเตือน', {
timeOut: 3000,
positionClass: 'toast-top-right',
});
}
showSuccessEdit() {
this.toastr.success('เเก้ไขข้อมูลสำเร็จ', 'เเจ้งเตือน', {
timeOut: 3000,
positionClass: 'toast-top-right',
});
}
showSuccessDelete() {
this.toastr.success('ลบข้อมูลสำเร็จ', 'เเจ้งเตือน', {
timeOut: 3000,
positionClass: 'toast-top-right',
});
}
} }
...@@ -120,6 +120,8 @@ import { CompetencytopicService } from 'src/app/shared/services/competencytopic. ...@@ -120,6 +120,8 @@ import { CompetencytopicService } from 'src/app/shared/services/competencytopic.
import { AssessmentService } from 'src/app/shared/services/assessment.service'; import { AssessmentService } from 'src/app/shared/services/assessment.service';
import { CompetencycourseService } from 'src/app/shared/services/competencycourse.service'; import { CompetencycourseService } from 'src/app/shared/services/competencycourse.service';
import { EmployeeService } from 'src/app/shared/services/employee.service'; import { EmployeeService } from 'src/app/shared/services/employee.service';
import { EvaluationCycleService } from 'src/app/shared/services/evaluation-cycle.service';
import { SettingAssessmentService } from 'src/app/shared/services/setting-assessment.service';
@NgModule({ @NgModule({
declarations: [ declarations: [
SalesComponent, SalesComponent,
...@@ -247,6 +249,8 @@ import { EmployeeService } from 'src/app/shared/services/employee.service'; ...@@ -247,6 +249,8 @@ import { EmployeeService } from 'src/app/shared/services/employee.service';
AssessmentService, AssessmentService,
CompetencycourseService, CompetencycourseService,
EmployeeService, EmployeeService,
EvaluationCycleService,
SettingAssessmentService,
{ {
provide: HTTP_INTERCEPTORS, provide: HTTP_INTERCEPTORS,
useClass: HttpRequestInterceptor, useClass: HttpRequestInterceptor,
......
import { MyStatusCodeModel, StatusCodeModel } from "./status-code.model";
export interface EvaluationCycleModel {
evaluationRoundId: string;
tdesc: string;
edesc: string;
apsyear: string;
apsPeriodStart: string;
apsPeriodEnd: string;
statusCode: StatusCodeModel;
}
export class MyEvaluationCycleModel implements EvaluationCycleModel {
evaluationRoundId: string;
tdesc: string;
edesc: string;
apsyear: string;
apsPeriodStart: string;
apsPeriodEnd: string;
statusCode: StatusCodeModel;
constructor(data: Partial<EvaluationCycleModel>) {
this.evaluationRoundId = data.evaluationRoundId || "";
this.tdesc = data.tdesc || "";
this.edesc = data.edesc || "";
this.apsyear = data.apsyear || "";
this.apsPeriodStart = data.apsPeriodStart || "";
this.apsPeriodEnd = data.apsPeriodEnd || "";
this.statusCode =new MyStatusCodeModel(data.statusCode || {})
}
}
export interface SettingAssessmentModel {
apsyear: string;
companyId: string;
expectationLevel: number;
settingGroupAssessment: string;
settingScore5: number;
settingScore4: number;
settingScore3: number;
settingScore2: number;
settingScore1: number;
}
export class MySettingAssessmentModel implements SettingAssessmentModel {
apsyear: string;
companyId: string;
expectationLevel: number;
settingGroupAssessment: string;
settingScore5: number;
settingScore4: number;
settingScore3: number;
settingScore2: number;
settingScore1: number;
constructor(data: Partial<SettingAssessmentModel>) {
this.apsyear = data.apsyear || "";
this.companyId = data.companyId || "";
this.expectationLevel = data.expectationLevel ?? 0;
this.settingGroupAssessment = data.settingGroupAssessment || "";
this.settingScore5 = data.settingScore5 ?? 0;
this.settingScore4 = data.settingScore4 ?? 0;
this.settingScore3 = data.settingScore3 ?? 0;
this.settingScore2 = data.settingScore2 ?? 0;
this.settingScore1 = data.settingScore1 ?? 0;
}
}
\ No newline at end of file
export interface StatusCodeModel {
code: string;
tdesc: string;
edesc: string;
}
export class MyStatusCodeModel implements StatusCodeModel {
code: string;
tdesc: string;
edesc: string;
constructor(data: Partial<StatusCodeModel>) {
this.code = data.code || "";
this.tdesc = data.tdesc || "";
this.edesc = data.edesc || "";
}
}
\ No newline at end of file
...@@ -19,18 +19,6 @@ export class EmpGroupService { ...@@ -19,18 +19,6 @@ export class EmpGroupService {
getById(groupId: string): Observable<EmpGroupModel> { getById(groupId: string): Observable<EmpGroupModel> {
return this.http.get<EmpGroupModel>(this.urlApi + "/" + groupId) return this.http.get<EmpGroupModel>(this.urlApi + "/" + groupId)
} }
// post(body: EmpGroupModel) {
// return this.http.post(this.urlApi, body)
// }
// delete(body: EmpGroupModel) {
// const options = {
// headers: new HttpHeaders({
// "Content-Type": "application/json",
// }),
// body: body
// };
// return this.http.delete(this.urlApi, options)
// }
post(body: EmpGroupModel): Observable<AlertModel> { post(body: EmpGroupModel): Observable<AlertModel> {
return this.http.post<AlertModel>(this.urlApi, body) return this.http.post<AlertModel>(this.urlApi, body)
} }
......
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 EvaluationCycleService {
api = "/evaluation-round"
urlApi = environment.baseUrl + this.api
constructor(private http: HttpClient) {
}
getList(): Observable<EvaluationCycleModel[]> {
return this.http.get<EvaluationCycleModel[]>(this.urlApi + "/lists")
}
getById(evaluationRoundId: string): Observable<EvaluationCycleModel> {
return this.http.get<EvaluationCycleModel>(this.urlApi + "/" + evaluationRoundId)
}
post(body: EvaluationCycleModel): Observable<AlertModel> {
return this.http.post<AlertModel>(this.urlApi, 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)
}
}
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 { SettingAssessmentModel } from '../model/setting-assessment.model';
@Injectable({
providedIn: 'root'
})
export class SettingAssessmentService {
api = "/setting-assessment"
urlApi = environment.baseUrl + this.api
constructor(private http: HttpClient) {
}
getList(): Observable<SettingAssessmentModel[]> {
return this.http.get<SettingAssessmentModel[]>(this.urlApi + "/lists")
}
// getById(companyId: string): Observable<SettingAssessmentModel> {
// return this.http.get<SettingAssessmentModel>(this.urlApi + "/" + companyId)
// }
post(body: SettingAssessmentModel): Observable<AlertModel> {
return this.http.post<AlertModel>(this.urlApi, body)
}
delete(body: SettingAssessmentModel | SettingAssessmentModel[]): Observable<AlertModel> {
const options = {
headers: new HttpHeaders({
"Content-Type": "application/json",
}),
body: body
};
return this.http.delete<AlertModel>(this.urlApi, 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