Commit fe3d7fa2 by Nakarin Luankla

Merge branch 'DEV' of https://mygit.myhr.co.th/angular/myAppraisal into DEV

parents 3c5bbb03 f61fc5dd
......@@ -11,34 +11,31 @@
<a class="font-size-16px font-weight-500 hs-tab-active:font-weight-700 hs-tab-active:border-secondary hs-tab-active:text-secondary pb-3 inline-flex items-center gap-2 border-b-[3px] border-transparent whitespace-nowrap text-gray-500 hover:text-secondary active"
href="javascript:void(0);" id="underline-item-1" data-hs-tab="#underline-1"
aria-controls="underline-1"
(click)="pathTitle = ['การประเมินสมรรถนะ','การจัดการสมรรถนะ','ตัวชี้วัดเเละหลักสูตร']">
(click)="currentPath = 1;pathTitle = ['การประเมินสมรรถนะ','การจัดการสมรรถนะ','ตัวชี้วัดเเละหลักสูตร']">
ตัวชี้วัดเเละหลักสูตร
</a>
<a class="font-size-16px font-weight-500 hs-tab-active:font-weight-700 hs-tab-active:border-secondary hs-tab-active:text-secondary pb-3 inline-flex items-center gap-2 border-b-[3px] border-transparent whitespace-nowrap text-gray-500 hover:text-secondary"
href="javascript:void(0);" id="underline-item-2" data-hs-tab="#underline-2"
aria-controls="underline-2"
(click)="pathTitle = ['การประเมินสมรรถนะ','การจัดการสมรรถนะ','จัดกลุ่มสมรรถนะ']">
(click)="currentPath = 2;pathTitle = ['การประเมินสมรรถนะ','การจัดการสมรรถนะ','จัดกลุ่มสมรรถนะ']">
จัดกลุ่มสมรรถนะ
</a>
<a class="font-size-16px font-weight-500 hs-tab-active:font-weight-700 hs-tab-active:border-secondary hs-tab-active:text-secondary pb-3 inline-flex items-center gap-2 border-b-[3px] border-transparent whitespace-nowrap text-gray-500 hover:text-secondary"
href="javascript:void(0);" id="underline-item-3" data-hs-tab="#underline-3"
aria-controls="underline-3"
(click)="pathTitle = ['การประเมินสมรรถนะ','การจัดการสมรรถนะ','กำหนดผู้ประเมิน']">
(click)="currentPath = 3;pathTitle = ['การประเมินสมรรถนะ','การจัดการสมรรถนะ','กำหนดผู้ประเมิน']">
กำหนดผู้ประเมิน
</a>
</nav>
</div>
<div class="mt-3 px-3rem !-mt-3 pt-50px">
<div id="underline-1" role="tabpanel" aria-labelledby="underline-item-1">
<div *ngIf="currentPath==1" id="underline-1" role="tabpanel" aria-labelledby="underline-item-1">
<app-indicators-and-curriculum (sendPathTitle)="pathTitle=$event"></app-indicators-and-curriculum>
</div>
<div id="underline-2" class="hidden" role="tabpanel" aria-labelledby="underline-item-2">
<app-group-competencies *ngIf="groupShow=='1'" [pathTitle]="pathTitle"
(sendPathTitle)="pathTitle=$event" (sendGroupShow)="groupShow=$event"></app-group-competencies>
<app-edit-group-competencies *ngIf="groupShow=='2'" [pathTitle]="pathTitle"
(sendPathTitle)="pathTitle=$event" (sendGroupShow)="groupShow=$event"></app-edit-group-competencies>
<div *ngIf="currentPath==2" id="underline-2" class="hidden" role="tabpanel" aria-labelledby="underline-item-2">
<app-group-competencies (sendPathTitle)="pathTitle=$event" ></app-group-competencies>
</div>
<div id="underline-3" class="hidden" role="tabpanel" aria-labelledby="underline-item-3">
<div *ngIf="currentPath==3" id="underline-3" class="hidden" role="tabpanel" aria-labelledby="underline-item-3">
<app-set-approvers [pathTitle]="pathTitle" (sendPathTitle)="pathTitle=$event"></app-set-approvers>
</div>
</div>
......
......@@ -7,5 +7,5 @@ import { Component } from '@angular/core';
})
export class CompetencyManagementComponent {
pathTitle = ['การประเมินสมรรถนะ', 'การจัดการสมรรถนะ','ตัวชี้วัดและหลักสูตร']
groupShow = '1'
currentPath = 1
}
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { ChangeDetectorRef, Component, EventEmitter, Input, Output } from '@angular/core';
import { ToastrService } from 'ngx-toastr';
import { MyPLModel, PLModel } from 'src/app/shared/model/pl.model';
import { PLService } from 'src/app/shared/services/pl.service';
export interface DataModel {
code: string
name: string
edesc: string
companyId: string
}
@Component({
selector: 'app-group-competencies',
......@@ -7,81 +15,66 @@ import { ToastrService } from 'ngx-toastr';
styleUrls: ['./group-competencies.component.scss']
})
export class GroupCompetenciesComponent {
@Input() pathTitle = ['การประเมินสมรรถนะ', 'การจัดการสมรรถนะ', 'จัดกลุ่มสมรรถนะ'];
@Output() sendPathTitle: EventEmitter<string[]> = new EventEmitter<string[]>();
@Output() sendGroupShow: EventEmitter<string> = new EventEmitter<string>();
activeTab: string = 'tab1'; // กำหนด tab เริ่มต้น
editTab = false
currentPage = 1
search = ""
page = Array.from({ length: 1 }, (_, i) => i + 1);
// ฟังก์ชันในการเปลี่ยนแท็บ
changeTab(tab: { id: string, text: string }) {
this.sendPathTitle.emit(['การประเมินสมรรถนะ', 'การจัดการสมรรถนะ', tab.text]);
this.activeTab = tab.id;
}
onEdit(){
this.sendGroupShow.emit('2');
}
// การจัดการการเปิดปิด modal
modalOptions: {
[nameModal: string]: {
isModalOpen: boolean;
modalSize: string;
backdropClose: boolean;
};
} = {
"add": {
isModalOpen: false,
modalSize: 'm',
backdropClose: true,
},
"edit": {
isModalOpen: false,
modalSize: 'm',
backdropClose: true,
}
};
dataList: DataModel[] = []
dataSelect: DataModel = { code: '', name: '', edesc: '', companyId: '' }
groupCompetenciesList: PLModel[] = []
groupCompetencies: PLModel = new MyPLModel({})
dataLoading = false
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';
constructor(private toastr: ToastrService,
private cdr: ChangeDetectorRef,
private pLService: PLService,
) {
this.pathTitleChange()
}
closeModal(name: string) {
this.modalOptions[name].isModalOpen = false;
if (!this.isAnyModalOpen()) {
document.body.style.overflow = ''; // คืนค่าการ Scroll เฉพาะเมื่อ Modal ทั้งหมดปิดแล้ว
}
ngOnInit(): void {
this.getList()
}
isAnyModalOpen(): boolean {
return Object.values(this.modalOptions).some(modal => modal.isModalOpen); // ตรวจสอบว่า modal อื่นยังเปิดอยู่หรือไม่
getList() {
this.dataLoading = true
this.pLService.getList().subscribe({
next: response => {
this.dataList = response.map(x => ({ code: x.plId, name: x.tdesc, edesc: x.edesc, companyId: x.companyId }))
this.groupCompetenciesList = response
this.dataLoading = false
this.searchChange()
this.cdr.detectChanges()
}, error: error => {
this.dataLoading = false
this.cdr.detectChanges()
}
})
}
// ฟังก์ชัน toggle checkbox
isChecked: boolean = false; // ใช้สำหรับตรวจสอบสถานะของ checkbox
toggleCheckbox() {
this.isChecked = !this.isChecked; // สลับสถานะ
selectData(data?: DataModel) {
this.dataSelect = JSON.parse(JSON.stringify(data || { code: '', name: '', edesc: '', companyId: '' }))
}
// ฟังก์ชันสำหรับการเพิ่ม ลบ หรือแก้ไข ข้อมูล
addUser() {
console.log('เพิ่มผู้ใช้งาน');
selectGroupCompetencies(data: DataModel) {
const groupCompetencies = this.groupCompetenciesList.find(x => x.plId == data.code)
this.groupCompetencies = new MyPLModel(groupCompetencies)
}
pathTitleChange() {
this.sendPathTitle.emit(this.editTab ? ['การประเมินสมรรถนะ', 'การจัดการสมรรถนะ', 'จัดกลุ่มสมรรถนะ', 'แก้ไขกลุ่มสมรรถนะ'] : ['การประเมินสมรรถนะ', 'การจัดการสมรรถนะ', 'จัดกลุ่มสมรรถนะ'])
}
deleteUser() {
console.log('ลบผู้ใช้งาน');
searchChange() {
this.currentPage = 1;
const filteredData = this.dataListFilter();
this.page = Array.from({ length: Math.ceil(filteredData.length / 10) }, (_, i) => i + 1);
}
editUser() {
console.log('แก้ไขผู้ใช้งาน');
dataListFilter() {
return this.dataList.filter(x => {
const match = x.code.toLocaleLowerCase().includes(this.search.toLocaleLowerCase()) || x.name.toLocaleLowerCase().includes(this.search.toLocaleLowerCase());
return match;
});
}
currentModal = "";
constructor(private toastr: ToastrService) { }
showSuccess() {
this.toastr.success('บันทึกข้อมูลสำเร็จ', 'เเจ้งเตือน', {
......@@ -103,4 +96,17 @@ export class GroupCompetenciesComponent {
positionClass: 'toast-top-right',
});
}
// ฟังก์ชันสำหรับการเพิ่ม ลบ หรือแก้ไข ข้อมูล
addUser() {
console.log('เพิ่มผู้ใช้งาน');
}
deleteUser() {
console.log('ลบผู้ใช้งาน');
}
editUser() {
console.log('แก้ไขผู้ใช้งาน');
}
}
<div class="w-full min-height-50px mb-10px justify-between items-center">
<div class="flex justify-between">
<div class="flex pr-2">
<!-- Content ของ div แรก -->
<div class="flex gap-x-6">
<div class="flex items-center">
<label for="hs-checkbox-group-1"
class="text-sm text-gray-500 ltr:ml-2 rtl:mr-2 dark:text-white/70">{{dataSelectList.length}}
Selected</label>
</div>
<div class="flex items-center">
<i (click)="toggleCheckbox()"
[ngClass]="{'ri-checkbox-multiple-line': !isChecked, 'ri-checkbox-multiple-fill': isChecked}"
class="ri-checkbox-multiple-line text-gray-500 dark:text-white/70"></i>
<label for="hs-checkbox-group-2" class="text-sm text-gray-500 ltr:ml-2 rtl:mr-2 dark:text-white/70"
(click)="toggleCheckbox()">Select All</label>
</div>
<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 class="flex justify-end">
<div class="px-1">
<div class="relative shadow-md">
......@@ -35,7 +31,8 @@
<div class="px-1">
<button type="button"
class="ti-btn ti-btn bg-pink-500/10 text-pink-500 hover:text-white hover:bg-pink-500 ring-offset-white focus:ring-pink-500 dark:focus:ring-offset-white/10 h-10 m-0 shadow-md"
data-hs-overlay="#competency-topic-upload-modal">
data-hs-overlay="#competency-topic-upload-modal"
(click)="fileInput.value = '';selectedFile=null;selectedFileName = 'กรุณาเลือกไฟล์'">
<i class="ti ti-file-plus"></i>
import
</button>
......@@ -103,7 +100,7 @@
*ngFor="let item of dataListFilter()| slice:((currentPage-1) * 10) : (((currentPage-1) * 10) + 10);let i = index">
<td class="text-center">
<input type="checkbox" class="ti-form-checkbox cursor-pointer" id="checkbox-{{item.data.id}}"
[(ngModel)]="item.check" (change)="checkSelect()">
[(ngModel)]="item.check" (change)="dataListCheck()">
<label for="checkbox-{{item.data.id}}">&nbsp;{{item.data.id}}</label>
</td>
<td>{{item.data.name}}</td>
......@@ -179,7 +176,7 @@
<div class="ti-modal-center">
<div class="flex justify-end" style="padding-right: 1rem;">
<div class="px-1">
<button type="button" class="ti-btn ti-btn-soft-indigo h-45px m-0 shadow-md">
<button type="button" class="ti-btn ti-btn-soft-indigo h-45px m-0 shadow-md" (click)="clearData(modalStatus)">
<svg class="svg-indigo" width="16" height="16" viewBox="0 0 64.00 64.00"
xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#595BEA" stroke-width="3.84"
transform="rotate(45)matrix(-1, 0, 0, 1, 0, 0)">
......@@ -208,22 +205,26 @@
<input type="text" id="input-label" class="ti-form-input w-1/2"
[ngClass]="{'bg-input-readonly':modalStatus=='edit'}" [readonly]="modalStatus=='edit'"
[(ngModel)]="dataSelect.id">
<label for="detail_th" class="ti-form-label mt-2rem">ชื่อหัวข้อ (ไทย)</label>
<label for="detail_th" class="ti-form-label mt-2rem">ชื่อหัวข้อ (ไทย)*</label>
<input type="text" id="detail_th" class="ti-form-input h-10" [(ngModel)]="dataSelect.name">
<label for="detail_eng" class="ti-form-label mt-2rem">ชื่อหัวข้อ (อังกฤษ)</label>
<input type="text" id="detail_eng" class="ti-form-input h-10" [(ngModel)]="dataSelect.edesc">
<label for="detail_eng" class="ti-form-label mt-2rem">นิยามสมรรถนะ</label>
<textarea type="text" id="detail_eng" class="ti-form-input" rows="4" cols="50"
[(ngModel)]="dataSelect.definition"> </textarea>
<label class="ti-form-label mt-2rem">ประเภท Competency</label>
<label class="ti-form-label mt-2rem">ประเภท Competency*</label>
<div class="flex">
<div class="relative flex rounded-md w-1/2">
<input type="text" id="hs-leading-button-add-on-with-icon-and-button"
name="hs-leading-button-add-on-with-icon-and-button"
class="ti-form-input rounded-md ltr:rounded-r-md rtl:rounded-l-md focus:z-10"
style="padding-right: 2.5rem;" [(ngModel)]="dataSelect.type.code">
style="padding-right: 2.5rem;" readonly [(ngModel)]="dataSelect.type.code">
<div
class="absolute inset-y-0 ltr:right-0 rtl:left-0 flex items-center z-20 ltr:pr-4 rtl:pl-4 space-x-2">
<button type="button" class="flex items-center text-red-500"
(click)="dataSelect.type.code=''">
<i class="ti ti-circle-x cursor-pointer"></i>
</button>
<button type="button" class="flex items-center text-gray-500 dark:text-white/70"
data-hs-overlay="#competency-topic-table-modal-select">
<i class="ri-search-line cursor-pointer text-gray"></i>
......@@ -257,10 +258,12 @@
data-hs-overlay="#competency-topic-page-modal">
ย้อนกลับ
</button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#competency-topic-page-alert-modal">
<button type="button" class="ti-btn ti-btn-success"
data-hs-overlay="#competency-topic-page-alert-modal"
[class.ti-btn-disabled]="!dataSelect.id||!dataSelect.name||!dataSelect.type.code"
[disabled]="!dataSelect.id||!dataSelect.name||!dataSelect.type.code">
บันทึกข้อมูล
</a>
</button>
</div>
</div>
</div>
......@@ -621,7 +624,7 @@
<h1 class="mt-2" style="text-align: center;">ไฟล์</h1>
<div class="mt-2 p-2">
<div class="flex rounded-md">
<input #fileInput type="file" (change)="onFileSelected($event)" hidden>
<input #fileInput id="fileInput" type="file" (change)="onFileSelected($event)" hidden>
<input type="text" [value]="selectedFileName" readonly (click)="fileInput.click()"
class="ti-form-input rounded-none ltr:rounded-l-md rtl:rounded-r-md focus:z-10 cursor-pointer">
<button type="button" (click)="fileInput.click()"
......@@ -630,8 +633,9 @@
</button>
</div>
<div class="flex justify-center mt-2rem mb-1rem space-x-4">
<button type="submit" class="ti-btn ti-btn-secondary" (click)="uploadFile()"
[disabled]="!selectedFile">
<button type="submit" class="ti-btn ti-btn-secondary"
data-hs-overlay="#competency-topic-upload-modal" [class.ti-btn-disabled]="!selectedFile"
(click)="uploadFile()" [disabled]="!selectedFile" [disabled]="!selectedFile">
อัปโหลด
</button>
</div>
......
......@@ -59,6 +59,10 @@ export class CompetencyTopic {
selectedFileName: string = 'กรุณาเลือกไฟล์';
selectedItems: string[] = [];
numDataListChecked = 0
isDataListChecked = false
isDataListCheckedAll = false
constructor(private toastr: ToastrService,
private cdr: ChangeDetectorRef,
private fileService: FileService,
......@@ -70,18 +74,6 @@ export class CompetencyTopic {
this.getCompetencytypeList()
}
checkSelect() {
this.dataSelectList = this.competoncyTopicList.filter(item => item.check).map(item => item.data);
}
toggleCheckbox() {
this.isChecked = !this.isChecked; // สลับสถานะ'
this.competoncyTopicList.forEach((item) => {
item.check = this.isChecked;
});
this.checkSelect();
}
onFileSelected(event: any) {
this.selectedFile = event.target.files.length > 0 ? event.target.files[0] : null;
this.selectedFileName = this.selectedFile?.name || "กรุณาเลือกไฟล์"
......@@ -94,6 +86,7 @@ export class CompetencyTopic {
}
const formData = new FormData();
formData.append('file', this.selectedFile);
this.dataLoading = true
this.fileService.upload(formData, 'competency_topic').subscribe({
next: response => {
if (response.success) {
......@@ -102,9 +95,13 @@ export class CompetencyTopic {
this.getCompetencytopicList()
} else {
this.showAlert(response.message, 'error')
this.dataLoading = false
this.cdr.detectChanges()
}
}, error: error => {
this.showAlert(error.message, 'error')
this.dataLoading = false
this.cdr.detectChanges()
}
})
}
......@@ -167,6 +164,8 @@ export class CompetencyTopic {
checked: false
}
}))
this.isDataListCheckedAll = false
this.dataListCheckAll()
this.dataLoading = false
this.searchChange()
this.cdr.detectChanges()
......@@ -180,11 +179,12 @@ export class CompetencyTopic {
searchChange() {
this.currentPage = 1
this.page = Array.from({ length: Math.ceil(this.dataListFilter().length / 10) }, (_, i) => i + 1);
this.dataListCheck()
}
dataListFilter() {
return this.competoncyTopicList.filter(x => {
const data = x.data
const match = data.id.toLowerCase().includes(this.search) || data.name.toLowerCase().includes(this.search) || data.code.toLowerCase().includes(this.search);
const match = data.id?.toLowerCase().includes(this.search.toLowerCase()) || data.name?.toLowerCase().includes(this.search.toLowerCase()) || data.code?.toLowerCase().includes(this.search.toLowerCase());
return match;
});
}
......@@ -198,6 +198,7 @@ export class CompetencyTopic {
competencyTopicId: this.dataSelect.id, tdesc: this.dataSelect.name, edesc: this.dataSelect.edesc, competencyDetail: this.dataSelect.definition,
competencyType: new MyCompetencytypeModel({ competencyTypeId: this.dataSelect.type.id, tdesc: this.dataSelect.type.name, edesc: this.dataSelect.type.edesc, shortName: this.dataSelect.type.code, expectationLevel: this.dataSelect.type.level }),
})
this.dataLoading = true
this.competencytopicService.post(body).subscribe({
next: response => {
if (response.success) {
......@@ -206,9 +207,13 @@ export class CompetencyTopic {
this.getCompetencytopicList()
} else {
this.showAlert(response.message, 'error')
this.dataLoading = false
this.cdr.detectChanges()
}
}, error: error => {
this.showAlert(error.message, 'error')
this.dataLoading = false
this.cdr.detectChanges()
}
})
}
......@@ -225,7 +230,7 @@ export class CompetencyTopic {
competencyType: new MyCompetencytypeModel({ competencyTypeId: this.dataSelect.type.id, tdesc: this.dataSelect.type.name, edesc: this.dataSelect.type.edesc, shortName: this.dataSelect.type.code, expectationLevel: this.dataSelect.type.level }),
})
}
console.log(body)
this.dataLoading = true
this.competencytopicService.delete(body).subscribe({
next: response => {
if (response.success) {
......@@ -234,9 +239,13 @@ export class CompetencyTopic {
this.getCompetencytopicList()
} else {
this.showAlert(response.message, 'error')
this.dataLoading = false
this.cdr.detectChanges()
}
}, error: error => {
this.showAlert(error.message, 'error')
this.dataLoading = false
this.cdr.detectChanges()
}
})
}
......@@ -247,4 +256,29 @@ export class CompetencyTopic {
positionClass: 'toast-top-right',
})
}
clearData(modalStatus: string) {
if (modalStatus == 'add') {
this.setData()
} else if (modalStatus == 'edit') {
this.setData({ id: this.dataSelect.id, name: "", edesc: "", code: "", definition: "", type: { id: "", name: "", edesc: "", code: "", level: "" }, checked: this.dataSelect.checked })
}
}
dataListCheckAll() {
const selectAll = this.isDataListCheckedAll;
this.competoncyTopicList.filter(x => {
const data = x.data
const match = data.id.toLowerCase().includes(this.search.toLowerCase()) || data.name.toLowerCase().includes(this.search.toLowerCase()) || data.code.toLowerCase().includes(this.search.toLowerCase());
return match;
}).forEach(x => x.check = selectAll);
this.dataListCheck();
}
dataListCheck() {
const dataCheck = this.dataListFilter();
this.isDataListCheckedAll = dataCheck.length ? dataCheck.every(x => x.check) : false;
this.numDataListChecked = this.competoncyTopicList.filter(x => x.check).length;
this.isDataListChecked = Boolean(this.numDataListChecked)
}
}
......@@ -10,24 +10,25 @@
<nav class="-mb-0.5 flex space-x-6 rtl:space-x-reverse">
<a class="text-base font-medium hs-tab-active:border-secondary hs-tab-active:text-secondary pb-3 inline-flex items-center gap-2 border-b-[3px] border-transparent whitespace-nowrap text-gray-500 dark:text-white/70 hover:text-secondary active"
href="javascript:void(0);" id="underline-item-1" data-hs-tab="#underline-1"
aria-controls="underline-1" (click)=" currentPage = 1;pathTitle = ['การประเมินสมรรถนะ','ทะเบียนกำหนดชื่อ','ประเภทสมรรถนะ']">
aria-controls="underline-1"
(click)=" currentPage = 1;pathTitle = ['การประเมินสมรรถนะ','ทะเบียนกำหนดชื่อ','ประเภทสมรรถนะ']">
ประเภทสมรรถนะ
</a>
<a class="text-base font-medium hs-tab-active:border-secondary hs-tab-active:text-secondary pb-3 inline-flex items-center gap-2 border-b-[3px] border-transparent whitespace-nowrap text-gray-500 dark:text-white/70 hover:text-secondary"
href="javascript:void(0);" id="underline-item-2" data-hs-tab="#underline-2"
aria-controls="underline-2" (click)="currentPage = 2;pathTitle = ['การประเมินสมรรถนะ','ทะเบียนกำหนดชื่อ','หัวข้อสมรรถนะ']">
aria-controls="underline-2"
(click)="currentPage = 2;pathTitle = ['การประเมินสมรรถนะ','ทะเบียนกำหนดชื่อ','หัวข้อสมรรถนะ']">
หัวข้อสมรรถนะ
</a>
</nav>
</div>
<div class="mt-3 px-3rem !-mt-3 pt-50px">
<div class="mt-3 px-2rem !-mt-3 pt-50px">
<div *ngIf="currentPage == 1" id="underline-1" role="tabpanel" aria-labelledby="underline-item-1">
<app-type-registration [pathTitle]="pathTitle"
(sendPathTitle)="pathTitle=$event"></app-type-registration>
<app-type-registration></app-type-registration>
</div>
<div *ngIf="currentPage == 2" id="underline-2" class="hidden" role="tabpanel" aria-labelledby="underline-item-2">
<app-competency-topic [pathTitle]="pathTitle"
(sendPathTitle)="pathTitle=$event"></app-competency-topic>
<div *ngIf="currentPage == 2" id="underline-2" class="hidden" role="tabpanel"
aria-labelledby="underline-item-2">
<app-competency-topic [pathTitle]="pathTitle" (sendPathTitle)="pathTitle=$event"></app-competency-topic>
</div>
</div>
</div>
......
<div class="w-full min-height-50px mb-10px justify-between items-center">
<div class="flex justify-between">
<div class="flex pr-2">
<!-- Content ของ div แรก -->
<div class="flex gap-x-6">
<div class="flex items-center">
<label for="hs-checkbox-group-1"
class="text-sm text-gray-500 ltr:ml-2 rtl:mr-2 dark:text-white/70">{{dataSelectList.length}}
Selected</label>
</div>
<div class="flex items-center">
<i (click)="toggleCheckbox()"
[ngClass]="{'ri-checkbox-multiple-line': !isChecked, 'ri-checkbox-multiple-fill': isChecked}"
class="ri-checkbox-multiple-line text-gray-500 dark:text-white/70"></i>
<label for="hs-checkbox-group-2" class="text-sm text-gray-500 ltr:ml-2 rtl:mr-2 dark:text-white/70"
(click)="toggleCheckbox()">Select All</label>
</div>
<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>
......@@ -35,7 +32,8 @@
<div class="px-1">
<button type="button"
class="ti-btn ti-btn bg-pink-500/10 text-pink-500 hover:text-white hover:bg-pink-500 ring-offset-white focus:ring-pink-500 dark:focus:ring-offset-white/10 h-10 m-0 shadow-md"
data-hs-overlay="#type-registration-component-upload-modal">
data-hs-overlay="#type-registration-component-upload-modal"
(click)="fileInput.value = '';selectedFile=null;selectedFileName = 'กรุณาเลือกไฟล์'">
<i class="ti ti-file-plus"></i>
import
</button>
......@@ -103,7 +101,7 @@
*ngFor="let item of dataListFilter()| slice:((currentPage-1) * 10) : (((currentPage-1) * 10) + 10);let i = index">
<td class="text-center">
<input type="checkbox" class="ti-form-checkbox cursor-pointer" id="checkbox-{{item.data.id}}"
[(ngModel)]="item.check" (change)="checkSelect()">
[(ngModel)]="item.check" (change)="dataListCheck()">
<label for="checkbox-{{item.data.id}}">&nbsp;{{item.data.id}}</label>
</td>
<td>{{item.data.name}}</td>
......@@ -179,7 +177,8 @@
<div class="ti-modal-center">
<div class="flex justify-end" style="padding-right: 1rem;">
<div class="px-1">
<button type="button" class="ti-btn ti-btn-soft-indigo h-45px m-0 shadow-md">
<button type="button" class="ti-btn ti-btn-soft-indigo h-45px m-0 shadow-md"
(click)="clearData(modalStatus)">
<svg class="svg-indigo" width="16" height="16" viewBox="0 0 64.00 64.00"
xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#595BEA" stroke-width="3.84"
transform="rotate(45)matrix(-1, 0, 0, 1, 0, 0)">
......@@ -223,10 +222,12 @@
data-hs-overlay="#type-registration-component-page-modal">
ย้อนกลับ
</button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#type-registration-component-page-alert-modal">
<button type="button" class="ti-btn ti-btn-success"
data-hs-overlay="#type-registration-component-page-alert-modal"
[class.ti-btn-disabled]="!dataSelect.id||!dataSelect.name||!dataSelect.code||!dataSelect.level"
[disabled]="!dataSelect.id||!dataSelect.name||!dataSelect.code||!dataSelect.level">
บันทึกข้อมูล
</a>
</button>
</div>
</div>
</div>
......@@ -243,7 +244,7 @@
<div class="flex justify-end">
<ng-container *ngIf="modalStatus=='add'||modalStatus=='edit'">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#type-registration-component-page-alert-modal">
data-hs-overlay="#type-registration-component-page-modal">
<span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i>
</button>
......@@ -309,7 +310,7 @@
<h1 class="mt-2" style="text-align: center;">ไฟล์</h1>
<div class="mt-2 p-2">
<div class="flex rounded-md">
<input #fileInput type="file" (change)="onFileSelected($event)" hidden>
<input #fileInput id="fileInput" type="file" (change)="onFileSelected($event)" hidden>
<input type="text" [value]="selectedFileName" readonly (click)="fileInput.click()"
class="ti-form-input rounded-none ltr:rounded-l-md rtl:rounded-r-md focus:z-10 cursor-pointer">
<button type="button" (click)="fileInput.click()"
......@@ -318,8 +319,9 @@
</button>
</div>
<div class="flex justify-center mt-2rem mb-1rem space-x-4">
<button type="submit" class="ti-btn ti-btn-secondary" (click)="uploadFile()"
[disabled]="!selectedFile">
<button type="submit" class="ti-btn ti-btn-secondary"
data-hs-overlay="#type-registration-component-upload-modal" [class.ti-btn-disabled]="!selectedFile"
(click)="uploadFile()" [disabled]="!selectedFile" [disabled]="!selectedFile">
อัปโหลด
</button>
</div>
......
......@@ -18,26 +18,21 @@ export interface DataModel {
styleUrls: ['./type-registration.component.scss']
})
export class TypeRegistration {
@Input() pathTitle = ['การประเมินสมรรถนะ', 'ทะเบียนกำหนดชื่อ', 'ประเภทสมรรถนะ'];
@Output() sendPathTitle: EventEmitter<string[]> = new EventEmitter<string[]>();
activeTab: string = 'tab1'; // กำหนด tab เริ่มต้น
// ฟังก์ชันในการเปลี่ยนแท็บ
changeTab(tab: { id: string, text: string }) {
this.sendPathTitle.emit(['การประเมินสมรรถนะ', 'ทะเบียนกำหนดชื่อ', tab.text]);
this.activeTab = tab.id;
}
isChecked: boolean = false;
currentPage = 1
selectedItems: string[] = [];
page = Array.from({ length: 1 }, (_, i) => i + 1);
numDataListChecked = 0
isDataListChecked = false
isDataListCheckedAll = false
dataSelectList: DataModel[] = [];
dataLoading = false
dataSelect: DataModel = { id: "", companyId: "", edesc: "", name: "", code: "", level: "", checked: false }
competoncy_typeList: { check: boolean; data: DataModel & { checked?: boolean } }[] = []
competoncy_type: CompetencytypeModel = new MyCompetencytypeModel({})
modalStatus = 'add'
modalStatus: 'add' | 'edit' | 'delete' | 'deleteGroup' = 'add'
search = ""
selectedFile: File | null = null;
selectedFileName: string = 'กรุณาเลือกไฟล์';
......@@ -52,18 +47,6 @@ export class TypeRegistration {
this.getCompetencytypeList()
}
checkSelect() {
this.dataSelectList = this.competoncy_typeList.filter(item => item.check).map(item => item.data);
}
toggleCheckbox() {
this.isChecked = !this.isChecked; // สลับสถานะ'
this.competoncy_typeList.forEach((item) => {
item.check = this.isChecked;
});
this.checkSelect();
}
onFileSelected(event: any) {
this.selectedFile = event.target.files.length > 0 ? event.target.files[0] : null;
this.selectedFileName = this.selectedFile?.name || "กรุณาเลือกไฟล์"
......@@ -76,6 +59,7 @@ export class TypeRegistration {
}
const formData = new FormData();
formData.append('file', this.selectedFile);
this.dataLoading = true
this.fileService.upload(formData, 'competency_type').subscribe({
next: response => {
if (response.success) {
......@@ -83,9 +67,13 @@ export class TypeRegistration {
this.getCompetencytypeList()
} else {
this.showAlert(response.message, 'error')
this.dataLoading = false
this.cdr.detectChanges()
}
}, error: error => {
this.showAlert(error.message, 'error')
this.dataLoading = false
this.cdr.detectChanges()
}
})
}
......@@ -115,11 +103,12 @@ export class TypeRegistration {
next: response => {
this.competoncy_typeList = response.map(x => ({ check: false, data: { id: x.competencyTypeId, companyId: x.companyId, edesc: x.edesc, name: x.tdesc, code: x.shortName, level: x.expectationLevel, checked: false } }))
this.dataLoading = false
this.isDataListCheckedAll = false
this.dataListCheckAll()
this.searchChange()
this.cdr.detectChanges()
}, error: error => {
this.dataLoading = false
console.error('Error fetching employee types:', error);
this.cdr.detectChanges()
}
})
......@@ -127,21 +116,22 @@ export class TypeRegistration {
searchChange() {
this.currentPage = 1
this.page = Array.from({ length: Math.ceil(this.dataListFilter().length / 10) }, (_, i) => i + 1);
this.dataListCheck()
}
dataListFilter() {
return this.competoncy_typeList.filter(x => {
const data = x.data
const match = data.id.toLowerCase().includes(this.search) || data.name.toLowerCase().includes(this.search) || data.code.toLowerCase().includes(this.search);
const match = data.id.toLowerCase().includes(this.search.toLowerCase()) || data.name.toLowerCase().includes(this.search.toLowerCase()) || data.code.toLowerCase().includes(this.search.toLowerCase());
return match;
});
}
setData(data?: DataModel) {
this.dataSelect = JSON.parse(JSON.stringify(data || { id: "", companyId: "", name: "", edesc: "", code: "", level: "" }));
this.dataSelect = JSON.parse(JSON.stringify(data || { id: "", companyId: "", name: "", edesc: "", code: "", level: "", checked: false }));
}
// ฟังก์ชันสำหรับการเพิ่ม ลบ หรือแก้ไข ข้อมูล
addType_registration() {
const body = new MyCompetencytypeModel({ competencyTypeId: this.dataSelect.id, tdesc: this.dataSelect.name, edesc: this.dataSelect.edesc, shortName: this.dataSelect.code, expectationLevel: this.dataSelect.level })
this.dataLoading = true
this.competencytypeService.post(body).subscribe({
next: response => {
if (response.success) {
......@@ -149,9 +139,13 @@ export class TypeRegistration {
this.getCompetencytypeList()
} else {
this.showAlert(response.message, 'error')
this.dataLoading = false
this.cdr.detectChanges()
}
}, error: error => {
this.showAlert(error.message, 'error')
this.dataLoading = false
this.cdr.detectChanges()
}
})
}
......@@ -163,6 +157,7 @@ export class TypeRegistration {
} else {
body = this.competoncy_typeList.filter(x => x.check).map(x => new MyCompetencytypeModel({ competencyTypeId: x.data.id, tdesc: x.data.name, edesc: x.data.edesc, shortName: x.data.code, expectationLevel: x.data.level }));
}
this.dataLoading = true
this.competencytypeService.delete(body).subscribe({
next: response => {
if (response.success) {
......@@ -170,10 +165,14 @@ export class TypeRegistration {
this.getCompetencytypeList();
} else {
this.showAlert(response.message, 'error');
this.dataLoading = false
this.cdr.detectChanges()
}
},
error: error => {
this.showAlert(error.message, 'error')
this.dataLoading = false
this.cdr.detectChanges()
}
});
}
......@@ -184,5 +183,30 @@ export class TypeRegistration {
positionClass: 'toast-top-right',
})
}
dataListCheckAll() {
const selectAll = this.isDataListCheckedAll;
this.competoncy_typeList.filter(x => {
const data = x.data
const match = data.id.toLowerCase().includes(this.search.toLowerCase()) || data.name.toLowerCase().includes(this.search.toLowerCase()) || data.code.toLowerCase().includes(this.search.toLowerCase());
return match;
}).forEach(x => x.check = selectAll);
this.dataListCheck();
}
dataListCheck() {
const dataCheck = this.dataListFilter();
this.isDataListCheckedAll = dataCheck.length ? dataCheck.every(x => x.check) : false;
this.numDataListChecked = this.competoncy_typeList.filter(x => x.check).length;
this.isDataListChecked = Boolean(this.numDataListChecked)
}
clearData(modalStatus: string) {
if (modalStatus == 'add') {
this.setData()
} else if (modalStatus == 'edit') {
this.setData({ id: this.dataSelect.id, companyId: "", name: "", edesc: "", code: "", level: "", checked: this.dataSelect.checked })
}
}
}
......@@ -134,6 +134,7 @@ import { FileService } from 'src/app/shared/services/file.service';
import { CompetencyGroupGradeService } from 'src/app/shared/services/competency-group-grade.service';
import { IndicatorsCoursesService } from 'src/app/shared/services/indicators-courses.service';
import { IdpDevelopmentService } from 'src/app/shared/services/idp-development.service';
import { GroupAssessmentService } from 'src/app/shared/services/group-assessment.service';
import { GroupApproveService } from 'src/app/shared/services/group-approve.service';
import { UserService } from 'src/app/shared/services/user.service';
import { ManageUserComponent } from '../company-components/account-settings/manage-user/manage-user.component';
......@@ -302,6 +303,7 @@ export class CustomDateAdapter extends NativeDateAdapter {
CompetencyGroupGradeService,
IndicatorsCoursesService,
IdpDevelopmentService,
GroupAssessmentService,
GroupApproveService,
UserService,
{
......
import { CompetencytopicModel, MyCompetencytopicModel } from "./competencytopic.model"
export interface CompetencyIndicatorsCourses0Model {
competencyTopic: CompetencytopicModel
companyId: string
edesc: string
tdesc: string
indicatorsCourseDetailTh: string
indicatorsCourseDetailEn: string
expectation:string
}
export class MyCompetencyIndicatorsCourses0Model implements CompetencyIndicatorsCourses0Model {
competencyTopic: CompetencytopicModel
companyId: string
edesc: string
tdesc: string
indicatorsCourseDetailTh: string
indicatorsCourseDetailEn: string
expectation:string
constructor(data: Partial<CompetencyIndicatorsCourses0Model>) {
this.competencyTopic = new MyCompetencytopicModel(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 || ""
}
}
......@@ -14,12 +14,12 @@ export class MyCompetencyIndicatorsCourses1ListModel implements CompetencyIndica
competencyCourseId: string
competencyCourse: CompetencyCourseModel[]
competencyIndicatorsCourses2List: CompetencyIndicatorsCourses2ListModel[]
constructor(data: Partial<CompetencyIndicatorsCourses1ListModel>) {
this.lineNo = data.lineNo ?? 0
this.companyId = data.companyId || ""
this.competencyCourseId = data.competencyCourseId || ""
this.competencyCourse = data.competencyCourse?.map(x => new MyCompetencyCourseModel(x)) || []
this.competencyIndicatorsCourses2List = data.competencyIndicatorsCourses2List?.map(x => new MyCompetencyIndicatorsCourses2ListModel(x)) || []
constructor(data?: Partial<CompetencyIndicatorsCourses1ListModel>) {
this.lineNo = data?.lineNo ?? 0
this.companyId = data?.companyId || ""
this.competencyCourseId = data?.competencyCourseId || ""
this.competencyCourse = data?.competencyCourse?.map(x => new MyCompetencyCourseModel(x)) || []
this.competencyIndicatorsCourses2List = data?.competencyIndicatorsCourses2List?.map(x => new MyCompetencyIndicatorsCourses2ListModel(x)) || []
}
}
import { CompetencyCourseModel, MyCompetencyCourseModel } from "./competency-course.model"
import { CompetencyIndicatorsCourses0Model, MyCompetencyIndicatorsCourses0Model } from "./competency-indicators-courses0.model"
export interface CompetencyIndicatorsCourses1MiniModel {
competencyIndicatorsCourses0: CompetencyIndicatorsCourses0Model
lineNo: number
companyId: string
competencyCourseId: string
competencyCourse: CompetencyCourseModel[]
}
export class MyCompetencyIndicatorsCourses1MiniModel implements CompetencyIndicatorsCourses1MiniModel {
competencyIndicatorsCourses0: CompetencyIndicatorsCourses0Model
lineNo: number
companyId: string
competencyCourseId: string
competencyCourse: CompetencyCourseModel[]
constructor(data?: Partial<CompetencyIndicatorsCourses1MiniModel>) {
this.competencyIndicatorsCourses0 = new MyCompetencyIndicatorsCourses0Model(data?.competencyIndicatorsCourses0 || {})
this.lineNo = data?.lineNo ?? 0
this.companyId = data?.companyId || ""
this.competencyCourseId = data?.competencyCourseId || ""
this.competencyCourse = data?.competencyCourse?.map(x => new MyCompetencyCourseModel(x)) || []
}
}
import { GroupAssessment1ListModel, MyGroupAssessment1ListModel } from "./group-assessment1-list.model"
import { MyPLModel, PLModel } from "./pl.model"
export interface GroupAssessmentModel {
personalLevel: PLModel
companyId: string
groupAssessment1List: GroupAssessment1ListModel[]
}
export class MyGroupAssessmentModel implements GroupAssessmentModel {
personalLevel: PLModel
companyId: string
groupAssessment1List: GroupAssessment1ListModel[]
constructor(data?: Partial<GroupAssessmentModel>) {
this.personalLevel = new MyPLModel(data?.personalLevel || {})
this.companyId = data?.companyId || ""
this.groupAssessment1List = data?.groupAssessment1List?.map(x => new MyGroupAssessment1ListModel(x)) || []
}
}
import { CompetencyIndicatorsCourses1MiniModel, MyCompetencyIndicatorsCourses1MiniModel } from "./competency-indicators-courses1-mini.model"
export interface GroupAssessment1ListModel {
competencyIndicatorsCourses1Mini: CompetencyIndicatorsCourses1MiniModel
companyId: string
}
export class MyGroupAssessment1ListModel implements GroupAssessment1ListModel {
competencyIndicatorsCourses1Mini: CompetencyIndicatorsCourses1MiniModel
companyId: string
constructor(data?: Partial<GroupAssessment1ListModel>) {
this.competencyIndicatorsCourses1Mini = new MyCompetencyIndicatorsCourses1MiniModel(data?.competencyIndicatorsCourses1Mini || {})
this.companyId = data?.companyId || ""
}
}
......@@ -9,6 +9,7 @@ export interface IndicatorsCoursesModel {
tdesc: string
indicatorsCourseDetailTh: string
indicatorsCourseDetailEn: string
expectation:string
competencyIndicatorsCourses1List: CompetencyIndicatorsCourses1ListModel[]
}
......@@ -19,15 +20,17 @@ export class MyIndicatorsCoursesModel implements IndicatorsCoursesModel {
tdesc: string
indicatorsCourseDetailTh: string
indicatorsCourseDetailEn: string
expectation:string
competencyIndicatorsCourses1List: CompetencyIndicatorsCourses1ListModel[]
constructor(data: Partial<IndicatorsCoursesModel>) {
this.competencyTopic = new MyCompetencytopicModel(data.competencyTopic || {})
this.companyId = data.companyId || ""
this.edesc = data.edesc || ""
this.tdesc = data.tdesc || ""
this.indicatorsCourseDetailTh = data.indicatorsCourseDetailTh || ""
this.indicatorsCourseDetailEn = data.indicatorsCourseDetailEn || ""
this.competencyIndicatorsCourses1List = data.competencyIndicatorsCourses1List?.map(x => new MyCompetencyIndicatorsCourses1ListModel(x)) || []
constructor(data?: Partial<IndicatorsCoursesModel>) {
this.competencyTopic = new MyCompetencytopicModel(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 || ""
this.competencyIndicatorsCourses1List = data?.competencyIndicatorsCourses1List?.map(x => new MyCompetencyIndicatorsCourses1ListModel(x)) || []
}
}
......@@ -11,11 +11,11 @@ export class MyPLModel implements PLModel {
tdesc: string;
edesc: string;
companyId: string
constructor(data: Partial<PLModel>) {
this.plId = data.plId || ""
this.tdesc = data.tdesc || ""
this.edesc = data.edesc || ""
this.companyId = data.companyId || ""
constructor(data?: Partial<PLModel>) {
this.plId = data?.plId || ""
this.tdesc = data?.tdesc || ""
this.edesc = data?.edesc || ""
this.companyId = data?.companyId || ""
}
}
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 { GroupAssessmentModel } from '../model/group-assessment.model';
@Injectable({
providedIn: 'root'
})
export class GroupAssessmentService {
api = "/groupassessment"
urlApi = environment.baseUrl + this.api
constructor(private http: HttpClient) {
}
getById(plId: string): Observable<GroupAssessmentModel> {
return this.http.get<GroupAssessmentModel>(this.urlApi + "/" + plId)
}
getList(): Observable<GroupAssessmentModel[]> {
return this.http.get<GroupAssessmentModel[]>(this.urlApi + "/lists")
}
post(body: GroupAssessmentModel): Observable<AlertModel> {
return this.http.post<AlertModel>(this.urlApi, body)
}
delete(body: GroupAssessmentModel | GroupAssessmentModel[]): Observable<AlertModel> {
const options = {
headers: new HttpHeaders({
"Content-Type": "application/json",
}),
body: body
};
return this.http.delete<AlertModel>(this.urlApi, options)
}
}
\ No newline at end of file
......@@ -13,7 +13,7 @@ export class IndicatorsCoursesService {
constructor(private http: HttpClient) {
}
getList(): Observable<IndicatorsCoursesModel[]> {
return this.http.get<IndicatorsCoursesModel[]>(this.urlApi + "/lists")
return this.http.get<IndicatorsCoursesModel[]>(this.urlApi + "/lists/indicators-courses")
}
getById(competencyIndicatorsId: string): Observable<IndicatorsCoursesModel> {
return this.http.get<IndicatorsCoursesModel>(this.urlApi + "/" + competencyIndicatorsId)
......
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