Commit 7dfbe0f3 by Natthaphat

การประเมินสมรรถนะ > ทะเบียนกำหนดชื่อ > หัวข้อสมรรถนะ

parent 127d762b
...@@ -31,7 +31,14 @@ ...@@ -31,7 +31,14 @@
</ng-container> </ng-container>
<!-- <td class="flex justify-center">
<i class="ti ti-eye cursor-pointer i-gray fs-l px-1"
(click)="selectIndicatorsCourses(item);seeTab=true;editTab=false;pathTitleChange()"></i>
<i class="ti ti-edit cursor-pointer i-gray fs-l px-1"
(click)="selectIndicatorsCourses(item);seeTab=false;editTab=true;pathTitleChange()"></i>
<i *ngIf="item.file" class="ti ti-file-download cursor-pointer i-gray fs-l px-1"
(click)="dowloadExam(item.file)"></i>
</td> -->
<ng-container *ngIf="editTab||seeTab"> <ng-container *ngIf="editTab||seeTab">
<app-edit-group-indicators [competencytopic]="indicatorsCourses" [seeTab]="seeTab" <app-edit-group-indicators [competencytopic]="indicatorsCourses" [seeTab]="seeTab"
......
<div class="w-full min-height-50px mb-10px justify-between items-center"> <div class="w-full min-height-50px mb-10px justify-between items-center">
<div class="flex justify-between"> <div class="flex justify-between">
<div class="flex"> <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()" id="checkbox"
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" for="checkbox">Select All</label>
</div>
</div> </div>
<div class="flex justify-end"> <div class="flex justify-end">
<div class="px-1"> <div class="px-1">
<div class="relative shadow-md"> <div class="relative shadow-md">
<input type="text" id="hs-leading-icon" name="hs-leading-icon" <input type="text" id="hs-leading-icon" name="hs-leading-icon"
class="ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 " placeholder="Search by No. or Name" class="ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 " placeholder="Search by No. or Name"
[(ngModel)]="search" (ngModelChange)="searchChange()" style="height: 40px;"> [(ngModel)]="search" style="height: 40px;">
<div <div
class="absolute inset-y-0 ltr:left-0 rtl:right-0 flex items-center pointer-events-none z-20 ltr:pl-4 rtl:pr-4"> class="absolute inset-y-0 ltr:left-0 rtl:right-0 flex items-center pointer-events-none z-20 ltr:pl-4 rtl:pr-4">
<i class="ri-search-line text-gray"></i> <i class="ri-search-line text-gray"></i>
...@@ -39,203 +26,77 @@ ...@@ -39,203 +26,77 @@
</div> </div>
<div class="px-1"> <div class="px-1">
<button type="button" class="ti-btn ti-btn-soft-secondary h-10 m-0 shadow-md" <button type="button" class="ti-btn ti-btn-soft-secondary h-10 m-0 shadow-md"
data-hs-overlay="#competency-topic-page-modal" (click)="currentModal='add';examFile=null;examFileName = 'กรุณาเลือกไฟล์';openDialog();selectCompetencyTopic()">
(click)="modalStatus='add';setData();fileInputMedium.value = '';examFile=null;examFileName = 'กรุณาเลือกไฟล์'">
<i class="ri-add-line"></i> <i class="ri-add-line"></i>
Add Add
</button> </button>
</div> </div>
<div class="px-1"> <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="#competency-topic-page-alert-modal" (click)="modalStatus='deleteGroup';setData()"> (click)="currentModal='delete';deleteCompetency_topic()">
<i class="ri-delete-bin-6-line"></i> <i class="ri-delete-bin-6-line"></i>
Delete Delete
</button> </button>
</div> </div>
<!-- <div class="px-1">
<button href="javascript:void(0);" class="ti-btn ti-btn-soft-warning h-10 m-0 shadow-md">
<i class="ti ti-book fs-l"></i>
Help
</button>
</div> -->
</div> </div>
</div> </div>
</div> </div>
<div class="page px-rem"> <div class="page px-rem">
<div class="overflow-auto shadow-md rounded-t-md"> <app-datagrid-syncfution [searchSettings]="searchSettings" [searchText]="search"
<table class="ti-custom-table ti-custom-table-head ti-custom-table-hover table-bordered"> [dataSource]="competencyTopic.dataList" [columns]="columns" [selectedItems]="selectedItems"
<thead> (sendSelectData)="currentModal='edit';selectCompetencyTopic($event);openDialog()"
<tr> (sendSelectedItems)="onSelectItemChange($event)">
<ng-container </app-datagrid-syncfution>
*ngFor="let item of ['','รหัส','ชื่อหัวข้อ','ประเภท','การจัดการ']; let f = first; let l = last; let i = index">
<th scope="col" class="relative px-10px py-10px bg-soft-secondary text-primary !text-center">
<span class="font-size-12px font-weight-700">{{ item }}</span>
<div class="absolute top-1/2 transform -translate-y-1/2 right-0" *ngIf="!f&&!l">
<i class="ti ti-dots-vertical fs-l"></i>
</div>
</th>
</ng-container>
</tr>
</thead>
<tbody *ngIf="dataLoading">
<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"
aria-label="loading">
<span class="sr-only">Loading...</span>
</div>
</td>
</tr>
</tbody>
<tbody *ngIf="!dataLoading&&!dataListFilter().length">
<tr>
<td class="text-center" colspan="100%">
ไม่พบข้อมูล
</td>
</tr>
</tbody>
<tbody *ngIf="!dataLoading&&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.data.id}}"
[(ngModel)]="item.check" (change)="dataListCheck()">
</td>
<td class="text-center">
<label for="checkbox-{{item.data.id}}">&nbsp;{{item.data.id}}</label>
</td>
<td>{{item.data.name}}</td>
<td class="text-center">{{item.data.code}}</td>
<td class="flex justify-center">
<i class="ti ti-edit cursor-pointer i-gray fs-l px-1"
(click)="modalStatus='edit';setData(item.data)"
data-hs-overlay="#competency-topic-page-modal"></i>
<!-- <i class="ti ti-trash cursor-pointer i-gray fs-l px-1"
(click)="modalStatus='delete';setData(item.data)"
data-hs-overlay="#competency-topic-page-alert-modal"></i> -->
</td>
</tr>
</tbody>
</table>
</div>
<nav class="pagination-style-3 overflow-auto my-5" *ngIf="page.length">
<ul class="ti-pagination">
<li>
<a aria-label="anchor" class="page-link" href="javascript:void(0);"
(click)="currentPage = (currentPage-1 || 1)">
<i class="ri-arrow-left-s-line align-middle rtl:rotate-180"></i>
</a>
</li>
<li *ngFor="let item of page;let f = first;let l = last">
<ng-container *ngIf="item==3&&currentPage!=1&&currentPage!=2&&currentPage!=3">
<a aria-label="anchor" class="page-link" href="javascript:void(0);"><i class="ri-more-line"></i>
</a>
</ng-container>
<ng-container *ngIf="(f||l)||(item==currentPage-1||item==currentPage||item==currentPage+1)">
<a class="page-link" href="javascript:void(0);" [class.active]="item==currentPage"
(click)="currentPage=item">{{item}}
</a>
</ng-container>
<ng-container
*ngIf="item==page.length-2&&currentPage!=page.length&&currentPage!=page.length-1&&currentPage!=page.length-2">
<a aria-label="anchor" class="page-link" href="javascript:void(0);"><i class="ri-more-line"></i>
</a>
</ng-container>
</li>
<li>
<a aria-label="anchor" class="page-link" href="javascript:void(0);"
(click)="currentPage = (currentPage > page.length-1 ? currentPage: currentPage+1 )">
<i class="ri-arrow-right-s-line align-middle rtl:rotate-180"></i>
</a>
</li>
</ul>
<ul class="nav-tabs mt-3">
<span>Show {{((currentPage-1) * 10)+1}} to {{dataListFilter().length<10 ?dataListFilter().length:
(currentPage==page.length ? ((currentPage * 10) - ((currentPage * 10) - dataListFilter().length) )
:(currentPage * 10) ) }} of {{dataListFilter().length}} items</span>
</ul>
</nav>
</div> </div>
<ng-template #competencyTopicModal let-modal>
<h3 mat-dialog-title>
<div id="competency-topic-page-modal" class="hs-overlay hidden ti-modal"> {{currentModal=='add'?'เพิ่มหัวข้อสมรรถนะ':'แก้ไขหัวข้อสมรรถนะ'}}
<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">
{{modalStatus=='add'?'เพิ่มหัวข้อสมรรถนะ':'แก้ไขหัวข้อสมรรถนะ'}}
</h3> </h3>
<div class="flex justify-end"> <div class="w-full flex justify-end mb-1rem">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger" <div class="absolute flex">
data-hs-overlay="#competency-topic-page-modal">
<span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i>
</button>
</div>
</div>
<div class="ti-modal-center">
<div class="flex justify-end" style="padding-right: 1rem;">
<div class="px-1"> <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)"> (click)="selectCompetencyTopic()">
<svg class="svg-indigo" width="16" height="16" viewBox="0 0 64.00 64.00" <i class="ti ti-eraser text-base"></i>
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 Clear
</button> </button>
</div> </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> </div>
<div class="ti-modal-body mt-1"> <mat-dialog-content>
<label for="input-label" class="ti-form-label">รหัส<span class="text-danger">*<ng-container <label for="input-label" class="ti-form-label">รหัส<span class="text-danger">*<ng-container
*ngIf="modalStatus=='add'&&checkPrimary()"> *ngIf="currentModal=='add'&&checkPrimary()">
รหัสซ้ำ รหัสซ้ำ
</ng-container></span></label> </ng-container></span></label>
<input type="text" id="input-label" class="ti-form-input w-1/2" <input type="text" id="input-label" class="ti-form-input w-1/2"
[ngClass]="{'bg-input-readonly':modalStatus=='edit'}" [readonly]="modalStatus=='edit'" [ngClass]="{'!bg-input-readonly':currentModal=='edit'}" [readonly]="currentModal=='edit'"
[(ngModel)]="dataSelect.id"> [(ngModel)]="competencyTopic.select.competencyTopicId">
<label for="detail_th" class="ti-form-label mt-2rem">ชื่อหัวข้อ (ไทย)<span <label for="detail_th" class="ti-form-label mt-2rem">ชื่อหัวข้อ (ไทย)<span class="text-danger">*</span></label>
class="text-danger">*</span></label> <input type="text" id="detail_th" class="ti-form-input h-10" [(ngModel)]="competencyTopic.select.tdesc">
<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> <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)]="competencyTopic.select.edesc">
<label for="detail_eng" class="ti-form-label mt-2rem">นิยามสมรรถนะ</label> <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" <textarea type="text" id="detail_eng" class="ti-form-input" rows="4" cols="50"
[(ngModel)]="dataSelect.definition"> </textarea> [(ngModel)]="competencyTopic.select.competencyDetail"> </textarea>
<label class="ti-form-label mt-2rem">ประเภท Competency<span class="text-danger">*</span></label> <label class="ti-form-label mt-2rem">ประเภท Competency<span class="text-danger">*</span></label>
<div class="flex"> <div class="flex">
<div class="relative flex rounded-md w-1/2"> <div class="relative flex rounded-md w-1/2">
<input type="text" id="hs-leading-button-add-on-with-icon-and-button" <input type="text" id="hs-leading-button-add-on-with-icon-and-button"
name="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" class="ti-form-input rounded-md ltr:rounded-r-md rtl:rounded-l-md focus:z-10"
style="padding-right: 2.5rem;" readonly [(ngModel)]="dataSelect.type.code"> style="padding-right: 2.5rem;" readonly
[(ngModel)]="competencyTopic.select.competencyType.shortName">
<div <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"> 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" <button type="button" class="flex items-center text-red-500"
(click)="dataSelect.type.code=''"> (click)="competencyTopic.select.competencyType.shortName=''">
<i class="ti ti-circle-x cursor-pointer"></i> <i class="ti ti-circle-x cursor-pointer"></i>
</button> </button>
<button type="button" class="flex items-center text-gray-500 dark:text-white/70" <button type="button" class="flex items-center text-gray-500 dark:text-white/70"
(click)="searchCompetencytypeChange()" (click)="openDialogType()" data-hs-overlay="#competency-topic-table-modal-select">
data-hs-overlay="#competency-topic-table-modal-select">
<i class="ri-search-line cursor-pointer text-gray"></i> <i class="ri-search-line cursor-pointer text-gray"></i>
</button> </button>
</div> </div>
...@@ -253,261 +114,85 @@ ...@@ -253,261 +114,85 @@
onclick="fileInputMedium.click();">Browse</button> onclick="fileInputMedium.click();">Browse</button>
</span> </span>
<div class="flex items-center ml-2"> <div class="flex items-center ml-2">
<button href="javascript:void(0);" <button href="javascript:void(0);" class="ti-btn ti-btn-soft-danger h-10px m-0 shadow-md rounded-md"
class="ti-btn ti-btn-soft-danger h-10px m-0 shadow-md rounded-md"
(click)="fileInputMedium.value = '';examFile=null;examFileName = 'กรุณาเลือกไฟล์'"> (click)="fileInputMedium.value = '';examFile=null;examFileName = 'กรุณาเลือกไฟล์'">
<i class="ri-delete-bin-6-line"></i> <i class="ri-delete-bin-6-line"></i>
Delete Delete
</button> </button>
</div> </div>
</div> </div>
<div class="flex" *ngIf="examFileName==dataSelect.file"> <div class="flex" *ngIf="examFileName==competencyTopic.select.competencyFiles">
<h1 class="cursor-pointer justify-center -mb-px inline-flex items-center gap-2 font-weight-500 font-size-12px <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" text-center text-secondary border-secondary border-b-2 align-items-end"
(click)="dowloadExam(examFileName)"> (click)="dowloadExam(examFileName)">
ดาวน์โหลดไฟล์ข้อสอบ</h1> ดาวน์โหลดไฟล์ข้อสอบ</h1>
</div> </div>
<div class="flex justify-end mt-3rem mb-1rem space-x-4"> </mat-dialog-content>
<button type="button" <mat-dialog-actions align="end">
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" <button type="button" mat-button [mat-dialog-close]
data-hs-overlay="#competency-topic-page-modal"> 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">
ย้อนกลับ ย้อนกลับ
</button> </button>
<button type="button" class="ti-btn ti-btn-success" <button type="button" class="ti-btn ti-btn-success" mat-button (click)="confirmAddCompetency_topic()"
data-hs-overlay="#competency-topic-page-alert-modal" [class.ti-btn-disabled]="!competencyTopic.select.competencyType.competencyTypeId||!competencyTopic.select.tdesc||!competencyTopic.select.competencyType.shortName||(currentModal=='add'&&checkPrimary())"
[class.ti-btn-disabled]="!dataSelect.id||!dataSelect.name||!dataSelect.type.code||(modalStatus=='add'&&checkPrimary())" [disabled]="!competencyTopic.select.competencyType.competencyTypeId||!competencyTopic.select.tdesc||!competencyTopic.select.competencyType.shortName||(currentModal=='add'&&checkPrimary())">
[disabled]="!dataSelect.id||!dataSelect.name||!dataSelect.type.code||(modalStatus=='add'&&checkPrimary())">
บันทึกข้อมูล บันทึกข้อมูล
</button> </button>
</div> </mat-dialog-actions>
</div> </ng-template>
</div>
</div>
</div>
<div id="competency-topic-table-modal-select" class="hs-overlay hidden ti-modal"> <ng-template #competencyTypeTableModal let-modal>
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out lg:!max-w-4xl lg:w-full m-3 lg:!mx-auto"> <h3 mat-dialog-title>
<div class="max-h-full overflow-hidden ti-modal-content">
<div class="ti-modal-header">
<h3 class="text-xxl font-bold text-primary">
ประเภทสมรรถนะ ประเภทสมรรถนะ
</h3> </h3>
<div class="flex justify-end">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#competency-topic-page-modal">
<span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i>
</button>
</div>
</div>
<div class="ti-modal-body">
<div class="flex justify-end pb-1rem">
<div class="px-1">
<div class="relative shadow-md">
<input type="text" id="hs-leading-icon" name="hs-leading-icon"
class="ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 "
placeholder="Search by No. or Name" [(ngModel)]="searchModal"
(ngModelChange)="searchCompetencytypeChange()">
<div
class="absolute inset-y-0 ltr:left-0 rtl:right-0 flex items-center pointer-events-none z-20 ltr:pl-4 rtl:pr-4">
<i class="ri-search-line text-gray"></i>
</div>
</div>
</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 class="overflow-auto table-bordered" style="border-radius: 5px;">
<div class="overflow-auto border">
<table class="ti-custom-table ti-custom-table-head ti-custom-table-hover">
<thead>
<tr>
<ng-container
*ngFor="let item of ['รหัส','ชื่อประเภท','ชื่อย่อ','การจัดการ']; let f = first; let l = last; let i = index">
<th scope="col" class="relative px-10px py-10px bg-soft-secondary text-primary"
[class.!text-center]="f||l">
<span class="font-size-12px font-weight-700">{{ item }}</span>
<div class="absolute top-1/2 transform -translate-y-1/2 right-0"
*ngIf="!f && !l">
<i class="ti ti-dots-vertical fs-l"></i>
</div>
</th>
</ng-container>
</tr>
</thead>
<tbody *ngIf="competencytypeListLoading">
<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" aria-label="loading">
<span class="sr-only">Loading...</span>
</div>
</td>
</tr>
</tbody>
<tbody *ngIf="!competencytypeListLoading&&!competencytypeListFilter().length">
<tr>
<td class="text-center" colspan="100%">
ไม่พบข้อมูล
</td>
</tr>
</tbody>
<tbody *ngIf="!competencytypeListLoading&&competencytypeListFilter().length">
<tr
*ngFor="let item of competencytypeListFilter()| slice:((currentPageModal-1) * 10) : (((currentPageModal-1) * 10) + 10);let i = index">
<td class="text-center">{{item.id}}</td>
<td>{{item.name}}</td>
<td class="text-center">{{item.code}}</td>
<td class="flex justify-center">
<div class="px-1">
<button type="button"
class="ti-btn ti-btn-soft-secondary h-20px m-0 shadow-md"
data-hs-overlay="#competency-topic-page-modal"
(click)="selectCompetencytype(item)">
<i class="ri-add-line"></i>
Select
</button>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<nav class="pagination-style-3 overflow-auto my-5" *ngIf="pageModal.length">
<ul class="ti-pagination">
<li>
<a aria-label="anchor" class="page-link" href="javascript:void(0);"
(click)="currentPageModal = (currentPageModal-1 || 1)">
<i class="ri-arrow-left-s-line align-middle rtl:rotate-180"></i>
</a>
</li>
<li *ngFor="let item of pageModal;let f = first;let l = last">
<ng-container
*ngIf="item==3&&currentPageModal!=1&&currentPageModal!=2&&currentPageModal!=3">
<a aria-label="anchor" class="page-link" href="javascript:void(0);"><i
class="ri-more-line"></i>
</a>
</ng-container>
<ng-container
*ngIf="(f||l)||(item==currentPageModal-1||item==currentPageModal||item==currentPageModal+1)">
<a class="page-link" href="javascript:void(0);" [class.active]="item==currentPageModal"
(click)="currentPageModal=item">{{item}}
</a>
</ng-container>
<ng-container
*ngIf="item==pageModal.length-2&&currentPageModal!=pageModal.length&&currentPageModal!=pageModal.length-1&&currentPageModal!=pageModal.length-2">
<a aria-label="anchor" class="page-link" href="javascript:void(0);"><i
class="ri-more-line"></i>
</a>
</ng-container>
</li>
<li>
<a aria-label="anchor" class="page-link" href="javascript:void(0);"
(click)="currentPageModal = (currentPageModal > pageModal.length-1 ? currentPageModal: currentPageModal+1 )">
<i class="ri-arrow-right-s-line align-middle rtl:rotate-180"></i>
</a>
</li>
</ul>
<ul class="nav-tabs mt-3">
<span>Show {{((currentPageModal-1) * 10)+1}} to {{competencytypeListFilter().length<10
?competencytypeListFilter().length: (currentPageModal==pageModal.length ?
((currentPageModal * 10) - ((currentPageModal * 10) - competencytypeListFilter().length)
) :(currentPageModal * 10) ) }} of {{competencytypeListFilter().length}} items</span>
</ul>
</nav>
</div>
</div>
</div>
</div>
<div id="competency-topic-table-modal-edit" class="hs-overlay hidden ti-modal"> <mat-dialog-content>
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out lg:!max-w-4xl lg:w-full m-3 lg:!mx-auto">
<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="#competency-topic-modal-edit">
<span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i>
</button>
</div>
</div>
<div class="ti-modal-body">
<div class="flex justify-end pb-1rem"> <div class="flex justify-end pb-1rem">
<div class="px-1"> <div class="px-1">
<div class="relative shadow-md"> <div class="relative shadow-md">
<input type="text" id="hs-leading-icon" name="hs-leading-icon" <input type="text" id="hs-leading-icon" name="hs-leading-icon"
class="ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 " class="ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 " placeholder="Search by No. or Name"
placeholder="Search by No. or Name" [(ngModel)]="searchModal" [(ngModel)]="typeModal.search" (ngModelChange)="searchCompetencytypeChange()">
(ngModelChange)="searchCompetencytypeChange()">
<div <div
class="absolute inset-y-0 ltr:left-0 rtl:right-0 flex items-center pointer-events-none z-20 ltr:pl-4 rtl:pr-4"> class="absolute inset-y-0 ltr:left-0 rtl:right-0 flex items-center pointer-events-none z-20 ltr:pl-4 rtl:pr-4">
<i class="ri-search-line text-gray"></i> <i class="ri-search-line text-gray"></i>
</div> </div>
</div> </div>
</div> </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="overflow-auto table-bordered" style="border-radius: 5px;">
<div class="overflow-auto border"> <div class="overflow-auto border">
<table class="ti-custom-table ti-custom-table-head ti-custom-table-hover"> <table class="ti-custom-table ti-custom-table-head ti-custom-table-hover">
<thead> <thead>
<tr> <tr>
<ng-container <ng-container
*ngFor="let item of ['รหัส','ชื่อประเภท','ชื่อย่อ','การจัดการ']; let f = first; let l = last; let i = index"> *ngFor="let item of ['รหัส','ชื่อประเภท','ชื่อย่อ','การจัดการ']; let f = first; let l = last">
<th scope="col" class="relative px-10px py-10px bg-soft-secondary text-primary" <th scope="col" class="relative px-10px py-10px bg-soft-secondary text-primary"
[class.!text-center]="f||l"> [class.!text-center]="f">
<span class="font-size-12px font-weight-700">{{ item }}</span> <span class="text-sm">{{ item }}</span>
<div class="absolute top-1/2 transform -translate-y-1/2 right-0" <div class="absolute top-1/2 transform -translate-y-1/2 right-0" *ngIf="!l">
*ngIf="!f && !l">
<i class="ti ti-dots-vertical fs-l"></i> <i class="ti ti-dots-vertical fs-l"></i>
</div> </div>
</th> </th>
</ng-container> </ng-container>
</tr> </tr>
</thead> </thead>
<tbody *ngIf="competencytypeListLoading"> <tbody *ngIf="!competencytypeListFilter().length">
<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" aria-label="loading">
<span class="sr-only">Loading...</span>
</div>
</td>
</tr>
</tbody>
<tbody *ngIf="!competencytypeListLoading&&!competencytypeListFilter().length">
<tr> <tr>
<td class="text-center" colspan="100%"> <td class="text-center" colspan="100%">
ไม่พบข้อมูล ไม่พบข้อมูล
</td> </td>
</tr> </tr>
</tbody> </tbody>
<tbody *ngIf="!competencytypeListLoading&&competencytypeListFilter().length"> <tbody *ngIf="competencytypeListFilter().length">
<tr <tr
*ngFor="let item of competencytypeListFilter()| slice:((currentPage-1) * 10) : (((currentPage-1) * 10) + 10);let i = index"> *ngFor="let item of competencytypeListFilter()| slice:((typeModal.currentPage-1) * 10) : (((typeModal.currentPage-1) * 10) + 10);let i = index">
<td class="text-center">{{item.id}}</td> <td>{{item.competencyTypeId}}</td>
<td>{{item.name}}</td> <td>{{item.tdesc}}</td>
<td class="text-center">{{item.code}}</td> <td>{{item.shortName}}</td>
<td class="flex justify-center"> <td class="flex justify-center">
<div class="px-1"> <div class="px-1">
<button type="button" <button type="button" class="ti-btn ti-btn-soft-secondary h-20px m-0 shadow-md"
class="ti-btn ti-btn-soft-secondary h-20px m-0 shadow-md" (click)="selectCompetencytype(item);closeDialogType()">
data-hs-overlay="#competency-topic-modal-edit"
(click)="selectCompetencytype(item)">
<i class="ri-add-line"></i> <i class="ri-add-line"></i>
Select Select
</button> </button>
...@@ -517,121 +202,17 @@ ...@@ -517,121 +202,17 @@
</tbody> </tbody>
</table> </table>
</div> </div>
</div> <app-pagination [totalItems]="competencytypeListFilter().length" [pageSize]="typeModal.pageSize"
<nav class="pagination-style-3 overflow-auto my-5" *ngIf="pageModal.length"> (pageChange)="typeModal.currentPage = $event"
<ul class="ti-pagination"> (pageSizeChange)="typeModal.pageSize = $event;typeModal.currentPage = 1"></app-pagination>
<li> </mat-dialog-content>
<a aria-label="anchor" class="page-link" href="javascript:void(0);" <mat-dialog-actions align="end">
(click)="currentPageModal = (currentPageModal-1 || 1)"> <button type="button" mat-button [mat-dialog-close]
<i class="ri-arrow-left-s-line align-middle rtl:rotate-180"></i> 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">
</a>
</li>
<li *ngFor="let item of page;let f = first;let l = last">
<ng-container
*ngIf="item==3&&currentPageModal!=1&&currentPageModal!=2&&currentPageModal!=3">
<a aria-label="anchor" class="page-link" href="javascript:void(0);"><i
class="ri-more-line"></i>
</a>
</ng-container>
<ng-container
*ngIf="(f||l)||(item==currentPageModal-1||item==currentPageModal||item==currentPageModal+1)">
<a class="page-link" href="javascript:void(0);" [class.active]="item==currentPageModal"
(click)="currentPageModal=item">{{item}}
</a>
</ng-container>
<ng-container
*ngIf="item==pageModal.length-2&&currentPageModal!=pageModal.length&&currentPageModal!=pageModal.length-1&&currentPageModal!=pageModal.length-2">
<a aria-label="anchor" class="page-link" href="javascript:void(0);"><i
class="ri-more-line"></i>
</a>
</ng-container>
</li>
<li>
<a aria-label="anchor" class="page-link" href="javascript:void(0);"
(click)="currentPageModal = (currentPageModal > pageModal.length-1 ? currentPageModal: currentPageModal+1 )">
<i class="ri-arrow-right-s-line align-middle rtl:rotate-180"></i>
</a>
</li>
</ul>
<ul class="nav-tabs mt-3">
<span>Show {{((currentPageModal-1) * 10)+1}} to {{competencytypeListFilter().length<10
?competencytypeListFilter().length: (currentPageModal==pageModal.length ?
((currentPageModal * 10) - ((currentPageModal * 10) - competencytypeListFilter().length)
) :(currentPageModal * 10) ) }} of {{competencytypeListFilter().length}} items</span>
</ul>
</nav>
</div>
</div>
</div>
</div>
<div id="competency-topic-page-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">
<h3 class="text-xxl font-bold text-primary">
แจ้งเตือน
</h3>
<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="#competency-topic-page-modal">
<span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i>
</button>
</ng-container>
<ng-container *ngIf="modalStatus=='delete'||modalStatus=='deleteGroup'">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#competency-topic-page-alert-modal">
<span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i>
</button>
</ng-container>
</div>
</div>
<div class="ti-modal-body ">
<p class="mt-1 text-gray-800 dark:text-white/70">
<ng-container *ngIf="modalStatus=='add'||modalStatus=='edit'">
ยืนยันการบันทึกข้อมูลหรือไม่
</ng-container>
<ng-container *ngIf="modalStatus=='delete'||modalStatus=='deleteGroup'">
<ng-container *ngIf="numDataListChecked">
ยืนยันการลบข้อมูลหรือไม่
</ng-container>
<ng-container *ngIf="!numDataListChecked">
เลือกข้อมูลที่ต้องการลบ
</ng-container>
</ng-container>
</p>
<div class="flex justify-end mt-2rem mb-1rem">
<ng-container *ngIf="modalStatus=='add'||modalStatus=='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="#competency-topic-page-modal">
ย้อนกลับ
</button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#competency-topic-page-alert-modal" (click)="addCompetency_topic()">
บันทึกข้อมูล
</a>
</ng-container>
<ng-container *ngIf="modalStatus=='delete'||modalStatus=='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="#competency-topic-page-alert-modal">
ย้อนกลับ ย้อนกลับ
</button> </button>
<a class="ti-btn ti-btn-danger" href="javascript:void(0);" *ngIf="numDataListChecked" </mat-dialog-actions>
data-hs-overlay="#competency-topic-page-alert-modal" (click)="deleteCompetency_topic()"> </ng-template>
ลบข้อมูล
</a>
</ng-container>
</div>
</div>
</div>
</div>
</div>
<div id="competency-topic-upload-modal" class="hs-overlay hidden ti-modal"> <div id="competency-topic-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="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out rounded-md">
......
import { ChangeDetectorRef, Component, EventEmitter, Input, Output } from '@angular/core'; import { ChangeDetectorRef, Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { ColumnModel } from '@syncfusion/ej2-grids'; import { ColumnModel } from '@syncfusion/ej2-grids';
import { ToastrService } from 'ngx-toastr'; import { ToastrService } from 'ngx-toastr';
import { MyCompetencytopicModel } from 'src/app/shared/model/competencytopic.model'; import { CompetencyTopicModel } from 'src/app/shared/model/appraisal-aps.model';
import { MyCompetencytypeModel } from 'src/app/shared/model/competencytype.model'; import { CompetencytopicModel, MyCompetencytopicModel } from 'src/app/shared/model/competencytopic.model';
import { CompetencytypeModel, MyCompetencytypeModel } from 'src/app/shared/model/competencytype.model';
import { CompetencytopicService } from 'src/app/shared/services/competencytopic.service'; import { CompetencytopicService } from 'src/app/shared/services/competencytopic.service';
import { CompetencytypeService } from 'src/app/shared/services/competencytype.service'; import { CompetencytypeService } from 'src/app/shared/services/competencytype.service';
import { FileService } from 'src/app/shared/services/file.service'; import { FileService } from 'src/app/shared/services/file.service';
export interface DataModel { import Swal from 'sweetalert2';
id: string import { data } from '../../../datagrid-syncfution/data';
name: string import { TokenService } from 'src/app/shared/services/token.service';
edesc: string
code: string interface table {
definition: string currentPage: number,
type: DataModel2 page: number[],
file: string search: string,
checked: boolean pageSize: number
}
export interface DataModel2 {
id: string
name: string
edesc: string
code: string
level: string
} }
@Component({ @Component({
selector: 'app-competency-topic', selector: 'app-competency-topic',
templateUrl: './competency-topic.component.html', templateUrl: './competency-topic.component.html',
styleUrls: ['./competency-topic.component.scss'] styleUrls: ['./competency-topic.component.scss']
}) })
export class CompetencyTopic { export class CompetencyTopic implements OnInit {
competencyTopic: { loading: boolean, select: CompetencytopicModel, dataList: CompetencytopicModel[] } = { loading: false, select: new MyCompetencytopicModel({}), dataList: [] }
selectedFile: File | null = null;
selectedFileName: string = 'กรุณาเลือกไฟล์';
examFile: File | null = null;
examFileName: string = 'กรุณาเลือกไฟล์';
topicModal: table = {
currentPage: 1,
page: Array.from({ length: 1 }, (_, i) => i + 1),
search: "",
pageSize: 10
}
typeList: CompetencytypeModel[] = []
type: CompetencytypeModel = new MyCompetencytypeModel()
typeModal: table = {
currentPage: 1,
page: Array.from({ length: 1 }, (_, i) => i + 1),
search: "",
pageSize: 10
}
currentPage = 1 currentPage = 1
page = Array.from({ length: 1 }, (_, i) => i + 1); page = Array.from({ length: 1 }, (_, i) => i + 1);
...@@ -36,19 +55,12 @@ export class CompetencyTopic { ...@@ -36,19 +55,12 @@ export class CompetencyTopic {
pageModal = Array.from({ length: 1 }, (_, i) => i + 1); pageModal = Array.from({ length: 1 }, (_, i) => i + 1);
searchModal = "" searchModal = ""
isChecked: boolean = false; // ใช้สำหรับตรวจสอบสถานะของ checkbox currentModal: 'add' | 'edit' | 'delete' = 'add'
currentModal = ""; competoncytopicList: CompetencytopicModel[] = [];
dataLoading = false
topicList: CompetencytopicService[] = [];
dataSelect: DataModel = { id: "", name: "", edesc: "", code: "", definition: "", file: "", type: { id: "", name: "", edesc: "", code: "", level: "" }, checked: false }
competencytypeListLoading = false competencytypeListLoading = false
competencytypeList: DataModel2[] = [] competoncy_type: CompetencytypeModel = new MyCompetencytypeModel({})
competoncyTopicList: { check: boolean; data: DataModel & { checked?: boolean } }[] = [] competoncy_topic: CompetencytopicModel = new MyCompetencytopicModel({})
modalStatus = 'add'
selectedFile: File | null = null;
selectedFileName: string = 'กรุณาเลือกไฟล์';
examFile: File | null = null;
examFileName: string = 'กรุณาเลือกไฟล์';
numDataListChecked = 0 numDataListChecked = 0
...@@ -56,7 +68,7 @@ export class CompetencyTopic { ...@@ -56,7 +68,7 @@ export class CompetencyTopic {
isDataListCheckedAll = false isDataListCheckedAll = false
columns: ColumnModel[] = [{ columns: ColumnModel[] = [{
field: "competencyTypeId", field: "competencyTopicId",
headerText: "รหัส", headerText: "รหัส",
type: "string", type: "string",
isPrimaryKey: true, isPrimaryKey: true,
...@@ -67,56 +79,67 @@ export class CompetencyTopic { ...@@ -67,56 +79,67 @@ export class CompetencyTopic {
type: "string" type: "string"
}, },
{ {
field: "shortName", field: "competencyType.shortName",
headerText: "ประะภท", headerText: "ประะภท",
type: "string" type: "string"
}] }]
searchSettings = { searchSettings = {
fields: ['competencyTypeId', 'tdesc', 'shortName'], fields: ['competencyTopicId', 'tdesc', 'competencyType.shortName'],
operator: 'contains', operator: 'contains',
ignoreCase: false ignoreCase: false
}; };
search = '' search = ''
selectedItems: { key: string, count: number, data: Map<string, boolean> } = { key: '', count: 0, data: new Map<string, boolean>() }; selectedItems: { key: string, count: number, data: Map<string, boolean> } = { key: '', count: 0, data: new Map<string, boolean>() };
@ViewChild("competencyTopicModal") competencyTopicModal: any;
@ViewChild("competencyTypeTableModal") competencyTypeTableModal: any;
@ViewChild("fileInputMedium") fileInputMedium: any;
dialogRef: any
dialogRefType: any
constructor(private toastr: ToastrService, constructor(private toastr: ToastrService,
private dialog: MatDialog,
private cdr: ChangeDetectorRef, private cdr: ChangeDetectorRef,
private fileService: FileService, private fileService: FileService,
private competencytopicService: CompetencytopicService, private competencytopicService: CompetencytopicService,
private competencytypeService: CompetencytypeService private competencytypeService: CompetencytypeService,
private tokenService: TokenService
) { } ) { }
ngOnInit(): void { ngOnInit(): void {
this.getCompetencytopicList() this.getCompetencytopicList()
this.getCompetencytypeList() this.getCompetencytypeList()
} }
onExamSelected(event: any) { onExamSelected(event: any) {
this.examFile = event.target.files.length > 0 ? event.target.files[0] : null; this.examFile = event.target.files.length > 0 ? event.target.files[0] : null;
this.examFileName = this.examFile?.name || "กรุณาเลือกไฟล์" this.examFileName = this.examFile?.name || "กรุณาเลือกไฟล์"
} }
uploadExam() { uploadExam() {
if (!this.examFile) { if (!this.examFile) return;
return
}
const formData = new FormData(); const formData = new FormData();
formData.append('file', this.examFile); formData.append('file', this.examFile);
this.fileService.uploadFiles(formData).subscribe({ this.fileService.uploadFiles(formData).subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
this.examFile = null this.examFile = null;
this.addCompetency_topic(response.resultObject) this.addCompetency_topic(response.resultObject); // ส่งชื่อไฟล์เข้าฟังก์ชัน
} else { } else {
this.showAlert(response.message, 'error') this.showAlert(response.message, 'error');
this.cdr.detectChanges() this.cdr.detectChanges();
} }
}, error: error => { },
this.showAlert(error.message, 'error') error: error => {
this.cdr.detectChanges() this.showAlert(error.message, 'error');
this.cdr.detectChanges();
} }
}) });
} }
dowloadExam(fileName: string) { dowloadExam(fileName: string) {
this.fileService.dowloadFiles(fileName).subscribe({ this.fileService.dowloadFiles(fileName).subscribe({
next: response => { next: response => {
...@@ -148,7 +171,7 @@ export class CompetencyTopic { ...@@ -148,7 +171,7 @@ export class CompetencyTopic {
} }
const formData = new FormData(); const formData = new FormData();
formData.append('file', this.selectedFile); formData.append('file', this.selectedFile);
this.dataLoading = true this.competencyTopic.loading = true
this.fileService.uploadExcel(formData, 'competency_topic').subscribe({ this.fileService.uploadExcel(formData, 'competency_topic').subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
...@@ -157,12 +180,12 @@ export class CompetencyTopic { ...@@ -157,12 +180,12 @@ export class CompetencyTopic {
this.getCompetencytopicList() this.getCompetencytopicList()
} else { } else {
this.showAlert(response.message, 'error') this.showAlert(response.message, 'error')
this.dataLoading = false this.competencyTopic.loading = false
this.cdr.detectChanges() this.cdr.detectChanges()
} }
}, error: error => { }, error: error => {
this.showAlert(error.message, 'error') this.showAlert(error.message, 'error')
this.dataLoading = false this.competencyTopic.loading = false
this.cdr.detectChanges() this.cdr.detectChanges()
} }
}) })
...@@ -189,11 +212,16 @@ export class CompetencyTopic { ...@@ -189,11 +212,16 @@ export class CompetencyTopic {
getCompetencytypeList() { getCompetencytypeList() {
this.competencytypeListLoading = true this.competencytypeListLoading = true
this.selectedItems.data.clear()
this.competencytypeService.getList().subscribe({ this.competencytypeService.getList().subscribe({
next: response => { next: response => {
this.competencytypeList = response.map(x => ({ id: x.competencyTypeId, name: x.tdesc, edesc: x.edesc, code: x.shortName, level: x.expectationLevel, checked: false })) this.typeList = response.map(x => {
this.selectedItems.data.set(x.competencyTypeId, false)
return new MyCompetencytypeModel(x)
})
this.selectedItems.key = 'competencyTypeId'
this.selectedItems.count = 0
this.competencytypeListLoading = false this.competencytypeListLoading = false
this.searchChange()
this.cdr.detectChanges() this.cdr.detectChanges()
}, error: error => { }, error: error => {
this.competencytypeListLoading = false this.competencytypeListLoading = false
...@@ -201,155 +229,190 @@ export class CompetencyTopic { ...@@ -201,155 +229,190 @@ export class CompetencyTopic {
} }
}) })
} }
selectCompetencyTopic(CompetencyTopic?: CompetencyTopicModel) {
if (CompetencyTopic) {
this.competencyTopic.select = new MyCompetencytopicModel(CompetencyTopic)
} else if (this.currentModal == 'add') {
this.competencyTopic.select = new MyCompetencytopicModel({})
} else if (this.currentModal == 'edit') {
this.competencyTopic.select = new MyCompetencytopicModel({ competencyTopicId: this.competencyTopic.select.competencyTopicId })
}
this.examFileName = this.competencyTopic.select.competencyFiles || 'กรุณาเลือกไฟล์'
}
searchCompetencytypeChange() { searchCompetencytypeChange() {
this.currentPageModal = 1 this.typeModal.currentPage = 1
this.pageModal = Array.from({ length: Math.ceil(this.competencytypeListFilter().length / 10) }, (_, i) => i + 1); this.typeModal.page = Array.from({ length: Math.ceil(this.competencytypeListFilter().length / 10) }, (_, i) => i + 1);
} }
competencytypeListFilter() { competencytypeListFilter() {
return this.competencytypeList.filter(x => { return this.typeList.filter(x =>
const data = x x.competencyTypeId.toLowerCase().includes(this.typeModal.search.toLowerCase()) ||
const match = data.id.toLowerCase().includes(this.searchModal) || data.name.toLowerCase().includes(this.searchModal) || data.code.toLowerCase().includes(this.searchModal); x.tdesc.toLowerCase().includes(this.typeModal.search.toLowerCase()) ||
return match; x.shortName.toLowerCase().includes(this.typeModal.search.toLowerCase()))
});
} }
selectCompetencytype(data: DataModel2) { selectCompetencytype(data: CompetencytypeModel) {
this.dataSelect.type = JSON.parse(JSON.stringify(data)); this.competencyTopic.select.competencyType = JSON.parse(JSON.stringify(data));
} }
getCompetencytopicList() { getCompetencytopicList() {
this.dataLoading = true this.competencyTopic.loading = true
this.selectedItems.data.clear()
this.competencytopicService.getList().subscribe({ this.competencytopicService.getList().subscribe({
next: response => { next: response => {
this.competoncyTopicList = response.map(x => ({ this.competencyTopic.dataList = response.map(x => {
check: false, data: { this.selectedItems.data.set(x.competencyTopicId, false)
id: x.competencyTopicId, name: x.tdesc, edesc: x.edesc, code: x.competencyType.shortName, definition: x.competencyDetail, file: x.competencyFiles, return new MyCompetencytopicModel(x)
type: { id: x.competencyType.competencyTypeId, name: x.competencyType.tdesc, edesc: x.competencyType.edesc, code: x.competencyType.shortName, level: x.expectationLevel }, })
checked: false this.selectedItems.key = 'competencyTopicId'
} this.selectedItems.count = 0
})) this.competencyTopic.loading = false
this.isDataListCheckedAll = false
this.dataListCheckAll()
this.dataLoading = false
this.searchChange()
this.cdr.detectChanges() this.cdr.detectChanges()
}, error: error => { }, error: error => {
this.dataLoading = false this.competencyTopic.loading = false
this.cdr.detectChanges() this.cdr.detectChanges()
} }
}) })
} }
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.toLowerCase()) || data.name?.toLowerCase().includes(this.search.toLowerCase()) || data.code?.toLowerCase().includes(this.search.toLowerCase());
return match;
});
}
setData(data?: DataModel) {
this.examFileName = data?.file || 'กรุณาเลือกไฟล์'
this.dataSelect = JSON.parse(JSON.stringify(data || { id: "", name: "", edesc: "", code: "", definition: "", file: "", type: { id: "", name: "", edesc: "", code: "", level: "" }, checked: false }));
}
addCompetency_topic(competencyFiles?: string) { addCompetency_topic(competencyFiles?: string) {
if (this.examFile) { if (this.examFile) {
this.uploadExam() this.uploadExam();
} else { return;
}
const user = this.tokenService.getUser();
const body = new MyCompetencytopicModel({ const body = new MyCompetencytopicModel({
competencyTopicId: this.dataSelect.id, tdesc: this.dataSelect.name, edesc: this.dataSelect.edesc, competencyDetail: this.dataSelect.definition, ...this.competencyTopic.select,
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 }), companyId: user?.companyid,
competencyFiles: competencyFiles || ((this.examFileName == this.dataSelect.file) ? this.dataSelect.file : '') competencyFiles: competencyFiles || ((this.examFileName == this.competencyTopic.select.competencyFiles) ? this.competencyTopic.select.competencyFiles : '')
}) });
this.dataLoading = true this.competencyTopic.loading = true;
this.competencytopicService.post(body).subscribe({ this.competencytopicService.post(body).subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
this.showAlert(response.message, 'success') this.showAlert(response.message, 'success');
this.getCompetencytypeList() this.getCompetencytypeList();
this.getCompetencytopicList() this.getCompetencytopicList();
this.closeDialog()
} else { } else {
this.showAlert(response.message, 'error') this.showAlert(response.message, 'error');
this.dataLoading = false this.competencyTopic.loading = false;
this.cdr.detectChanges() this.cdr.detectChanges();
} }
}, error: error => { },
this.showAlert(error.message, 'error') error: error => {
this.dataLoading = false this.showAlert(error.message, 'error');
this.cdr.detectChanges() this.competencyTopic.loading = false;
this.cdr.detectChanges();
} }
}) });
} }
confirmAddCompetency_topic() {
Swal.fire({
icon: 'question',
title: 'แจ้งเตือน',
text: 'ยืนยันการบันทึกข้อมูลหรือไม่',
showCancelButton: true,
confirmButtonText: 'บันทึกข้อมูล',
cancelButtonText: 'ย้อนกลับ',
reverseButtons: true,
}).then(result => {
if (result.isConfirmed) {
this.addCompetency_topic();
}
});
} }
deleteCompetency_topic() { deleteCompetency_topic() {
let body: any if (!this.numSelectItem()) {
if (this.modalStatus == "deleteGroup") { this.showAlert('กรุณาเลือกข้อมูลที่ต้องการลบ', 'error');
body = this.competoncyTopicList.filter(x => x.check).map(x => new MyCompetencytopicModel({ return;
competencyTopicId: x.data.id, tdesc: x.data.name, edesc: x.data.edesc, competencyDetail: x.data.definition, }
competencyType: new MyCompetencytypeModel({ competencyTypeId: x.data.type.id, tdesc: x.data.type.name, edesc: x.data.type.edesc, shortName: x.data.type.code, expectationLevel: x.data.type.level }),
})) Swal.fire({
} else { icon: 'question',
body = new MyCompetencytopicModel({ title: 'แจ้งเตือน',
competencyTopicId: this.dataSelect.id, tdesc: this.dataSelect.name, edesc: this.dataSelect.edesc, competencyDetail: this.dataSelect.definition, text: 'ยืนยันการลบข้อมูลหรือไม่',
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 }), showCancelButton: true,
}) confirmButtonText: 'ลบข้อมูล',
cancelButtonText: 'ย้อนกลับ',
reverseButtons: true,
}).then(result => {
if (result.isConfirmed) {
let body: MyCompetencytopicModel[] = [];
if (this.currentModal === "delete") {
const selectedKeys = Array.from(this.selectedItems.data.keys());
body = this.competencyTopic.dataList
.filter(x => selectedKeys.includes(x.competencyTopicId) && this.selectedItems.data.get(x.competencyTopicId))
.map(x => new MyCompetencytopicModel(x));
} }
this.dataLoading = true this.competencyTopic.loading = true;
this.competencytopicService.delete(body).subscribe({ this.competencytopicService.delete(body).subscribe({
next: response => { next: response => {
this.competencyTopic.loading = false;
if (response.success) { if (response.success) {
this.showAlert(response.message, 'success') this.showAlert(response.message, 'success');
this.getCompetencytypeList() this.getCompetencytypeList();
this.getCompetencytopicList() this.getCompetencytopicList();
this.dataLoading = false
} else { } else {
this.showAlert(response.message, 'error') this.showAlert(response.message, 'error');
this.dataLoading = false this.cdr.detectChanges();
this.cdr.detectChanges()
} }
}, error: error => { },
this.showAlert(error.message, 'error') error: error => {
this.dataLoading = false this.competencyTopic.loading = false;
this.cdr.detectChanges() this.showAlert(error.message, 'error');
this.cdr.detectChanges();
} }
}) });
} }
});
}
showAlert(text: string, type: 'success' | 'error') { showAlert(text: string, type: 'success' | 'error') {
this.toastr[type](text, 'แจ้งเตือน', { Swal.fire({
timeOut: 3000, title: 'แจ้งเตือน',
positionClass: 'toast-top-right', text: text,
}) icon: type,
confirmButtonText: 'ตกลง',
});
} }
clearData(modalStatus: string) { checkPrimary() {
if (modalStatus == 'add') { return this.competencyTopic.dataList.find(x => x.competencyTopicId == this.competencyTopic.select.competencyTopicId)
this.setData()
} else if (modalStatus == 'edit') {
this.setData({ id: this.dataSelect.id, name: "", edesc: "", code: "", definition: "", file: "", type: { id: "", name: "", edesc: "", code: "", level: "" }, checked: this.dataSelect.checked })
}
} }
dataListCheckAll() { numSelectItem() {
const selectAll = this.isDataListCheckedAll; const selectedKeys = Array.from(this.selectedItems.data.keys());
this.competoncyTopicList.filter(x => { const num = selectedKeys.filter(key => this.selectedItems.data.get(key)).length;
const data = x.data return num;
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() { onSelectItemChange(arg: any) {
const dataCheck = this.dataListFilter(); this.selectedItems = arg
this.isDataListCheckedAll = dataCheck.length ? dataCheck.every(x => x.check) : false;
this.numDataListChecked = this.competoncyTopicList.filter(x => x.check).length;
this.isDataListChecked = Boolean(this.numDataListChecked)
} }
checkPrimary() { openDialog() {
return this.competoncyTopicList.find(x => x.data.id == this.dataSelect.id) this.dialogRef = this.dialog.open(this.competencyTopicModal, {
width: '500px',
disableClose: false,
});
}
openDialogType() {
this.fileInputMedium.value = ""
this.dialogRefType = this.dialog.open(this.competencyTypeTableModal, {
width: '800px',
disableClose: false,
})
}
closeDialog() {
this.dialogRef.close()
}
closeDialogType() {
this.dialogRefType.close()
} }
} }
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