Commit 7961588b by Natthaphat

การประเมินสมรรถนะ > การจัดการรอบการประเมิน > รอบการประเมิน

การประเมินจัดการประสิทธิภาพ > รอบการประเมิน > รอบการประเมิน
parent 52f56c3d
...@@ -12,10 +12,10 @@ ...@@ -12,10 +12,10 @@
</div> </div>
<div class="grid grid-cols-2 gap-6 mb-5"> <div class="grid grid-cols-2 gap-6 mb-5">
<div class="col-span-1"> <div class="col-span-1">
<input type="text" id="input-label" class="ti-form-input w-full pr-10 bg-input-readonly" readonly [value]="evaluationRound.tdesc"> <input type="text" id="input-label" class="ti-form-input w-full pr-10 bg-input-readonly" readonly [value]="evaluationRound?.tdesc">
</div> </div>
<div class="col-span-1"> <div class="col-span-1">
<input type="text" id="input-label" class="ti-form-input w-full pr-10 bg-input-readonly" readonly [value]="evaluationRound.apsyear"> <input type="text" id="input-label" class="ti-form-input w-full pr-10 bg-input-readonly" readonly [value]="evaluationRound?.apsyear">
</div> </div>
</div> </div>
</div> </div>
...@@ -472,7 +472,7 @@ ...@@ -472,7 +472,7 @@
</ng-template> </ng-template>
<div id="form-pm-emp" class="hs-overlay hidden ti-modal" > <div id="form-pm-emp" class="hs-overlay hidden ti-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 mt-7"> <div class="hs-overlay-open:mt-7 ti-modal-box ease-out lg:!max-w-4xl lg:w-full m-3 lg:!mx-auto mt-7">
<div class="max-h-full overflow-hidden ti-modal-content !width-80 !box-modal" > <div class="max-h-full overflow-hidden ti-modal-content !width-80 !box-modal" >
<div class="ti-modal-header"> <div class="ti-modal-header">
<h3 class="text-xxl font-bold text-primary"> <h3 class="text-xxl font-bold text-primary">
...@@ -670,7 +670,7 @@ ...@@ -670,7 +670,7 @@
</div> </div>
<div id="form-assessment" class="hs-overlay hidden ti-modal" > <div id="form-assessment" class="hs-overlay hidden ti-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 mt-7"> <div class="hs-overlay-open:mt-7 ti-modal-box ease-out lg:!max-w-4xl lg:w-full m-3 lg:!mx-auto mt-7">
<div class="max-h-full overflow-hidden ti-modal-content !width-80 !box-modal" > <div class="max-h-full overflow-hidden ti-modal-content !width-80 !box-modal" >
<div class="ti-modal-header"> <div class="ti-modal-header">
<h3 class="text-xxl font-bold text-primary"> <h3 class="text-xxl font-bold text-primary">
......
...@@ -112,15 +112,20 @@ export class EditDefineDocumentFormComponent { ...@@ -112,15 +112,20 @@ export class EditDefineDocumentFormComponent {
}); });
} }
assessmentListFilter() { assessmentListFilter() {
return this.assessmentList.filter(x => if (!Array.isArray(this.assessmentList)) {
x.apsassessy.fname.toLowerCase().includes(this.search.toLowerCase()) || return []; // หรือ return null แล้วจัดการใน HTML
x.apsassessy.lname.toLowerCase().includes(this.search.toLowerCase()) ||
x.apsassessy.efname.toLowerCase().includes(this.search.toLowerCase()) ||
x.apsassessy.elname.toLowerCase().includes(this.search.toLowerCase()) ||
x.masfromEvaluationRound.evaluationRoundId.toLowerCase().includes(this.search.toLowerCase()) ||
x.apsassessy.employeeId.toLowerCase().includes(this.search.toLowerCase())
)
} }
return this.assessmentList.filter(x =>
x.apsassessy.fname.toLowerCase().includes(this.search.toLowerCase()) ||
x.apsassessy.lname.toLowerCase().includes(this.search.toLowerCase()) ||
x.apsassessy.efname.toLowerCase().includes(this.search.toLowerCase()) ||
x.apsassessy.elname.toLowerCase().includes(this.search.toLowerCase()) ||
x.masfromEvaluationRound.evaluationRoundId.toLowerCase().includes(this.search.toLowerCase()) ||
x.apsassessy.employeeId.toLowerCase().includes(this.search.toLowerCase())
);
}
searchChange() { searchChange() {
this.currentPage = 1; this.currentPage = 1;
const filteredData = this.assessmentListFilter(); const filteredData = this.assessmentListFilter();
......
...@@ -2,20 +2,7 @@ ...@@ -2,20 +2,7 @@
<div class="flex justify-between"> <div class="flex justify-between">
<div class="flex pr-2"> <div class="flex pr-2">
<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="check-boxall"
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="check-boxall">Select All</label>
</div>
</div> </div>
</div> </div>
<div class="flex justify-end"> <div class="flex justify-end">
...@@ -32,14 +19,14 @@ ...@@ -32,14 +19,14 @@
</div> </div>
<div class="px-1"> <div class="px-1">
<button type="button" class="ti-btn ti-btn-soft-secondary h-20px m-0 shadow-md" <button type="button" class="ti-btn ti-btn-soft-secondary h-20px m-0 shadow-md"
data-hs-overlay="#evaluation-cycle-page-modal" (click)="modalStatus='add';modalStatusEdit=true;setData()"> (click)="modalStatus='add';modalStatusEdit=true;setData();openDialog()">
<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-20px m-0 shadow-md" <button href="javascript:void(0);" class="ti-btn ti-btn-soft-danger h-20px m-0 shadow-md"
data-hs-overlay="#evaluation-cycle-page-alert-modal" (click)="modalStatus='deleteGroup';setData()"> (click)="modalStatus='deleteGroup';setData();deleteevaluation_cycle()">
<i class="ti ti-trash fs-l"></i> <i class="ti ti-trash fs-l"></i>
Delete Delete
</button> </button>
...@@ -55,6 +42,215 @@ ...@@ -55,6 +42,215 @@
</div> </div>
<div class="page px-rem"> <div class="page px-rem">
<app-datagrid-syncfution [searchSettings]="searchSettings" [searchText]="search" [dataSource]="evaluation_cyclelist"
[columns]="columns" [selectedItems]="selectedItems" [childForm]="true" (createFormEvent)="createForm($event)"
(sendNextPageForm)="selectEvaluationCycle($event); openDialogForm()"
(sendSelectData)="modalStatus='edit';selectEvaluationCycle($event);openDialog()"
(sendSelectedItems)="onSelectItemChange($event)">
</app-datagrid-syncfution>
</div>
<ng-template #evaluationRoundModal let-modal>
<h3 mat-dialog-title>
{{modalStatus=='add'?'เพิ่มรอบการประเมิน':'แก้ไขรอบการประเมิน'}}
</h3>
<div class="w-full flex justify-end">
<div class="absolute flex">
<div class="px-1">
<button type="button" class="ti-btn ti-btn-soft-indigo h-45px m-0 shadow-md" (click)="selectEvaluationCycle()">
<i class="ti ti-eraser text-base"></i>
Clear
</button>
</div>
</div>
</div>
<mat-dialog-content>
<label for="input-label" class="ti-form-label mt-2rem">รหัสรอบการประเมิน
<span class="text-danger">*
<ng-container *ngIf="checkPrimary()&&modalStatus=='add'">
รหัสรอบการประเมินซ้ำ
</ng-container>
</span>
</label>
<input type="text" id="input-label" class="ti-form-input w-1/2"
[ngClass]="{'!bg-input-readonly': modalStatus == 'edit'}" [readonly]="modalStatus =='edit'"
[(ngModel)]="evaluation_cycle.evaluationRoundId">
<label for="detail_th" class="ti-form-label mt-2rem">รายละเอียด (ไทย)<span class="text-danger">*</span></label>
<input type="text" id="detail_th" class="ti-form-input h-16"
[ngClass]="{'!bg-input-readonly': modalStatus == 'edit'}" [readonly]="modalStatus == 'edit'"
[(ngModel)]="evaluation_cycle.tdesc">
<label for="detail_eng" class="ti-form-label mt-2rem">รายละเอียด (อังกฤษ)</label>
<input type="text" id="detail_eng" class="ti-form-input h-16"
[ngClass]="{'!bg-input-readonly': modalStatus == 'edit'}" [readonly]="modalStatus == 'edit'"
[(ngModel)]="evaluation_cycle.edesc">
<label for="input-label" class="ti-form-label mt-2rem">ปีการประเมิน<span class="text-danger">*</span></label>
<!-- <input type="text" id="input-label" class="ti-form-input w-1/2"
oninput="this.value = this.value.replace(/\D/g, '')" [(ngModel)]="evaluation_cycle.apsyear"> -->
<select class="ti-form-select" [(ngModel)]="evaluation_cycle.apsyear"
[ngClass]="{'!bg-input-readonly': modalStatus == 'edit'}" [disabled]="modalStatus == 'edit'">
<option *ngFor="let item of yearList" [ngValue]="item">{{ item }}</option>
</select>
<label for="input-label" class="ti-form-label mt-2rem">เริ่มวันที่<span class="text-danger">*</span></label>
<input type="date" id="input-label" class="ti-form-input w-1/2" [(ngModel)]="evaluation_cycle.apsPeriodStart"
[ngClass]="{'!bg-input-readonly': modalStatus == 'edit'}" [readonly]="modalStatus == 'edit'">
<label for="input-label" class="ti-form-label mt-2rem">สิ้นสุดวันที่<span class="text-danger">*</span></label>
<input type="date" id="input-label" class="ti-form-input w-1/2" [(ngModel)]="evaluation_cycle.apsPeriodEnd"
[ngClass]="{'!bg-input-readonly': modalStatus == 'edit'}" [readonly]="modalStatus == 'edit'">
<label for="input-label" class="ti-form-label mt-2rem">ระดับพนักงาน (JL)</label>
<div *ngFor="let item of evaluation_cycle.personalLevel;let i = index;let f=first;let l = last"
class="grid grid-cols-2">
<div class="col-span-1">
<div class="flex relative">
<input type="text" class="ti-form-input pointer-events-none" readonly
[ngClass]="{'input-list-f1': f&&!l, 'input-list-c1': !f&&!l, 'input-list-l1': !f&&l, 'input-list-fl1': f&&l,'!bg-input-readonly':!modalStatusEdit}"
[(ngModel)]="item.plId">
<div
[ngClass]="{'input-list-line-f': f&&!l, 'input-list-line-c': !f&&!l, 'input-list-line-l': !f&&l, 'input-list-line-fl': f&&l}">
<div class="input-list-line"></div>
</div>
<input type="text" class="ti-form-input pointer-events-none" readonly
[ngClass]="{'input-list-f2': f&&!l, 'input-list-c2': !f&&!l, 'input-list-l2': !f&&l, 'input-list-fl2': f&&l,'!bg-input-readonly':!modalStatusEdit}"
[(ngModel)]="item.tdesc">
<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 *ngIf="item.plId && modalStatus !== 'edit'" type="button" class="flex items-center text-red-500"
(click)="pl.selectIndex=i;selectPl()">
<i class="ti ti-circle-x cursor-pointer"></i>
</button>
</div>
</div>
</div>
<div class="col-span-1 ml-1" *ngIf="f && modalStatus !== 'edit'">
<ng-component *ngTemplateOutlet="plSearchButton"></ng-component>
</div>
</div>
<div class="grid grid-cols-2" *ngIf="!evaluation_cycle.personalLevel.length">
<div class="col-span-1">
<div class="flex relative">
<input type="text" class="ti-form-input input-list-fl1 pointer-events-none" readonly>
<div class="input-list-line-fl">
<div class="input-list-line"></div>
</div>
<input type="text" class="ti-form-input input-list-fl2 pointer-events-none" readonly>
</div>
</div>
<div class="col-span-1 ml-1" *ngIf="modalStatus !== 'edit'">
<ng-component *ngTemplateOutlet="plSearchButton"></ng-component>
</div>
</div>
<ng-template #plSearchButton>
<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 !m-0 h-full"
style="height: 44.8px !important;" (click)="openDialogPL();modal.search='';searchModalChange(plListFilter())">
<i class="ri-search-line cursor-pointer text-gray"></i>
</button>
</ng-template>
<span class="text-danger mt-1">**หมายเหตุ ถ้าไม่เลือกระดับ JL ระบบจะทำการเลือกทั้งหมด</span>
</mat-dialog-content>
<mat-dialog-actions align="end">
<button type="button" mat-button [mat-dialog-close]
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 *ngIf="modalStatus == 'add'" type="button" class="ti-btn ti-btn-success" mat-button
(click)="addevaluation_cycle()"
[class.ti-btn-disabled]="!evaluation_cycle.evaluationRoundId||!evaluation_cycle.tdesc||!evaluation_cycle.apsyear||!evaluation_cycle.apsPeriodStart||!evaluation_cycle.apsPeriodEnd||(modalStatus=='add'&&checkPrimary())"
[disabled]="!evaluation_cycle.evaluationRoundId||!evaluation_cycle.tdesc||!evaluation_cycle.apsyear||!evaluation_cycle.apsPeriodStart||!evaluation_cycle.apsPeriodEnd||(modalStatus=='add'&&checkPrimary())">
บันทึกข้อมูล
</button>
</mat-dialog-actions>
</ng-template>
<ng-template #evaluationRoundModalForm let-modal>
<h3 mat-dialog-title>
เเก้ไขเเบบฟอร์มตามรอบการประเมิน
</h3>
<mat-dialog-content>
<app-edit-define-document-form *ngIf="evaluation_cycle?.evaluationRoundId"
[evaluationRoundId]="evaluation_cycle.evaluationRoundId"></app-edit-define-document-form>
</mat-dialog-content>
<mat-dialog-actions align="end">
<button type="button" mat-button [mat-dialog-close]
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>
</mat-dialog-actions>
</ng-template>
<ng-template #PLModal let-modal>
<h3 mat-dialog-title>
ข้อมูลระดับพนักงาน (JL)
</h3>
<mat-dialog-content>
<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)]="PLsearchmodal.search" (ngModelChange)="onPLModalSearchChange()">
<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>
<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 ['ลำดับ','รหัสระดับพนักงาน (JL)','รายละเอียดฝ่าย (ไทย)','รายละเอียดฝ่าย (อังกฤษ)']; let f = first; let l = last">
<th scope="col" class="relative px-10px py-10px bg-soft-secondary text-primary" [class.!text-center]="f">
<span class="text-sm">{{ item }}</span>
<div class="absolute top-1/2 transform -translate-y-1/2 right-0" *ngIf="!l">
<i class="ti ti-dots-vertical fs-l"></i>
</div>
</th>
</ng-container>
</tr>
</thead>
<tbody *ngIf="!plListFilter().length">
<tr>
<td class="text-center" colspan="100%">
ไม่พบข้อมูล
</td>
</tr>
</tbody>
<tbody *ngIf="plListFilter().length">
<tr
*ngFor="let item of plListFilter() | slice:((PLsearchmodal.currentPage-1) * PLsearchmodal.pageSize) : (((PLsearchmodal.currentPage-1) * PLsearchmodal.pageSize) + PLsearchmodal.pageSize);let i = index"
class="cursor-pointer" (click)="selectPl(item);closeDialogPL()">
<td class="flex justify-center">
{{((PLsearchmodal.currentPage-1) * PLsearchmodal.pageSize)+(i+1)}}
</td>
<td>{{item.plId}}</td>
<td>{{item.tdesc}}</td>
<td>{{item.edesc}}</td>
</tr>
</tbody>
</table>
</div>
<app-pagination [totalItems]="plListFilter().length" [pageSize]="PLsearchmodal.pageSize"
(pageChange)="PLsearchmodal.currentPage = $event"
(pageSizeChange)="PLsearchmodal.pageSize = $event;PLsearchmodal.currentPage = 1"></app-pagination>
</mat-dialog-content>
<mat-dialog-actions align="end">
<button type="button" mat-button [mat-dialog-close]
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>
</mat-dialog-actions>
</ng-template>
<!-- <div class="page px-rem">
<div class="overflow-auto table-bordered rounded-top-0.65rem"> <div class="overflow-auto table-bordered rounded-top-0.65rem">
<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 class="height-50px"> <thead class="height-50px">
...@@ -95,7 +291,7 @@ ...@@ -95,7 +291,7 @@
[(ngModel)]="item.check" (ngModelChange)="dataListCheck()"> [(ngModel)]="item.check" (ngModelChange)="dataListCheck()">
</td> </td>
<td> <td>
<!-- <i class="ti ti-user cursor-pointer i-gray fs-l px-1" data-hs-overlay="#evaluation-cycle-person-modal" (click)="openModal('evaluation-cycle-person-modal',item.data.evaluationRoundId)"></i> --> <i class="ti ti-user cursor-pointer i-gray fs-l px-1" data-hs-overlay="#evaluation-cycle-person-modal" (click)="openModal('evaluation-cycle-person-modal',item.data.evaluationRoundId)"></i>
<label for="checkbox-{{item.data.evaluationRoundId}}">&nbsp;{{item.data.evaluationRoundId}}</label> <label for="checkbox-{{item.data.evaluationRoundId}}">&nbsp;{{item.data.evaluationRoundId}}</label>
</td> </td>
<td>{{item.data.tdesc}}</td> <td>{{item.data.tdesc}}</td>
...@@ -140,11 +336,11 @@ ...@@ -140,11 +336,11 @@
data-hs-overlay="#evaluation-cycle-page-modal"></i> data-hs-overlay="#evaluation-cycle-page-modal"></i>
<i class="ti ti-user cursor-pointer i-gray fs-l px-1" *ngIf="item.data.statusFrom.code =='1'" <i class="ti ti-user cursor-pointer i-gray fs-l px-1" *ngIf="item.data.statusFrom.code =='1'"
(click)="openModal(item.data.evaluationRoundId)"></i> (click)="openModal(item.data.evaluationRoundId)"></i>
<!-- <i class="ti ti-trash cursor-pointer i-gray fs-l px-1" (click)="modalStatus='delete';setData(item.data)" <i class="ti ti-trash cursor-pointer i-gray fs-l px-1" (click)="modalStatus='delete';setData(item.data)"
data-hs-overlay="#evaluation-cycle-page-alert-modal"></i> --> data-hs-overlay="#evaluation-cycle-page-alert-modal"></i>
<!-- <span class="badge text-white m-1" *ngIf="item.data.statusCode.code!='1'" <span class="badge text-white m-1" *ngIf="item.data.statusCode.code!='1'"
[ngClass]="{'bg-primary':item.data.statusCode.code=='1','bg-gray-400':item.data.statusCode.code!='3'}">ปิดรอบประเมิน</span> [ngClass]="{'bg-primary':item.data.statusCode.code=='1','bg-gray-400':item.data.statusCode.code!='3'}">ปิดรอบประเมิน</span>
<span class="badge text-white m-1 bg-secondary" *ngIf="item.data.statusCode.code=='0'">สร้างแบบฟอร์ม</span> --> <span class="badge text-white m-1 bg-secondary" *ngIf="item.data.statusCode.code=='0'">สร้างแบบฟอร์ม</span>
<span class="badge text-white m-1 cursor-pointer" data-hs-overlay="#evaluation-cycle-page-alert-modal" <span class="badge text-white m-1 cursor-pointer" data-hs-overlay="#evaluation-cycle-page-alert-modal"
(click)="modalStatus='createForm';setData(item.data)" *ngIf="item.data.statusFrom.code == '0'" [ngClass]="{ (click)="modalStatus='createForm';setData(item.data)" *ngIf="item.data.statusFrom.code == '0'" [ngClass]="{
'bg-secondary': item.data.statusFrom.code == '0', 'bg-secondary': item.data.statusFrom.code == '0',
...@@ -208,9 +404,9 @@ ...@@ -208,9 +404,9 @@
items</span> items</span>
</ul> </ul>
</nav> </nav>
</div> </div> -->
<div id="evaluation-cycle-page-modal" class="hs-overlay hidden ti-modal"> <!-- <div id="evaluation-cycle-page-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="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="max-h-full overflow-hidden ti-modal-content">
<div class="ti-modal-header"> <div class="ti-modal-header">
...@@ -244,12 +440,12 @@ ...@@ -244,12 +440,12 @@
Clear Clear
</button> </button>
</div> </div>
<!-- <div class="px-1"> <div class="px-1">
<button href="javascript:void(0);" class="ti-btn ti-btn-soft-warning h-45px m-0 shadow-md"> <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> <i class="ti ti-book fs-l"></i>
Help Help
</button> </button>
</div> --> </div>
</div> </div>
</div> </div>
<div class="ti-modal-body padding-16px pt-0 overflow-y-0"> <div class="ti-modal-body padding-16px pt-0 overflow-y-0">
...@@ -270,8 +466,8 @@ ...@@ -270,8 +466,8 @@
[readonly]="!modalStatusEdit" [(ngModel)]="evaluation_cycle.edesc"> [readonly]="!modalStatusEdit" [(ngModel)]="evaluation_cycle.edesc">
<label for="input-label" class="ti-form-label mt-2rem">ปีการประเมิน<span class="text-danger">*</span></label> <label for="input-label" class="ti-form-label mt-2rem">ปีการประเมิน<span class="text-danger">*</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"
oninput="this.value = this.value.replace(/\D/g, '')" [(ngModel)]="evaluation_cycle.apsyear"> --> oninput="this.value = this.value.replace(/\D/g, '')" [(ngModel)]="evaluation_cycle.apsyear">
<select class="ti-form-select" [(ngModel)]="evaluation_cycle.apsyear" <select class="ti-form-select" [(ngModel)]="evaluation_cycle.apsyear"
[ngClass]="{'bg-input-readonly':!modalStatusEdit}" [disabled]="!modalStatusEdit"> [ngClass]="{'bg-input-readonly':!modalStatusEdit}" [disabled]="!modalStatusEdit">
<option *ngFor="let item of yearList" [ngValue]="item">{{ item }}</option> <option *ngFor="let item of yearList" [ngValue]="item">{{ item }}</option>
...@@ -353,9 +549,9 @@ ...@@ -353,9 +549,9 @@
</div> </div>
</div> </div>
</div> </div>
</div> </div> -->
<div id="evaluation-cycle-page-alert-modal" class="hs-overlay hidden ti-modal"> <!-- <div id="evaluation-cycle-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="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="max-h-full overflow-hidden ti-modal-content w-full">
<div class="ti-modal-header"> <div class="ti-modal-header">
...@@ -428,7 +624,7 @@ ...@@ -428,7 +624,7 @@
ย้อนกลับ ย้อนกลับ
</button> </button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);" <a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#evaluation-cycle-page-alert-modal" (click)="createForm()"> data-hs-overlay="#evaluation-cycle-page-alert-modal" (click)="createForm($event)">
ยืนยัน ยืนยัน
</a> </a>
</ng-container> </ng-container>
...@@ -436,25 +632,9 @@ ...@@ -436,25 +632,9 @@
</div> </div>
</div> </div>
</div> </div>
</div> </div> -->
<ng-template #evaluationRoundModal let-modal> <!-- <div id="evaluation-cycle-person-modal" class="hs-overlay hidden ti-modal">
<h3 mat-dialog-title>
เเก้ไขเเบบฟอร์มตามรอบการประเมิน
</h3>
<mat-dialog-content >
<app-edit-define-document-form *ngIf="evaluationRoundId"
[evaluationRoundId]="evaluationRoundId"></app-edit-define-document-form>
</mat-dialog-content>
<mat-dialog-actions align="end">
<button type="button" mat-button [mat-dialog-close]
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>
</mat-dialog-actions>
</ng-template>
<div id="evaluation-cycle-person-modal" class="hs-overlay hidden ti-modal">
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out m-3 lg:!mx-auto " style="min-width: 70%;"> <div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out m-3 lg:!mx-auto " style="min-width: 70%;">
<div class="max-h-full overflow-hidden ti-modal-content w-full"> <div class="max-h-full overflow-hidden ti-modal-content w-full">
<div class="ti-modal-header"> <div class="ti-modal-header">
...@@ -470,18 +650,15 @@ ...@@ -470,18 +650,15 @@
</div> </div>
</div> </div>
<div class="ti-modal-body "> <div class="ti-modal-body ">
<!-- <app-edit-evaluation-form *ngIf="evaluationRoundId" [evaluationRoundId]="evaluationRoundId" ></app-edit-evaluation-form> --> คอมเม้นปิด<app-edit-evaluation-form *ngIf="evaluationRoundId" [evaluationRoundId]="evaluationRoundId" ></app-edit-evaluation-form>
<app-edit-define-document-form *ngIf="evaluationRoundId" <app-edit-define-document-form *ngIf="evaluationRoundId"
[evaluationRoundId]="evaluationRoundId"></app-edit-define-document-form> [evaluationRoundId]="evaluationRoundId"></app-edit-define-document-form>
</div> </div>
</div> </div>
</div> </div>
</div> </div> -->
<div id="evaluation-cycle-pl-table-modal" class="hs-overlay hidden ti-modal"> <!-- <div id="evaluation-cycle-pl-table-modal" class="hs-overlay hidden ti-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"> <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="max-h-full overflow-hidden ti-modal-content">
<div class="ti-modal-header"> <div class="ti-modal-header">
...@@ -605,4 +782,4 @@ ...@@ -605,4 +782,4 @@
</div> </div>
</div> </div>
</div> </div>
</div> </div> -->
\ No newline at end of file \ No newline at end of file
...@@ -2,15 +2,16 @@ import { ChangeDetectorRef, Component, EventEmitter, Output, Renderer2, ViewChil ...@@ -2,15 +2,16 @@ import { ChangeDetectorRef, Component, EventEmitter, Output, Renderer2, ViewChil
import { ToastrService } from 'ngx-toastr'; import { ToastrService } from 'ngx-toastr';
import { EvaluationCycleModel, MyEvaluationCycleModel } from 'src/app/shared/model/evaluation-cycle.model'; import { EvaluationCycleModel, MyEvaluationCycleModel } from 'src/app/shared/model/evaluation-cycle.model';
import { EvaluationCycleService } from 'src/app/shared/services/evaluation-cycle.service'; import { EvaluationCycleService } from 'src/app/shared/services/evaluation-cycle.service';
import { MyStatusCodeModel, StatusCodeModel } from 'src/app/shared/model/status-code.model';
import { EvaluationAssessmentService } from 'src/app/shared/services/evaluation-assessment.service';
import { PLService } from 'src/app/shared/services/pl.service'; import { PLService } from 'src/app/shared/services/pl.service';
import { PLModel, MyPLModel } from 'src/app/shared/model/pl.model'; import { PLModel, MyPLModel } from 'src/app/shared/model/pl.model';
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
import { ColumnModel } from '@syncfusion/ej2-grids';
import Swal from 'sweetalert2';
export interface DataModal { export interface DataModal {
search: string, search: string,
currentPage: number, currentPage: number,
page: number[] page: number[],
pageSize: number
} }
@Component({ @Component({
selector: 'app-evaluation-cycle', selector: 'app-evaluation-cycle',
...@@ -20,14 +21,21 @@ export interface DataModal { ...@@ -20,14 +21,21 @@ export interface DataModal {
export class EvaluationCycleComponent { export class EvaluationCycleComponent {
@Output() evaluationRoundIdChange = new EventEmitter<string>(); @Output() evaluationRoundIdChange = new EventEmitter<string>();
@ViewChild("evaluationRoundModal") evaluationRoundModal: any; @ViewChild("evaluationRoundModal") evaluationRoundModal: any;
dialogRef: any
@ViewChild("evaluationRoundModalForm") evaluationRoundModalForm: any;
dialogRefForm: any
@ViewChild("PLModal") PLModal: any;
dialogRefPL: any
apsPeriodStart: string = ''; apsPeriodStart: string = '';
apsPeriodEnd: string = ''; apsPeriodEnd: string = '';
currentPage = 1 currentPage = 1
page = Array.from({ length: 1 }, (_, i) => i + 1); page = Array.from({ length: 1 }, (_, i) => i + 1);
search = "" modalStatus : 'createForm' | 'add' | 'edit' | 'delete' | 'deleteGroup' = 'add'
modalStatus = 'add' evaluation_cyclelist: EvaluationCycleModel[] = []
evaluation_cyclelist: { check: boolean, data: EvaluationCycleModel }[] = []
evaluation_cycle: EvaluationCycleModel = new MyEvaluationCycleModel({}) evaluation_cycle: EvaluationCycleModel = new MyEvaluationCycleModel({})
dataLoading = false dataLoading = false
itemToDelete: EvaluationCycleModel | null = null; itemToDelete: EvaluationCycleModel | null = null;
...@@ -40,7 +48,14 @@ export class EvaluationCycleComponent { ...@@ -40,7 +48,14 @@ export class EvaluationCycleComponent {
modal: DataModal = { modal: DataModal = {
search: "", search: "",
currentPage: 1, currentPage: 1,
page: Array.from({ length: 1 }, (_, i) => i + 1) page: Array.from({ length: 1 }, (_, i) => i + 1),
pageSize: 10
}
PLsearchmodal: DataModal = {
currentPage: 1,
page: Array.from({ length: 1 }, (_, i) => i + 1),
search: "",
pageSize: 10
} }
pl: { loading: boolean, selectIndex: number, dataList: PLModel[] } = { loading: false, selectIndex: -1, dataList: [] } pl: { loading: boolean, selectIndex: number, dataList: PLModel[] } = { loading: false, selectIndex: -1, dataList: [] }
currentDate = new Date() currentDate = new Date()
...@@ -51,12 +66,52 @@ export class EvaluationCycleComponent { ...@@ -51,12 +66,52 @@ export class EvaluationCycleComponent {
] ]
modalStatusEdit = false modalStatusEdit = false
dialogFormRef: any dialogFormRef: any
columns: ColumnModel[] = [{
field: "evaluationRoundId",
headerText: "รหัส",
type: "string",
isPrimaryKey: true,
},
{
field: "tdesc",
headerText: "รายละเอียด",
type: "string"
},
{
field: "apsyear",
headerText: " รอบปีการประเมิน",
type: "string"
},
{
field: "apsPeriodStart",
headerText: " วันที่เริ่มต้น",
type: "string"
},
{
field: "apsPeriodEnd",
headerText: "วันที่สิ้นสุด",
type: "string"
},
{
field: "statusCode.tdesc",
headerText: "สถานะ",
type: "string"
}]
searchSettings = {
fields: ['evaluationRoundId', 'tdesc', 'apsyear', 'apsPeriodStart', 'apsPeriodEnd', 'statusCode.tdesc'],
operator: 'contains',
ignoreCase: false
};
search = ''
selectedItems: { key: string, count: number, data: Map<string, boolean> } = { key: '', count: 0, data: new Map<string, boolean>() };
constructor(private evaluationCycleService: EvaluationCycleService, constructor(private evaluationCycleService: EvaluationCycleService,
private toastr: ToastrService, private toastr: ToastrService,
private cdr: ChangeDetectorRef, private cdr: ChangeDetectorRef,
private renderer: Renderer2, private renderer: Renderer2,
private pLService: PLService, private pLService: PLService,
private dialog: MatDialog private dialog: MatDialog
) { } ) { }
ngOnInit(): void { ngOnInit(): void {
...@@ -91,12 +146,15 @@ export class EvaluationCycleComponent { ...@@ -91,12 +146,15 @@ export class EvaluationCycleComponent {
} }
plListFilter() { plListFilter() {
return this.pl.dataList.filter(x => return this.pl.dataList.filter(x =>
(x.plId.toLowerCase().includes(this.modal.search.toLowerCase()) || (x.plId.toLowerCase().includes(this.PLsearchmodal.search.toLowerCase()) ||
x.tdesc.toLowerCase().includes(this.modal.search.toLowerCase()) || x.tdesc.toLowerCase().includes(this.PLsearchmodal.search.toLowerCase()) ||
x.edesc.toLowerCase().includes(this.modal.search.toLowerCase())) && x.edesc.toLowerCase().includes(this.PLsearchmodal.search.toLowerCase())) &&
!this.evaluation_cycle.personalLevel.some(y => y.plId == x.plId) !this.evaluation_cycle.personalLevel.some(y => y.plId == x.plId)
); );
}
onPLModalSearchChange() {
this.PLsearchmodal.currentPage = 1
this.PLsearchmodal.page = Array.from({ length: Math.ceil(this.plListFilter().length / 10) }, (_, i) => i + 1);
} }
selectPl(data?: PLModel) { selectPl(data?: PLModel) {
if (!data) { if (!data) {
...@@ -108,16 +166,17 @@ export class EvaluationCycleComponent { ...@@ -108,16 +166,17 @@ export class EvaluationCycleComponent {
getEvaluationCycleList() { getEvaluationCycleList() {
this.dataLoading = true this.dataLoading = true
this.selectedItems.data.clear()
this.evaluationCycleService.getList().subscribe({ this.evaluationCycleService.getList().subscribe({
next: response => { next: response => {
this.evaluation_cyclelist = response.map(x => ({ this.evaluation_cyclelist = response.map(x => {
check: false, this.selectedItems.data.set(x.evaluationRoundId, false)
data: new MyEvaluationCycleModel(x) return new MyEvaluationCycleModel(x)
})); })
this.selectedItems.key = 'evaluationRoundId'
this.selectedItems.count = 0
this.dataLoading = false this.dataLoading = false
this.isDataListCheckedAll = false this.isDataListCheckedAll = false
this.dataListCheckAll()
this.searchChange();
this.cdr.detectChanges(); this.cdr.detectChanges();
}, },
error: err => { error: err => {
...@@ -126,16 +185,16 @@ export class EvaluationCycleComponent { ...@@ -126,16 +185,16 @@ export class EvaluationCycleComponent {
} }
}); });
} }
dataListCheckAll() { // dataListCheckAll() {
const selectAll = this.isDataListCheckedAll; // const selectAll = this.isDataListCheckedAll;
this.evaluation_cycleListFilter().forEach(x => x.check = selectAll); // this.evaluation_cycleListFilter().forEach(x => x = selectAll);
this.dataListCheck(); // this.dataListCheck();
} // }
dataListCheck() { dataListCheck() {
const dataCheck = this.evaluation_cycleListFilter(); const dataCheck = this.evaluation_cycleListFilter();
this.isDataListCheckedAll = dataCheck.length ? dataCheck.every(x => x.check) : false; this.isDataListCheckedAll = dataCheck.length ? dataCheck.every(x => x) : false;
this.numDataListChecked = this.evaluation_cyclelist.filter(x => x.check).length; this.numDataListChecked = this.evaluation_cyclelist.filter(x => x).length;
this.isDataListChecked = Boolean(this.numDataListChecked) this.isDataListChecked = Boolean(this.numDataListChecked)
} }
searchChange() { searchChange() {
...@@ -145,7 +204,7 @@ export class EvaluationCycleComponent { ...@@ -145,7 +204,7 @@ export class EvaluationCycleComponent {
} }
evaluation_cycleListFilter() { evaluation_cycleListFilter() {
return this.evaluation_cyclelist.filter(x => { return this.evaluation_cyclelist.filter(x => {
const data = x.data const data = x
const match = data.evaluationRoundId.toLowerCase().includes(this.search.toLowerCase()) || data.tdesc.toLowerCase().includes(this.search.toLowerCase()) || data.edesc.toLowerCase().includes(this.search.toLowerCase()); const match = data.evaluationRoundId.toLowerCase().includes(this.search.toLowerCase()) || data.tdesc.toLowerCase().includes(this.search.toLowerCase()) || data.edesc.toLowerCase().includes(this.search.toLowerCase());
return match; return match;
}); });
...@@ -153,61 +212,154 @@ export class EvaluationCycleComponent { ...@@ -153,61 +212,154 @@ export class EvaluationCycleComponent {
setData(data?: EvaluationCycleModel) { setData(data?: EvaluationCycleModel) {
this.evaluation_cycle = new MyEvaluationCycleModel(data) this.evaluation_cycle = new MyEvaluationCycleModel(data)
} }
addevaluation_cycle() {
if (this.evaluation_cycle.personalLevel.length == 0) { selectEvaluationCycle(EvaluationCycle?: EvaluationCycleModel) {
this.plListFilter().forEach(x => this.selectPl(x)) if (EvaluationCycle) {
this.evaluation_cycle = new MyEvaluationCycleModel(EvaluationCycle);
this.evaluationRoundId = this.evaluation_cycle.evaluationRoundId;
} else if (this.modalStatus == 'add') {
this.evaluation_cycle = new MyEvaluationCycleModel();
this.evaluationRoundId = '';
} else if (this.modalStatus == 'edit') {
this.evaluation_cycle = new MyEvaluationCycleModel({ evaluationRoundId: this.evaluation_cycle.evaluationRoundId });
this.evaluationRoundId = this.evaluation_cycle.evaluationRoundId;
} }
const body = new MyEvaluationCycleModel(this.evaluation_cycle) }
this.dataLoading = true
this.evaluationCycleService.post(body).subscribe({ addevaluation_cycle() {
next: response => { Swal.fire({
if (response.success) { icon: 'question',
this.showAlert(response.message, 'success') title: 'แจ้งเตือน',
this.getEvaluationCycleList() text: 'ยืนยันการบันทึกข้อมูลหรือไม่',
} else { showCancelButton: true,
this.dataLoading = false confirmButtonText: 'บันทึกข้อมูล',
this.showAlert(response.message, 'error') cancelButtonText: 'ย้อนกลับ',
this.cdr.detectChanges() reverseButtons: true,
}).then((result) => {
if (result.isConfirmed) {
if (this.evaluation_cycle.personalLevel.length === 0) {
this.plListFilter().forEach(x => this.selectPl(x));
} }
}, error: error => {
this.showAlert(error.message, 'error') const body = new MyEvaluationCycleModel(this.evaluation_cycle);
this.dataLoading = false this.dataLoading = true;
this.cdr.detectChanges()
this.evaluationCycleService.post(body).subscribe({
next: response => {
if (response.success) {
this.showAlert(response.message, 'success');
this.getEvaluationCycleList();
this.closeDialog()
} else {
this.dataLoading = false;
this.showAlert(response.message, 'error');
this.cdr.detectChanges();
}
},
error: error => {
this.showAlert(error.message, 'error');
this.dataLoading = false;
this.cdr.detectChanges();
}
});
} }
}) });
} }
deleteevaluation_cycle() { deleteevaluation_cycle() {
let body: EvaluationCycleModel | EvaluationCycleModel[] = [] if (!this.numSelectItem()) {
if (this.evaluation_cycle.evaluationRoundId) { this.showAlert('กรุณาเลือกข้อมูลที่ต้องการลบ', 'error')
body = new MyEvaluationCycleModel(this.evaluation_cycle) return
} else {
body = this.evaluation_cyclelist.filter(x => x.check).map(x => new MyEvaluationCycleModel(x.data))
} }
this.dataLoading = true Swal.fire({
this.evaluationCycleService.delete(body).subscribe({ icon: 'question',
next: response => { title: 'แจ้งเตือน',
if (response.success) { text: 'ยืนยันการลบข้อมูลหรือไม่',
this.showAlert(response.message, 'success') showCancelButton: true,
this.getEvaluationCycleList() confirmButtonText: 'ลบข้อมูล',
} else { cancelButtonText: 'ย้อนกลับ',
this.dataLoading = false reverseButtons: true,
this.showAlert(response.message, 'error') }).then((result) => {
this.dataLoading = false if (result.isConfirmed) {
this.cdr.detectChanges() const selectedKeys = Array.from(this.selectedItems.data.keys());
} const body = this.evaluation_cyclelist.filter(x => selectedKeys.includes(x.evaluationRoundId) && this.selectedItems.data.get(x.evaluationRoundId)).map(x => new MyEvaluationCycleModel(x))
}, error: error => { console.log(body);
this.showAlert(error.message, 'error')
this.dataLoading = false this.dataLoading = true
this.cdr.detectChanges() this.evaluationCycleService.delete(body).subscribe({
next: response => {
if (response.success) {
this.showAlert(response.message, 'success')
this.getEvaluationCycleList()
} else {
this.showAlert(response.message, 'error')
this.dataLoading = false
this.cdr.detectChanges()
}
}, error: error => {
this.showAlert(error.message, 'error')
this.cdr.detectChanges()
this.dataLoading = false
}
})
} }
}) });
} }
// ลบหลายรายการ
// deleteevaluation_cycleall() {
// Swal.fire({
// icon: 'question',
// title: 'แจ้งเตือน',
// text: 'ยืนยันการลบข้อมูลหรือไม่',
// showCancelButton: true,
// confirmButtonText: 'ลบข้อมูล',
// cancelButtonText: 'ย้อนกลับ',
// reverseButtons: true,
// }).then((result) => {
// if (result.isConfirmed) {
// let body: EvaluationCycleModel | EvaluationCycleModel[] = [];
// if (this.evaluation_cycle.evaluationRoundId) {
// body = new MyEvaluationCycleModel(this.evaluation_cycle);
// } else {
// body = this.evaluation_cyclelist
// .filter(x => x)
// .map(x => new MyEvaluationCycleModel(x));
// }
// console.log(body);
// this.dataLoading = true;
// this.evaluationCycleService.delete(body).subscribe({
// next: response => {
// if (response.success) {
// this.showAlert(response.message, 'success');
// this.getEvaluationCycleList();
// } 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();
// }
// });
// }
// });
// }
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: 'ตกลง',
}); });
} }
...@@ -221,8 +373,8 @@ export class EvaluationCycleComponent { ...@@ -221,8 +373,8 @@ export class EvaluationCycleComponent {
openModal(evaluationRoundId: string) { openModal(evaluationRoundId: string) {
this.evaluationRoundId = '' this.evaluationRoundId = ''
this.dialogFormRef = this.dialog.open(this.evaluationRoundModal, { this.dialogFormRef = this.dialog.open(this.evaluationRoundModalForm, {
width: '80vw', width: '80vw',
disableClose: true, disableClose: true,
enterAnimationDuration: '300ms', // ระยะเวลาการเปิด enterAnimationDuration: '300ms', // ระยะเวลาการเปิด
exitAnimationDuration: '150ms', // ระยะเวลาการปิด exitAnimationDuration: '150ms', // ระยะเวลาการปิด
...@@ -246,45 +398,103 @@ export class EvaluationCycleComponent { ...@@ -246,45 +398,103 @@ export class EvaluationCycleComponent {
this.modal.page = Array.from({ length: Math.ceil(dataList.length / 10) }, (_, i) => i + 1); this.modal.page = Array.from({ length: Math.ceil(dataList.length / 10) }, (_, i) => i + 1);
} }
createForm() { createForm(data: any) {
const body = new MyEvaluationCycleModel(this.evaluation_cycle) Swal.fire({
body.active = 1 title: 'สร้างแบบฟอร์ม?',
this.dataLoading = true text: 'คุณต้องการสร้างแบบฟอร์มการประเมินใหม่หรือไม่',
this.evaluationCycleService.post(body).subscribe({ icon: 'question',
next: response => { showCancelButton: true,
if (response.success) { confirmButtonText: 'ยืนยัน',
this.showAlert(response.message, 'success') cancelButtonText: 'ยกเลิก',
} else { reverseButtons: true,
this.dataLoading = false }).then((result) => {
this.showAlert(response.message, 'error') if (result.isConfirmed) {
this.cdr.detectChanges() this.modalStatus = 'createForm';
this.setData(data); // เซ็ตข้อมูลก่อน
const body = new MyEvaluationCycleModel(this.evaluation_cycle);
body.active = 1;
this.dataLoading = true;
this.evaluationCycleService.post(body).subscribe({
next: response => {
if (response.success) {
this.showAlert(response.message, 'success');
} else {
this.dataLoading = false;
this.showAlert(response.message, 'error');
this.cdr.detectChanges();
}
},
error: error => {
this.showAlert(error.message, 'error');
this.dataLoading = false;
this.cdr.detectChanges();
} }
}, error: error => { });
this.showAlert(error.message, 'error')
this.dataLoading = false this.evaluationCycleService.postCreateForm(body).subscribe({
this.cdr.detectChanges() next: response => {
} if (response.success) {
}) this.showAlert(response.message, 'success');
this.evaluationCycleService.postCreateForm(body).subscribe({ this.getEvaluationCycleList();
next: response => { } else {
if (response.success) { this.dataLoading = false;
this.showAlert(response.message, 'success') this.showAlert(response.message, 'error');
this.getEvaluationCycleList() this.cdr.detectChanges();
} else { }
this.dataLoading = false },
this.showAlert(response.message, 'error') error: error => {
this.cdr.detectChanges() this.showAlert(error.message, 'error');
this.dataLoading = false;
this.cdr.detectChanges();
} }
}, error: error => { });
this.showAlert(error.message, 'error') }
this.dataLoading = false });
this.cdr.detectChanges() }
}
})
}
checkPrimary() { checkPrimary() {
return this.evaluation_cyclelist.find(x => x.data.evaluationRoundId == this.evaluation_cycle.evaluationRoundId) return this.evaluation_cyclelist.find(x => x.evaluationRoundId == this.evaluation_cycle.evaluationRoundId)
}
numSelectItem() {
const selectedKeys = Array.from(this.selectedItems.data.keys());
const num = this.evaluation_cyclelist.filter(x => selectedKeys.includes(x.evaluationRoundId) && this.selectedItems.data.get(x.evaluationRoundId)).length
return num
}
onSelectItemChange(arg: any) {
this.selectedItems = arg
}
openDialog() {
this.dialogRef = this.dialog.open(this.evaluationRoundModal, {
width: '500px',
disableClose: false,
});
}
closeDialog() {
this.dialogRef.close()
}
openDialogForm() {
this.dialogRefForm = this.dialog.open(this.evaluationRoundModalForm, {
width: '1200px',
disableClose: false,
});
}
closeDialogForm() {
this.dialogRefForm.close()
}
openDialogPL() {
this.dialogRefPL = this.dialog.open(this.PLModal, {
width: '800px',
});
}
closeDialogPL() {
this.dialogRefPL.close()
} }
} }
......
...@@ -29,8 +29,31 @@ ...@@ -29,8 +29,31 @@
<ng-template #headerTemplate let-data> <ng-template #headerTemplate let-data>
<span class="font-size-12px font-weight-700 text-primary">{{ col.headerText }}</span> <span class="font-size-12px font-weight-700 text-primary">{{ col.headerText }}</span>
</ng-template> </ng-template>
<ng-template #template let-data *ngIf="col.field == 'statusCode.tdesc'">
<div class="flex justify-center items-center w-full h-full">
<span
class="hs-tooltip ti-main-tooltip [--trigger:hover] flex items-center justify-center rounded-full h-6 w-6 text-white"
[ngClass]="{
'bg-success': data.statusCode.tdesc == 'กำลังดำเนินการประเมิน',
'bg-warning': data.statusCode.tdesc == 'รอดำเนินการ',
'bg-gray-400': data.statusCode.tdesc == 'สิ้นสุดช่วงเวลาประเมิน'
}" role="tooltip">
<ng-container [ngSwitch]="data.statusCode.tdesc">
<i *ngSwitchCase="'กำลังดำเนินการประเมิน'" class="ti ti-clock hs-tooltip-toggle ti-main-tooltip-toggle"></i>
<i *ngSwitchCase="'รอดำเนินการ'" class="ti ti-hourglass-empty hs-tooltip-toggle ti-main-tooltip-toggle"></i>
<i *ngSwitchCase="'สิ้นสุดช่วงเวลาประเมิน'" class="ti ti-check hs-tooltip-toggle ti-main-tooltip-toggle"></i>
</ng-container>
<span
class="hs-tooltip-content ti-main-tooltip-content py-1 px-2 bg-primary text-white shadow-sm dark:bg-slate-700">
{{ data.statusCode.tdesc }}
</span>
</span>
</div>
</ng-template>
</e-column> </e-column>
<e-column headerText='action' width='150' textAlign='Center' *ngIf="actionSetting"> <e-column headerText='action' width='205' textAlign='Center' *ngIf="actionSetting">
<ng-template #headerTemplate let-data *ngIf="actionSetting"> <ng-template #headerTemplate let-data *ngIf="actionSetting">
<span class="font-size-12px font-weight-700 text-primary">การจัดการ</span> <span class="font-size-12px font-weight-700 text-primary">การจัดการ</span>
</ng-template> </ng-template>
...@@ -38,10 +61,32 @@ ...@@ -38,10 +61,32 @@
<i class="ti ti-eye cursor-pointer i-gray fs-l px-1" (click)="onNextPageView(data)" *ngIf="childView"></i> <i class="ti ti-eye cursor-pointer i-gray fs-l px-1" (click)="onNextPageView(data)" *ngIf="childView"></i>
<i class="ti ti-edit cursor-pointer i-gray fs-l px-1" [attr.data-hs-overlay]="modalName" *ngIf="canEdit" <i class="ti ti-edit cursor-pointer i-gray fs-l px-1" [attr.data-hs-overlay]="modalName" *ngIf="canEdit"
(click)="onSelectData(data)"></i> (click)="onSelectData(data)"></i>
<i class="ti ti-file-download cursor-pointer i-gray fs-l px-1" (click)="onFileDownload(data)" <i class="ti ti-file-download cursor-pointer i-gray fs-l px-1" (click)="onFileDownload(data)"
*ngIf="canDownload && data.competencyFiles"></i> *ngIf="canDownload && data.competencyFiles"></i>
<i class="ti ti-menu-2 cursor-pointer i-gray fs-l px-1" (click)="onNextPage(data)" *ngIf="canChild"></i> <i class="ti ti-menu-2 cursor-pointer i-gray fs-l px-1" (click)="onNextPage(data)" *ngIf="canChild"></i>
</ng-template> <i class="ti ti-user cursor-pointer i-gray fs-l px-1" (click)="onNextPageForm(data)" *ngIf="childForm"></i>
<ng-container *ngIf="data.statusFrom as statusFrom">
<ng-container [ngSwitch]="statusFrom.code">
<span class="badge text-white m-1 cursor-pointer"
(click)="modalStatus='createForm'; createFormEvent.emit(data)" *ngIf="statusFrom.code == '0'"
[ngClass]="{'bg-secondary': true, 'text-white': true}">
สร้างแบบฟอร์ม
</span>
<span class="badge text-white m-1" *ngIf="statusFrom.code == '1'"
[ngClass]="{'bg-primary': true, 'text-white': true}">
ปิดรอบประเมิน
</span>
<span class="badge text-white m-1" *ngIf="statusFrom.code == '2'"
[ngClass]="{'bg-gray-400': true, 'text-white': true}">
ปิดรอบประเมิน
</span>
</ng-container>
</ng-container>
</ng-template>
</e-column> </e-column>
</e-columns> </e-columns>
......
...@@ -108,7 +108,11 @@ export class DatagridSyncfutionComponent implements OnInit { ...@@ -108,7 +108,11 @@ export class DatagridSyncfutionComponent implements OnInit {
@Output() sendNextPageView = new EventEmitter<any>(); @Output() sendNextPageView = new EventEmitter<any>();
@Input() canDownload = false @Input() canDownload = false
@Output() sendFileDownload = new EventEmitter<any>(); @Output() sendFileDownload = new EventEmitter<any>();
@Input() childForm = false
@Output() sendNextPageForm = new EventEmitter<any>();
modalStatus = '';
@Output() createFormEvent = new EventEmitter<any>();
@Input() checkBoxSetting = true @Input() checkBoxSetting = true
@Input() actionSetting = true @Input() actionSetting = true
@Input() detailSetting = false @Input() detailSetting = false
...@@ -376,12 +380,13 @@ export class DatagridSyncfutionComponent implements OnInit { ...@@ -376,12 +380,13 @@ export class DatagridSyncfutionComponent implements OnInit {
} }
} }
onNextPageView(data: any) { onNextPageView(data: any) {
this.sendNextPageView.emit(data); this.sendNextPageView.emit(data);
} }
onFileDownload(data: any) { onFileDownload(data: any) {
this.sendFileDownload.emit(data); this.sendFileDownload.emit(data);
} }
onNextPageForm(data: any) {
this.sendNextPageForm.emit(data);
}
} }
...@@ -34,42 +34,239 @@ ...@@ -34,42 +34,239 @@
<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-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"> [(ngModel)]="search">
<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 class="px-1">
<button type="button" class="ti-btn ti-btn-soft-secondary h-45px m-0 shadow-md"
(click)="modalStatus='add';modalStatusEdit=true;selectPl();selectPmsMasfromEvaluationCycle();openDialog();">
<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-45px m-0 shadow-md"
(click)="modalStatus='delete';selectPmsMasfromEvaluationCycle();deletePmsMasfromEvaluation()" >
<i class="ri-delete-bin-6-line"></i>
Delete
</button>
</div> </div>
</div>
<div class="px-1">
<button type="button" class="ti-btn ti-btn-soft-secondary h-45px m-0 shadow-md"
(click)="modalStatus='add';modalStatusEdit=true;selectPl();selectPmsMasfromEvaluationCycle();openDialog();">
<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-45px m-0 shadow-md"
(click)="modalStatus='delete';selectPmsMasfromEvaluationCycle();deletePmsMasfromEvaluation()">
<i class="ri-delete-bin-6-line"></i>
Delete
</button>
</div>
</div> </div>
</div> </div>
<div class="page px-rem"> <div class="page px-rem">
<app-datagrid-syncfution [searchSettings]="searchSettings" [searchText]="search" [dataSource]="pmsMasfromEvaluation.dataList" <app-datagrid-syncfution [searchSettings]="searchSettings" [searchText]="search"
[columns]="columns" [selectedItems]="selectedItems" [dataSource]="pmsMasfromEvaluation.dataList" [columns]="columns" [selectedItems]="selectedItems" [childForm]="true"
(sendSelectData)="modalStatus='edit';selectPmsMasfromEvaluationCycle($event);openDialog()" (sendSelectedItems)="onSelectItemChange($event)" (createFormEvent)="createForm($event)"
> (sendNextPageForm)="selectPmsMasfromEvaluationCycle($event); openDialogForm()"
(sendSelectData)="modalStatus='edit';selectPmsMasfromEvaluationCycle($event);openDialog()"
(sendSelectedItems)="onSelectItemChange($event)">
</app-datagrid-syncfution> </app-datagrid-syncfution>
</div> </div>
<ng-template #managementEvaluationCycleModal let-modal>
<h3 mat-dialog-title>
{{modalStatus=='add'?'เพิ่มรอบการประเมิน':'เเก้ไขรอบการประเมิน'}}
</h3>
<div class="w-full flex justify-end mb-1rem">
<div class="absolute flex">
<div class="px-1">
<button type="button" class="ti-btn ti-btn-soft-indigo h-45px m-0 shadow-md"
(click)="selectPl();selectPmsMasfromEvaluationCycle()">
<i class="ti ti-eraser text-base"></i>
Clear
</button>
</div>
</div>
</div>
<mat-dialog-content>
<label for="input-label" class="ti-form-label mt-2rem">รหัสรอบการประเมิน<span class="text-danger">*<ng-container
*ngIf="modalStatus=='add'&&checkPrimary()">
รหัสรอบการประเมินซ้ำ
</ng-container></span></label>
<input type="text" id="input-label" class="ti-form-input w-1/2" [ngClass]="{'!bg-input-readonly': modalStatus == 'edit'}"
[readonly]="modalStatus =='edit'" [(ngModel)]="pmsMasfromEvaluation.select.pmsEvaluationRoundId">
<label for="detail_th" class="ti-form-label mt-2rem">รายละเอียด (ไทย)<span class="text-danger">*</span></label>
<input type="text" id="detail_th" class="ti-form-input h-16" [ngClass]="{'!bg-input-readonly': modalStatus == 'edit'}"
[(ngModel)]="pmsMasfromEvaluation.select.tdesc" [readonly]="modalStatus =='edit'">
<label for="detail_eng" class="ti-form-label mt-2rem">รายละเอียด (อังกฤษ)</label>
<input type="text" id="detail_eng" class="ti-form-input h-16" [ngClass]="{'!bg-input-readonly': modalStatus == 'edit'}"
[(ngModel)]="pmsMasfromEvaluation.select.edesc" [readonly]="modalStatus =='edit'">
<label for="input-label" class="ti-form-label mt-2rem">ปีการประเมิน<span class="text-danger">*</span></label>
<select class="ti-form-select" [(ngModel)]="pmsMasfromEvaluation.select.apsyear"
[ngClass]="{'!bg-input-readonly': modalStatus == 'edit'}" [disabled]="modalStatus == 'edit'">
<option *ngFor="let item of yearList" [ngValue]="item">{{ item }}</option>
</select>
<label for="input-label" class="ti-form-label mt-2rem">เริ่มวันที่<span class="text-danger">*</span></label>
<input type="date" id="input-label" class="ti-form-input w-1/2"
[(ngModel)]="pmsMasfromEvaluation.select.apsPeriodStart" [ngClass]="{'!bg-input-readonly': modalStatus == 'edit'}"
[readonly]="modalStatus =='edit'">
<label for="input-label" class="ti-form-label mt-2rem">สิ้นสุดวันที่<span class="text-danger">*</span></label>
<input type="date" id="input-label" class="ti-form-input w-1/2"
[(ngModel)]="pmsMasfromEvaluation.select.apsPeriodEnd" [ngClass]="{'!bg-input-readonly': modalStatus == 'edit'}"
[readonly]="modalStatus =='edit'">
<label for="input-label" class="ti-form-label mt-2rem">ระดับพนักงาน (JL)</label>
<div *ngFor="let item of pmsMasfromEvaluation.select.personalLevel;let i = index;let f=first;let l = last"
class="grid grid-cols-2">
<div class="col-span-1">
<div class="flex relative">
<input type="text" class="ti-form-input pointer-events-none" readonly
[ngClass]="{'input-list-f1': f&&!l, 'input-list-c1': !f&&!l, 'input-list-l1': !f&&l, 'input-list-fl1': f&&l,'bg-input-readonly':!modalStatusEdit}"
[(ngModel)]="item.plId">
<div
[ngClass]="{'input-list-line-f': f&&!l, 'input-list-line-c': !f&&!l, 'input-list-line-l': !f&&l, 'input-list-line-fl': f&&l,'bg-input-readonly':!modalStatusEdit}">
<div class="input-list-line"></div>
</div>
<input type="text" class="ti-form-input pointer-events-none" readonly
[ngClass]="{'input-list-f2': f&&!l, 'input-list-c2': !f&&!l, 'input-list-l2': !f&&l, 'input-list-fl2': f&&l,'bg-input-readonly':!modalStatusEdit}"
[(ngModel)]="item.tdesc">
<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 *ngIf="item.plId && modalStatus !== 'edit'" type="button" class="flex items-center text-red-500"
(click)="pl.selectIndex=i;selectPl();">
<i class="ti ti-circle-x cursor-pointer"></i>
</button>
</div>
</div>
</div>
<div class="col-span-1 ml-1" *ngIf="f && modalStatus !== 'edit'">
<ng-component *ngTemplateOutlet="plSearchButton"></ng-component>
</div>
</div>
<div class="grid grid-cols-2" *ngIf="!pmsMasfromEvaluation.select.personalLevel.length">
<div class="col-span-1">
<div class="flex relative">
<input type="text" class="ti-form-input input-list-fl1 pointer-events-none" readonly>
<div class="input-list-line-fl">
<div class="input-list-line"></div>
</div>
<input type="text" class="ti-form-input input-list-fl2 pointer-events-none" readonly>
</div>
</div>
<div class="col-span-1 ml-1" *ngIf="modalStatus !== 'edit'">
<ng-component *ngTemplateOutlet="plSearchButton"></ng-component>
</div>
</div>
<ng-template #plSearchButton>
<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 !m-0 h-full"
style="height: 44.8px !important;" (click)="openPLDialog();modal.search='';searchModalChange(plListFilter())">
<i class="ri-search-line cursor-pointer text-gray"></i>
</button>
</ng-template>
<span class="text-danger mt-1">**หมายเหตุ ถ้าไม่เลือกระดับ JL ระบบจะทำการเลือกทั้งหมด</span>
</mat-dialog-content>
<mat-dialog-actions align="end">
<button type="button" mat-button [mat-dialog-close]
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 *ngIf="modalStatus !== 'edit'" type="button" class="ti-btn ti-btn-success" mat-button
[class.ti-btn-disabled]="!pmsMasfromEvaluation.select.pmsEvaluationRoundId||!pmsMasfromEvaluation.select.tdesc||(modalStatus=='add'&&checkPrimary())"
(click)="addPmsMasfromEvaluation()"
[disabled]="!pmsMasfromEvaluation.select.pmsEvaluationRoundId||!pmsMasfromEvaluation.select.tdesc||(modalStatus=='add'&&checkPrimary())">
บันทึกข้อมูล
</button>
</mat-dialog-actions>
</ng-template>
<ng-template #managementEvaluationCycleModalForm let-modal>
<h3 mat-dialog-title>
เเก้ไขเเบบฟอร์มตามรอบการประเมิน
</h3>
<mat-dialog-content>
<app-edit-define-document-form *ngIf="pmsMasfromEvaluation.select.pmsEvaluationRoundId"
[evaluationRoundId]="pmsMasfromEvaluation.select.pmsEvaluationRoundId"></app-edit-define-document-form>
</mat-dialog-content>
<mat-dialog-actions align="end">
<button type="button" mat-button [mat-dialog-close]
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>
</mat-dialog-actions>
</ng-template>
<ng-template #PLModal let-modal>
<h3 mat-dialog-title>
ข้อมูลระดับพนักงาน (JL)
</h3>
<mat-dialog-content>
<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)]="PLsearchmodal.search" (ngModelChange)="onPLModalSearchChange()">
<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>
<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 ['ลำดับ','รหัสระดับพนักงาน (JL)','รายละเอียดฝ่าย (ไทย)','รายละเอียดฝ่าย (อังกฤษ)']; let f = first; let l = last">
<th scope="col" class="relative px-10px py-10px bg-soft-secondary text-primary" [class.!text-center]="f">
<span class="text-sm">{{ item }}</span>
<div class="absolute top-1/2 transform -translate-y-1/2 right-0" *ngIf="!l">
<i class="ti ti-dots-vertical fs-l"></i>
</div>
</th>
</ng-container>
</tr>
</thead>
<tbody *ngIf="!plListFilter().length">
<tr>
<td class="text-center" colspan="100%">
ไม่พบข้อมูล
</td>
</tr>
</tbody>
<tbody *ngIf="plListFilter().length">
<tr
*ngFor="let item of plListFilter() | slice:((PLsearchmodal.currentPage-1) * PLsearchmodal.pageSize) : (((PLsearchmodal.currentPage-1) * PLsearchmodal.pageSize) + PLsearchmodal.pageSize);let i = index"
class="cursor-pointer" (click)="selectPl(item);closePLDialog()">
<td class="flex justify-center">
{{((PLsearchmodal.currentPage-1) * PLsearchmodal.pageSize)+(i+1)}}
</td>
<td>{{item.plId}}</td>
<td>{{item.tdesc}}</td>
<td>{{item.edesc}}</td>
</tr>
</tbody>
</table>
</div>
<app-pagination [totalItems]="plListFilter().length" [pageSize]="PLsearchmodal.pageSize"
(pageChange)="PLsearchmodal.currentPage = $event"
(pageSizeChange)="PLsearchmodal.pageSize = $event;PLsearchmodal.currentPage = 1"></app-pagination>
</mat-dialog-content>
<mat-dialog-actions align="end">
<button type="button" mat-button [mat-dialog-close]
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>
</mat-dialog-actions>
</ng-template>
<!-- <div class="page px-rem"> <!-- <div class="page px-rem">
<div class="overflow-auto table-bordered rounded-top-0.65rem"> <div class="overflow-auto table-bordered rounded-top-0.65rem">
<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">
...@@ -223,110 +420,6 @@ ...@@ -223,110 +420,6 @@
</nav> </nav>
</div> --> </div> -->
<ng-template #managementEvaluationCycleModal let-modal>
<h3 mat-dialog-title>
{{modalStatus=='add'?'เพิ่มรอบการประเมิน':'เเก้ไขรอบการประเมิน'}}
</h3>
<div class="w-full flex justify-end mb-1rem">
<div class="absolute flex">
<div class="px-1">
<button type="button" class="ti-btn ti-btn-soft-indigo h-45px m-0 shadow-md" (click)="selectPl();selectPmsMasfromEvaluationCycle()">
<i class="ti ti-eraser text-base"></i>
Clear
</button>
</div>
</div>
</div>
<mat-dialog-content>
<label for="input-label" class="ti-form-label mt-2rem">รหัสรอบการประเมิน<span
class="text-danger">*<ng-container *ngIf="modalStatus=='add'&&checkPrimary()">
รหัสรอบการประเมินซ้ำ
</ng-container></span></label>
<input type="text" id="input-label" class="ti-form-input w-1/2"
[class.!bg-input-readonly]="modalStatus=='edit'" [readonly]="modalStatus=='edit'"
[(ngModel)]="pmsMasfromEvaluation.select.pmsEvaluationRoundId">
<label for="detail_th" class="ti-form-label mt-2rem">รายละเอียด (ไทย)<span
class="text-danger">*</span></label>
<input type="text" id="detail_th" class="ti-form-input h-16" [ngClass]="{'bg-input-readonly':!modalStatusEdit}" [(ngModel)]="pmsMasfromEvaluation.select.tdesc" [readonly]="!modalStatusEdit">
<label for="detail_eng" class="ti-form-label mt-2rem">รายละเอียด (อังกฤษ)</label>
<input type="text" id="detail_eng" class="ti-form-input h-16" [ngClass]="{'bg-input-readonly':!modalStatusEdit}" [(ngModel)]="pmsMasfromEvaluation.select.edesc" [readonly]="!modalStatusEdit">
<label for="input-label" class="ti-form-label mt-2rem">ปีการประเมิน<span class="text-danger">*</span></label>
<select class="ti-form-select" [(ngModel)]="pmsMasfromEvaluation.select.apsyear" [ngClass]="{'bg-input-readonly':!modalStatusEdit}" [disabled]="!modalStatusEdit">
<option *ngFor="let item of yearList" [ngValue]="item">{{ item }}</option>
</select>
<label for="input-label" class="ti-form-label mt-2rem">เริ่มวันที่<span class="text-danger">*</span></label>
<input type="date" id="input-label" class="ti-form-input w-1/2"
[(ngModel)]="pmsMasfromEvaluation.select.apsPeriodStart" [ngClass]="{'bg-input-readonly':!modalStatusEdit}" [readonly]="!modalStatusEdit">
<label for="input-label" class="ti-form-label mt-2rem">สิ้นสุดวันที่<span class="text-danger">*</span></label>
<input type="date" id="input-label" class="ti-form-input w-1/2" [(ngModel)]="pmsMasfromEvaluation.select.apsPeriodEnd" [ngClass]="{'bg-input-readonly':!modalStatusEdit}" [readonly]="!modalStatusEdit">
<label for="input-label" class="ti-form-label mt-2rem">ระดับพนักงาน (JL)</label>
<div *ngFor="let item of pmsMasfromEvaluation.select.personalLevel;let i = index;let f=first;let l = last"
class="grid grid-cols-2">
<div class="col-span-1">
<div class="flex relative">
<input type="text" class="ti-form-input pointer-events-none" readonly
[ngClass]="{'input-list-f1': f&&!l, 'input-list-c1': !f&&!l, 'input-list-l1': !f&&l, 'input-list-fl1': f&&l,'bg-input-readonly':!modalStatusEdit}"
[(ngModel)]="item.plId">
<div
[ngClass]="{'input-list-line-f': f&&!l, 'input-list-line-c': !f&&!l, 'input-list-line-l': !f&&l, 'input-list-line-fl': f&&l,'bg-input-readonly':!modalStatusEdit}">
<div class="input-list-line"></div>
</div>
<input type="text" class="ti-form-input pointer-events-none" readonly
[ngClass]="{'input-list-f2': f&&!l, 'input-list-c2': !f&&!l, 'input-list-l2': !f&&l, 'input-list-fl2': f&&l,'bg-input-readonly':!modalStatusEdit}"
[(ngModel)]="item.tdesc">
<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 *ngIf="item.plId&&modalStatusEdit" type="button" class="flex items-center text-red-500"
(click)="pl.selectIndex=i;selectPl();">
<i class="ti ti-circle-x cursor-pointer"></i>
</button>
</div>
</div>
</div>
<div class="col-span-1 ml-1" *ngIf="f&&modalStatusEdit">
<ng-component *ngTemplateOutlet="plSearchButton"></ng-component>
</div>
</div>
<div class="grid grid-cols-2" *ngIf="!pmsMasfromEvaluation.select.personalLevel.length">
<div class="col-span-1">
<div class="flex relative">
<input type="text" class="ti-form-input input-list-fl1 pointer-events-none" readonly>
<div class="input-list-line-fl">
<div class="input-list-line"></div>
</div>
<input type="text" class="ti-form-input input-list-fl2 pointer-events-none" readonly>
</div>
</div>
<div class="col-span-1 ml-1">
<ng-component *ngTemplateOutlet="plSearchButton"></ng-component>
</div>
</div>
<ng-template #plSearchButton>
<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 !m-0 h-full"
style="height: 44.8px !important;" (click)="modal.search='';searchModalChange(plListFilter())"
(click)="openPLDialog()">
<i class="ri-search-line cursor-pointer text-gray"></i>
</button>
</ng-template>
<span class="text-danger mt-1">**หมายเหตุ ถ้าไม่เลือกระดับ JL ระบบจะทำการเลือกทั้งหมด</span>
</mat-dialog-content>
<mat-dialog-actions align="end">
<button type="button" mat-button [mat-dialog-close]
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 type="button" class="ti-btn ti-btn-success" mat-button [class.ti-btn-disabled]="!pmsMasfromEvaluation.select.pmsEvaluationRoundId||!pmsMasfromEvaluation.select.tdesc||(modalStatus=='add'&&checkPrimary())" (click)="addPmsMasfromEvaluation()"
[disabled]="!pmsMasfromEvaluation.select.pmsEvaluationRoundId||!pmsMasfromEvaluation.select.tdesc||(modalStatus=='add'&&checkPrimary())">
บันทึกข้อมูล
</button>
</mat-dialog-actions>
</ng-template>
<!-- <div id="management-evaluation-cycle-page-modal" class="hs-overlay hidden ti-modal"> <!-- <div id="management-evaluation-cycle-page-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="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="max-h-full overflow-hidden ti-modal-content">
...@@ -369,26 +462,26 @@ ...@@ -369,26 +462,26 @@
รหัสรอบการประเมินซ้ำ รหัสรอบการประเมินซ้ำ
</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':modalStatus =='edit'}" [readonly]="modalStatus =='edit'"
[(ngModel)]="pmsMasfromEvaluation.pmsEvaluationRoundId"> [(ngModel)]="pmsMasfromEvaluation.pmsEvaluationRoundId">
<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-16" [ngClass]="{'bg-input-readonly':!modalStatusEdit}" [(ngModel)]="pmsMasfromEvaluation.tdesc" [readonly]="!modalStatusEdit"> <input type="text" id="detail_th" class="ti-form-input h-16" [ngClass]="{'!bg-input-readonly': modalStatus == 'edit'}" [(ngModel)]="pmsMasfromEvaluation.tdesc" [readonly]="modalStatus =='edit'">
<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-16" [ngClass]="{'bg-input-readonly':!modalStatusEdit}" [(ngModel)]="pmsMasfromEvaluation.edesc" [readonly]="!modalStatusEdit"> <input type="text" id="detail_eng" class="ti-form-input h-16" [ngClass]="{'!bg-input-readonly': modalStatus == 'edit'}" [(ngModel)]="pmsMasfromEvaluation.edesc" [readonly]="modalStatus =='edit'">
<label for="input-label" class="ti-form-label mt-2rem">ปีการประเมิน<span class="text-danger">*</span></label> <label for="input-label" class="ti-form-label mt-2rem">ปีการประเมิน<span class="text-danger">*</span></label>
<select class="ti-form-select" [(ngModel)]="pmsMasfromEvaluation.apsyear" [ngClass]="{'bg-input-readonly':!modalStatusEdit}" [disabled]="!modalStatusEdit"> <select class="ti-form-select" [(ngModel)]="pmsMasfromEvaluation.apsyear" [ngClass]="{'!bg-input-readonly': modalStatus == 'edit'}" [disabled]="!modalStatusEdit">
<option *ngFor="let item of yearList" [ngValue]="item">{{ item }}</option> <option *ngFor="let item of yearList" [ngValue]="item">{{ item }}</option>
</select> </select>
<label for="input-label" class="ti-form-label mt-2rem">เริ่มวันที่<span class="text-danger">*</span></label> <label for="input-label" class="ti-form-label mt-2rem">เริ่มวันที่<span class="text-danger">*</span></label>
<input type="date" id="input-label" class="ti-form-input w-1/2" <input type="date" id="input-label" class="ti-form-input w-1/2"
[(ngModel)]="pmsMasfromEvaluation.apsPeriodStart" [ngClass]="{'bg-input-readonly':!modalStatusEdit}" [readonly]="!modalStatusEdit"> [(ngModel)]="pmsMasfromEvaluation.apsPeriodStart" [ngClass]="{'!bg-input-readonly': modalStatus == 'edit'}" [readonly]="modalStatus =='edit'">
<label for="input-label" class="ti-form-label mt-2rem">สิ้นสุดวันที่<span class="text-danger">*</span></label> <label for="input-label" class="ti-form-label mt-2rem">สิ้นสุดวันที่<span class="text-danger">*</span></label>
<input type="date" id="input-label" class="ti-form-input w-1/2" [(ngModel)]="pmsMasfromEvaluation.apsPeriodEnd" [ngClass]="{'bg-input-readonly':!modalStatusEdit}" [readonly]="!modalStatusEdit"> <input type="date" id="input-label" class="ti-form-input w-1/2" [(ngModel)]="pmsMasfromEvaluation.apsPeriodEnd" [ngClass]="{'!bg-input-readonly': modalStatus == 'edit'}" [readonly]="modalStatus =='edit'">
<label for="input-label" class="ti-form-label mt-2rem">ระดับพนักงาน (JL)</label> <label for="input-label" class="ti-form-label mt-2rem">ระดับพนักงาน (JL)</label>
<div *ngFor="let item of pmsMasfromEvaluation.personalLevel;let i = index;let f=first;let l = last" <div *ngFor="let item of pmsMasfromEvaluation.personalLevel;let i = index;let f=first;let l = last"
...@@ -467,7 +560,7 @@ ...@@ -467,7 +560,7 @@
แจ้งเตือน แจ้งเตือน
</h3> </h3>
<div class="flex justify-end"> <div class="flex justify-end">
<ng-container *ngIf="modalStatus=='add'||modalStatus=='edit'"> <ng-container *ngIf="modalStatus=='add'||modalStatus =='edit'">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger" <button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#management-evaluation-cycle-page-modal"> data-hs-overlay="#management-evaluation-cycle-page-modal">
<span class="sr-only">Close</span> <span class="sr-only">Close</span>
...@@ -485,7 +578,7 @@ ...@@ -485,7 +578,7 @@
</div> </div>
<div class="ti-modal-body "> <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">
<ng-container *ngIf="modalStatus=='add'||modalStatus=='edit'"> <ng-container *ngIf="modalStatus=='add'||modalStatus =='edit'">
ยืนยันการบันทึกข้อมูลหรือไม่ ยืนยันการบันทึกข้อมูลหรือไม่
</ng-container> </ng-container>
<ng-container *ngIf="modalStatus=='delete'||modalStatus=='deleteGroup'"> <ng-container *ngIf="modalStatus=='delete'||modalStatus=='deleteGroup'">
...@@ -502,7 +595,7 @@ ...@@ -502,7 +595,7 @@
</p> </p>
<div class="flex justify-end mt-2rem mb-1rem"> <div class="flex justify-end mt-2rem mb-1rem">
<ng-container *ngIf="modalStatus=='add'||modalStatus=='edit'"> <ng-container *ngIf="modalStatus=='add'||modalStatus =='edit'">
<button type="button" <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" 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="#management-evaluation-cycle-page-modal"> data-hs-overlay="#management-evaluation-cycle-page-modal">
...@@ -541,97 +634,6 @@ ...@@ -541,97 +634,6 @@
</div> </div>
</div> --> </div> -->
<!-- <div id="evaluation-cycle-person-modal" class="hs-overlay hidden ti-modal">
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out m-3 lg:!mx-auto " style="min-width: 70%;">
<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" (click)="evaluationRoundId=''"
data-hs-overlay="#evaluation-cycle-person-modal">
<span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i>
</button>
</div>
</div>
<div class="ti-modal-body ">
<app-edit-evaluation-form *ngIf="evaluationRoundId"
[evaluationRoundId]="evaluationRoundId"></app-edit-evaluation-form>
</div>
</div>
</div>
</div> -->
<ng-template #PLModal let-modal>
<h3 mat-dialog-title>
ข้อมูลระดับพนักงาน (JL)
</h3>
<mat-dialog-content>
<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)]="PLsearchmodal.search" (ngModelChange)="onPLModalSearchChange()">
<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>
<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 ['ลำดับ','รหัสระดับพนักงาน (JL)','รายละเอียดฝ่าย (ไทย)','รายละเอียดฝ่าย (อังกฤษ)']; let f = first; let l = last">
<th scope="col" class="relative px-10px py-10px bg-soft-secondary text-primary"
[class.!text-center]="f">
<span class="text-sm">{{ item }}</span>
<div class="absolute top-1/2 transform -translate-y-1/2 right-0" *ngIf="!l">
<i class="ti ti-dots-vertical fs-l"></i>
</div>
</th>
</ng-container>
</tr>
</thead>
<tbody *ngIf="!plListFilter().length">
<tr>
<td class="text-center" colspan="100%">
ไม่พบข้อมูล
</td>
</tr>
</tbody>
<tbody *ngIf="plListFilter().length">
<tr *ngFor="let item of plListFilter() | slice:((PLsearchmodal.currentPage-1) * PLsearchmodal.pageSize) : (((PLsearchmodal.currentPage-1) * PLsearchmodal.pageSize) + PLsearchmodal.pageSize);let i = index"
class="cursor-pointer" (click)="selectPl(item);closePLDialog()" >
<td class="flex justify-center">
{{((PLsearchmodal.currentPage-1) * PLsearchmodal.pageSize)+(i+1)}}
</td>
<td>{{item.plId}}</td>
<td>{{item.tdesc}}</td>
<td>{{item.edesc}}</td>
</tr>
</tbody>
</table>
</div>
<app-pagination [totalItems]="plListFilter().length" [pageSize]="PLsearchmodal.pageSize"
(pageChange)="PLsearchmodal.currentPage = $event"
(pageSizeChange)="PLsearchmodal.pageSize = $event;PLsearchmodal.currentPage = 1"></app-pagination>
</mat-dialog-content>
<mat-dialog-actions align="end">
<button type="button" mat-button [mat-dialog-close]
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>
</mat-dialog-actions>
</ng-template>
<!-- <div id="management-evaluation-cycle-pl-table-modal" class="hs-overlay hidden ti-modal"> <!-- <div id="management-evaluation-cycle-pl-table-modal" class="hs-overlay hidden ti-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"> <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="max-h-full overflow-hidden ti-modal-content">
......
...@@ -9,385 +9,408 @@ import { MatDialog } from '@angular/material/dialog'; ...@@ -9,385 +9,408 @@ import { MatDialog } from '@angular/material/dialog';
import Swal from 'sweetalert2'; import Swal from 'sweetalert2';
export interface DataModal { export interface DataModal {
search: string, search: string,
currentPage: number, currentPage: number,
page: number[], page: number[],
pageSize: number pageSize: number
} }
@Component({ @Component({
selector: 'app-management-evaluation-cycle', selector: 'app-management-evaluation-cycle',
templateUrl: './management-evaluation-cycle.component.html', templateUrl: './management-evaluation-cycle.component.html',
styleUrls: ['./management-evaluation-cycle.component.scss'] styleUrls: ['./management-evaluation-cycle.component.scss']
}) })
export class ManagementCycleComponent { export class ManagementCycleComponent {
@Output() evaluationRoundIdChange = new EventEmitter<string>(); @Output() evaluationRoundIdChange = new EventEmitter<string>();
apsPeriodStart: string = ''; apsPeriodStart: string = '';
apsPeriodEnd: string = ''; apsPeriodEnd: string = '';
currentPage = 1 currentPage = 1
page = Array.from({ length: 1 }, (_, i) => i + 1); page = Array.from({ length: 1 }, (_, i) => i + 1);
search = "" search = ""
modalStatus: 'createForm' | 'add' | 'edit' | 'delete' | 'deleteGroup' = 'add' modalStatus: 'createForm' | 'add' | 'edit' | 'delete' | 'deleteGroup' = 'add'
pmsMasfromEvaluation: { pmsMasfromEvaluation: {
loading: boolean, loading: boolean,
select: PmsMasfromEvaluationModel, select: PmsMasfromEvaluationModel,
dataList: PmsMasfromEvaluationModel[] dataList: PmsMasfromEvaluationModel[]
} = { } = {
loading: false, loading: false,
select: new MyPmsMasfromEvaluationModel({}), select: new MyPmsMasfromEvaluationModel({}),
dataList: [] dataList: []
}
dataLoading = false
itemToDelete: PmsMasfromEvaluationModel | null = null;
isDataListChecked = false
isDataListCheckedAll = false
numDataListChecked = 0
evaluationRoundId = ''
private unlisten!: () => void;
modal: DataModal = {
search: "",
currentPage: 1,
page: Array.from({ length: 1 }, (_, i) => i + 1),
pageSize: 10
} }
PLsearchmodal: DataModal = { dataLoading = false
currentPage: 1, itemToDelete: PmsMasfromEvaluationModel | null = null;
page: Array.from({ length: 1 }, (_, i) => i + 1), isDataListChecked = false
search: "", isDataListCheckedAll = false
pageSize: 10 numDataListChecked = 0
} evaluationRoundId = ''
pl: { loading: boolean, selectIndex: number, dataList: PLModel[] } = { loading: false, selectIndex: -1, dataList: [] } private unlisten!: () => void;
currentDate = new Date() modal: DataModal = {
yearList = [ search: "",
(this.currentDate.getFullYear() - 1) + "", currentPage: 1,
(this.currentDate.getFullYear()) + "", page: Array.from({ length: 1 }, (_, i) => i + 1),
(this.currentDate.getFullYear() + 1) + "", pageSize: 10
] }
PLsearchmodal: DataModal = {
currentPage: 1,
page: Array.from({ length: 1 }, (_, i) => i + 1),
search: "",
pageSize: 10
}
pl: { loading: boolean, selectIndex: number, dataList: PLModel[] } = { loading: false, selectIndex: -1, dataList: [] }
columns: ColumnModel[] = [{ currentDate = new Date()
field: "pmsEvaluationRoundId", yearList = [
headerText: "รหัส", (this.currentDate.getFullYear() - 1) + "",
type: "string", (this.currentDate.getFullYear()) + "",
isPrimaryKey: true, (this.currentDate.getFullYear() + 1) + "",
}, ]
{
field: "tdesc",
headerText: "รายละเอียด",
type: "string"
},
{
field: "apsyear",
headerText: "รอบปีการประเมิน",
type: "string"
},
{
field: "apsPeriodStart",
headerText: "วันที่เริ่มต้น",
type: "string"
},
{
field: "apsPeriodEnd",
headerText: "วันที่สิ้นสุด",
type: "string"
},
{
field: "statusCode.tdesc",
headerText: "สถานะ",
type: "string"
},]
searchSettings = {
fields: ['pmsEvaluationRoundId', 'tdesc', 'apsyear', 'apsPeriodStart', 'apsPeriodEnd', 'statusCode.tdesc'],
operator: 'contains',
ignoreCase: false
};
selectedItems: { key: string, count: number, data: Map<string, boolean> } = { key: '', count: 0, data: new Map<string, boolean>() };
@ViewChild("managementEvaluationCycleModal") managementEvaluationCycleModal: any;
dialogRef: any
@ViewChild("PLModal") PLModal: any;
dialogRefPL: any
modalStatusEdit = false columns: ColumnModel[] = [{
constructor(private pmsMasfromEvaluationCycleService: PmsMasfromEvaluationCycleService, field: "pmsEvaluationRoundId",
private toastr: ToastrService, headerText: "รหัส",
private dialog: MatDialog, type: "string",
private cdr: ChangeDetectorRef, isPrimaryKey: true,
private renderer: Renderer2, },
private pLService: PLService {
) { } field: "tdesc",
headerText: "รายละเอียด",
type: "string"
},
{
field: "apsyear",
headerText: "รอบปีการประเมิน",
type: "string"
},
{
field: "apsPeriodStart",
headerText: "วันที่เริ่มต้น",
type: "string"
},
{
field: "apsPeriodEnd",
headerText: "วันที่สิ้นสุด",
type: "string"
},
{
field: "statusCode.tdesc",
headerText: "สถานะ",
type: "string"
},]
searchSettings = {
fields: ['pmsEvaluationRoundId', 'tdesc', 'apsyear', 'apsPeriodStart', 'apsPeriodEnd', 'statusCode.tdesc'],
operator: 'contains',
ignoreCase: false
};
selectedItems: { key: string, count: number, data: Map<string, boolean> } = { key: '', count: 0, data: new Map<string, boolean>() };
@ViewChild("managementEvaluationCycleModal") managementEvaluationCycleModal: any;
dialogRef: any
@ViewChild("PLModal") PLModal: any;
dialogRefPL: any
@ViewChild("managementEvaluationCycleModalForm") managementEvaluationCycleModalForm: any;
dialogRefForm: any
ngOnInit(): void { modalStatusEdit = false
this.getPmsMasfromEvaluationCycleList() constructor(private pmsMasfromEvaluationCycleService: PmsMasfromEvaluationCycleService,
this.unlisten = this.renderer.listen('document', 'keydown', (event) => { private toastr: ToastrService,
if (event.key === 'Escape') { private dialog: MatDialog,
this.evaluationRoundId = '' private cdr: ChangeDetectorRef,
} private renderer: Renderer2,
}); private pLService: PLService
this.getPlList() ) { }
}
ngOnDestroy() { ngOnInit(): void {
if (this.unlisten) { this.getPmsMasfromEvaluationCycleList()
this.unlisten(); // เรียกใช้งานจริง ๆ เพื่อลบ event listener this.unlisten = this.renderer.listen('document', 'keydown', (event) => {
} if (event.key === 'Escape') {
this.evaluationRoundId = ''
}
});
this.getPlList()
}
ngOnDestroy() {
if (this.unlisten) {
this.unlisten(); // เรียกใช้งานจริง ๆ เพื่อลบ event listener
} }
}
getPlList() { getPlList() {
this.pl.loading = false
this.pLService.getList().subscribe({
next: response => {
this.pl.dataList = response.map((x: any) => new MyPLModel(x))
this.pl.loading = false this.pl.loading = false
this.pLService.getList().subscribe({ // this.searchChange()
next: response => { this.cdr.detectChanges()
this.pl.dataList = response.map((x: any) => new MyPLModel(x)) }, error: error => {
this.pl.loading = false this.pl.loading = false
// this.searchChange() this.cdr.detectChanges()
this.cdr.detectChanges() }
}, error: error => { })
this.pl.loading = false }
this.cdr.detectChanges() plListFilter() {
} return this.pl.dataList.filter(x =>
}) (x.plId.toLowerCase().includes(this.PLsearchmodal.search.toLowerCase()) ||
} x.tdesc.toLowerCase().includes(this.PLsearchmodal.search.toLowerCase()) ||
plListFilter() { x.edesc.toLowerCase().includes(this.PLsearchmodal.search.toLowerCase())) &&
return this.pl.dataList.filter(x => !this.pmsMasfromEvaluation.select.personalLevel.some(y => y.plId == x.plId)
(x.plId.toLowerCase().includes(this.PLsearchmodal.search.toLowerCase()) || );
x.tdesc.toLowerCase().includes(this.PLsearchmodal.search.toLowerCase()) ||
x.edesc.toLowerCase().includes(this.PLsearchmodal.search.toLowerCase())) &&
!this.pmsMasfromEvaluation.select.personalLevel.some(y => y.plId == x.plId)
);
}
onPLModalSearchChange() {
this.PLsearchmodal.currentPage = 1
this.PLsearchmodal.page = Array.from({ length: Math.ceil(this.plListFilter().length / 10) }, (_, i) => i + 1);
}
selectPl(data?: PLModel) {
if (!data) {
this.pmsMasfromEvaluation.select.personalLevel.splice(this.pl.selectIndex, 1);
return;
} }
onPLModalSearchChange() { this.pmsMasfromEvaluation.select.personalLevel.push(new MyPLModel(data))
this.PLsearchmodal.currentPage = 1 }
this.PLsearchmodal.page = Array.from({ length: Math.ceil(this.plListFilter().length / 10) }, (_, i) => i + 1);
getPmsMasfromEvaluationCycleList() {
this.dataLoading = true
this.selectedItems.data.clear()
this.pmsMasfromEvaluationCycleService.getList().subscribe({
next: response => {
this.pmsMasfromEvaluation.dataList = response.map(x => {
this.selectedItems.data.set(x.pmsEvaluationRoundId, false)
return new MyPmsMasfromEvaluationModel(x)
})
this.selectedItems.key = 'pmsEvaluationRoundId'
this.selectedItems.count = 0
this.dataLoading = false
this.isDataListCheckedAll = false
this.cdr.detectChanges();
},
error: err => {
this.dataLoading = false
this.cdr.detectChanges();
} }
selectPl(data?: PLModel) { });
if (!data) { }
this.pmsMasfromEvaluation.select.personalLevel.splice(this.pl.selectIndex, 1); selectPmsMasfromEvaluationCycle(pmsMasfromEvaluation?: PmsMasfromEvaluationModel) {
return; if (pmsMasfromEvaluation) {
} this.pmsMasfromEvaluation.select = new MyPmsMasfromEvaluationModel(pmsMasfromEvaluation)
this.pmsMasfromEvaluation.select.personalLevel.push(new MyPLModel(data)) } else if (this.modalStatus == 'add') {
this.pmsMasfromEvaluation.select = new MyPmsMasfromEvaluationModel()
} else if (this.modalStatus == 'edit') {
this.pmsMasfromEvaluation.select = new MyPmsMasfromEvaluationModel({ pmsEvaluationRoundId: this.pmsMasfromEvaluation.select.pmsEvaluationRoundId })
} }
}
setData(data?: PmsMasfromEvaluationModel) {
this.pmsMasfromEvaluation.select = new MyPmsMasfromEvaluationModel(data)
}
getPmsMasfromEvaluationCycleList() { addPmsMasfromEvaluation() {
this.dataLoading = true Swal.fire({
this.selectedItems.data.clear() icon: 'question',
this.pmsMasfromEvaluationCycleService.getList().subscribe({ title: 'แจ้งเตือน',
next: response => { text: 'ยืนยันการบันทึกข้อมูลหรือไม่',
this.pmsMasfromEvaluation.dataList = response.map(x => { showCancelButton: true,
this.selectedItems.data.set(x.pmsEvaluationRoundId, false) confirmButtonText: 'บันทึกข้อมูล',
return new MyPmsMasfromEvaluationModel(x) cancelButtonText: 'ย้อนกลับ',
}) reverseButtons: true,
this.selectedItems.key = 'pmsEvaluationRoundId' }).then((result) => {
this.selectedItems.count = 0 if (result.isConfirmed) {
this.dataLoading = false if (this.pmsMasfromEvaluation.select.personalLevel.length === 0) {
this.isDataListCheckedAll = false this.plListFilter().forEach(x => this.selectPl(x));
this.cdr.detectChanges();
},
error: err => {
this.dataLoading = false
this.cdr.detectChanges();
}
});
}
selectPmsMasfromEvaluationCycle(pmsMasfromEvaluation?: PmsMasfromEvaluationModel) {
if (pmsMasfromEvaluation) {
this.pmsMasfromEvaluation.select = new MyPmsMasfromEvaluationModel(pmsMasfromEvaluation)
} else if (this.modalStatus == 'add') {
this.pmsMasfromEvaluation.select = new MyPmsMasfromEvaluationModel()
} else if (this.modalStatus == 'edit') {
this.pmsMasfromEvaluation.select = new MyPmsMasfromEvaluationModel({ pmsEvaluationRoundId: this.pmsMasfromEvaluation.select.pmsEvaluationRoundId })
}
} }
const body = new MyPmsMasfromEvaluationModel(this.pmsMasfromEvaluation.select);
setData(data?: PmsMasfromEvaluationModel) { this.dataLoading = true;
this.pmsMasfromEvaluation.select = new MyPmsMasfromEvaluationModel(data) this.pmsMasfromEvaluationCycleService.post(body).subscribe({
} next: response => {
addPmsMasfromEvaluation() { if (response.success) {
Swal.fire({ this.showAlert(response.message, 'success');
icon: 'question', this.getPmsMasfromEvaluationCycleList();
title: 'แจ้งเตือน', this.closeDialog();
text: 'ยืนยันการบันทึกข้อมูลหรือไม่', } else {
showCancelButton: true, this.showAlert(response.message, 'error');
confirmButtonText: 'บันทึกข้อมูล', this.dataLoading = false;
cancelButtonText: 'ย้อนกลับ', this.cdr.detectChanges();
reverseButtons: true,
}).then((result) => {
if (result.isConfirmed) {
if (this.pmsMasfromEvaluation.select.personalLevel.length === 0) {
this.plListFilter().forEach(x => this.selectPl(x));
} }
const body = new MyPmsMasfromEvaluationModel(this.pmsMasfromEvaluation.select); },
this.dataLoading = true; error: error => {
this.pmsMasfromEvaluationCycleService.post(body).subscribe({ this.showAlert(error.message, 'error');
next: response => { this.dataLoading = false;
if (response.success) { this.cdr.detectChanges();
this.showAlert(response.message, 'success');
this.getPmsMasfromEvaluationCycleList();
this.closeDialog();
} 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();
}
});
} }
}); });
} }
deletePmsMasfromEvaluation() { });
if (!this.numSelectItem()) { }
this.showAlert('กรุณาเลือกข้อมูลที่ต้องการลบ', 'error'); deletePmsMasfromEvaluation() {
return; if (!this.numSelectItem()) {
} this.showAlert('กรุณาเลือกข้อมูลที่ต้องการลบ', 'error');
return;
Swal.fire({ }
icon: 'question',
title: 'แจ้งเตือน', Swal.fire({
text: 'ยืนยันการลบข้อมูลหรือไม่', icon: 'question',
showCancelButton: true, title: 'แจ้งเตือน',
confirmButtonText: 'ลบข้อมูล', text: 'ยืนยันการลบข้อมูลหรือไม่',
cancelButtonText: 'ย้อนกลับ', showCancelButton: true,
reverseButtons: true, confirmButtonText: 'ลบข้อมูล',
}).then((result) => { cancelButtonText: 'ย้อนกลับ',
if (result.isConfirmed) { reverseButtons: true,
this.dataLoading = true; }).then((result) => {
let body: PmsMasfromEvaluationModel[] = []; if (result.isConfirmed) {
if (this.pmsMasfromEvaluation.select.pmsEvaluationRoundId) { this.dataLoading = true;
body = [new MyPmsMasfromEvaluationModel(this.pmsMasfromEvaluation.select)]; const selectedKeys = Array.from(this.selectedItems.data.keys());
const body = this.pmsMasfromEvaluation.dataList.filter(x => selectedKeys.includes(x.pmsEvaluationRoundId) && this.selectedItems.data.get(x.pmsEvaluationRoundId)).map(x => new MyPmsMasfromEvaluationModel(x))
console.log(body);
this.pmsMasfromEvaluationCycleService.delete(body).subscribe({
next: response => {
if (response.success) {
this.showAlert(response.message, 'success');
this.getPmsMasfromEvaluationCycleList();
this.closeDialog();
} else { } else {
const selectedKeys = Array.from(this.selectedItems.data.keys()); this.showAlert(response.message, 'error');
body = this.pmsMasfromEvaluation.dataList this.dataLoading = false;
.filter(x => selectedKeys.includes(x.pmsEvaluationRoundId) && this.selectedItems.data.get(x.pmsEvaluationRoundId)) this.cdr.detectChanges();
.map(x => new MyPmsMasfromEvaluationModel(x));
} }
this.pmsMasfromEvaluationCycleService.delete(body).subscribe({ },
next: response => { error: error => {
if (response.success) { this.showAlert(error.message, 'error');
this.showAlert(response.message, 'success'); this.dataLoading = false;
this.getPmsMasfromEvaluationCycleList(); this.cdr.detectChanges();
this.closeDialog();
} 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();
}
});
} }
}); });
} }
});
}
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: 'ตกลง',
clear() { });
if (this.modalStatus == 'add') { }
this.setData()
} else if (this.modalStatus == 'edit') {
this.setData(new MyPmsMasfromEvaluationModel({ pmsEvaluationRoundId: this.pmsMasfromEvaluation.select.pmsEvaluationRoundId }))
}
}
openModal(id: string, evaluationRoundId: string) { clear() {
this.evaluationRoundId = '' if (this.modalStatus == 'add') {
if (id == 'evaluation-cycle-person-modal') { this.setData()
this.evaluationRoundId = evaluationRoundId } else if (this.modalStatus == 'edit') {
this.evaluationRoundIdChange.emit(evaluationRoundId) this.setData(new MyPmsMasfromEvaluationModel({ pmsEvaluationRoundId: this.pmsMasfromEvaluation.select.pmsEvaluationRoundId }))
setTimeout(() => {
document.getElementById(id)?.classList.add('open');
document.getElementById(id)?.classList.remove('hidden');
document.getElementById(id)?.setAttribute('aria-overlay', 'false');
}, 10);
}
} }
}
searchModalChange(dataList: any[]) { openModal(id: string, evaluationRoundId: string) {
this.modal.currentPage = 1 this.evaluationRoundId = ''
this.modal.page = Array.from({ length: Math.ceil(dataList.length / 10) }, (_, i) => i + 1); if (id == 'evaluation-cycle-person-modal') {
this.evaluationRoundId = evaluationRoundId
this.evaluationRoundIdChange.emit(evaluationRoundId)
setTimeout(() => {
document.getElementById(id)?.classList.add('open');
document.getElementById(id)?.classList.remove('hidden');
document.getElementById(id)?.setAttribute('aria-overlay', 'false');
}, 10);
} }
createForm() { }
searchModalChange(dataList: any[]) {
this.modal.currentPage = 1
this.modal.page = Array.from({ length: Math.ceil(dataList.length / 10) }, (_, i) => i + 1);
}
createForm(data: any) {
Swal.fire({
title: 'สร้างแบบฟอร์ม?',
text: 'คุณต้องการสร้างแบบฟอร์มการประเมินใหม่หรือไม่',
icon: 'question',
showCancelButton: true,
confirmButtonText: 'ยืนยัน',
cancelButtonText: 'ยกเลิก',
reverseButtons: true,
}).then((result) => {
if (result.isConfirmed) {
this.modalStatus = 'createForm';
this.setData(data); // เซ็ตข้อมูลก่อน
const body = new MyPmsMasfromEvaluationModel(this.pmsMasfromEvaluation.select) const body = new MyPmsMasfromEvaluationModel(this.pmsMasfromEvaluation.select)
body.active = 1 body.active = 1
this.dataLoading = true this.dataLoading = true
this.pmsMasfromEvaluationCycleService.post(body).subscribe({ this.pmsMasfromEvaluationCycleService.post(body).subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
this.showAlert(response.message, 'success') this.showAlert(response.message, 'success')
} else { } else {
this.dataLoading = false this.dataLoading = false
this.showAlert(response.message, 'error') this.showAlert(response.message, 'error')
this.cdr.detectChanges() this.cdr.detectChanges()
}
}, error: error => {
this.showAlert(error.message, 'error')
this.dataLoading = false
this.cdr.detectChanges()
} }
}, error: error => {
this.showAlert(error.message, 'error')
this.dataLoading = false
this.cdr.detectChanges()
}
}) })
this.pmsMasfromEvaluationCycleService.postCreateForm(body).subscribe({ this.pmsMasfromEvaluationCycleService.postCreateForm(body).subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
this.showAlert(response.message, 'success') this.showAlert(response.message, 'success')
this.getPmsMasfromEvaluationCycleList() this.getPmsMasfromEvaluationCycleList()
} else { } else {
this.dataLoading = false this.dataLoading = false
this.showAlert(response.message, 'error') this.showAlert(response.message, 'error')
this.cdr.detectChanges() this.cdr.detectChanges()
}
}, error: error => {
this.showAlert(error.message, 'error')
this.dataLoading = false
this.cdr.detectChanges()
} }
}) }, error: error => {
} this.showAlert(error.message, 'error')
this.dataLoading = false
checkPrimary() { this.cdr.detectChanges()
return this.pmsMasfromEvaluation.dataList.find(x => x.pmsEvaluationRoundId == this.pmsMasfromEvaluation.select.pmsEvaluationRoundId) }
}
openDialog() {
this.dialogRef = this.dialog.open(this.managementEvaluationCycleModal, {
width: '500px',
disableClose: false,
}); });
} }
openPLDialog() { });
this.dialogRefPL = this.dialog.open(this.PLModal, { }
width: '800px',
}) checkPrimary() {
} return this.pmsMasfromEvaluation.dataList.find(x => x.pmsEvaluationRoundId == this.pmsMasfromEvaluation.select.pmsEvaluationRoundId)
closeDialog() { }
this.dialogRef.close()
} openDialog() {
closePLDialog() { this.dialogRef = this.dialog.open(this.managementEvaluationCycleModal, {
this.dialogRefPL.close() width: '500px',
} disableClose: false,
});
onSelectItemChange(arg: any) { }
this.selectedItems = arg openPLDialog() {
console.log(this.selectedItems) this.dialogRefPL = this.dialog.open(this.PLModal, {
} width: '800px',
})
numSelectItem() { }
const selectedKeys = Array.from(this.selectedItems.data.keys()); openDialogForm() {
const num = this.pmsMasfromEvaluation.dataList.filter(x => selectedKeys.includes(x.pmsEvaluationRoundId) && this.selectedItems.data.get(x.pmsEvaluationRoundId)).length this.dialogRefForm = this.dialog.open(this.managementEvaluationCycleModalForm, {
return num width: '1200px',
} disableClose: false,
});
}
closeDialog() {
this.dialogRef.close()
}
closePLDialog() {
this.dialogRefPL.close()
}
closeDialogForm() {
this.dialogRefForm.close()
}
onSelectItemChange(arg: any) {
this.selectedItems = arg
console.log(this.selectedItems)
}
numSelectItem() {
const selectedKeys = Array.from(this.selectedItems.data.keys());
const num = this.pmsMasfromEvaluation.dataList.filter(x => selectedKeys.includes(x.pmsEvaluationRoundId) && this.selectedItems.data.get(x.pmsEvaluationRoundId)).length
return num
}
} }
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