Commit 8a0f2a39 by Nattana Chaiyamat

ทะเบียนหลักสูตร

parent cec1bf1a
......@@ -62,7 +62,8 @@
<td>{{item.data.employee.lname}}</td>
<td class="text-center">{{item.data.status=='0'?'ไม่ใช้งาน':'ใช้งาน'}}</td>
<td class="flex justify-center">
<i class="ti ti-edit cursor-pointer i-gray fs-l px-1" (click)="selectUser(item.data)"
<i class="ti ti-edit cursor-pointer i-gray fs-l px-1"
(click)="changePassword=false;selectUser(item.data)"
data-hs-overlay="#manage-user-modal"></i>
</td>
</tr>
......
......@@ -10,15 +10,15 @@
<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)="pathTitle = ['การประเมินสมรรถนะ','ทะเบียนหลักสูตร','หลักสูตรการพัฒนา']">
aria-controls="underline-1"
(click)="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 id="underline-1" role="tabpanel" aria-labelledby="underline-item-1">
<app-development-course [pathTitle]="pathTitle"
(sendPathTitle)="pathTitle=$event"></app-development-course>
<app-development-course></app-development-course>
</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">
<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">{{mockDataSelect.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>
<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,28 +32,26 @@
<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="#development-course-modal-add">
data-hs-overlay="#development-course-upload-modal"
(click)="fileInput.value = '';selectedFile=null;selectedFileName = 'กรุณาเลือกไฟล์'">
<i class="ti ti-file-plus"></i>
import
</button>
</div>
<div class="px-1">
<button type="button" class="ti-btn ti-btn-soft-secondary h-10 m-0 shadow-md"
data-hs-overlay="#development-course-modal-add" (click)="selectCompetencycourse()">
data-hs-overlay="#development-course-modal" (click)="currentModal='add';selectCompetencycourse()">
<i class="ri-add-line"></i>
Add
</button>
</div>
<div class="px-1">
<button href="javascript:void(0);" class="ti-btn ti-btn-soft-danger h-10 m-0 shadow-md">
<button href="javascript:void(0);" class="ti-btn ti-btn-soft-danger h-10 m-0 shadow-md"
data-hs-overlay="#development-course-alert-modal"
(click)="currentModal='deleteGroup';selectCompetencycourse()">
<i class="ri-delete-bin-6-line"></i>
Delete
</button>
<!-- <button href="javascript:void(0);" class="ti-btn ti-btn-soft-danger h-10 m-0 shadow-md"
data-hs-overlay="#development-course-alert-delete-modal">
<i class="ri-delete-bin-6-line"></i>
Delete
</button> -->
</div>
<div class="px-1">
<button href="javascript:void(0);" class="ti-btn ti-btn-soft-warning h-10 m-0 shadow-md">
......@@ -85,7 +80,7 @@
</ng-container>
</tr>
</thead>
<tbody *ngIf="dataLoading">
<tbody *ngIf="competencyCourse.loading">
<tr>
<td class="text-center" colspan="100%">
<div *ngFor="let item of [1,2,3]" class="ti-spinner w-8 h-8 text-secondary mx-1" role="status"
......@@ -95,27 +90,31 @@
</td>
</tr>
</tbody>
<tbody *ngIf="!dataLoading&&!dataListFilter().length">
<tbody *ngIf="!competencyCourse.loading&&!dataListFilter().length">
<tr>
<td class="text-center" colspan="100%">
ไม่พบข้อมูล
</td>
</tr>
</tbody>
<tbody *ngIf="!dataLoading&&dataListFilter().length">
<tbody *ngIf="!competencyCourse.loading&&dataListFilter().length">
<tr
*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.id}}"
[(ngModel)]="item.checked" (change)="checkSelect()">
<label for="checkbox-{{item.id}}">&nbsp;{{item.id}}</label>
<input type="checkbox" class="ti-form-checkbox cursor-pointer"
id="checkbox-{{item.data.competencyCourseId}}" [(ngModel)]="item.check"
(change)="dataListCheck()">
<label
for="checkbox-{{item.data.competencyCourseId}}">&nbsp;{{item.data.competencyCourseId}}</label>
</td>
<td>{{item.name}}</td>
<td>{{item.data.tdesc}}</td>
<td class="flex justify-center">
<i class="ti ti-edit cursor-pointer i-gray fs-l px-1" (click)="selectCompetencycourse(item)"
data-hs-overlay="#development-course-modal-edit"></i>
<i class="ti ti-trash cursor-pointer i-gray fs-l px-1" (click)="selectCompetencycourse(item)"
data-hs-overlay="#development-course-alert-delete-modal"></i>
<i class="ti ti-edit cursor-pointer i-gray fs-l px-1"
(click)="currentModal='edit' ;selectCompetencycourse(item.data)"
data-hs-overlay="#development-course-modal"></i>
<i class="ti ti-trash cursor-pointer i-gray fs-l px-1"
(click)="currentModal='delete' ;selectCompetencycourse(item.data)"
data-hs-overlay="#development-course-alert-modal"></i>
</td>
</tr>
</tbody>
......@@ -160,91 +159,77 @@
</nav>
</div>
<div id="development-course-modal-add" class="hs-overlay hidden ti-modal">
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)]">
<div class="max-h-full overflow-hidden ti-modal-content">
<div class="ti-modal-header">
<h3 class="text-xxl font-bold text-primary">
เพิ่มหลักสูตรการพัฒนา
</h3>
<div class="flex justify-end">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#development-course-modal-add">
<span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i>
<div id="development-course-upload-modal" class="hs-overlay hidden ti-modal">
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out rounded-md">
<div class="ti-modal-header bg-primary !rounded-none !rounded-t-sm">
<h5 class="text-xxl font-bold text-white">
นำเข้าหลักสูตรการพัฒนา
</h5>
</div>
<div class="ti-modal-body max-h-full overflow-hidden ti-modal-content !rounded-t-none !rounded-b-sm">
<h1 class="mt-2" style="text-align: center;">ไฟล์</h1>
<div class="mt-2 p-2">
<div class="flex rounded-md">
<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()"
class="inline-flex flex-shrink-0 justify-center items-center h-[2.875rem] w-[2.875rem] ltr:rounded-r-md rtl:rounded-l-md border border-transparent font-semibold bg-secondary text-white hover:bg-secondary focus:z-10 focus:outline-none focus:ring-0 focus:ring-secondary transition-all text-sm">
<i class="ti ti-upload"></i>
</button>
</div>
</div>
<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">
<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)">
<g id="SVGRepo_bgCarrier" stroke-width="0"></g>
<g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g>
<g id="SVGRepo_iconCarrier">
<path d="M15 49A24 24 0 0 1 32 8"></path>
<path d="M49 15a24 24 0 0 1-17 41"></path>
<polyline points="15.03 40 15.03 48.97 8 48.97"></polyline>
<polyline points="48.97 24 48.97 15.03 56 15.03"></polyline>
</g>
</svg>
Clear
</button>
</div>
<div class="px-1">
<button href="javascript:void(0);" class="ti-btn ti-btn-soft-warning h-45px m-0 shadow-md">
<i class="ti ti-book fs-l"></i>
Help
</button>
</div>
</div>
</div>
<div class="ti-modal-body mt-1">
<label for="input-label" class="ti-form-label">รหัสหลักสูตร*</label>
<input type="text" id="input-label" class="ti-form-input w-1/2" [(ngModel)]="dataSelect.id">
<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.detail"> </textarea>
<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.topic"> </textarea>
<label for="input-label" class="ti-form-label">Link myLearn</label>
<input type="text" id="input-label" class="ti-form-input h-10" [(ngModel)]="dataSelect.courseLinkMylearn">
<div class="flex justify-end mt-3rem mb-1rem space-x-4">
<button type="button"
class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
data-hs-overlay="#development-course-modal-add">
ย้อนกลับ
<div class="flex justify-center mt-2rem ">
<h1 class="cursor-pointer justify-center -mb-px inline-flex items-center gap-2 font-weight-500 font-size-12px
text-center text-secondary border-secondary border-b-2 align-items-end" (click)="downloadFile()">
ดาวน์โหลดตัวอย่างไฟล์</h1>
</div>
<div class="flex justify-center mt-2rem mb-1rem space-x-4">
<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>
<a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#development-course-alert-add-modal">
บันทึกข้อมูล
</a>
</div>
</div>
</div>
</div>
</div>
<div id="development-course-modal-edit" class="hs-overlay hidden ti-modal">
<div id="development-course-modal" class="hs-overlay hidden ti-modal">
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)]">
<div class="max-h-full overflow-hidden ti-modal-content">
<div class="ti-modal-header">
<h3 class="text-xxl font-bold text-primary">
<h3 class="text-xxl font-bold text-primary" *ngIf="currentModal=='add'">
เพิ่มหลักสูตรการพัฒนา
</h3>
<h3 class="text-xxl font-bold text-primary" *ngIf="currentModal=='edit'">
แก้ไขหัวข้อสมรรถนะ
</h3>
<div class="flex justify-end">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#development-course-modal-edit">
data-hs-overlay="#development-course-modal">
<span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i>
</button>
......@@ -253,7 +238,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(currentModal)">
<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)">
......@@ -279,30 +265,35 @@
</div>
<div class="ti-modal-body mt-1">
<label for="input-label" class="ti-form-label">รหัสหลักสูตร*</label>
<input type="text" id="input-label" class="ti-form-input w-1/2 bg-input-readonly" readonly
[(ngModel)]="dataSelect.id">
<input type="text" id="input-label" class="ti-form-input w-1/2"
[ngClass]="{'bg-input-readonly':currentModal=='edit'}" [readonly]="currentModal=='edit'"
[(ngModel)]="competencyCourse.select.competencyCourseId">
<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">
<input type="text" id="detail_th" class="ti-form-input h-10"
[(ngModel)]="competencyCourse.select.tdesc">
<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">
<input type="text" id="detail_eng" class="ti-form-input h-10"
[(ngModel)]="competencyCourse.select.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.detail"> </textarea>
[(ngModel)]="competencyCourse.select.courseDetail"> </textarea>
<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.topic"> </textarea>
<label for="input-label" class="ti-form-label">Link myLearn</label>
<input type="text" id="input-label" class="ti-form-input h-10" [(ngModel)]="dataSelect.courseLinkMylearn">
[(ngModel)]="competencyCourse.select.courseTopic"> </textarea>
<label class="ti-form-label mt-2rem">Link myLearn</label>
<input type="text" class="ti-form-input h-10" [(ngModel)]="competencyCourse.select.courseLinkMylearn">
<div class="flex justify-end mt-3rem mb-1rem space-x-4">
<button type="button"
class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
data-hs-overlay="#development-course-modal-edit">
data-hs-overlay="#development-course-modal">
ย้อนกลับ
</button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#development-course-alert-edit-modal">
<button type="button" class="ti-btn ti-btn-success"
data-hs-overlay="#development-course-alert-modal"
[class.ti-btn-disabled]="!competencyCourse.select.competencyCourseId||!competencyCourse.select.tdesc"
[disabled]="!competencyCourse.select.competencyCourseId||!competencyCourse.select.tdesc">
บันทึกข้อมูล
</a>
</button>
</div>
</div>
</div>
......@@ -310,7 +301,7 @@
</div>
<div id="development-course-alert-add-modal" class="hs-overlay hidden ti-modal">
<div id="development-course-alert-modal" class="hs-overlay hidden ti-modal">
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)] flex items-center">
<div class="max-h-full overflow-hidden ti-modal-content w-full">
<div class="ti-modal-header">
......@@ -319,96 +310,48 @@
</h3>
<div class="flex justify-end">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#development-course-alert-add-modal">
*ngIf="currentModal=='add'||currentModal=='edit'"
data-hs-overlay="#development-course-modal">
<span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i>
</button>
</div>
</div>
<div class="ti-modal-body ">
<p class="mt-1 text-gray-800 dark:text-white/70">
ยืนยันการบันทึกข้อมูลหรือไม่
</p>
<div class="flex justify-end mt-2rem mb-1rem">
<button type="button"
class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
data-hs-overlay="#development-course-modal-add">
ย้อนกลับ
</button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#development-course-alert-add-modal" (click)="addUser()">
บันทึกข้อมูล
</a>
</div>
</div>
</div>
</div>
</div>
<div id="development-course-alert-edit-modal" class="hs-overlay hidden ti-modal">
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)] flex items-center">
<div class="max-h-full overflow-hidden ti-modal-content w-full">
<div class="ti-modal-header">
<h3 class="text-xxl font-bold text-primary">
แจ้งเตือน
</h3>
<div class="flex justify-end">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#development-course-alert-edit-modal">
*ngIf="currentModal=='delete'||currentModal=='deleteGroup'"
data-hs-overlay="#development-course-alert-modal">
<span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i>
</button>
</div>
</div>
<div class="ti-modal-body ">
<p class="mt-1 text-gray-800 dark:text-white/70">
ยืนยันการเเก้ไขข้อมูลหรือไม่
<p class="mt-1 text-gray-800 dark:text-white/70" *ngIf="currentModal=='add'||currentModal=='edit'">
ยืนยันการบันทึกข้อมูลหรือไม่
</p>
<p class="mt-1 text-gray-800 dark:text-white/70"
*ngIf="currentModal=='delete'||currentModal=='deleteGroup'">
ยืนยันการลบข้อมูลหรือไม่
</p>
<div class="flex justify-end mt-2rem mb-1rem">
<div class="flex justify-end mt-2rem mb-1rem" *ngIf="currentModal=='add'||currentModal=='edit'">
<button type="button"
class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
data-hs-overlay="#development-course-modal-edit">
data-hs-overlay="#development-course-modal">
ย้อนกลับ
</button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#development-course-alert-edit-modal" (click)="addUser()">
data-hs-overlay="#development-course-alert-modal" (click)="updateCompetencyCourse('post')">
บันทึกข้อมูล
</a>
</div>
</div>
</div>
</div>
</div>
<div id="development-course-alert-delete-modal" class="hs-overlay hidden ti-modal">
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)] flex items-center">
<div class="max-h-full overflow-hidden ti-modal-content w-full">
<div class="ti-modal-header">
<h3 class="text-xxl font-bold text-primary">
แจ้งเตือน
</h3>
<div class="flex justify-end">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#development-course-alert-delete-modal">
<span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i>
</button>
</div>
</div>
<div class="ti-modal-body ">
<p class="mt-1 text-gray-800 dark:text-white/70">
ยืนยันการลบข้อมูลหรือไม่!
</p>
<div class="flex justify-end mt-2rem mb-1rem">
<div class="flex justify-end mt-2rem mb-1rem"
*ngIf="currentModal=='delete'||currentModal=='deleteGroup'">
<button type="button"
class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
data-hs-overlay="#development-course-alert-delete-modal">
data-hs-overlay="#development-course-alert-modal">
ย้อนกลับ
</button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#development-course-alert-delete-modal" (click)="deleteUser()">
<a class="ti-btn ti-btn-danger" href="javascript:void(0);"
data-hs-overlay="#development-course-alert-modal" (click)="updateCompetencyCourse('delete')">
ลบข้อมูล
</a>
</div>
......
import { ChangeDetectorRef, Component, EventEmitter, Input, Output } from '@angular/core';
import { ToastrService } from 'ngx-toastr';
import { CompetencyCourseModel, MyCompetencyCourseModel } from 'src/app/shared/model/competency-course.model';
import { MyCompetencycourseModel } from 'src/app/shared/model/competencycourse.model';
import { CompetencycourseService } from 'src/app/shared/services/competencycourse.service';
export interface DataModel {
id: string
name: string
edesc: string
detail: string
topic: string
courseLinkMylearn: string
checked: boolean
}
import { FileService } from 'src/app/shared/services/file.service';
@Component({
selector: 'app-development-course',
templateUrl: './development-course.component.html',
styleUrls: ['./development-course.component.scss']
})
export class DevelopmentCourseComponent {
@Input() pathTitle = ['การประเมินสมรรถนะ', 'ทะเบียนหลักสูตร', 'หลักสูตรการพัฒนา'];
@Output() sendPathTitle: EventEmitter<string[]> = new EventEmitter<string[]>();
activeTab: string = 'tab1'; // กำหนด tab เริ่มต้น
currentPage = 1
page = Array.from({ length: 1 }, (_, i) => i + 1);
search = ""
// ฟังก์ชันในการเปลี่ยนแท็บ
changeTab(tab: { id: string, text: string }) {
this.sendPathTitle.emit(['การประเมินสมรรถนะ', 'ตั้งค่าผู้ใช้งาน', tab.text]);
this.activeTab = tab.id;
}
// การจัดการการเปิดปิด modal
modalOptions: {
[nameModal: string]: {
isModalOpen: boolean;
modalSize: string;
backdropClose: boolean;
};
} = {
"add": {
isModalOpen: false,
modalSize: 'm',
backdropClose: true,
},
"edit": {
isModalOpen: false,
modalSize: 'm',
backdropClose: true,
}
};
currentModal: 'add' | 'edit' | 'delete' | 'deleteGroup' = "add";
competencyCourse: { loading: boolean, select: CompetencyCourseModel, dataList: { check: boolean, data: CompetencyCourseModel }[] } = { loading: false, select: new MyCompetencyCourseModel(), dataList: [] }
numDataListChecked = 0
isDataListChecked = false
isDataListCheckedAll = 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';
}
closeModal(name: string) {
this.modalOptions[name].isModalOpen = false;
if (!this.isAnyModalOpen()) {
document.body.style.overflow = ''; // คืนค่าการ Scroll เฉพาะเมื่อ Modal ทั้งหมดปิดแล้ว
}
selectedFile: File | null = null;
selectedFileName: string = 'กรุณาเลือกไฟล์';
constructor(private toastr: ToastrService,
private cdr: ChangeDetectorRef,
private competencycourseService: CompetencycourseService,
private fileService: FileService
) { }
ngOnInit(): void {
this.getCompetencycourseList()
}
isAnyModalOpen(): boolean {
return Object.values(this.modalOptions).some(modal => modal.isModalOpen); // ตรวจสอบว่า modal อื่นยังเปิดอยู่หรือไม่
onFileSelected(event: any) {
this.selectedFile = event.target.files.length > 0 ? event.target.files[0] : null;
this.selectedFileName = this.selectedFile?.name || "กรุณาเลือกไฟล์"
}
// ฟังก์ชัน toggle checkbox
isChecked: boolean = false; // ใช้สำหรับตรวจสอบสถานะของ checkbox
toggleCheckbox() {
this.isChecked = !this.isChecked;
this.mockData.forEach((item) => {
item.checked = this.isChecked;
});
this.checkSelect();
uploadFile() {
if (!this.selectedFile) {
alert('กรุณาเลือกไฟล์ก่อนอัปโหลด')
return
}
// ฟังก์ชันสำหรับการเพิ่ม ลบ หรือแก้ไข ข้อมูล
addUser() {
const body = new MyCompetencycourseModel({ competencyCourseId: this.dataSelect.id, tdesc: this.dataSelect.name, edesc: this.dataSelect.edesc, courseTopic: this.dataSelect.topic, courseDetail: this.dataSelect.detail, courseLinkMylearn: this.dataSelect.courseLinkMylearn })
this.competencycourseService.post(body).subscribe((response: any) => {
const formData = new FormData();
formData.append('file', this.selectedFile);
this.competencyCourse.loading = true
this.fileService.uploadExcel(formData, '').subscribe({
next: response => {
if (response.success) {
this.showSuccess()
this.showAlert(response.message, 'success')
this.getCompetencycourseList()
} else {
this.showAlert(response.message, 'error')
this.competencyCourse.loading = false
this.cdr.detectChanges()
}
}, error: error => {
this.showAlert(error.message, 'error')
this.competencyCourse.loading = false
this.cdr.detectChanges()
}
})
}
deleteUser() {
const body = new MyCompetencycourseModel({ competencyCourseId: this.dataSelect.id, tdesc: this.dataSelect.name, edesc: this.dataSelect.edesc, courseTopic: this.dataSelect.topic, courseDetail: this.dataSelect.detail,courseLinkMylearn: this.dataSelect.courseLinkMylearn })
this.competencycourseService.delete(body).subscribe((response: any) => {
if (response.success) {
this.showSuccessDelete()
this.getCompetencycourseList()
downloadFile() {
const fileName = '.xlsx'
this.fileService.downloadTemplate(fileName).subscribe({
next: response => {
const url = window.URL.createObjectURL(response);
const a = document.createElement("a");
a.href = url;
a.download = fileName;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
window.URL.revokeObjectURL(url);
}, error: error => {
this.showAlert(error.message, 'error')
}
})
}
currentModal = "";
mockData: DataModel[] = []
dataLoading = false
dataSelect: DataModel = { id: "", name: "", edesc: "", topic: "", detail: "",courseLinkMylearn:"", checked: false }
mockDataSelect: any = []
constructor(private toastr: ToastrService,
private cdr: ChangeDetectorRef,
private competencycourseService: CompetencycourseService
) { }
ngOnInit(): void {
this.getCompetencycourseList()
}
getCompetencycourseList() {
this.dataLoading = true
this.competencyCourse.loading = true
this.competencycourseService.getList().subscribe({
next: response => {
this.mockData = response.map(x => ({ id: x.competencyCourseId, name: x.tdesc, edesc: x.edesc, topic: x.courseTopic, detail: x.courseDetail,courseLinkMylearn:x.courseLinkMylearn, checked: false }))
this.dataLoading = false
this.competencyCourse.dataList = response.map(x => ({ check: false, data: new MyCompetencyCourseModel(x) }))
this.competencyCourse.loading = false
this.isDataListCheckedAll = false
this.dataListCheckAll()
this.searchChange()
this.cdr.detectChanges()
}, error: error => {
this.dataLoading = false
this.competencyCourse.loading = false
this.cdr.detectChanges()
}
})
......@@ -133,39 +97,78 @@ export class DevelopmentCourseComponent {
searchChange() {
this.currentPage = 1
this.page = Array.from({ length: Math.ceil(this.dataListFilter().length / 10) }, (_, i) => i + 1);
this.dataListCheck()
}
dataListFilter() {
return this.mockData.filter(x => {
const data = x
const match = data.id.includes(this.search) || data.name.includes(this.search)
return this.competencyCourse.dataList.filter(x => {
const data = x.data
const match = data.competencyCourseId.toLowerCase().includes(this.search.toLowerCase()) || data.tdesc.toLowerCase().includes(this.search.toLowerCase())
return match;
});
}
selectCompetencycourse(data?: DataModel) {
this.dataSelect = JSON.parse(JSON.stringify(data || { id: "", name: "", edesc: "", topic: "", detail: "", checked: false }));
selectCompetencycourse(data?: CompetencyCourseModel) {
this.competencyCourse.select = new MyCompetencyCourseModel(data)
}
checkSelect() {
this.mockDataSelect = this.mockData.filter(item => item.checked);
updateCompetencyCourse(typeApi: 'post' | 'delete') {
this.competencyCourse.loading = true
let body: CompetencyCourseModel | CompetencyCourseModel[]
switch (this.currentModal) {
case ('deleteGroup'): {
body = this.competencyCourse.dataList.filter(x => x.check).map(x => new MyCompetencyCourseModel(x.data))
break;
}
default: {
body = new MyCompetencyCourseModel(this.competencyCourse.select)
}
}
this.competencycourseService[typeApi]((body as any)).subscribe({
next: response => {
if (response.success) {
this.showAlert(response.message, 'success')
this.getCompetencycourseList()
this.searchChange()
} else {
this.showAlert(response.message, 'error')
this.competencyCourse.loading = false
}
this.cdr.detectChanges()
}, error: error => {
this.showAlert(error.message, 'error')
this.competencyCourse.loading = false
this.cdr.detectChanges()
}
})
}
showSuccess() {
this.toastr.success('บันทึกข้อมูลสำเร็จ', 'เเจ้งเตือน', {
showAlert(text: string, type: 'success' | 'error') {
this.toastr[type](text, 'แจ้งเตือน', {
timeOut: 3000,
positionClass: 'toast-top-right',
});
})
}
showSuccessEdit() {
this.toastr.success('เเก้ไขข้อมูลสำเร็จ', 'เเจ้งเตือน', {
timeOut: 3000,
positionClass: 'toast-top-right',
});
dataListCheckAll() {
const selectAll = this.isDataListCheckedAll;
this.competencyCourse.dataList.filter(x => {
const data = x.data
const match = data.competencyCourseId.toLowerCase().includes(this.search.toLowerCase()) || data.tdesc.toLowerCase().includes(this.search.toLowerCase())
return match;
}).forEach(x => x.check = selectAll);
this.dataListCheck();
}
showSuccessDelete() {
this.toastr.success('ลบข้อมูลสำเร็จ', 'เเจ้งเตือน', {
timeOut: 3000,
positionClass: 'toast-top-right',
});
dataListCheck() {
const dataCheck = this.dataListFilter();
this.isDataListCheckedAll = dataCheck.length ? dataCheck.every(x => x.check) : false;
this.numDataListChecked = this.competencyCourse.dataList.filter(x => x.check).length;
this.isDataListChecked = Boolean(this.numDataListChecked)
}
clearData(modalStatus: string) {
if (modalStatus == 'add') {
this.selectCompetencycourse()
} else if (modalStatus == 'edit') {
this.selectCompetencycourse(new MyCompetencyCourseModel({ competencyCourseId: this.competencyCourse.select.competencyCourseId }))
}
}
}
......@@ -5,6 +5,7 @@ export interface CompetencyCourseModel {
tdesc: string
courseDetail: string
courseTopic: string
courseLinkMylearn: string
}
export class MyCompetencyCourseModel implements CompetencyCourseModel {
competencyCourseId: string
......@@ -13,13 +14,15 @@ export class MyCompetencyCourseModel implements CompetencyCourseModel {
tdesc: string
courseDetail: string
courseTopic: string
constructor(data: Partial<CompetencyCourseModel>) {
this.competencyCourseId = data.competencyCourseId || ""
this.tdesc = data.tdesc || ""
this.edesc = data.edesc || ""
this.companyId = data.companyId || ""
this.courseDetail = data.courseDetail || ""
this.courseTopic = data.courseTopic || ""
courseLinkMylearn: string
constructor(data?: Partial<CompetencyCourseModel>) {
this.competencyCourseId = data?.competencyCourseId || ""
this.tdesc = data?.tdesc || ""
this.edesc = data?.edesc || ""
this.companyId = data?.companyId || ""
this.courseDetail = data?.courseDetail || ""
this.courseTopic = data?.courseTopic || ""
this.courseLinkMylearn = data?.courseLinkMylearn || ""
}
}
......@@ -3,6 +3,7 @@ import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { environment } from 'src/environments/environment';
import { CompetencycourseModel } from '../model/competencycourse.model';
import { AlertModel } from '../model/alert.model';
@Injectable({
providedIn: 'root'
})
......@@ -17,16 +18,16 @@ export class CompetencycourseService {
getList(): Observable<CompetencycourseModel[]> {
return this.http.get<CompetencycourseModel[]>(this.urlApi + "/lists")
}
post(body: CompetencycourseModel) {
return this.http.post(this.urlApi, body)
post(body: CompetencycourseModel): Observable<AlertModel> {
return this.http.post<AlertModel>(this.urlApi, body)
}
delete(body: CompetencycourseModel) {
delete(body: CompetencycourseModel): Observable<AlertModel> {
const options = {
headers: new HttpHeaders({
"Content-Type": "application/json",
}),
body: body
};
return this.http.delete(this.urlApi, options)
return this.http.delete<AlertModel>(this.urlApi, options)
}
}
\ No newline at end of file
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