Commit e51f5a3a by Nattana Chaiyamat

การจัดการข้อมูลสถิติเวลาทำงาน

parent ad80cbdc
...@@ -162,6 +162,8 @@ import { EmpStatusService } from 'src/app/shared/services/emp-status.service'; ...@@ -162,6 +162,8 @@ import { EmpStatusService } from 'src/app/shared/services/emp-status.service';
import { PaginationComponent } from '../pagination/pagination.component'; import { PaginationComponent } from '../pagination/pagination.component';
import { RolePermissionConfigComponent } from '../company-components/account-settings/role-permission-config/role-permission-config.component'; import { RolePermissionConfigComponent } from '../company-components/account-settings/role-permission-config/role-permission-config.component';
import { ConfigPermissionService } from 'src/app/shared/services/config-permission.service'; import { ConfigPermissionService } from 'src/app/shared/services/config-permission.service';
import { TimeAttendanceManageComponent } from '../performance-management-evaluation/time-attendance/time-attendance-manage/time-attendance-manage.component';
import { TimeAttendanceStatisticsComponent } from '../performance-management-evaluation/time-attendance/time-attendance-statistics/time-attendance-statistics.component';
export const MY_DATE_FORMATS = { export const MY_DATE_FORMATS = {
...@@ -290,6 +292,8 @@ export class CustomDateAdapter extends NativeDateAdapter { ...@@ -290,6 +292,8 @@ export class CustomDateAdapter extends NativeDateAdapter {
TimeAttendanceComponent, TimeAttendanceComponent,
PaginationComponent, PaginationComponent,
RolePermissionConfigComponent, RolePermissionConfigComponent,
TimeAttendanceManageComponent,
TimeAttendanceStatisticsComponent,
], ],
imports: [ imports: [
CommonModule, CommonModule,
......
<div class="w-full min-height-50px mb-10px justify-between items-center">
<div class="flex justify-between">
<div class="flex">
<div class="flex items-center">
<input type="checkbox" class="ti-form-checkbox pointer-events-none" id="hs-default-checkbox"
[(ngModel)]="isDataListChecked">
<label for="hs-default-checkbox" class="text-sm text-gray-500 mx-2 pointer-events-none">
{{numDataListChecked}} Selected</label>
</div>
<div class="mx-1 flex items-center">
<button (click)="isDataListCheckedAll = !isDataListCheckedAll;dataListCheckAll()" id="checkbox"
class="focus:ring-2 focus:ring-primary rounded-sm flex item-center">
<i class="fs-l transition-all duration-200"
[ngClass]="{'ri-checkbox-multiple-line text-gray-500': !isDataListCheckedAll, 'ri-checkbox-multiple-fill text-primary': isDataListCheckedAll}"></i>
</button>
<label class="text-sm text-gray-500 ml-2" for="checkbox">Select All</label>
</div>
</div>
<div class="flex justify-end">
<div class="px-1">
<div class="relative shadow-md">
<input type="text" class="ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 "
placeholder="Search by No. or Name" style="height: 40px;" [(ngModel)]="search"
(ngModelChange)="searchChange()">
<div
class="absolute inset-y-0 ltr:left-0 rtl:right-0 flex items-center pointer-events-none z-20 ltr:pl-4 rtl:pr-4">
<i class="ri-search-line text-gray"></i>
</div>
</div>
</div>
<div class="px-1">
<button type="button" class="ti-btn ti-btn-soft-secondary h-10 m-0 shadow-md"
(click)="modalStatus='add';selectData()" data-hs-overlay="#time-attendance-modal">
<i class="ri-add-line"></i>
Add
</button>
</div>
<div class="px-1">
<button href="javascript:void(0);" class="ti-btn ti-btn-soft-danger h-10 m-0 shadow-md"
(click)="modalStatus='deleteGroup';selectData()" data-hs-overlay="#time-attendance-alert-modal">
<i class="ri-delete-bin-6-line"></i>
Delete
</button>
</div>
<!-- <div class="px-1">
<button href="javascript:void(0);" class="ti-btn ti-btn-soft-warning h-10 m-0 shadow-md">
<i class="ti ti-book fs-l"></i>
Help
</button>
</div> -->
</div>
</div>
</div>
<div class="page px-rem">
<div class="overflow-auto table-bordered rounded-top-0.65rem">
<table class="ti-custom-table ti-custom-table-head ti-custom-table-hover">
<thead class="height-50px">
<tr class="font-size-12px">
<ng-container
*ngFor="let item of ['','รหัส','ชื่อหัวข้อ','หน่วยนับ','น้ำหนัก','การจัดการ']; let f = first; let l = last">
<th scope="col" class="relative px-10px py-10px bg-soft-secondary text-primary"
[class.!text-center]="f||l">
<span class="font-size-12px font-weight-700">{{ item }}</span>
<div class="absolute top-1/2 transform -translate-y-1/2 right-0" *ngIf="!f && !l">
<i class="ti ti-dots-vertical fs-l"></i>
</div>
</th>
</ng-container>
</tr>
</thead>
<tbody *ngIf="pmsWorkingTime.loading">
<tr>
<td class="text-center" colspan="100%">
<div *ngFor="let item of [1,2,3]" class="ti-spinner w-8 h-8 text-secondary mx-1" role="status"
aria-label="loading">
<span class="sr-only">Loading...</span>
</div>
</td>
</tr>
</tbody>
<tbody *ngIf="!pmsWorkingTime.loading&&!pmsWorkingTimeFilter().length">
<tr>
<td class="text-center" colspan="100%">
ไม่พบข้อมูล
</td>
</tr>
</tbody>
<tbody *ngIf="!pmsWorkingTime.loading&&pmsWorkingTimeFilter().length">
<tr
*ngFor="let item of pmsWorkingTimeFilter() | slice:((currentPage-1) * 10) : (((currentPage-1) * 10) + 10);let i = index">
<td class="text-center">
<input type="checkbox" class="ti-form-checkbox cursor-pointer" [(ngModel)]="item.check"
(ngModelChange)="dataListCheck()" id="checkbox-{{item.data.pmsWorkingTimeId}}">
</td>
<td>
<label for="checkbox-{{item.data.pmsWorkingTimeId}}">{{item.data.pmsWorkingTimeId}}</label>
</td>
<td>{{item.data.tdesc}}</td>
<td>{{item.data.detailUnit}}</td>
<td>{{item.data.weight}}</td>
<td class="flex justify-center">
<i class="ti ti-edit cursor-pointer i-gray fs-l px-1" data-hs-overlay="#time-attendance-modal"
(click)="modalStatus='edit';selectData(item.data)"></i>
<!-- <i class="ti ti-trash cursor-pointer i-gray fs-l px-1"
data-hs-overlay="#time-attendance-alert-modal"
(click)="modalStatus='delete';selectData(item.data)"></i> -->
</td>
</tr>
</tbody>
</table>
</div>
<nav class="pagination-style-3 overflow-auto my-5" *ngIf="page.length">
<ul class="ti-pagination">
<li>
<a aria-label="anchor" class="page-link" href="javascript:void(0);"
(click)="currentPage = (currentPage-1 || 1)">
<i class="ri-arrow-left-s-line align-middle rtl:rotate-180"></i>
</a>
</li>
<li *ngFor="let item of page;let f = first;let l = last">
<ng-container *ngIf="item==3&&currentPage!=1&&currentPage!=2&&currentPage!=3">
<a aria-label="anchor" class="page-link" href="javascript:void(0);"><i class="ri-more-line"></i>
</a>
</ng-container>
<ng-container *ngIf="(f||l)||(item==currentPage-1||item==currentPage||item==currentPage+1)">
<a class="page-link" href="javascript:void(0);" [class.active]="item==currentPage"
(click)="currentPage=item">{{item}}
</a>
</ng-container>
<ng-container
*ngIf="item==page.length-2&&currentPage!=page.length&&currentPage!=page.length-1&&currentPage!=page.length-2">
<a aria-label="anchor" class="page-link" href="javascript:void(0);"><i class="ri-more-line"></i>
</a>
</ng-container>
</li>
<li>
<a aria-label="anchor" class="page-link" href="javascript:void(0);"
(click)="currentPage = (currentPage > page.length-1 ? currentPage: currentPage+1 )">
<i class="ri-arrow-right-s-line align-middle rtl:rotate-180"></i>
</a>
</li>
</ul>
<ul class="nav-tabs mt-3">
<span>Show {{((currentPage-1) * 10)+1}} to {{pmsWorkingTimeFilter().length<10
?pmsWorkingTimeFilter().length: (currentPage==page.length ? ((currentPage * 10) - ((currentPage *
10) - pmsWorkingTimeFilter().length) ) :(currentPage * 10) ) }} of {{pmsWorkingTimeFilter().length}}
items</span>
</ul>
</nav>
</div>
<div id="time-attendance-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)] !max-w-1/2">
<div class="max-h-full overflow-hidden ti-modal-content">
<div class="ti-modal-header">
<h3 class="text-xxl font-bold text-primary">
{{modalStatus=='add'?'เพิ่มข้อมูลประเภทวัน':'แก้ไขข้อมูลประเภทวัน'}}
</h3>
<div class="flex justify-end">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#time-attendance-modal">
<span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i>
</button>
</div>
</div>
<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)="clearData(modalStatus)">
<svg class="svg-indigo" width="16" height="16" viewBox="0 0 64.00 64.00"
xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#595BEA" stroke-width="3.84"
transform="rotate(45)matrix(-1, 0, 0, 1, 0, 0)">
<g id="SVGRepo_bgCarrier" stroke-width="0"></g>
<g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g>
<g id="SVGRepo_iconCarrier">
<path d="M15 49A24 24 0 0 1 32 8"></path>
<path d="M49 15a24 24 0 0 1-17 41"></path>
<polyline points="15.03 40 15.03 48.97 8 48.97"></polyline>
<polyline points="48.97 24 48.97 15.03 56 15.03"></polyline>
</g>
</svg>
Clear
</button>
</div>
<!-- <div class="px-1">
<button href="javascript:void(0);" class="ti-btn ti-btn-soft-warning h-45px m-0 shadow-md">
<i class="ti ti-book fs-l"></i>
Help
</button>
</div> -->
</div>
</div>
<div class="ti-modal-body padding-16px pt-0 overflow-y-0">
<label class="ti-form-label mt-2rem">รหัส<span class="text-danger">*</span></label>
<input type="text" class="ti-form-input w-1/2" [ngClass]="{'bg-input-readonly':modalStatus=='edit'}"
[readonly]="modalStatus=='edit'" [(ngModel)]="pmsWorkingTime.select.pmsWorkingTimeId">
<label class="ti-form-label mt-2rem">รหัสประเภทวัน <span class="text-danger">*</span></label>
<div *ngFor="let item of pmsWorkingTime.select.emeventgrp;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}"
[(ngModel)]="item.eventgrpId">
<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}"
[(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.eventgrpId" type="button" class="flex items-center text-red-500"
(click)="eventgrp.selectIndex=i;selectEventgrp()">
<i class="ti ti-circle-x cursor-pointer"></i>
</button>
</div>
</div>
</div>
<div class="col-span-1 ml-1" *ngIf="f">
<ng-component *ngTemplateOutlet="emeventgrpSearchButton"></ng-component>
</div>
</div>
<div class="grid grid-cols-2" *ngIf="!pmsWorkingTime.select.emeventgrp.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="emeventgrpSearchButton"></ng-component>
</div>
</div>
<ng-template #emeventgrpSearchButton>
<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='';modalSearchChange(eventgrpListFilter())"
data-hs-overlay="#time-attendance-eventgrp-table-modal">
<i class="ri-search-line cursor-pointer text-gray"></i>
</button>
</ng-template>
<label class="ti-form-label mt-2rem">ชื่อหัวข้อ (ไทย)<span class="text-danger">*</span></label>
<input type="text" class="ti-form-input" [(ngModel)]="pmsWorkingTime.select.tdesc">
<label class="ti-form-label mt-2rem">ชื่อหัวข้อ (อังกฤษ)</label>
<input type="text" class="ti-form-input" [(ngModel)]="pmsWorkingTime.select.edesc">
<label class="ti-form-label mt-2rem">เป้าหมายผลงาน</label>
<input type="text" class="ti-form-input" [(ngModel)]="pmsWorkingTime.select.performanceTargets">
<label class="ti-form-label mt-2rem">หน่วยนับ</label>
<!-- <input type="text" class="ti-form-input" [(ngModel)]="pmsWorkingTime.select.detailUnit"> -->
<select class="ti-form-select" [(ngModel)]="pmsWorkingTime.select.detailUnit">
<option *ngFor="let item of ['นาที','ชั่วโมง','วัน','ครั้ง']" [value]="item">{{item}}</option>
</select>
<label class="ti-form-label mt-2rem">น้ำหนัก</label>
<input type="text" class="ti-form-input"
oninput="this.value = this.value.replace(/[^\d.]/g, '').replace(/(\..*?)\..*/g, '$1').replace(/(\..*?)(\d{2})./g, '$1$2');"
onchange="this.value = this.value.replace('', '0');this.value = parseFloat(this.value).toFixed(2)"
[(ngModel)]="pmsWorkingTime.select.weight">
<label class="ti-form-label mt-2rem">ค่าเป้าหมาย</label>
<div class="grid grid-cols-1 gap-y-2">
<div class="col-span-1 grid grid-cols-12 gap-x-2">
<label class="ti-form-label col-span-2 align-center m-0">A (5 คะแนน) ชื่อ</label>
<input type="text" class="ti-form-input col-span-10"
[(ngModel)]="pmsWorkingTime.select.targetADetail">
</div>
<div class="col-span-1 grid grid-cols-12 gap-x-2">
<label class="ti-form-label col-span-2 align-center m-0">เงื่อนไข ช่วงระหว่าง</label>
<input type="text" class="ti-form-input col-span-2"
oninput="this.value = this.value.replace(/[^\d.]/g, '').replace(/(\..*?)\..*/g, '$1').replace(/(\..*?)(\d{2})./g, '$1$2');"
onchange="this.value = this.value.replace('', '0');this.value = parseFloat(this.value).toFixed(2)"
[(ngModel)]="pmsWorkingTime.select.conditionAMin">
<label class="ti-form-label col-span-1 align-center text-center m-0">ถึง</label>
<input type="text" class="ti-form-input col-span-2"
oninput="this.value = this.value.replace(/[^\d.]/g, '').replace(/(\..*?)\..*/g, '$1').replace(/(\..*?)(\d{2})./g, '$1$2');"
onchange="this.value = this.value.replace('', '0');this.value = parseFloat(this.value).toFixed(2)"
[(ngModel)]="pmsWorkingTime.select.conditionAMax">
</div>
</div>
<div class="grid grid-cols-1 gap-y-2 mt-2rem">
<div class="col-span-1 grid grid-cols-12 gap-x-2">
<label class="ti-form-label col-span-2 align-center m-0">B (4 คะแนน) ชื่อ</label>
<input type="text" class="ti-form-input col-span-10"
[(ngModel)]="pmsWorkingTime.select.targetBDetail">
</div>
<div class="col-span-1 grid grid-cols-12 gap-x-2">
<label class="ti-form-label col-span-2 align-center m-0">เงื่อนไข ช่วงระหว่าง</label>
<input type="text" class="ti-form-input col-span-2"
oninput="this.value = this.value.replace(/[^\d.]/g, '').replace(/(\..*?)\..*/g, '$1').replace(/(\..*?)(\d{2})./g, '$1$2');"
onchange="this.value = this.value.replace('', '0');this.value = parseFloat(this.value).toFixed(2)"
[(ngModel)]="pmsWorkingTime.select.conditionBMin">
<label class="ti-form-label col-span-1 align-center text-center m-0">ถึง</label>
<input type="text" class="ti-form-input col-span-2"
oninput="this.value = this.value.replace(/[^\d.]/g, '').replace(/(\..*?)\..*/g, '$1').replace(/(\..*?)(\d{2})./g, '$1$2');"
onchange="this.value = this.value.replace('', '0');this.value = parseFloat(this.value).toFixed(2)"
[(ngModel)]="pmsWorkingTime.select.conditionBMax">
</div>
</div>
<div class="grid grid-cols-1 gap-y-2 mt-2rem">
<div class="col-span-1 grid grid-cols-12 gap-x-2">
<label class="ti-form-label col-span-2 align-center m-0">C (3 คะแนน) ชื่อ</label>
<input type="text" class="ti-form-input col-span-10"
[(ngModel)]="pmsWorkingTime.select.targetCDetail">
</div>
<div class="col-span-1 grid grid-cols-12 gap-x-2">
<label class="ti-form-label col-span-2 align-center m-0">เงื่อนไข ช่วงระหว่าง</label>
<input type="text" class="ti-form-input col-span-2"
oninput="this.value = this.value.replace(/[^\d.]/g, '').replace(/(\..*?)\..*/g, '$1').replace(/(\..*?)(\d{2})./g, '$1$2');"
onchange="this.value = this.value.replace('', '0');this.value = parseFloat(this.value).toFixed(2)"
[(ngModel)]="pmsWorkingTime.select.conditionCMin">
<label class="ti-form-label col-span-1 align-center text-center m-0">ถึง</label>
<input type="text" class="ti-form-input col-span-2"
oninput="this.value = this.value.replace(/[^\d.]/g, '').replace(/(\..*?)\..*/g, '$1').replace(/(\..*?)(\d{2})./g, '$1$2');"
onchange="this.value = this.value.replace('', '0');this.value = parseFloat(this.value).toFixed(2)"
[(ngModel)]="pmsWorkingTime.select.conditionCMax">
</div>
</div>
<div class="grid grid-cols-1 gap-y-2 mt-2rem">
<div class="col-span-1 grid grid-cols-12 gap-x-2">
<label class="ti-form-label col-span-2 align-center m-0">D (2 คะแนน) ชื่อ</label>
<input type="text" class="ti-form-input col-span-10"
[(ngModel)]="pmsWorkingTime.select.targetDDetail">
</div>
<div class="col-span-1 grid grid-cols-12 gap-x-2">
<label class="ti-form-label col-span-2 align-center m-0">เงื่อนไข ช่วงระหว่าง</label>
<input type="text" class="ti-form-input col-span-2"
oninput="this.value = this.value.replace(/[^\d.]/g, '').replace(/(\..*?)\..*/g, '$1').replace(/(\..*?)(\d{2})./g, '$1$2');"
onchange="this.value = this.value.replace('', '0');this.value = parseFloat(this.value).toFixed(2)"
[(ngModel)]="pmsWorkingTime.select.conditionDMin">
<label class="ti-form-label col-span-1 align-center text-center m-0">ถึง</label>
<input type="text" class="ti-form-input col-span-2"
oninput="this.value = this.value.replace(/[^\d.]/g, '').replace(/(\..*?)\..*/g, '$1').replace(/(\..*?)(\d{2})./g, '$1$2');"
onchange="this.value = this.value.replace('', '0');this.value = parseFloat(this.value).toFixed(2)"
[(ngModel)]="pmsWorkingTime.select.conditionDMax">
</div>
</div>
<div class="grid grid-cols-1 gap-y-2 mt-2rem">
<div class="col-span-1 grid grid-cols-12 gap-x-2">
<label class="ti-form-label col-span-2 align-center m-0">E (1 คะแนน) ชื่อ</label>
<input type="text" class="ti-form-input col-span-10"
[(ngModel)]="pmsWorkingTime.select.targetEDetail">
</div>
<div class="col-span-1 grid grid-cols-12 gap-x-2">
<label class="ti-form-label col-span-2 align-center m-0">เงื่อนไข ช่วงระหว่าง</label>
<input type="text" class="ti-form-input col-span-2"
oninput="this.value = this.value.replace(/[^\d.]/g, '').replace(/(\..*?)\..*/g, '$1').replace(/(\..*?)(\d{2})./g, '$1$2');"
onchange="this.value = this.value.replace('', '0');this.value = parseFloat(this.value).toFixed(2)"
[(ngModel)]="pmsWorkingTime.select.conditionEMin">
<label class="ti-form-label col-span-1 align-center text-center m-0">ถึง</label>
<input type="text" class="ti-form-input col-span-2"
oninput="this.value = this.value.replace(/[^\d.]/g, '').replace(/(\..*?)\..*/g, '$1').replace(/(\..*?)(\d{2})./g, '$1$2');"
onchange="this.value = this.value.replace('', '0');this.value = parseFloat(this.value).toFixed(2)"
[(ngModel)]="pmsWorkingTime.select.conditionEMax">
</div>
</div>
<div class="flex justify-end mt-2rem mb-1rem">
<button type="button"
class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
data-hs-overlay="#time-attendance-modal">
ย้อนกลับ
</button>
<button type="button" class="ti-btn ti-btn-success" data-hs-overlay="#time-attendance-alert-modal"
[class.ti-btn-disabled]="!pmsWorkingTime.select.pmsWorkingTimeId||!pmsWorkingTime.select.emeventgrp.length||!pmsWorkingTime.select.tdesc"
[disabled]="!pmsWorkingTime.select.pmsWorkingTimeId||!pmsWorkingTime.select.emeventgrp.length||!pmsWorkingTime.select.tdesc">
บันทึกข้อมูล
</button>
</div>
</div>
</div>
</div>
</div>
<div id="time-attendance-alert-modal" class="hs-overlay hidden ti-modal">
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)] flex items-center">
<div class="max-h-full overflow-hidden ti-modal-content w-full">
<div class="ti-modal-header">
<h3 class="text-xxl font-bold text-primary">
แจ้งเตือน
</h3>
<div class="flex justify-end">
<ng-container *ngIf="modalStatus=='add'||modalStatus=='edit'">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#time-attendance-modal">
<span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i>
</button>
</ng-container>
<ng-container *ngIf="modalStatus=='delete'||modalStatus=='deleteGroup'">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#time-attendance-alert-modal">
<span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i>
</button>
</ng-container>
</div>
</div>
<div class="ti-modal-body ">
<p class="mt-1 text-gray-800 dark:text-white/70">
<ng-container *ngIf="modalStatus=='add'||modalStatus=='edit'">
ยืนยันการบันทึกข้อมูลหรือไม่
</ng-container>
<ng-container *ngIf="modalStatus=='delete'||modalStatus=='deleteGroup'">
<ng-container *ngIf="numDataListChecked">
ยืนยันการลบข้อมูลหรือไม่
</ng-container>
<ng-container *ngIf="!numDataListChecked">
เลือกข้อมูลที่ต้องการลบ
</ng-container>
</ng-container>
</p>
<div class="flex justify-end mt-2rem mb-1rem">
<ng-container *ngIf="modalStatus=='add'||modalStatus=='edit'">
<button type="button"
class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
data-hs-overlay="#time-attendance-modal">
ย้อนกลับ
</button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#time-attendance-alert-modal" (click)="updatePmsWorkingTime()">
บันทึกข้อมูล
</a>
</ng-container>
<ng-container *ngIf="modalStatus=='delete'||modalStatus=='deleteGroup'">
<button type="button"
class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
data-hs-overlay="#time-attendance-alert-modal">
ย้อนกลับ
</button>
<a class="ti-btn ti-btn-danger" href="javascript:void(0);" *ngIf="numDataListChecked"
data-hs-overlay="#time-attendance-alert-modal" (click)="deletePmsWorkingTime()">
ลบข้อมูล
</a>
</ng-container>
</div>
</div>
</div>
</div>
</div>
<div id="time-attendance-eventgrp-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="max-h-full overflow-hidden ti-modal-content">
<div class="ti-modal-header">
<h3 class="text-xxl font-bold text-primary">
รายการทะเบียนประเภทวัน
</h3>
<div class="flex justify-end">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#time-attendance-modal">
<span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i>
</button>
</div>
</div>
<div class="ti-modal-body">
<div class="flex justify-end pb-1rem">
<div class="px-1">
<div class="relative shadow-md">
<input type="text" class="ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 "
placeholder="Search by No. or Name" [(ngModel)]="modal.search"
(ngModelChange)="modalSearchChange(eventgrpListFilter())">
<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 ['ประเภทวัน','รายละเอียด(ไทย) ','รายละเอียด(อังกฤษ)']; let f = first; let l = last">
<th scope="col" class="relative px-10px py-10px bg-soft-secondary text-primary">
<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="eventgrp.loading">
<tr>
<td class="text-center" colspan="100%">
<div *ngFor="let item of [1,2,3]" class="ti-spinner w-8 h-8 text-secondary mx-1"
role="status" aria-label="loading">
<span class="sr-only">Loading...</span>
</div>
</td>
</tr>
</tbody>
<tbody *ngIf="!eventgrp.loading&&!eventgrpListFilter().length">
<tr>
<td class="text-center" colspan="100%">
ไม่พบข้อมูล
</td>
</tr>
</tbody>
<tbody *ngIf="!eventgrp.loading&&eventgrpListFilter().length">
<tr *ngFor="let item of eventgrpListFilter() | slice:((modal.currentPage-1) * 10) : (((modal.currentPage-1) * 10) + 10);let i = index"
class="cursor-pointer" (click)="selectEventgrp(item.data)"
data-hs-overlay="#time-attendance-modal">
<td>{{item.data.eventgrpId}}</td>
<td>{{item.data.tdesc}}</td>
<td>{{item.data.edesc}}</td>
</tr>
</tbody>
</table>
</div>
<nav class="pagination-style-3 my-5" *ngIf="modal.page.length">
<ul class="ti-pagination">
<li>
<a aria-label="anchor" class="page-link" href="javascript:void(0);"
(click)="modal.currentPage = (modal.currentPage-1 || 1)">
<i class="ri-arrow-left-s-line align-middle rtl:rotate-180"></i>
</a>
</li>
<li *ngFor="let item of modal.page;let f = first;let l = last">
<ng-container
*ngIf="item==3&&modal.currentPage!=1&&modal.currentPage!=2&&modal.currentPage!=3">
<a aria-label="anchor" class="page-link" href="javascript:void(0);"><i
class="ri-more-line"></i>
</a>
</ng-container>
<ng-container
*ngIf="(f||l)||(item==modal.currentPage-1||item==modal.currentPage||item==modal.currentPage+1)">
<a class="page-link" href="javascript:void(0);" [class.active]="item==modal.currentPage"
(click)="modal.currentPage=item">{{item}}
</a>
</ng-container>
<ng-container
*ngIf="item==modal.page.length-2&&modal.currentPage!=modal.page.length&&modal.currentPage!=modal.page.length-1&&modal.currentPage!=modal.page.length-2">
<a aria-label="anchor" class="page-link" href="javascript:void(0);"><i
class="ri-more-line"></i>
</a>
</ng-container>
</li>
<li>
<a aria-label="anchor" class="page-link" href="javascript:void(0);"
(click)="modal.currentPage = (modal.currentPage > modal.page.length-1 ? modal.currentPage: modal.currentPage+1 )">
<i class="ri-arrow-right-s-line align-middle rtl:rotate-180"></i>
</a>
</li>
</ul>
<ul class="nav-tabs mt-3">
<span>Show {{((modal.currentPage-1) * 10)+1}} to {{eventgrpListFilter().length<10
?eventgrpListFilter().length: (modal.currentPage==modal.page.length ?
((modal.currentPage * 10) - ((modal.currentPage * 10) - eventgrpListFilter().length) )
:(modal.currentPage * 10) ) }} of {{eventgrpListFilter().length}} items</span>
</ul>
</nav>
<div class="flex justify-end mt-2rem mb-1rem space-x-4">
<button type="button"
class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
data-hs-overlay="#time-attendance-modal">
ย้อนกลับ
</button>
</div>
</div>
</div>
</div>
</div>
\ No newline at end of file
import { ChangeDetectorRef, Component } from '@angular/core';
import { ToastrService } from 'ngx-toastr';
import { MyEmeventgrpModel } from 'src/app/shared/model/emeventgrp.model';
import { EventgrpModel, MyEventgrpModel, } from 'src/app/shared/model/eventgrp.model';
import { PmsWorkingTimeModel, MyPmsWorkingTimeModel } from 'src/app/shared/model/pms-working-time.model';
import { EventgrpService } from 'src/app/shared/services/eventgrp.service';
import { FileService } from 'src/app/shared/services/file.service';
import { PmsWorkingTimeService } from 'src/app/shared/services/pms-working-time.service';
interface table {
currentPage: number,
page: number[],
search: string
}
@Component({
selector: 'app-time-attendance-manage',
templateUrl: './time-attendance-manage.component.html',
styleUrls: ['./time-attendance-manage.component.scss']
})
export class TimeAttendanceManageComponent {
numDataListChecked = 0
isDataListChecked = false
isDataListCheckedAll = false
currentPage = 1;
page = Array.from({ length: 1 }, (_, i) => i + 1);
search = '';
modalStatus: "add" | "edit" | "delete" | "deleteGroup" = "add"
modal: table = {
currentPage: 1,
page: Array.from({ length: 1 }, (_, i) => i + 1),
search: ""
}
eventgrp: { loading: boolean, selectIndex: number, selectList: EventgrpModel[], dataList: { check: boolean, data: EventgrpModel }[] } = { loading: false, selectIndex: -1, selectList: [new MyEventgrpModel()], dataList: [] }
pmsWorkingTime: { loading: boolean, select: PmsWorkingTimeModel, dataList: { check: boolean, data: PmsWorkingTimeModel }[] } = { loading: false, select: new MyPmsWorkingTimeModel(), dataList: [] }
constructor(
private toastr: ToastrService,
private cdr: ChangeDetectorRef,
private fileService: FileService,
private eventgrpService: EventgrpService,
private pmsWorkingTimeService: PmsWorkingTimeService,
) { }
ngOnInit(): void {
this.getEventgrpList()
this.getPmsWorkingTimeList()
}
getPmsWorkingTimeList() {
this.pmsWorkingTime.loading = true
this.pmsWorkingTimeService.getList().subscribe({
next: response => {
this.pmsWorkingTime.dataList = response.map(x => ({ check: false, data: new MyPmsWorkingTimeModel(x) }))
this.pmsWorkingTime.loading = false
this.isDataListCheckedAll = false
this.dataListCheckAll()
this.searchChange()
this.cdr.detectChanges();
}, error: error => {
this.pmsWorkingTime.loading = false
this.cdr.detectChanges()
}
})
}
pmsWorkingTimeFilter() {
return this.pmsWorkingTime.dataList.filter((x) => {
const data = x.data
const match = data.pmsWorkingTimeId.toLowerCase().includes(this.search.toLowerCase()) ||
data.tdesc.toLowerCase().includes(this.search.toLowerCase()) ||
data.detailUnit.toLowerCase().includes(this.search.toLowerCase()) ||
(data.weight + "").toLowerCase().includes(this.search.toLowerCase())
return match;
});
}
searchChange() {
this.currentPage = 1;
const filteredData = this.pmsWorkingTimeFilter();
this.page = Array.from({ length: Math.ceil(filteredData.length / 10) }, (_, i) => i + 1);
this.dataListCheck();
}
selectData(data?: PmsWorkingTimeModel) {
this.pmsWorkingTime.select = new MyPmsWorkingTimeModel(data)
}
dataListCheckAll() {
const selectAll = this.isDataListCheckedAll;
this.pmsWorkingTimeFilter().forEach(x => x.check = selectAll);
this.dataListCheck();
}
dataListCheck() {
const dataCheck = this.pmsWorkingTimeFilter();
this.isDataListCheckedAll = dataCheck.length ? dataCheck.every(x => x.check) : false;
this.numDataListChecked = this.pmsWorkingTime.dataList.filter(x => x.check).length;
this.isDataListChecked = Boolean(this.numDataListChecked)
}
getEventgrpList() {
this.eventgrp.loading = true
this.eventgrpService.getList().subscribe({
next: response => {
this.eventgrp.dataList = response.map(x => ({ check: false, data: new MyEventgrpModel(x) }))
this.eventgrp.loading = false
this.isDataListCheckedAll = false
this.dataListCheckAll()
this.searchChange()
this.cdr.detectChanges();
}, error: error => {
this.eventgrp.loading = false
this.cdr.detectChanges()
}
})
}
eventgrpListFilter() {
return this.eventgrp.dataList.filter(x => {
const data = x.data
const match = data.eventgrpId.toLowerCase().includes(this.modal.search.toLowerCase()) || data.tdesc.toLowerCase().includes(this.modal.search.toLowerCase()) || data.edesc.toLowerCase().includes(this.modal.search.toLowerCase());
return match;
})
}
selectEventgrp(data?: EventgrpModel) {
if (!data) {
this.pmsWorkingTime.select.emeventgrp.splice(this.eventgrp.selectIndex, 1);
return;
}
this.pmsWorkingTime.select.emeventgrp.push(new MyEmeventgrpModel(data))
}
clearData(modalStatus: string) {
if (modalStatus == 'add') {
this.pmsWorkingTime.select = new MyPmsWorkingTimeModel()
} else if (modalStatus == 'edit') {
this.pmsWorkingTime.select = new MyPmsWorkingTimeModel({ pmsWorkingTimeId: this.pmsWorkingTime.select.pmsWorkingTimeId })
}
this.eventgrp.selectList = [new MyEventgrpModel()]
}
modalSearchChange(dataList: any) {
this.modal.currentPage = 1
this.modal.page = Array.from({ length: Math.ceil(dataList.length / 10) }, (_, i) => i + 1);
}
updatePmsWorkingTime() {
this.pmsWorkingTime.loading = true
this.pmsWorkingTimeService.post(new MyPmsWorkingTimeModel(this.pmsWorkingTime.select)).subscribe({
next: response => {
if (response.success) {
this.showAlert(response.message, 'success')
this.getPmsWorkingTimeList()
this.searchChange()
} else {
this.showAlert(response.message, 'error')
this.pmsWorkingTime.loading = false
}
this.cdr.detectChanges()
}, error: error => {
this.showAlert(error.message, 'error')
this.pmsWorkingTime.loading = false
this.cdr.detectChanges()
}
})
}
deletePmsWorkingTime() {
let body: PmsWorkingTimeModel[] = []
if (this.modalStatus == "deleteGroup") {
body = this.pmsWorkingTime.dataList.filter(x => x.check).map(x => new MyPmsWorkingTimeModel(x.data))
} else {
body = [new MyPmsWorkingTimeModel(this.pmsWorkingTime.select)]
}
this.pmsWorkingTime.loading = true
this.pmsWorkingTimeService.delete(body).subscribe({
next: response => {
if (response.success) {
this.showAlert(response.message, 'success')
this.getPmsWorkingTimeList()
} else {
this.showAlert(response.message, 'error')
this.pmsWorkingTime.loading = false
this.cdr.detectChanges()
}
}, error: error => {
this.showAlert(error.message, 'error')
this.pmsWorkingTime.loading = false
this.cdr.detectChanges()
}
})
}
showAlert(text: string, type: 'success' | 'error') {
this.toastr[type](text, 'แจ้งเตือน', {
timeOut: 3000,
positionClass: 'toast-top-right',
})
}
}
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out rounded-md">
<div class="ti-modal-header bg-primary text-center">
<h5 class="text-xxl font-bold text-white">
นำเข้าข้อมูลสถิติเวลาทำงาน
</h5>
</div>
<div class="ti-modal-body max-h-full overflow-hidden ti-modal-content !rounded-t-none !rounded-b-sm">
<h1 class="mt-2rem text-xl" style="text-align: center;">ไฟล์</h1>
<div class="mt-2rem p-2">
<div class="flex rounded-md">
<input #fileInput id="fileInput" type="file" (change)="onFileSelected($event)" hidden>
<input type="text" [value]="selectedFileName" readonly (click)="fileInput.click()"
class="ti-form-input rounded-none ltr:rounded-l-md rtl:rounded-r-md focus:z-10 cursor-pointer">
<button type="button" (click)="fileInput.click()"
class="inline-flex flex-shrink-0 justify-center items-center h-[2.875rem] w-[2.875rem] ltr:rounded-r-md rtl:rounded-l-md border border-transparent font-semibold bg-secondary text-white hover:bg-secondary focus:z-10 focus:outline-none focus:ring-0 focus:ring-secondary transition-all text-sm">
<i class="ti ti-upload"></i>
</button>
</div>
<div class="flex justify-center mt-2rem ">
<h1 class="cursor-pointer justify-center -mb-px inline-flex items-center gap-2
text-center text-secondary border-secondary border-b-2 align-items-end text-xl"
(click)="downloadFile()">
ดาวน์โหลดตัวอย่างไฟล์</h1>
</div>
<div class="flex justify-center mt-2rem mb-1rem space-x-4">
<button type="submit" class="ti-btn ti-btn-secondary"
data-hs-overlay="#company-registration-page-upload-modal" [class.ti-btn-disabled]="!selectedFile"
(click)="uploadFile()" [disabled]="!selectedFile" [disabled]="!selectedFile">
อัปโหลด
</button>
</div>
</div>
</div>
</div>
\ No newline at end of file
import { ChangeDetectorRef, Component } from '@angular/core';
import { ToastrService } from 'ngx-toastr';
import { FileService } from 'src/app/shared/services/file.service';
interface table {
currentPage: number,
page: number[],
search: string
}
@Component({
selector: 'app-time-attendance-statistics',
templateUrl: './time-attendance-statistics.component.html',
styleUrls: ['./time-attendance-statistics.component.scss']
})
export class TimeAttendanceStatisticsComponent {
selectedFile: File | null = null;
selectedFileName: string = 'กรุณาเลือกไฟล์';
constructor(private toastr: ToastrService,
private cdr: ChangeDetectorRef,
private fileService: FileService) { }
onFileSelected(event: any) {
this.selectedFile = event.target.files.length > 0 ? event.target.files[0] : null;
this.selectedFileName = this.selectedFile?.name || "กรุณาเลือกไฟล์"
}
uploadFile() {
if (!this.selectedFile) {
alert('กรุณาเลือกไฟล์ก่อนอัปโหลด')
return
}
const formData = new FormData();
formData.append('file', this.selectedFile);
this.fileService.uploadExcel(formData, 'PMS_WORKING_TIME_EMP').subscribe({
next: response => {
if (response.success) {
this.showAlert(response.message, 'success')
} else {
this.showAlert(response.message, 'error')
this.cdr.detectChanges();
}
}, error: error => {
this.showAlert(error.message, 'error')
this.cdr.detectChanges();
}
})
}
downloadFile() {
const fileName = 'IMPORT_PMS_WORKING_TIME_EMP.xlsx'
this.fileService.downloadTemplate(fileName).subscribe({
next: response => {
const url = window.URL.createObjectURL(response);
const a = document.createElement("a");
a.href = url;
a.download = fileName;
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
window.URL.revokeObjectURL(url);
}, error: error => {
this.showAlert(error.message, 'error')
}
})
}
showAlert(text: string, type: 'success' | 'error') {
this.toastr[type](text, 'แจ้งเตือน', {
timeOut: 3000,
positionClass: 'toast-top-right',
});
}
}
\ No newline at end of file
...@@ -11,591 +11,23 @@ ...@@ -11,591 +11,23 @@
<a class="font-size-16px font-weight-500 hs-tab-active:font-weight-700 hs-tab-active:border-secondary hs-tab-active:text-secondary pb-3 inline-flex items-center gap-2 border-b-[3px] border-transparent whitespace-nowrap text-gray-500 hover:text-secondary active" <a class="font-size-16px font-weight-500 hs-tab-active:font-weight-700 hs-tab-active:border-secondary hs-tab-active:text-secondary pb-3 inline-flex items-center gap-2 border-b-[3px] border-transparent whitespace-nowrap text-gray-500 hover:text-secondary active"
href="javascript:void(0);" id="underline-item-1" data-hs-tab="#underline-1" href="javascript:void(0);" id="underline-item-1" data-hs-tab="#underline-1"
aria-controls="underline-1" aria-controls="underline-1"
(click)="pathTitle = ['การประเมินจัดการประสิทธิภาพ','ทะเบียนการประเมินเวลาทำงาน','การจัดการหัวข้อการประเมินเวลาทำงาน']"> (click)="pathTitle = ['การประเมินจัดการประสิทธิภาพ','ทะเบียนการประเมินเวลาทำงาน','การจัดการหัวข้อการประเมินเวลาทำงาน'];currentPath=1">
การจัดการหัวข้อการประเมินเวลาทำงาน การจัดการหัวข้อการประเมินเวลาทำงาน
</a> </a>
<a class="font-size-16px font-weight-500 hs-tab-active:font-weight-700 hs-tab-active:border-secondary hs-tab-active:text-secondary pb-3 px-1 inline-flex items-center gap-2 border-b-[3px] border-transparent whitespace-nowrap text-gray-500 hover:text-secondary"
href="javascript:void(0);" id="underline-item-2" data-hs-tab="#underline-2"
aria-controls="underline-2"
(click)="pathTitle = ['การประเมินจัดการประสิทธิภาพ','ทะเบียนการประเมินเวลาทำงาน' ,'การจัดการข้อมูลสถิติเวลาทำงาน'];currentPath=2">
การจัดการข้อมูลสถิติเวลาทำงาน
</a>
</nav> </nav>
</div> </div>
<div class="px-2rem pt-50px !-mt-3 pt-50px"> <div class="px-2rem pt-50px !-mt-3 pt-50px">
<div id="underline-1" role="tabpanel" aria-labelledby="underline-item-1"> <div *ngIf="currentPath==1" id="underline-1" role="tabpanel" aria-labelledby="underline-item-1">
<ng-container *ngTemplateOutlet="timeAttendance"></ng-container> <app-time-attendance-manage></app-time-attendance-manage>
</div>
</div>
</div>
</div>
<ng-template #timeAttendance>
<div class="w-full min-height-50px mb-10px justify-between items-center">
<div class="flex justify-between">
<div class="flex">
<div class="flex items-center">
<input type="checkbox" class="ti-form-checkbox pointer-events-none" id="hs-default-checkbox"
[(ngModel)]="isDataListChecked">
<label for="hs-default-checkbox" class="text-sm text-gray-500 mx-2 pointer-events-none">
{{numDataListChecked}} Selected</label>
</div>
<div class="mx-1 flex items-center">
<button (click)="isDataListCheckedAll = !isDataListCheckedAll;dataListCheckAll()" id="checkbox"
class="focus:ring-2 focus:ring-primary rounded-sm flex item-center">
<i class="fs-l transition-all duration-200"
[ngClass]="{'ri-checkbox-multiple-line text-gray-500': !isDataListCheckedAll, 'ri-checkbox-multiple-fill text-primary': isDataListCheckedAll}"></i>
</button>
<label class="text-sm text-gray-500 ml-2" for="checkbox">Select All</label>
</div>
</div>
<div class="flex justify-end">
<div class="px-1">
<div class="relative shadow-md">
<input type="text" class="ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 "
placeholder="Search by No. or Name" style="height: 40px;" [(ngModel)]="search"
(ngModelChange)="searchChange()">
<div
class="absolute inset-y-0 ltr:left-0 rtl:right-0 flex items-center pointer-events-none z-20 ltr:pl-4 rtl:pr-4">
<i class="ri-search-line text-gray"></i>
</div>
</div>
</div>
<div class="px-1">
<button type="button" class="ti-btn ti-btn-soft-secondary h-10 m-0 shadow-md"
(click)="modalStatus='add';selectData()" data-hs-overlay="#time-attendance-modal">
<i class="ri-add-line"></i>
Add
</button>
</div>
<div class="px-1">
<button href="javascript:void(0);" class="ti-btn ti-btn-soft-danger h-10 m-0 shadow-md"
(click)="modalStatus='deleteGroup';selectData()" data-hs-overlay="#time-attendance-alert-modal">
<i class="ri-delete-bin-6-line"></i>
Delete
</button>
</div>
<!-- <div class="px-1">
<button href="javascript:void(0);" class="ti-btn ti-btn-soft-warning h-10 m-0 shadow-md">
<i class="ti ti-book fs-l"></i>
Help
</button>
</div> -->
</div>
</div>
</div>
<div class="page px-rem">
<div class="overflow-auto table-bordered rounded-top-0.65rem">
<table class="ti-custom-table ti-custom-table-head ti-custom-table-hover">
<thead class="height-50px">
<tr class="font-size-12px">
<ng-container
*ngFor="let item of ['','รหัส','ชื่อหัวข้อ','หน่วยนับ','น้ำหนัก','การจัดการ']; let f = first; let l = last">
<th scope="col" class="relative px-10px py-10px bg-soft-secondary text-primary"
[class.!text-center]="f||l">
<span class="font-size-12px font-weight-700">{{ item }}</span>
<div class="absolute top-1/2 transform -translate-y-1/2 right-0" *ngIf="!f && !l">
<i class="ti ti-dots-vertical fs-l"></i>
</div>
</th>
</ng-container>
</tr>
</thead>
<tbody *ngIf="pmsWorkingTime.loading">
<tr>
<td class="text-center" colspan="100%">
<div *ngFor="let item of [1,2,3]" class="ti-spinner w-8 h-8 text-secondary mx-1"
role="status" aria-label="loading">
<span class="sr-only">Loading...</span>
</div>
</td>
</tr>
</tbody>
<tbody *ngIf="!pmsWorkingTime.loading&&!pmsWorkingTimeFilter().length">
<tr>
<td class="text-center" colspan="100%">
ไม่พบข้อมูล
</td>
</tr>
</tbody>
<tbody *ngIf="!pmsWorkingTime.loading&&pmsWorkingTimeFilter().length">
<tr
*ngFor="let item of pmsWorkingTimeFilter() | slice:((currentPage-1) * 10) : (((currentPage-1) * 10) + 10);let i = index">
<td class="text-center">
<input type="checkbox" class="ti-form-checkbox cursor-pointer" [(ngModel)]="item.check"
(ngModelChange)="dataListCheck()" id="checkbox-{{item.data.pmsWorkingTimeId}}">
</td>
<td>
<label for="checkbox-{{item.data.pmsWorkingTimeId}}">{{item.data.pmsWorkingTimeId}}</label>
</td>
<td>{{item.data.tdesc}}</td>
<td>{{item.data.detailUnit}}</td>
<td>{{item.data.weight}}</td>
<td class="flex justify-center">
<i class="ti ti-edit cursor-pointer i-gray fs-l px-1"
data-hs-overlay="#time-attendance-modal"
(click)="modalStatus='edit';selectData(item.data)"></i>
<!-- <i class="ti ti-trash cursor-pointer i-gray fs-l px-1"
data-hs-overlay="#time-attendance-alert-modal"
(click)="modalStatus='delete';selectData(item.data)"></i> -->
</td>
</tr>
</tbody>
</table>
</div>
<nav class="pagination-style-3 overflow-auto my-5" *ngIf="page.length">
<ul class="ti-pagination">
<li>
<a aria-label="anchor" class="page-link" href="javascript:void(0);"
(click)="currentPage = (currentPage-1 || 1)">
<i class="ri-arrow-left-s-line align-middle rtl:rotate-180"></i>
</a>
</li>
<li *ngFor="let item of page;let f = first;let l = last">
<ng-container *ngIf="item==3&&currentPage!=1&&currentPage!=2&&currentPage!=3">
<a aria-label="anchor" class="page-link" href="javascript:void(0);"><i class="ri-more-line"></i>
</a>
</ng-container>
<ng-container *ngIf="(f||l)||(item==currentPage-1||item==currentPage||item==currentPage+1)">
<a class="page-link" href="javascript:void(0);" [class.active]="item==currentPage"
(click)="currentPage=item">{{item}}
</a>
</ng-container>
<ng-container
*ngIf="item==page.length-2&&currentPage!=page.length&&currentPage!=page.length-1&&currentPage!=page.length-2">
<a aria-label="anchor" class="page-link" href="javascript:void(0);"><i class="ri-more-line"></i>
</a>
</ng-container>
</li>
<li>
<a aria-label="anchor" class="page-link" href="javascript:void(0);"
(click)="currentPage = (currentPage > page.length-1 ? currentPage: currentPage+1 )">
<i class="ri-arrow-right-s-line align-middle rtl:rotate-180"></i>
</a>
</li>
</ul>
<ul class="nav-tabs mt-3">
<span>Show {{((currentPage-1) * 10)+1}} to {{pmsWorkingTimeFilter().length<10
?pmsWorkingTimeFilter().length: (currentPage==page.length ? ((currentPage * 10) - ((currentPage
* 10) - pmsWorkingTimeFilter().length) ) :(currentPage * 10) ) }} of
{{pmsWorkingTimeFilter().length}} items</span>
</ul>
</nav>
</div>
</ng-template>
<div id="time-attendance-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)] !max-w-1/2">
<div class="max-h-full overflow-hidden ti-modal-content">
<div class="ti-modal-header">
<h3 class="text-xxl font-bold text-primary">
{{modalStatus=='add'?'เพิ่มข้อมูลประเภทวัน':'แก้ไขข้อมูลประเภทวัน'}}
</h3>
<div class="flex justify-end">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#time-attendance-modal">
<span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i>
</button>
</div>
</div>
<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)="clearData(modalStatus)">
<svg class="svg-indigo" width="16" height="16" viewBox="0 0 64.00 64.00"
xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#595BEA" stroke-width="3.84"
transform="rotate(45)matrix(-1, 0, 0, 1, 0, 0)">
<g id="SVGRepo_bgCarrier" stroke-width="0"></g>
<g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g>
<g id="SVGRepo_iconCarrier">
<path d="M15 49A24 24 0 0 1 32 8"></path>
<path d="M49 15a24 24 0 0 1-17 41"></path>
<polyline points="15.03 40 15.03 48.97 8 48.97"></polyline>
<polyline points="48.97 24 48.97 15.03 56 15.03"></polyline>
</g>
</svg>
Clear
</button>
</div>
<!-- <div class="px-1">
<button href="javascript:void(0);" class="ti-btn ti-btn-soft-warning h-45px m-0 shadow-md">
<i class="ti ti-book fs-l"></i>
Help
</button>
</div> -->
</div>
</div>
<div class="ti-modal-body padding-16px pt-0 overflow-y-0">
<label class="ti-form-label mt-2rem">รหัส<span class="text-danger">*</span></label>
<input type="text" class="ti-form-input w-1/2" [ngClass]="{'bg-input-readonly':modalStatus=='edit'}"
[readonly]="modalStatus=='edit'" [(ngModel)]="pmsWorkingTime.select.pmsWorkingTimeId">
<label class="ti-form-label mt-2rem">รหัสประเภทวัน <span class="text-danger">*</span></label>
<div *ngFor="let item of pmsWorkingTime.select.emeventgrp;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}"
[(ngModel)]="item.eventgrpId">
<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}"
[(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.eventgrpId" type="button" class="flex items-center text-red-500"
(click)="eventgrp.selectIndex=i;selectEventgrp()">
<i class="ti ti-circle-x cursor-pointer"></i>
</button>
</div>
</div>
</div>
<div class="col-span-1 ml-1" *ngIf="f">
<ng-component *ngTemplateOutlet="emeventgrpSearchButton"></ng-component>
</div>
</div>
<div class="grid grid-cols-2" *ngIf="!pmsWorkingTime.select.emeventgrp.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="emeventgrpSearchButton"></ng-component>
</div>
</div>
<ng-template #emeventgrpSearchButton>
<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='';modalSearchChange(eventgrpListFilter())"
data-hs-overlay="#time-attendance-eventgrp-table-modal">
<i class="ri-search-line cursor-pointer text-gray"></i>
</button>
</ng-template>
<label class="ti-form-label mt-2rem">ชื่อหัวข้อ (ไทย)<span class="text-danger">*</span></label>
<input type="text" class="ti-form-input" [(ngModel)]="pmsWorkingTime.select.tdesc">
<label class="ti-form-label mt-2rem">ชื่อหัวข้อ (อังกฤษ)</label>
<input type="text" class="ti-form-input" [(ngModel)]="pmsWorkingTime.select.edesc">
<label class="ti-form-label mt-2rem">เป้าหมายผลงาน</label>
<input type="text" class="ti-form-input" [(ngModel)]="pmsWorkingTime.select.performanceTargets">
<label class="ti-form-label mt-2rem">หน่วยนับ</label>
<!-- <input type="text" class="ti-form-input" [(ngModel)]="pmsWorkingTime.select.detailUnit"> -->
<select class="ti-form-select" [(ngModel)]="pmsWorkingTime.select.detailUnit">
<option *ngFor="let item of ['นาที','ชั่วโมง','วัน','ครั้ง']" [value]="item">{{item}}</option>
</select>
<label class="ti-form-label mt-2rem">น้ำหนัก</label>
<input type="text" class="ti-form-input"
oninput="this.value = this.value.replace(/[^\d.]/g, '').replace(/(\..*?)\..*/g, '$1').replace(/(\..*?)(\d{2})./g, '$1$2');"
onchange="this.value = this.value.replace('', '0');this.value = parseFloat(this.value).toFixed(2)"
[(ngModel)]="pmsWorkingTime.select.weight">
<label class="ti-form-label mt-2rem">ค่าเป้าหมาย</label>
<div class="grid grid-cols-1 gap-y-2">
<div class="col-span-1 grid grid-cols-12 gap-x-2">
<label class="ti-form-label col-span-2 align-center m-0">A (5 คะแนน) ชื่อ</label>
<input type="text" class="ti-form-input col-span-10"
[(ngModel)]="pmsWorkingTime.select.targetADetail">
</div>
<div class="col-span-1 grid grid-cols-12 gap-x-2">
<label class="ti-form-label col-span-2 align-center m-0">เงื่อนไข ช่วงระหว่าง</label>
<input type="text" class="ti-form-input col-span-2"
oninput="this.value = this.value.replace(/[^\d.]/g, '').replace(/(\..*?)\..*/g, '$1').replace(/(\..*?)(\d{2})./g, '$1$2');"
onchange="this.value = this.value.replace('', '0');this.value = parseFloat(this.value).toFixed(2)"
[(ngModel)]="pmsWorkingTime.select.conditionAMin">
<label class="ti-form-label col-span-1 align-center text-center m-0">ถึง</label>
<input type="text" class="ti-form-input col-span-2"
oninput="this.value = this.value.replace(/[^\d.]/g, '').replace(/(\..*?)\..*/g, '$1').replace(/(\..*?)(\d{2})./g, '$1$2');"
onchange="this.value = this.value.replace('', '0');this.value = parseFloat(this.value).toFixed(2)"
[(ngModel)]="pmsWorkingTime.select.conditionAMax">
</div>
</div>
<div class="grid grid-cols-1 gap-y-2 mt-2rem">
<div class="col-span-1 grid grid-cols-12 gap-x-2">
<label class="ti-form-label col-span-2 align-center m-0">B (4 คะแนน) ชื่อ</label>
<input type="text" class="ti-form-input col-span-10"
[(ngModel)]="pmsWorkingTime.select.targetBDetail">
</div>
<div class="col-span-1 grid grid-cols-12 gap-x-2">
<label class="ti-form-label col-span-2 align-center m-0">เงื่อนไข ช่วงระหว่าง</label>
<input type="text" class="ti-form-input col-span-2"
oninput="this.value = this.value.replace(/[^\d.]/g, '').replace(/(\..*?)\..*/g, '$1').replace(/(\..*?)(\d{2})./g, '$1$2');"
onchange="this.value = this.value.replace('', '0');this.value = parseFloat(this.value).toFixed(2)"
[(ngModel)]="pmsWorkingTime.select.conditionBMin">
<label class="ti-form-label col-span-1 align-center text-center m-0">ถึง</label>
<input type="text" class="ti-form-input col-span-2"
oninput="this.value = this.value.replace(/[^\d.]/g, '').replace(/(\..*?)\..*/g, '$1').replace(/(\..*?)(\d{2})./g, '$1$2');"
onchange="this.value = this.value.replace('', '0');this.value = parseFloat(this.value).toFixed(2)"
[(ngModel)]="pmsWorkingTime.select.conditionBMax">
</div>
</div>
<div class="grid grid-cols-1 gap-y-2 mt-2rem">
<div class="col-span-1 grid grid-cols-12 gap-x-2">
<label class="ti-form-label col-span-2 align-center m-0">C (3 คะแนน) ชื่อ</label>
<input type="text" class="ti-form-input col-span-10"
[(ngModel)]="pmsWorkingTime.select.targetCDetail">
</div>
<div class="col-span-1 grid grid-cols-12 gap-x-2">
<label class="ti-form-label col-span-2 align-center m-0">เงื่อนไข ช่วงระหว่าง</label>
<input type="text" class="ti-form-input col-span-2"
oninput="this.value = this.value.replace(/[^\d.]/g, '').replace(/(\..*?)\..*/g, '$1').replace(/(\..*?)(\d{2})./g, '$1$2');"
onchange="this.value = this.value.replace('', '0');this.value = parseFloat(this.value).toFixed(2)"
[(ngModel)]="pmsWorkingTime.select.conditionCMin">
<label class="ti-form-label col-span-1 align-center text-center m-0">ถึง</label>
<input type="text" class="ti-form-input col-span-2"
oninput="this.value = this.value.replace(/[^\d.]/g, '').replace(/(\..*?)\..*/g, '$1').replace(/(\..*?)(\d{2})./g, '$1$2');"
onchange="this.value = this.value.replace('', '0');this.value = parseFloat(this.value).toFixed(2)"
[(ngModel)]="pmsWorkingTime.select.conditionCMax">
</div>
</div>
<div class="grid grid-cols-1 gap-y-2 mt-2rem">
<div class="col-span-1 grid grid-cols-12 gap-x-2">
<label class="ti-form-label col-span-2 align-center m-0">D (2 คะแนน) ชื่อ</label>
<input type="text" class="ti-form-input col-span-10"
[(ngModel)]="pmsWorkingTime.select.targetDDetail">
</div>
<div class="col-span-1 grid grid-cols-12 gap-x-2">
<label class="ti-form-label col-span-2 align-center m-0">เงื่อนไข ช่วงระหว่าง</label>
<input type="text" class="ti-form-input col-span-2"
oninput="this.value = this.value.replace(/[^\d.]/g, '').replace(/(\..*?)\..*/g, '$1').replace(/(\..*?)(\d{2})./g, '$1$2');"
onchange="this.value = this.value.replace('', '0');this.value = parseFloat(this.value).toFixed(2)"
[(ngModel)]="pmsWorkingTime.select.conditionDMin">
<label class="ti-form-label col-span-1 align-center text-center m-0">ถึง</label>
<input type="text" class="ti-form-input col-span-2"
oninput="this.value = this.value.replace(/[^\d.]/g, '').replace(/(\..*?)\..*/g, '$1').replace(/(\..*?)(\d{2})./g, '$1$2');"
onchange="this.value = this.value.replace('', '0');this.value = parseFloat(this.value).toFixed(2)"
[(ngModel)]="pmsWorkingTime.select.conditionDMax">
</div>
</div>
<div class="grid grid-cols-1 gap-y-2 mt-2rem">
<div class="col-span-1 grid grid-cols-12 gap-x-2">
<label class="ti-form-label col-span-2 align-center m-0">E (1 คะแนน) ชื่อ</label>
<input type="text" class="ti-form-input col-span-10"
[(ngModel)]="pmsWorkingTime.select.targetEDetail">
</div>
<div class="col-span-1 grid grid-cols-12 gap-x-2">
<label class="ti-form-label col-span-2 align-center m-0">เงื่อนไข ช่วงระหว่าง</label>
<input type="text" class="ti-form-input col-span-2"
oninput="this.value = this.value.replace(/[^\d.]/g, '').replace(/(\..*?)\..*/g, '$1').replace(/(\..*?)(\d{2})./g, '$1$2');"
onchange="this.value = this.value.replace('', '0');this.value = parseFloat(this.value).toFixed(2)"
[(ngModel)]="pmsWorkingTime.select.conditionEMin">
<label class="ti-form-label col-span-1 align-center text-center m-0">ถึง</label>
<input type="text" class="ti-form-input col-span-2"
oninput="this.value = this.value.replace(/[^\d.]/g, '').replace(/(\..*?)\..*/g, '$1').replace(/(\..*?)(\d{2})./g, '$1$2');"
onchange="this.value = this.value.replace('', '0');this.value = parseFloat(this.value).toFixed(2)"
[(ngModel)]="pmsWorkingTime.select.conditionEMax">
</div>
</div>
<div class="flex justify-end mt-2rem mb-1rem">
<button type="button"
class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
data-hs-overlay="#time-attendance-modal">
ย้อนกลับ
</button>
<button type="button" class="ti-btn ti-btn-success" data-hs-overlay="#time-attendance-alert-modal"
[class.ti-btn-disabled]="!pmsWorkingTime.select.pmsWorkingTimeId||!pmsWorkingTime.select.emeventgrp.length||!pmsWorkingTime.select.tdesc"
[disabled]="!pmsWorkingTime.select.pmsWorkingTimeId||!pmsWorkingTime.select.emeventgrp.length||!pmsWorkingTime.select.tdesc">
บันทึกข้อมูล
</button>
</div>
</div>
</div>
</div>
</div>
<div id="time-attendance-alert-modal" class="hs-overlay hidden ti-modal">
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)] flex items-center">
<div class="max-h-full overflow-hidden ti-modal-content w-full">
<div class="ti-modal-header">
<h3 class="text-xxl font-bold text-primary">
แจ้งเตือน
</h3>
<div class="flex justify-end">
<ng-container *ngIf="modalStatus=='add'||modalStatus=='edit'">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#time-attendance-modal">
<span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i>
</button>
</ng-container>
<ng-container *ngIf="modalStatus=='delete'||modalStatus=='deleteGroup'">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#time-attendance-alert-modal">
<span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i>
</button>
</ng-container>
</div>
</div>
<div class="ti-modal-body ">
<p class="mt-1 text-gray-800 dark:text-white/70">
<ng-container *ngIf="modalStatus=='add'||modalStatus=='edit'">
ยืนยันการบันทึกข้อมูลหรือไม่
</ng-container>
<ng-container *ngIf="modalStatus=='delete'||modalStatus=='deleteGroup'">
<ng-container *ngIf="numDataListChecked">
ยืนยันการลบข้อมูลหรือไม่
</ng-container>
<ng-container *ngIf="!numDataListChecked">
เลือกข้อมูลที่ต้องการลบ
</ng-container>
</ng-container>
</p>
<div class="flex justify-end mt-2rem mb-1rem">
<ng-container *ngIf="modalStatus=='add'||modalStatus=='edit'">
<button type="button"
class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
data-hs-overlay="#time-attendance-modal">
ย้อนกลับ
</button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#time-attendance-alert-modal" (click)="updatePmsWorkingTime()">
บันทึกข้อมูล
</a>
</ng-container>
<ng-container *ngIf="modalStatus=='delete'||modalStatus=='deleteGroup'">
<button type="button"
class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
data-hs-overlay="#time-attendance-alert-modal">
ย้อนกลับ
</button>
<a class="ti-btn ti-btn-danger" href="javascript:void(0);" *ngIf="numDataListChecked"
data-hs-overlay="#time-attendance-alert-modal" (click)="deletePmsWorkingTime()">
ลบข้อมูล
</a>
</ng-container>
</div>
</div>
</div>
</div>
</div>
<div id="time-attendance-eventgrp-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="max-h-full overflow-hidden ti-modal-content">
<div class="ti-modal-header">
<h3 class="text-xxl font-bold text-primary">
รายการทะเบียนประเภทวัน
</h3>
<div class="flex justify-end">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#time-attendance-modal">
<span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i>
</button>
</div>
</div> </div>
<div class="ti-modal-body"> <div *ngIf="currentPath==2" id="underline-2" role="tabpanel" aria-labelledby="underline-item-2">
<div class="flex justify-end pb-1rem"> <app-time-attendance-statistics></app-time-attendance-statistics>
<div class="px-1">
<div class="relative shadow-md">
<input type="text" class="ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 "
placeholder="Search by No. or Name" [(ngModel)]="modal.search"
(ngModelChange)="modalSearchChange(eventgrpListFilter())">
<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 ['ประเภทวัน','รายละเอียด(ไทย) ','รายละเอียด(อังกฤษ)']; let f = first; let l = last">
<th scope="col" class="relative px-10px py-10px bg-soft-secondary text-primary">
<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="eventgrp.loading">
<tr>
<td class="text-center" colspan="100%">
<div *ngFor="let item of [1,2,3]" class="ti-spinner w-8 h-8 text-secondary mx-1"
role="status" aria-label="loading">
<span class="sr-only">Loading...</span>
</div>
</td>
</tr>
</tbody>
<tbody *ngIf="!eventgrp.loading&&!eventgrpListFilter().length">
<tr>
<td class="text-center" colspan="100%">
ไม่พบข้อมูล
</td>
</tr>
</tbody>
<tbody *ngIf="!eventgrp.loading&&eventgrpListFilter().length">
<tr *ngFor="let item of eventgrpListFilter() | slice:((modal.currentPage-1) * 10) : (((modal.currentPage-1) * 10) + 10);let i = index"
class="cursor-pointer" (click)="selectEventgrp(item.data)"
data-hs-overlay="#time-attendance-modal">
<td>{{item.data.eventgrpId}}</td>
<td>{{item.data.tdesc}}</td>
<td>{{item.data.edesc}}</td>
</tr>
</tbody>
</table>
</div>
<nav class="pagination-style-3 my-5" *ngIf="modal.page.length">
<ul class="ti-pagination">
<li>
<a aria-label="anchor" class="page-link" href="javascript:void(0);"
(click)="modal.currentPage = (modal.currentPage-1 || 1)">
<i class="ri-arrow-left-s-line align-middle rtl:rotate-180"></i>
</a>
</li>
<li *ngFor="let item of modal.page;let f = first;let l = last">
<ng-container
*ngIf="item==3&&modal.currentPage!=1&&modal.currentPage!=2&&modal.currentPage!=3">
<a aria-label="anchor" class="page-link" href="javascript:void(0);"><i
class="ri-more-line"></i>
</a>
</ng-container>
<ng-container
*ngIf="(f||l)||(item==modal.currentPage-1||item==modal.currentPage||item==modal.currentPage+1)">
<a class="page-link" href="javascript:void(0);" [class.active]="item==modal.currentPage"
(click)="modal.currentPage=item">{{item}}
</a>
</ng-container>
<ng-container
*ngIf="item==modal.page.length-2&&modal.currentPage!=modal.page.length&&modal.currentPage!=modal.page.length-1&&modal.currentPage!=modal.page.length-2">
<a aria-label="anchor" class="page-link" href="javascript:void(0);"><i
class="ri-more-line"></i>
</a>
</ng-container>
</li>
<li>
<a aria-label="anchor" class="page-link" href="javascript:void(0);"
(click)="modal.currentPage = (modal.currentPage > modal.page.length-1 ? modal.currentPage: modal.currentPage+1 )">
<i class="ri-arrow-right-s-line align-middle rtl:rotate-180"></i>
</a>
</li>
</ul>
<ul class="nav-tabs mt-3">
<span>Show {{((modal.currentPage-1) * 10)+1}} to {{eventgrpListFilter().length<10
?eventgrpListFilter().length: (modal.currentPage==modal.page.length ?
((modal.currentPage * 10) - ((modal.currentPage * 10) - eventgrpListFilter().length) )
:(modal.currentPage * 10) ) }} of {{eventgrpListFilter().length}} items</span>
</ul>
</nav>
<div class="flex justify-end mt-2rem mb-1rem space-x-4">
<button type="button"
class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
data-hs-overlay="#time-attendance-modal">
ย้อนกลับ
</button>
</div>
</div> </div>
</div> </div>
</div> </div>
......
import { ChangeDetectorRef, Component } from '@angular/core'; import { Component } from '@angular/core';
import { ToastrService } from 'ngx-toastr';
import { MyEmeventgrpModel } from 'src/app/shared/model/emeventgrp.model';
import { EventgrpModel, MyEventgrpModel, } from 'src/app/shared/model/eventgrp.model';
import { PmsWorkingTimeModel, MyPmsWorkingTimeModel } from 'src/app/shared/model/pms-working-time.model';
import { EventgrpService } from 'src/app/shared/services/eventgrp.service';
import { FileService } from 'src/app/shared/services/file.service';
import { PmsWorkingTimeService } from 'src/app/shared/services/pms-working-time.service';
interface table { interface table {
currentPage: number, currentPage: number,
page: number[], page: number[],
...@@ -18,176 +11,5 @@ interface table { ...@@ -18,176 +11,5 @@ interface table {
}) })
export class TimeAttendanceComponent { export class TimeAttendanceComponent {
pathTitle = ['การประเมินจัดการประสิทธิภาพ', 'ทะเบียนการประเมินเวลาทำงาน', 'การจัดการหัวข้อการประเมินเวลาทำงาน'] pathTitle = ['การประเมินจัดการประสิทธิภาพ', 'ทะเบียนการประเมินเวลาทำงาน', 'การจัดการหัวข้อการประเมินเวลาทำงาน']
currentPath = 1
numDataListChecked = 0
isDataListChecked = false
isDataListCheckedAll = false
currentPage = 1;
page = Array.from({ length: 1 }, (_, i) => i + 1);
search = '';
modalStatus: "add" | "edit" | "delete" | "deleteGroup" = "add"
modal: table = {
currentPage: 1,
page: Array.from({ length: 1 }, (_, i) => i + 1),
search: ""
}
eventgrp: { loading: boolean, selectIndex: number, selectList: EventgrpModel[], dataList: { check: boolean, data: EventgrpModel }[] } = { loading: false, selectIndex: -1, selectList: [new MyEventgrpModel()], dataList: [] }
pmsWorkingTime: { loading: boolean, select: PmsWorkingTimeModel, dataList: { check: boolean, data: PmsWorkingTimeModel }[] } = { loading: false, select: new MyPmsWorkingTimeModel(), dataList: [] }
constructor(
private toastr: ToastrService,
private cdr: ChangeDetectorRef,
private fileService: FileService,
private eventgrpService: EventgrpService,
private pmsWorkingTimeService: PmsWorkingTimeService,
) { }
ngOnInit(): void {
this.getEventgrpList()
this.getPmsWorkingTimeList()
}
getPmsWorkingTimeList() {
this.pmsWorkingTime.loading = true
this.pmsWorkingTimeService.getList().subscribe({
next: response => {
this.pmsWorkingTime.dataList = response.map(x => ({ check: false, data: new MyPmsWorkingTimeModel(x) }))
this.pmsWorkingTime.loading = false
this.isDataListCheckedAll = false
this.dataListCheckAll()
this.searchChange()
this.cdr.detectChanges();
}, error: error => {
this.pmsWorkingTime.loading = false
this.cdr.detectChanges()
}
})
}
pmsWorkingTimeFilter() {
return this.pmsWorkingTime.dataList.filter((x) => {
const data = x.data
const match = data.pmsWorkingTimeId.toLowerCase().includes(this.search.toLowerCase()) ||
data.tdesc.toLowerCase().includes(this.search.toLowerCase()) ||
data.detailUnit.toLowerCase().includes(this.search.toLowerCase()) ||
(data.weight + "").toLowerCase().includes(this.search.toLowerCase())
return match;
});
}
searchChange() {
this.currentPage = 1;
const filteredData = this.pmsWorkingTimeFilter();
this.page = Array.from({ length: Math.ceil(filteredData.length / 10) }, (_, i) => i + 1);
this.dataListCheck();
}
selectData(data?: PmsWorkingTimeModel) {
this.pmsWorkingTime.select = new MyPmsWorkingTimeModel(data)
}
dataListCheckAll() {
const selectAll = this.isDataListCheckedAll;
this.pmsWorkingTimeFilter().forEach(x => x.check = selectAll);
this.dataListCheck();
}
dataListCheck() {
const dataCheck = this.pmsWorkingTimeFilter();
this.isDataListCheckedAll = dataCheck.length ? dataCheck.every(x => x.check) : false;
this.numDataListChecked = this.pmsWorkingTime.dataList.filter(x => x.check).length;
this.isDataListChecked = Boolean(this.numDataListChecked)
}
getEventgrpList() {
this.eventgrp.loading = true
this.eventgrpService.getList().subscribe({
next: response => {
this.eventgrp.dataList = response.map(x => ({ check: false, data: new MyEventgrpModel(x) }))
this.eventgrp.loading = false
this.isDataListCheckedAll = false
this.dataListCheckAll()
this.searchChange()
this.cdr.detectChanges();
}, error: error => {
this.eventgrp.loading = false
this.cdr.detectChanges()
}
})
}
eventgrpListFilter() {
return this.eventgrp.dataList.filter(x => {
const data = x.data
const match = data.eventgrpId.toLowerCase().includes(this.modal.search.toLowerCase()) || data.tdesc.toLowerCase().includes(this.modal.search.toLowerCase()) || data.edesc.toLowerCase().includes(this.modal.search.toLowerCase());
return match;
})
}
selectEventgrp(data?: EventgrpModel) {
if (!data) {
this.pmsWorkingTime.select.emeventgrp.splice(this.eventgrp.selectIndex, 1);
return;
}
this.pmsWorkingTime.select.emeventgrp.push(new MyEmeventgrpModel(data))
}
clearData(modalStatus: string) {
if (modalStatus == 'add') {
this.pmsWorkingTime.select = new MyPmsWorkingTimeModel()
} else if (modalStatus == 'edit') {
this.pmsWorkingTime.select = new MyPmsWorkingTimeModel({ pmsWorkingTimeId: this.pmsWorkingTime.select.pmsWorkingTimeId })
}
this.eventgrp.selectList = [new MyEventgrpModel()]
}
modalSearchChange(dataList: any) {
this.modal.currentPage = 1
this.modal.page = Array.from({ length: Math.ceil(dataList.length / 10) }, (_, i) => i + 1);
}
updatePmsWorkingTime() {
this.pmsWorkingTime.loading = true
this.pmsWorkingTimeService.post(new MyPmsWorkingTimeModel(this.pmsWorkingTime.select)).subscribe({
next: response => {
if (response.success) {
this.showAlert(response.message, 'success')
this.getPmsWorkingTimeList()
this.searchChange()
} else {
this.showAlert(response.message, 'error')
this.pmsWorkingTime.loading = false
}
this.cdr.detectChanges()
}, error: error => {
this.showAlert(error.message, 'error')
this.pmsWorkingTime.loading = false
this.cdr.detectChanges()
}
})
}
deletePmsWorkingTime() {
let body: PmsWorkingTimeModel[] = []
if (this.modalStatus == "deleteGroup") {
body = this.pmsWorkingTime.dataList.filter(x => x.check).map(x => new MyPmsWorkingTimeModel(x.data))
} else {
body = [new MyPmsWorkingTimeModel(this.pmsWorkingTime.select)]
}
this.pmsWorkingTime.loading = true
this.pmsWorkingTimeService.delete(body).subscribe({
next: response => {
if (response.success) {
this.showAlert(response.message, 'success')
this.getPmsWorkingTimeList()
} else {
this.showAlert(response.message, 'error')
this.pmsWorkingTime.loading = false
this.cdr.detectChanges()
}
}, error: error => {
this.showAlert(error.message, 'error')
this.pmsWorkingTime.loading = false
this.cdr.detectChanges()
}
})
}
showAlert(text: string, type: 'success' | 'error') {
this.toastr[type](text, 'แจ้งเตือน', {
timeOut: 3000,
positionClass: 'toast-top-right',
})
}
} }
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