Commit 14e5a470 by Nattana Chaiyamat

การจัดการข้อมูลองค์กร > ข้อมูลลักษณะงาน

การจัดการข้อมูลองค์กร > ตั้งค่าผู้ใช้งาน
parent ca6384bb
...@@ -28,13 +28,17 @@ ...@@ -28,13 +28,17 @@
</a> </a>
</nav> </nav>
</div> </div>
<div class="mt-3 px-3rem !-mt-3 pt-50px"> <div class="mt-3 px-2rem !-mt-3 pt-50px">
<div *ngIf="currentPage==1" id="underline-1" role="tabpanel" aria-labelledby="underline-item-1"> <div *ngIf="currentPage==1" id="underline-1" role="tabpanel" aria-labelledby="underline-item-1">
<app-user-settings></app-user-settings> <app-user-settings></app-user-settings>
</div> </div>
<div *ngIf="currentPage==2" id="underline-2" class="hidden" role="tabpanel" <div *ngIf="currentPage==2" id="underline-2" class="hidden" role="tabpanel"
aria-labelledby="underline-item-2"> aria-labelledby="underline-item-2">
<app-set-a-password [pathTitle]="pathTitle" (sendPathTitle)="pathTitle=$event"></app-set-a-password> <app-set-a-password></app-set-a-password>
</div>
<div *ngIf="currentPage==3" id="underline-3" class="hidden" role="tabpanel"
aria-labelledby="underline-item-3">
จัดการผู้ใช้งาน
</div> </div>
</div> </div>
</div> </div>
......
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
<div class="flex pr-2"> <div class="flex pr-2">
<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="#company-registration-page-upload-modal"> data-hs-overlay="#user-setting-upload-modal"
(click)="fileInput.value = '';selectedFile=null;selectedFileName = 'กรุณาเลือกไฟล์'">
<i class="ri-add-line"></i> <i class="ri-add-line"></i>
นำเข้าข้อมูล นำเข้าข้อมูล
</button> </button>
...@@ -16,8 +17,9 @@ ...@@ -16,8 +17,9 @@
<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" class="ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 "
class="ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 " placeholder="Search by No. or Name" style="height: 40px;"> placeholder="Search by No. or Name" style="height: 40px;" [(ngModel)]="search"
(ngModelChange)="searchChange()">
<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>
...@@ -25,30 +27,16 @@ ...@@ -25,30 +27,16 @@
</div> </div>
</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-warning h-20px m-0 shadow-md">
data-hs-overlay="#set-a-password-modal-add">
<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-20px m-0 shadow-md"
data-hs-overlay="#set-a-password-alert-delete-modal">
<i class="ri-delete-bin-6-line"></i>
Delete
</button>
</div>
<div class="px-1">
<button href="javascript:void(0);" class="ti-btn ti-btn-soft-warning h-20px 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> </div>
<div class="page px-rem"> <div class="page px-rem">
<div class="overflow-auto shadow-md rounded-t-md"> <div class="overflow-auto shadow-md rounded-t-md">
<table class="ti-custom-table ti-custom-table-head ti-custom-table-hover table-bordered"> <table class="ti-custom-table ti-custom-table-head ti-custom-table-hover table-bordered">
<thead> <thead>
...@@ -64,152 +52,118 @@ ...@@ -64,152 +52,118 @@
</ng-container> </ng-container>
</tr> </tr>
</thead> </thead>
<tbody> <tbody *ngIf="user.loading">
<tr *ngFor="let item of[ <tr>
['CC01','620010','จรูญ', 'เทพทมาศ','ใช้งาน'], <td class="text-center" colspan="100%">
['CC02','592530','มานะ', 'มิณนา','ใช้งาน'], <div *ngFor="let item of [1,2,3]" class="ti-spinner w-8 h-8 text-secondary mx-1" role="status"
['CC03','5812142','ชาญชัย', 'โพธิ์สุข','ใช้งาน'], aria-label="loading">
['FC01','6125365','อดิศร', 'สมสัย','ใช้งาน'], <span class="sr-only">Loading...</span>
['FC02','5211475','ธนศักดิ์', 'ตาศรี','ใช้งาน'], </div>
['KC01','525258','สุทธิชา', 'สิบประเสริฐ','ใช้งาน'], </td>
['KC02','647589','ศรสุข', 'ยอดสิงห์','ใช้งาน']];let i = index"> </tr>
</tbody>
<tbody *ngIf="!user.loading&&!userListFilter().length">
<tr>
<td class="text-center" colspan="100%">
ไม่พบข้อมูล
</td>
</tr>
</tbody>
<tbody *ngIf="!user.loading&&userListFilter().length">
<tr
*ngFor="let item of userListFilter() | slice:((currentPage-1) * 10) : (((currentPage-1) * 10) + 10);let i = index">
<td class="text-center"> <td class="text-center">
<input type="checkbox" class="ti-form-checkbox cursor-pointer" id="checkbox-{{item[0]}}"> <input type="checkbox" class="ti-form-checkbox cursor-pointer"
<label for="checkbox-{{item[0]}}">&nbsp;{{item[0]}}</label> id="checkbox-{{item.data.usernameId}}" [(ngModel)]="item.check">
<label for="checkbox-{{item.data.usernameId}}">&nbsp;{{item.data.usernameId}}</label>
</td> </td>
<td class="text-center">{{item[1]}}</td> <td class="text-center">{{item.data.empId}}</td>
<td>{{item[2]}}</td> <td>{{item.data.employee.fname}}</td>
<td>{{item[3]}}</td> <td>{{item.data.employee.lname}}</td>
<td class="text-center">{{item[4]}}</td> <td class="text-center">{{item.data.status=='0'?'ไม่ใช้งาน':'ใช้งาน'}}</td>
<td class="flex justify-center"> <td class="flex justify-center">
<i class="ti ti-edit cursor-pointer i-gray fs-l px-1" data-hs-overlay="#set-a-password-modal-edit"></i> <i class="ti ti-edit cursor-pointer i-gray fs-l px-1" (click)="selectUser(item.data)"
<i class="ti ti-trash cursor-pointer i-gray fs-l px-1" data-hs-overlay="#set-a-password-alert-delete-modal"></i> data-hs-overlay="#user-setting-modal"></i>
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</div> </div>
<nav class="pagination-style-3 overflow-auto my-5" *ngIf="page.length">
<div class="body-content" style="margin-top: 20px;">
<ul class="nav-tabs">
<div class="px-1 py-1 bg-white rounded-2 shadow justify-content-center align-items-center">
<div class="box-body">
<nav class="pagination-style-3 overflow-auto">
<ul class="ti-pagination"> <ul class="ti-pagination">
<li> <li>
<a aria-label="anchor" class="page-link" href="javascript:void(0);"> <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> <i class="ri-arrow-left-s-line align-middle rtl:rotate-180"></i>
</a> </a>
</li> </li>
<li><a class="page-link active" href="javascript:void(0);" aria-current="page">1</a></li> <li *ngFor="let item of page;let f = first;let l = last">
<li><a class="page-link" href="javascript:void(0);">2</a></li> <ng-container *ngIf="item==3&&currentPage!=1&&currentPage!=2&&currentPage!=3">
<li><a class="page-link" href="javascript:void(0);">3</a></li> <a aria-label="anchor" class="page-link" href="javascript:void(0);"><i class="ri-more-line"></i>
<li><a class="page-link" href="javascript:void(0);">4</a></li> </a>
<li><a class="page-link" href="javascript:void(0);">5</a></li> </ng-container>
<li><a class="page-link" href="javascript:void(0);">...</a></li> <ng-container *ngIf="(f||l)||(item==currentPage-1||item==currentPage||item==currentPage+1)">
<li><a class="page-link" href="javascript:void(0);">31</a></li> <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> <li>
<a aria-label="anchor" class="page-link" href="javascript:void(0);"> <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> <i class="ri-arrow-right-s-line align-middle rtl:rotate-180"></i>
</a> </a>
</li> </li>
</ul> </ul>
</nav> <ul class="nav-tabs mt-3">
</div> <span>Show {{((currentPage-1) * 10)+1}} to {{userListFilter().length<10 ?userListFilter().length:
</div> (currentPage==page.length ? ((currentPage * 10) - ((currentPage * 10) - userListFilter().length) )
</ul> :(currentPage * 10) ) }} of {{userListFilter().length}} items</span>
<ul class="nav-tabs">
<p>Show 1 to 10 of 50 items</p>
</ul> </ul>
</div> </nav>
</div> </div>
<div id="user-setting-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 id="set-a-password-modal-add" class="hs-overlay hidden ti-modal"> <div class="max-h-full overflow-hidden ti-modal-content">
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out md:!max-w-2xl md:w-full m-3 md:mx-auto h-[calc(100%-3.5rem)] items-center">
<div class="max-h-full overflow-hidden ti-modal-content-new">
<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">
กำหนดรหัสผ่าน กำหนดรหัสผ่าน
</h3> </h3>
<div class="flex justify-end"> <div class="flex justify-end">
<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="#set-a-password-modal-add"> data-hs-overlay="#user-setting-modal">
<span class="sr-only">Close</span> <span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i> <i class="ti ti-circle-x fs-xxl"></i>
</button> </button>
</div> </div>
</div> </div>
<div class="ti-modal-center"> <div class="w-full flex justify-end">
<div class="flex justify-end" style="padding-right: 1rem;"> <div class="absolute flex">
<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 type="button" class="ti-btn ti-btn-soft-indigo h-45px m-0 shadow-md"
<i class="ti ti-book fs-l"></i> (click)="userPassword.oldPassword=='';userPassword.newPassword=''">
Help <svg class="svg-indigo" width="16" height="16" viewBox="0 0 64.00 64.00"
</button> xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#595BEA" stroke-width="3.84"
</div> transform="rotate(45)matrix(-1, 0, 0, 1, 0, 0)">
</div> <g id="SVGRepo_bgCarrier" stroke-width="0"></g>
</div> <g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g>
<div class="ti-modal-body-new"> <g id="SVGRepo_iconCarrier">
<form class="space-y-5"> <path d="M15 49A24 24 0 0 1 32 8"></path>
<div class="sm:grid grid-cols-12 gap-x-6"> <path d="M49 15a24 24 0 0 1-17 41"></path>
<label class="col-span-12 sm:col-span-3 ti-form-label text-primary">ชื่อล็อคอิน</label> <polyline points="15.03 40 15.03 48.97 8 48.97"></polyline>
<div class="col-span-6 sm:col-span-6 relative"> <polyline points="48.97 24 48.97 15.03 56 15.03"></polyline>
<input type="text" id="hs-leading-button-add-on-with-icon-and-button" name="hs-leading-button-add-on-with-icon-and-button" class="ti-form-input ltr:pr-11 rtl:pl-11 rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10"> </g>
<div class="absolute inset-y-0 ltr:right-0 rtl:left-0 flex items-center pointer-events-none z-20 ltr:pr-4 rtl:pl-4">
<svg class="h-4 w-4 text-gray-400 dark:text-white/70" xmlns="http://www.w3.org/2000/svg" width="10" height="10" fill="currentColor" viewBox="0 0 16 16">
<path d="M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z"/>
</svg> </svg>
</div> Clear
</div>
</div>
<div class="sm:grid grid-cols-12 gap-x-6">
<label class="col-span-12 sm:col-span-3 ti-form-label text-primary">รหัสผ่าน</label>
<input type="password" class="col-span-12 sm:col-span-6 ti-form-input" placeholder="" style="width: 330px;">
</div>
<div class="sm:grid grid-cols-12 gap-x-6">
<label class="col-span-12 sm:col-span-3 ti-form-label text-primary">รหัสพนักงาน</label>
<input type="text" class="col-span-12 sm:col-span-4 ti-form-input" style="background-color: rgb(241, 245, 249);" placeholder="" disabled>
</div>
</form>
</div>
<div class="flex justify-end mt-4 sm:mt-2 mb-4 sm:mb-1 space-x-4" style="margin-right: 30px;">
<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="#set-a-password-modal-add">
ย้อนกลับ
</button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#set-a-password-alert-add-modal">
บันทึกข้อมูล
</a>
</div>
</div>
</div>
</div>
<div id="set-a-password-modal-edit" class="hs-overlay hidden ti-modal">
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out md:!max-w-2xl md:w-full m-3 md:mx-auto h-[calc(100%-3.5rem)] items-center">
<div class="max-h-full overflow-hidden ti-modal-content-new">
<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="#set-a-password-modal-edit">
<span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i>
</button> </button>
</div> </div>
</div>
<div class="ti-modal-center">
<div class="flex justify-end" style="padding-right: 1rem;">
<div class="px-1"> <div class="px-1">
<button 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>
...@@ -218,74 +172,24 @@ ...@@ -218,74 +172,24 @@
</div> </div>
</div> </div>
</div> </div>
<div class="ti-modal-body-new"> <div class="ti-modal-body padding-16px pt-0 overflow-y-0">
<form class="space-y-5"> <label class="ti-form-label mt-2rem">ชื่อล็อคอิน</label>
<div class="sm:grid grid-cols-12 gap-x-6"> <input type="text" class="ti-form-input bg-input-readonly" readonly
<label class="col-span-12 sm:col-span-3 ti-form-label text-primary">ชื่อล็อคอิน</label> [(ngModel)]="userPassword.usernameId">
<div class="col-span-6 sm:col-span-6 relative"> <label class="ti-form-label mt-2rem">รหัสพนักงาน</label>
<input type="text" id="hs-leading-button-add-on-with-icon-and-button" name="hs-leading-button-add-on-with-icon-and-button" class="ti-form-input ltr:pr-11 rtl:pl-11 rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10"> <input type="text" class="ti-form-input bg-input-readonly" readonly [(ngModel)]="userPassword.empId">
<div class="absolute inset-y-0 ltr:right-0 rtl:left-0 flex items-center pointer-events-none z-20 ltr:pr-4 rtl:pl-4"> <label class="ti-form-label mt-2rem">รหัสผ่านเก่า</label>
<svg class="h-4 w-4 text-gray-400 dark:text-white/70" xmlns="http://www.w3.org/2000/svg" width="10" height="10" fill="currentColor" viewBox="0 0 16 16"> <input type="text" class="ti-form-input" [(ngModel)]="userPassword.oldPassword">
<path d="M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z"/> <label class="ti-form-label mt-2rem">รหัสผ่านใหม่</label>
</svg> <input type="text" class="ti-form-input" [(ngModel)]="userPassword.newPassword">
</div>
</div>
</div>
<div class="sm:grid grid-cols-12 gap-x-6">
<label class="col-span-12 sm:col-span-3 ti-form-label text-primary">รหัสผ่าน</label>
<input type="password" class="col-span-12 sm:col-span-6 ti-form-input" placeholder="" style="width: 330px;">
</div>
<div class="sm:grid grid-cols-12 gap-x-6">
<label class="col-span-12 sm:col-span-3 ti-form-label text-primary">รหัสพนักงาน</label>
<input type="text" class="col-span-12 sm:col-span-4 ti-form-input"style="background-color: rgb(241, 245, 249);" placeholder="" disabled>
</div>
</form>
</div>
<div class="flex justify-end mt-4 sm:mt-2 mb-4 sm:mb-1 space-x-4" style="margin-right: 70px;">
<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="#set-a-password-modal-edit">
ย้อนกลับ
</button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#set-a-password-alert-edit-modal">
บันทึกข้อมูล
</a>
</div>
</div>
</div>
</div>
<div id="set-a-password-alert-add-modal" class="hs-overlay hidden ti-modal">
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)] flex items-center">
<div class="max-h-full overflow-hidden ti-modal-content w-full">
<div class="ti-modal-header">
<h3 class="text-xxl font-bold text-primary">
แจ้งเตือน
</h3>
<div class="flex justify-end">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#set-a-password-alert-add-modal">
<span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i>
</button>
</div>
</div>
<div class="ti-modal-body ">
<p class="mt-1 text-gray-800 dark:text-white/70">
ยืนยันการบันทึกข้อมูลหรือไม่
</p>
<div class="flex justify-end mt-2rem mb-1rem"> <div class="flex justify-end mt-2rem mb-1rem">
<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="#set-a-password-modal-add"> data-hs-overlay="#user-setting-modal">
ย้อนกลับ ย้อนกลับ
</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="#set-a-password-alert-add-modal" (click)="showSuccessAdd()"> data-hs-overlay="#user-setting-alert-modal">
บันทึกข้อมูล บันทึกข้อมูล
</a> </a>
</div> </div>
...@@ -294,43 +198,37 @@ ...@@ -294,43 +198,37 @@
</div> </div>
</div> </div>
<div id="set-a-password-alert-edit-modal" class="hs-overlay hidden ti-modal"> <div id="user-setting-upload-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 rounded-md">
<div class="max-h-full overflow-hidden ti-modal-content w-full"> <div class="ti-modal-header bg-primary !rounded-none !rounded-t-sm">
<div class="ti-modal-header"> <h5 class="text-xxl font-bold text-white">
<h3 class="text-xxl font-bold text-primary"> นำเข้าผู้ใช้งาน
แจ้งเตือน </h5>
</h3> </div>
<div class="flex justify-end"> <div class="ti-modal-body max-h-full overflow-hidden ti-modal-content !rounded-t-none !rounded-b-sm">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger" <h1 class="mt-2" style="text-align: center;">ไฟล์</h1>
data-hs-overlay="#set-a-password-alert-edit-modal"> <div class="mt-2 p-2">
<span class="sr-only">Close</span> <div class="flex rounded-md">
<i class="ti ti-circle-x fs-xxl"></i> <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> </button>
</div> </div>
</div> <div class="flex justify-center mt-2rem mb-1rem space-x-4">
<div class="ti-modal-body "> <button type="submit" data-hs-overlay="#user-setting-upload-modal" class="ti-btn ti-btn-secondary"
<p class="mt-1 text-gray-800 dark:text-white/70"> [class.ti-btn-disabled]="!selectedFile" (click)="uploadFile()" [disabled]="!selectedFile">
ยืนยันการแก้ไขข้อมูลหรือไม่ อัปโหลด
</p>
<div class="flex justify-end mt-2rem mb-1rem">
<button type="button"
class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
data-hs-overlay="#set-a-password-modal-edit">
ย้อนกลับ
</button> </button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#set-a-password-alert-edit-modal" (click)="showSuccessEdit()">
บันทึกข้อมูล
</a>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div id="set-a-password-alert-delete-modal" class="hs-overlay hidden ti-modal"> <div id="user-setting-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">
...@@ -339,7 +237,7 @@ ...@@ -339,7 +237,7 @@
</h3> </h3>
<div class="flex justify-end"> <div class="flex justify-end">
<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="#set-a-password-alert-delete-modal"> data-hs-overlay="#user-setting-modal">
<span class="sr-only">Close</span> <span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i> <i class="ti ti-circle-x fs-xxl"></i>
</button> </button>
...@@ -347,18 +245,17 @@ ...@@ -347,18 +245,17 @@
</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">
ยืนยันการลบข้อมูลหรือไม่ ยืนยันการบันทึกข้อมูลหรือไม่
</p> </p>
<div class="flex justify-end mt-2rem mb-1rem"> <div class="flex justify-end mt-2rem mb-1rem">
<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="#set-a-password-alert-delete-modal"> data-hs-overlay="#user-setting-modal">
ย้อนกลับ ย้อนกลับ
</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="#set-a-password-alert-delete-modal" (click)="showSuccessDelete()"> data-hs-overlay="#user-setting-alert-modal" (click)="updateUserPassword()">
ลบข้อมูล บันทึกข้อมูล
</a> </a>
</div> </div>
</div> </div>
......
import { Component, EventEmitter, Input, Output } from '@angular/core'; import { ChangeDetectorRef, Component, EventEmitter, Input, Output } from '@angular/core';
import { ToastrService } from 'ngx-toastr'; import { ToastrService } from 'ngx-toastr';
import { MyUserModel, UserModel } from 'src/app/shared/model/user.model';
import { FileService } from 'src/app/shared/services/file.service';
import { UserService } from 'src/app/shared/services/user.service';
export interface DataPassword {
usernameId: string,
empId: string,
companyId: string,
oldPassword: string,
newPassword: string,
}
@Component({ @Component({
selector: 'app-set-a-password', selector: 'app-set-a-password',
templateUrl: './set-a-password.component.html', templateUrl: './set-a-password.component.html',
styleUrls: ['./set-a-password.component.scss'] styleUrls: ['./set-a-password.component.scss']
}) })
export class SetAPasswordComponent { export class SetAPasswordComponent {
@Input() pathTitle = ['การจัดการข้อมูลองค์กร', 'ตั้งค่าผู้ใช้งาน', 'สร้างรหัสผู้ใช้งาน'] selectedFile: File | null = null;
@Output() sendPathTitle: EventEmitter<string[]> = new EventEmitter<string[]>(); selectedFileName: string = 'กรุณาเลือกไฟล์';
activeTab: string = 'tab1'; // กำหนด tab เริ่มต้น currentPage = 1
page = Array.from({ length: 1 }, (_, i) => i + 1);
companyId = ""
user: { loading: boolean, select: UserModel, dataList: { check: boolean, data: UserModel }[] } = { loading: false, select: new MyUserModel(), dataList: [] }
search = ""
// ฟังก์ชันในการเปลี่ยนแท็บ userPassword: DataPassword = {
changeTab(tab: { id: string, text: string }) { usernameId: "",
this.sendPathTitle.emit(['การจัดการข้อมูลองค์กร', 'ตั้งค่าผู้ใช้งาน', tab.text]) empId: "",
this.activeTab = tab.id; companyId: "",
} oldPassword: "",
modalOptions: { newPassword: "",
[nameModal: string]: { // ชื่อตรวจสอบการเปิดปิด }
isModalOpen: boolean; // เปิด/ปิด constructor(private toastr: ToastrService,
modalSize: string; // ขนาดของ Modal (s,m,l,vw10-vw100 ) private cdr: ChangeDetectorRef,
backdropClose: boolean; // (คลิก Backdrop แล้ว true ปิด false ไม่ปิด ) private userService: UserService,
} private fileService: FileService) {
} = { this.companyId = this.decodeJWT(sessionStorage.getItem("accessToken") || '').companyid
"add": { }
isModalOpen: false, ngOnInit(): void {
modalSize: 'm', this.getUserList()
backdropClose: true, }
},
"edit": {
isModalOpen: false,
modalSize: 'm',
backdropClose: true,
}
}
constructor(private toastr: ToastrService) { }
openModal(name: string, size: string, closeOnBackdrop?: boolean) { decodeJWT(token: string) {
this.modalOptions[name].modalSize = size; let base64Url = token.split('.')[1]; // ดึงส่วนที่เป็น Payload
this.modalOptions[name].backdropClose = closeOnBackdrop || false; let base64 = base64Url.replace('-', '+').replace('_', '/'); // แก้ไข base64 ให้ถูกต้อง
this.modalOptions[name].isModalOpen = true; let jsonPayload = decodeURIComponent(atob(base64).split('').map(function (c) {
document.body.style.overflow = 'hidden'; // ล็อก Scroll return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
}).join(''));
return JSON.parse(jsonPayload);
} }
closeModal(name: string) {
this.modalOptions[name].isModalOpen = false; getUserList() {
// ตรวจสอบว่ามี Modal อื่นเปิดอยู่หรือไม่ this.user.loading = true
if (!this.isAnyModalOpen()) { this.userService.getList().subscribe({
document.body.style.overflow = ''; // คืนค่าการ Scroll เฉพาะเมื่อ Modal ทั้งหมดปิดแล้ว next: response => {
this.user.dataList = response.map(x => ({ check: false, data: new MyUserModel(x) }))
this.user.loading = false
this.searchChange()
this.cdr.detectChanges()
}, error: error => {
this.user.loading = false
this.cdr.detectChanges()
}
})
}
userListFilter() {
return this.user.dataList.filter(x => {
const data = x.data
const match = data.usernameId.toLowerCase().includes(this.search.toLowerCase()) ||
data.empId.toLowerCase().includes(this.search.toLowerCase()) ||
data.employee.thFullName.toLowerCase().includes(this.search.toLowerCase())
return match
})
}
selectUser(data?: UserModel) {
this.user.select = new MyUserModel({ ...data, companyId: data?.companyId || this.companyId, status: data?.status || '0' })
this.userPassword = {
usernameId: this.user.select.usernameId,
empId: this.user.select.empId,
companyId: this.user.select.companyId,
oldPassword: "",
newPassword: "",
}
}
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.user.loading = true
this.fileService.upload(formData, 'mbu1').subscribe({
next: response => {
if (response.success) {
this.showAlert(response.message, 'success')
this.getUserList()
} else {
this.showAlert(response.message, 'error')
this.user.loading = false
} }
}, error: error => {
this.showAlert(error.message, 'error')
this.user.loading = false
} }
})
}
downloadFile() {
const fileName = 'IMPORT_USER.xlsx'
this.fileService.download(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')
}
})
isAnyModalOpen(): boolean {
// Logic ตรวจสอบว่า Modal อื่นยังเปิดอยู่หรือไม่
return Object.values(this.modalOptions).some(modal => modal.isModalOpen); // หากไม่มี Modal อื่นเปิด
} }
showSuccessAdd() {
this.toastr.success('บันทึกข้อมูลสำเร็จ', 'แจ้งเตือน', {
timeOut: 3000, updateUserPassword() {
positionClass: 'toast-top-right', this.user.loading = true
}); this.userService.changePassword(this.userPassword).subscribe({
next: response => {
if (response.success) {
this.showAlert(response.message, 'success')
this.getUserList()
this.searchChange()
} else {
this.showAlert(response.message, 'error')
this.user.loading = false
} }
showSuccessEdit() { this.cdr.detectChanges()
this.toastr.success('แก้ไขข้อมูลสำเร็จ', 'แจ้งเตือน', { }, error: error => {
timeOut: 3000, this.showAlert(error.message, 'error')
positionClass: 'toast-top-right', this.user.loading = false
}); this.cdr.detectChanges()
}
})
} }
showSuccessDelete() { searchChange() {
this.toastr.success('ลบข้อมูลสำเร็จ', 'แจ้งเตือน', { this.currentPage = 1
this.page = Array.from({ length: Math.ceil(this.userListFilter().length / 10) }, (_, i) => i + 1);
}
selectDataModal(target: { [key: string]: any }, field: string, data: any) {
target[field] = JSON.parse(JSON.stringify(data))
}
showAlert(text: string, type: 'success' | 'error') {
this.toastr[type](text, 'แจ้งเตือน', {
timeOut: 3000, timeOut: 3000,
positionClass: 'toast-top-right', positionClass: 'toast-top-right',
}); })
} }
} }
\ No newline at end of file
<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 pr-2 pb-2rem">
<div class="flex">
<div class="flex items-center">
<input type="checkbox" class="ti-form-checkbox pointer-events-none" id="hs-default-checkbox"
[(ngModel)]="isDataListChecked">
<label for="hs-default-checkbox" class="text-sm text-gray-500 mx-2 pointer-events-none">
{{numDataListChecked}} Selected</label>
</div>
<div class="mx-1 flex items-center">
<button (click)="isDataListCheckedAll = !isDataListCheckedAll;dataListCheckAll()"
class="focus:ring-2 focus:ring-primary rounded-sm flex item-center">
<i class="fs-l transition-all duration-200"
[ngClass]="{'ri-checkbox-multiple-line text-gray-500': !isDataListCheckedAll, 'ri-checkbox-multiple-fill text-primary': isDataListCheckedAll}"></i>
</button>
<label class="text-sm text-gray-500 ml-2">Select All</label>
</div>
</div>
</div>
<div class="flex justify-between"> <div class="flex justify-between">
<div class="flex pr-2"> <div class="flex pr-2">
<div class="px-1"> <div class="px-1">
...@@ -17,9 +35,9 @@ ...@@ -17,9 +35,9 @@
<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" class="ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 "
class="ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 " placeholder="Search by No. or Name" placeholder="Search by No. or Name" style="height: 40px;" [(ngModel)]="search"
style="height: 40px;"> (ngModelChange)="searchChange()">
<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>
...@@ -28,20 +46,20 @@ ...@@ -28,20 +46,20 @@
</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="#user-setting-modal" (click)="currentModal=='add';selectUser()"> data-hs-overlay="#user-setting-modal" (click)="currentModal='add';selectUser()">
<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 type="button" class="ti-btn ti-btn-soft-danger h-20px m-0 shadow-md"
data-hs-overlay="#user-settings-component-alert-delete-modal"> data-hs-overlay="#user-setting-alert-modal" (click)="currentModal='deleteGroup'">
<i class="ri-delete-bin-6-line"></i> <i class="ri-delete-bin-6-line"></i>
Delete Delete
</button> </button>
</div> </div>
<div class="px-1"> <div class="px-1">
<button href="javascript:void(0);" class="ti-btn ti-btn-soft-warning h-20px m-0 shadow-md"> <button type="button" class="ti-btn ti-btn-soft-warning h-20px m-0 shadow-md">
<i class="ti ti-book fs-l"></i> <i class="ti ti-book fs-l"></i>
Help Help
</button> </button>
...@@ -66,69 +84,88 @@ ...@@ -66,69 +84,88 @@
</ng-container> </ng-container>
</tr> </tr>
</thead> </thead>
<tbody> <tbody *ngIf="user.loading">
<tr *ngFor="let item of[ <tr>
['CC001', '620010','จรุณ','เทพมาศ','ใช้งาน'], <td class="text-center" colspan="100%">
['CC002', '592530','มานะ','มิณนา','ใช้งาน'], <div *ngFor="let item of [1,2,3]" class="ti-spinner w-8 h-8 text-secondary mx-1" role="status"
['CC003', '5812142','ชาญชัย','โพธิ์สุข','ใช้งาน'], aria-label="loading">
['FC001', '6125365','อดิศร','สมสัย','ใช้งาน'], <span class="sr-only">Loading...</span>
['FC002', '5211475','ธนศักดิ์','ตาศรี','ใช้งาน'], </div>
['KC001', '525258','สุทธิดา','สินประเสริฐ','ใช้งาน'], </td>
['KC002', '647589','ศรสุข','ยอดสิงฆ์','ใช้งาน']];let i = index"> </tr>
</tbody>
<tbody *ngIf="!user.loading&&!userListFilter().length">
<tr>
<td class="text-center" colspan="100%">
ไม่พบข้อมูล
</td>
</tr>
</tbody>
<tbody *ngIf="!user.loading&&userListFilter().length">
<tr
*ngFor="let item of userListFilter() | slice:((currentPage-1) * 10) : (((currentPage-1) * 10) + 10);let i = index">
<td class="text-center"> <td class="text-center">
<input type="checkbox" class="ti-form-checkbox cursor-pointer" id="checkbox-{{item[0]}}"> <input type="checkbox" class="ti-form-checkbox cursor-pointer"
<label for="checkbox-{{item[0]}}">&nbsp;{{item[0]}}</label> id="checkbox-{{item.data.usernameId}}" [(ngModel)]="item.check"
(ngModelChange)="dataListCheck()">
<label for="checkbox-{{item.data.usernameId}}">&nbsp;{{item.data.usernameId}}</label>
</td> </td>
<td class="text-center">{{item[1]}}</td> <td class="text-center">{{item.data.empId}}</td>
<td>{{item[2]}}</td> <td>{{item.data.employee.fname}}</td>
<td>{{item[3]}}</td> <td>{{item.data.employee.lname}}</td>
<td class="text-center">{{item[4]}}</td> <td class="text-center">{{item.data.status=='0'?'ไม่ใช้งาน':'ใช้งาน'}}</td>
<td class="flex justify-center"> <td class="flex justify-center">
<i class="ti ti-edit cursor-pointer i-gray fs-l px-1" <i class="ti ti-edit cursor-pointer i-gray fs-l px-1"
data-hs-overlay="#user-settings-component-modal-edit"></i> (click)="currentModal='edit';selectUser(item.data)"
data-hs-overlay="#user-setting-modal"></i>
<i class="ti ti-trash cursor-pointer i-gray fs-l px-1" <i class="ti ti-trash cursor-pointer i-gray fs-l px-1"
data-hs-overlay="#user-settings-component-alert-delete-modal"></i> data-hs-overlay="#user-setting-alert-modal"
(click)="currentModal='delete';selectUser(item.data)"></i>
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</div> </div>
</div> <nav class="pagination-style-3 overflow-auto my-5" *ngIf="page.length">
<div class="body-content" style="margin-top: 20px;">
<ul class="nav-tabs">
<div class="px-1 py-1 bg-white rounded-2 shadow justify-content-center align-items-center">
<div class="box-body">
<nav class="pagination-style-3 overflow-auto">
<ul class="ti-pagination"> <ul class="ti-pagination">
<li> <li>
<a aria-label="anchor" class="page-link" href="javascript:void(0);"> <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> <i class="ri-arrow-left-s-line align-middle rtl:rotate-180"></i>
</a> </a>
</li> </li>
<li><a class="page-link active" href="javascript:void(0);" aria-current="page">1</a></li> <li *ngFor="let item of page;let f = first;let l = last">
<li><a class="page-link" href="javascript:void(0);">2</a></li> <ng-container *ngIf="item==3&&currentPage!=1&&currentPage!=2&&currentPage!=3">
<li><a class="page-link" href="javascript:void(0);">3</a></li> <a aria-label="anchor" class="page-link" href="javascript:void(0);"><i class="ri-more-line"></i>
<li><a class="page-link" href="javascript:void(0);">4</a></li> </a>
<li><a class="page-link" href="javascript:void(0);">5</a></li> </ng-container>
<li><a class="page-link" href="javascript:void(0);">...</a></li> <ng-container *ngIf="(f||l)||(item==currentPage-1||item==currentPage||item==currentPage+1)">
<li><a class="page-link" href="javascript:void(0);">31</a></li> <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> <li>
<a aria-label="anchor" class="page-link" href="javascript:void(0);"> <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> <i class="ri-arrow-right-s-line align-middle rtl:rotate-180"></i>
</a> </a>
</li> </li>
</ul> </ul>
</nav> <ul class="nav-tabs mt-3">
</div> <span>Show {{((currentPage-1) * 10)+1}} to {{userListFilter().length<10 ?userListFilter().length:
</div> (currentPage==page.length ? ((currentPage * 10) - ((currentPage * 10) - userListFilter().length) )
</ul> :(currentPage * 10) ) }} of {{userListFilter().length}} items</span>
<ul class="nav-tabs">
<p>Show 1 to 10 of 50 items</p>
</ul> </ul>
</nav>
</div> </div>
<div id="user-setting-modal" class="hs-overlay hidden ti-modal"> <div id="user-setting-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">
...@@ -138,7 +175,7 @@ ...@@ -138,7 +175,7 @@
</h3> </h3>
<div class="flex justify-end"> <div class="flex justify-end">
<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="#company-registration-page-modal"> data-hs-overlay="#user-setting-modal">
<span class="sr-only">Close</span> <span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i> <i class="ti ti-circle-x fs-xxl"></i>
</button> </button>
...@@ -147,7 +184,8 @@ ...@@ -147,7 +184,8 @@
<div class="w-full flex justify-end"> <div class="w-full flex justify-end">
<div class="absolute flex"> <div class="absolute flex">
<div class="px-1"> <div class="px-1">
<button type="button" class="ti-btn ti-btn-soft-indigo h-45px m-0 shadow-md"> <button type="button" class="ti-btn ti-btn-soft-indigo h-45px m-0 shadow-md"
(click)="clearDataUser(currentModal)">
<svg class="svg-indigo" width="16" height="16" viewBox="0 0 64.00 64.00" <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" 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)"> transform="rotate(45)matrix(-1, 0, 0, 1, 0, 0)">
...@@ -178,15 +216,15 @@ ...@@ -178,15 +216,15 @@
<label class="ti-form-label mt-2rem">รหัสพนักงาน</label> <label class="ti-form-label mt-2rem">รหัสพนักงาน</label>
<div class="grid grid-cols-2 gap-2"> <div class="grid grid-cols-2 gap-2">
<div class="relative flex rounded-md"> <div class="relative flex rounded-md">
<input type="text" class="ti-form-input bg-input-readonly" readonly <input type="text" class="ti-form-input" readonly [(ngModel)]="user.select.employee.employeeId">
[(ngModel)]="user.select.empId">
<div <div
class="absolute inset-y-0 ltr:right-0 rtl:left-0 flex items-center z-20 ltr:pr-4 rtl:pl-4 space-x-2"> class="absolute inset-y-0 ltr:right-0 rtl:left-0 flex items-center z-20 ltr:pr-4 rtl:pl-4 space-x-2">
<button type="button" class="flex items-center text-red-500"> <button type="button" class="flex items-center text-red-500" (click)="selectEmployee()">
<i class="ti ti-circle-x cursor-pointer"></i> <i class=" ti ti-circle-x cursor-pointer"></i>
</button> </button>
<button type="button" class="flex items-center text-gray-500 dark:text-white/70" <button type="button" class="flex items-center text-gray-500 dark:text-white/70"
data-hs-overlay="#department-list-bu1-table-modal"> data-hs-overlay="#user-setting-employee-table-modal"
(click)="modal.search='';modal.currentPage=1;searchModalChange(employeeListFilter())">
<i class="ri-search-line cursor-pointer text-gray"></i> <i class="ri-search-line cursor-pointer text-gray"></i>
</button> </button>
</div> </div>
...@@ -194,20 +232,62 @@ ...@@ -194,20 +232,62 @@
<input type="text" class="ti-form-input bg-input-readonly" readonly <input type="text" class="ti-form-input bg-input-readonly" readonly
[(ngModel)]="user.select.employee.thFullName"> [(ngModel)]="user.select.employee.thFullName">
</div> </div>
<!-- <label class="ti-form-label mt-2rem">รายละเอียด (อังกฤษ)</label> <label class="ti-form-label mt-2rem">บทบาท</label>
<input type="text" class="ti-form-input h-16" [(ngModel)]="data.select.edesc"> <div class="grid grid-cols-2 gap-2">
<label class="ti-form-label mt-2rem">ที่อยู่ บริษัท</label> <div class="relative flex rounded-md">
<textarea type="text" rows="2" class="ti-form-input" [(ngModel)]="data.select.address"></textarea> <input type="text" class="ti-form-input" readonly [(ngModel)]="user.select.role.roleId">
<label class="ti-form-label mt-2rem">ข้อมูล ติดต่อ</label> <div
<textarea type="text" rows="2" class="ti-form-input" [(ngModel)]="data.select.contact"></textarea> --> class="absolute inset-y-0 ltr:right-0 rtl:left-0 flex items-center z-20 ltr:pr-4 rtl:pl-4 space-x-2">
<button type="button" class="flex items-center text-red-500" (click)="selectRole()">
<i class=" ti ti-circle-x cursor-pointer"></i>
</button>
<button type="button" class="flex items-center text-gray-500 dark:text-white/70"
data-hs-overlay="#user-setting-role-table-modal"
(click)="modal.search='';modal.currentPage=1;searchModalChange(roleListFilter())">
<i class="ri-search-line cursor-pointer text-gray"></i>
</button>
</div>
</div>
<input type="text" class="ti-form-input bg-input-readonly" readonly
[(ngModel)]="user.select.role.tdesc">
</div>
<label class="ti-form-label mt-2rem">ระดับ</label>
<div class="grid grid-cols-2 gap-2">
<div class="relative flex rounded-md">
<input type="text" class="ti-form-input" readonly [(ngModel)]="user.select.level.userLevel">
<div
class="absolute inset-y-0 ltr:right-0 rtl:left-0 flex items-center z-20 ltr:pr-4 rtl:pl-4 space-x-2">
<button type="button" class="flex items-center text-red-500" (click)="selectLevel()">
<i class=" ti ti-circle-x cursor-pointer"></i>
</button>
<button type="button" class="flex items-center text-gray-500 dark:text-white/70"
data-hs-overlay="#user-setting-level-table-modal"
(click)="modal.search='';modal.currentPage=1;searchModalChange(levelListFilter())">
<i class="ri-search-line cursor-pointer text-gray"></i>
</button>
</div>
</div>
<input type="text" class="ti-form-input bg-input-readonly" readonly
[(ngModel)]="user.select.level.tdesc">
</div>
<label class="ti-form-label mt-2rem">สถานะรหัสผ่าน</label>
<select class="ti-form-select w-1/2" placeholder="Select" [(ngModel)]="user.select.status">
<ng-container *ngIf="currentModal=='add'">
<option [ngValue]="'0'">รหัสผ่านถูกตั้งใหม่</option>
</ng-container>
<ng-container *ngIf="currentModal=='edit'">
<option [ngValue]="'0'">รหัสผ่านถูกตั้งใหม่</option>
<option [ngValue]="'1'">รหัสผ่านถูกใช้งาน</option>
</ng-container>
</select>
<div class="flex justify-end mt-2rem mb-1rem"> <div class="flex justify-end mt-2rem mb-1rem">
<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="#company-registration-page-modal"> data-hs-overlay="#user-setting-modal">
ย้อนกลับ ย้อนกลับ
</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="#company-registration-page-alert-modal"> data-hs-overlay="#user-setting-alert-modal">
บันทึกข้อมูล บันทึกข้อมูล
</a> </a>
</div> </div>
...@@ -216,381 +296,415 @@ ...@@ -216,381 +296,415 @@
</div> </div>
</div> </div>
<!-- <div id="user-settings-component-modal-add" class="hs-overlay hidden ti-modal"> <div id="user-setting-employee-table-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 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">
<h3 class="text-xxl font-bold text-primary"> <h3 class="text-xxl font-bold text-primary">
กำหนดค่าผู้ใช้งานระบบ ข้อมูลพนักงาน
</h3> </h3>
<div class="flex justify-end"> <div class="flex justify-end">
<div class="button-help">
<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>
<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="#user-settings-component-modal-add"> data-hs-overlay="#user-setting-modal">
<span class="sr-only">Close</span> <span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i> <i class="ti ti-circle-x fs-xxl"></i>
</button> </button>
</div> </div>
</div> </div>
<div class="ti-modal-body-content " style="margin-top: 60px;"> <div class="ti-modal-body">
<div class="checkbox-container text-primary" <div class="flex justify-end pb-1rem">
style="display: flex; justify-content: flex-end; gap: 3px; margin-bottom: 10px;"> <div class="px-1">
<label style="display: flex; align-items: center; margin-right: 20px;"> <div class="relative shadow-md">
<input type="checkbox" style="transform: scale(0.6); margin-right: 2px;">ใช้งาน <input type="text" id="hs-leading-icon" name="hs-leading-icon"
</label> class="ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 "
<label style="display: flex; align-items: center;"> placeholder="Search by No. or Name" [(ngModel)]="modal.search"
<input type="checkbox" style="transform: scale(0.6); margin-right: 2px;">ไม่ใช้งาน (ngModelChange)="searchModalChange(employeeListFilter())">
</label>
</div>
<form class="space-y-3">
<div class="sm:grid grid-cols-12 gap-x-6">
<label class="col-span-3 ti-form-label text-primary mt-2">ชื่อล็อคอิน</label>
<input type="email" class="sm:col-span-4 ti-form-input" placeholder="">
</div>
<div class="sm:grid grid-cols-12 gap-x-6">
<label class="col-span-3 ti-form-label text-primary mt-4">รหัสพนักงาน</label>
<div class="col-span-3 relative mt-2">
<div>
<div class="relative flex rounded-md">
<input type="text" id="hs-leading-button-add-on-with-icon-and-button"
name="hs-leading-button-add-on-with-icon-and-button"
class="ti-form-input ltr:pr-11 rtl:pl-11 rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10">
<div
class="absolute inset-y-0 ltr:right-0 rtl:left-0 flex items-center pointer-events-none z-20 ltr:pr-4 rtl:pl-4">
<svg class="h-4 w-4 text-gray-500 dark:text-white/70"
xmlns="http://www.w3.org/2000/svg" width="16" height="16"
fill="currentColor" viewBox="0 0 16 16">
<path
d="M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z" />
</svg>
</div>
</div>
</div>
</div>
<div class="flex col-span-4 relative mt-2">
<input type="password" class="ti-form-input bg-input-readonly" disabled placeholder="">
</div>
</div>
<div class="sm:grid grid-cols-12 gap-x-6">
<label class="col-span-3 ti-form-label text-primary mt-4">บทบาท</label>
<div class="col-span-3 relative mt-2">
<div>
<div class="relative flex rounded-md">
<input type="text" id="hs-leading-button-add-on-with-icon-and-button"
name="hs-leading-button-add-on-with-icon-and-button"
class="ti-form-input ltr:pr-11 rtl:pl-11 rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10">
<div <div
class="absolute inset-y-0 ltr:right-0 rtl:left-0 flex items-center pointer-events-none z-20 ltr:pr-4 rtl:pl-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">
<svg class="h-4 w-4 text-gray-500 dark:text-white/70" <i class="ri-search-line text-gray"></i>
xmlns="http://www.w3.org/2000/svg" width="16" height="16"
fill="currentColor" viewBox="0 0 16 16">
<path
d="M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z" />
</svg>
</div>
</div>
</div>
</div>
<div class="flex col-span-4 relative mt-2">
<input type="password" class="ti-form-input bg-input-readonly" disabled placeholder="">
</div>
</div> </div>
<div class="sm:grid grid-cols-12 gap-x-6">
<label class="col-span-3 ti-form-label text-primary mt-4">ระดับ</label>
<div class="col-span-3 relative mt-2">
<div>
<div class="relative flex rounded-md">
<input type="text" id="hs-leading-button-add-on-with-icon-and-button"
name="hs-leading-button-add-on-with-icon-and-button"
class="ti-form-input ltr:pr-11 rtl:pl-11 rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10">
<div
class="absolute inset-y-0 ltr:right-0 rtl:left-0 flex items-center pointer-events-none z-20 ltr:pr-4 rtl:pl-4">
<svg class="h-4 w-4 text-gray-500 dark:text-white/70"
xmlns="http://www.w3.org/2000/svg" width="16" height="16"
fill="currentColor" viewBox="0 0 16 16">
<path
d="M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z" />
</svg>
</div> </div>
</div> </div>
</div> </div>
<div class="page px-rem">
<div class="overflow-auto table-bordered rounded-t-md">
<div class="overflow-auto shadow-md rounded-t-md">
<table class="ti-custom-table ti-custom-table-head ti-custom-table-hover">
<thead>
<tr>
<ng-container
*ngFor="let item of ['รหัสพนักงาน','ชื่อ','นามสกุล','ตำแหน่ง','หน่วยงาน']; let f = first; let l = last; let i = index">
<th scope="col"
class=" px-10px py-10px bg-soft-secondary text-primary !text-center">
<span class="font-size-12px font-weight-700">{{ item }}</span>
<div class="absolute top-1/2 transform -translate-y-1/2 right-0">
<i class="ti ti-dots-vertical fs-l"></i>
</div> </div>
<div class="flex col-span-4 relative mt-2"> </th>
<input type="password" class="ti-form-input bg-input-readonly" disabled placeholder=""> </ng-container>
</tr>
</thead>
<tbody *ngIf="employee.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> </div>
</td>
</tr>
</tbody>
<tbody *ngIf="!employee.loading&&!employeeListFilter().length">
<tr>
<td class="text-center" colspan="100%">
ไม่พบข้อมูล
</td>
</tr>
</tbody>
<tbody *ngIf="!employee.loading&&employeeListFilter().length">
<tr *ngFor="let item of employeeListFilter() | slice:((modal.currentPage-1) * 10) : (((modal.currentPage-1) * 10) + 10);let i = index"
class="cursor-pointer" (click)="selectEmployee(item.data)"
data-hs-overlay="#user-setting-modal">
<td class="text-center">
{{item.data.employeeId}}
</td>
<td>{{item.data.fname}}</td>
<td>{{item.data.lname}}</td>
<td>{{item.data.position.tdesc}}</td>
<td>{{item.data.jobCode.bu1.tdesc}}</td>
</tr>
</tbody>
</table>
</div> </div>
<div class="sm:grid grid-cols-12 gap-x-6 mt-4">
<label class="col-span-3 ti-form-label text-primary mt-2">สถานะรหัสผ่าน</label>
<div class="col-span-6 mt-2 flex">
<select class="ti-form-input flex">
<option value="1">รหัสผ่านถูกตั้งใหม่เเล้ว</option>
</select>
</div> </div>
<nav class="pagination-style-3 overflow-auto 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 {{employeeListFilter().length<10
?employeeListFilter().length: (modal.currentPage==modal.page.length ?
((modal.currentPage * 10) - ((modal.currentPage * 10) - employeeListFilter().length)
) :(modal.currentPage * 10) ) }} of {{employeeListFilter().length}} items</span>
</ul>
</nav>
</div> </div>
</form> <div class="flex justify-end mt-2rem mb-1rem space-x-4">
<div class="flex justify-end mt-2rem mb-1rem space-x-2" style="margin-top: 75px;">
<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="#user-settings-component-modal-add"> data-hs-overlay="#user-setting-modal">
ย้อนกลับ ย้อนกลับ
</button> </button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#user-settings-component-alert-modal">
บันทึกข้อมูล
</a>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div id="user-settings-component-modal-edit" class="hs-overlay hidden ti-modal"> <div id="user-setting-role-table-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 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">
<h3 class="text-xxl font-bold text-primary"> <h3 class="text-xxl font-bold text-primary">
แก้ไขข้อมูลกลุ่มพนักงาน ข้อมูลบทบาท
</h3> </h3>
<div class="flex justify-end"> <div class="flex justify-end">
<div class="button-help">
<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>
<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="#user-settings-component-modal-edit"> data-hs-overlay="#user-setting-modal">
<span class="sr-only">Close</span> <span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i> <i class="ti ti-circle-x fs-xxl"></i>
</button> </button>
</div> </div>
</div> </div>
<div class="ti-modal-body-content " style="margin-top: 60px;"> <div class="ti-modal-body">
<div class="checkbox-container text-primary" <div class="flex justify-end pb-1rem">
style="display: flex; justify-content: flex-end; gap: 3px; margin-bottom: 10px;"> <div class="px-1">
<label style="display: flex; align-items: center; margin-right: 20px;"> <div class="relative shadow-md">
<input type="checkbox" style="transform: scale(0.6); margin-right: 2px;">ใช้งาน <input type="text" id="hs-leading-icon" name="hs-leading-icon"
</label> class="ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 "
<label style="display: flex; align-items: center;"> placeholder="Search by No. or Name" [(ngModel)]="modal.search"
<input type="checkbox" style="transform: scale(0.6); margin-right: 2px;">ไม่ใช้งาน (ngModelChange)="searchModalChange(roleListFilter())">
</label>
</div>
<form class="space-y-3">
<div class="sm:grid grid-cols-12 gap-x-6">
<label class="col-span-3 ti-form-label text-primary mt-2">ชื่อล็อคอิน</label>
<input type="email" class="sm:col-span-4 ti-form-input" placeholder="">
</div>
<div class="sm:grid grid-cols-12 gap-x-6">
<label class="col-span-3 ti-form-label text-primary mt-4">รหัสพนักงาน</label>
<div class="col-span-3 relative mt-2">
<div>
<div class="relative flex rounded-md">
<input type="text" id="hs-leading-button-add-on-with-icon-and-button"
name="hs-leading-button-add-on-with-icon-and-button"
class="ti-form-input ltr:pr-11 rtl:pl-11 rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10">
<div
class="absolute inset-y-0 ltr:right-0 rtl:left-0 flex items-center pointer-events-none z-20 ltr:pr-4 rtl:pl-4">
<svg class="h-4 w-4 text-gray-500 dark:text-white/70"
xmlns="http://www.w3.org/2000/svg" width="16" height="16"
fill="currentColor" viewBox="0 0 16 16">
<path
d="M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z" />
</svg>
</div>
</div>
</div>
</div>
<div class="flex col-span-4 relative mt-2">
<input type="password" class="ti-form-input bg-input-readonly" disabled placeholder="">
</div>
</div>
<div class="sm:grid grid-cols-12 gap-x-6">
<label class="col-span-3 ti-form-label text-primary mt-4">บทบาท</label>
<div class="col-span-3 relative mt-2">
<div>
<div class="relative flex rounded-md">
<input type="text" id="hs-leading-button-add-on-with-icon-and-button"
name="hs-leading-button-add-on-with-icon-and-button"
class="ti-form-input ltr:pr-11 rtl:pl-11 rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10">
<div <div
class="absolute inset-y-0 ltr:right-0 rtl:left-0 flex items-center pointer-events-none z-20 ltr:pr-4 rtl:pl-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">
<svg class="h-4 w-4 text-gray-500 dark:text-white/70" <i class="ri-search-line text-gray"></i>
xmlns="http://www.w3.org/2000/svg" width="16" height="16"
fill="currentColor" viewBox="0 0 16 16">
<path
d="M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z" />
</svg>
</div>
</div>
</div>
</div>
<div class="flex col-span-4 relative mt-2">
<input type="password" class="ti-form-input bg-input-readonly" disabled placeholder="">
</div>
</div> </div>
<div class="sm:grid grid-cols-12 gap-x-6">
<label class="col-span-3 ti-form-label text-primary mt-4">ระดับ</label>
<div class="col-span-3 relative mt-2">
<div>
<div class="relative flex rounded-md">
<input type="text" id="hs-leading-button-add-on-with-icon-and-button"
name="hs-leading-button-add-on-with-icon-and-button"
class="ti-form-input ltr:pr-11 rtl:pl-11 rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10">
<div
class="absolute inset-y-0 ltr:right-0 rtl:left-0 flex items-center pointer-events-none z-20 ltr:pr-4 rtl:pl-4">
<svg class="h-4 w-4 text-gray-500 dark:text-white/70"
xmlns="http://www.w3.org/2000/svg" width="16" height="16"
fill="currentColor" viewBox="0 0 16 16">
<path
d="M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0z" />
</svg>
</div> </div>
</div> </div>
</div> </div>
<div class="page px-rem">
<div class="overflow-auto table-bordered rounded-t-md">
<div class="overflow-auto shadow-md rounded-t-md">
<table class="ti-custom-table ti-custom-table-head ti-custom-table-hover">
<thead>
<tr>
<ng-container
*ngFor="let item of ['รหัสบทบาท','ชื่อ']; let f = first; let l = last; let i = index">
<th scope="col"
class=" px-10px py-10px bg-soft-secondary text-primary !text-center">
<span class="font-size-12px font-weight-700">{{ item }}</span>
<div class="absolute top-1/2 transform -translate-y-1/2 right-0">
<i class="ti ti-dots-vertical fs-l"></i>
</div> </div>
<div class="flex col-span-4 relative mt-2"> </th>
<input type="password" class="ti-form-input bg-input-readonly" disabled placeholder=""> </ng-container>
</tr>
</thead>
<tbody *ngIf="employee.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> </div>
</td>
</tr>
</tbody>
<tbody *ngIf="!employee.loading&&!roleListFilter().length">
<tr>
<td class="text-center" colspan="100%">
ไม่พบข้อมูล
</td>
</tr>
</tbody>
<tbody *ngIf="!employee.loading&&roleListFilter().length">
<tr *ngFor="let item of roleListFilter() | slice:((modal.currentPage-1) * 10) : (((modal.currentPage-1) * 10) + 10);let i = index"
class="cursor-pointer" (click)="selectRole(item.data)"
data-hs-overlay="#user-setting-modal">
<td class="text-center">
{{item.data.roleId}}
</td>
<td>{{item.data.tdesc}}</td>
</tr>
</tbody>
</table>
</div> </div>
<div class="sm:grid grid-cols-12 gap-x-6 mt-4">
<label class="col-span-3 ti-form-label text-primary mt-2">สถานะรหัสผ่าน</label>
<div class="col-span-6 mt-2 flex">
<select class="ti-form-input flex">
<option value="1">รหัสผ่านถูกตั้งใหม่เเล้ว</option>
</select>
</div> </div>
<nav class="pagination-style-3 overflow-auto 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 {{roleListFilter().length<10
?roleListFilter().length: (modal.currentPage==modal.page.length ?
((modal.currentPage * 10) - ((modal.currentPage * 10) - roleListFilter().length) )
:(modal.currentPage * 10) ) }} of {{roleListFilter().length}} items</span>
</ul>
</nav>
</div> </div>
</form> <div class="flex justify-end mt-2rem mb-1rem space-x-4">
<div class="flex justify-end mt-2rem mb-1rem space-x-2" style="margin-top: 75px;">
<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="#user-settings-component-modal-edit"> data-hs-overlay="#user-setting-modal">
ย้อนกลับ ย้อนกลับ
</button> </button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#user-settings-component-alert-edit-modal">
บันทึกข้อมูล
</a>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div id="user-settings-component-alert-modal" class="hs-overlay hidden ti-modal"> <div id="user-setting-level-table-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 lg:!max-w-4xl lg:w-full m-3 lg:!mx-auto">
<div class="max-h-full overflow-hidden ti-modal-content-alert w-full"> <div class="max-h-full overflow-hidden ti-modal-content">
<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">
แจ้งเตือน ข้อมูลระดับ
</h3> </h3>
<div class="flex justify-end"> <div class="flex justify-end">
<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="#user-settings-component-alert-modal"> data-hs-overlay="#user-setting-modal">
<span class="sr-only">Close</span> <span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i> <i class="ti ti-circle-x fs-xxl"></i>
</button> </button>
</div> </div>
</div> </div>
<div class="ti-modal-body "> <div class="ti-modal-body">
<p class="mt-1 text-gray-800 dark:text-white/70"> <div class="flex justify-end pb-1rem">
ยืนยันการบันทึกข้อมูลหรือไม่ <div class="px-1">
</p> <div class="relative shadow-md">
<input type="text" id="hs-leading-icon" name="hs-leading-icon"
<div class="flex justify-end mt-2rem mb-1rem"> class="ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 "
<button type="button" placeholder="Search by No. or Name" [(ngModel)]="modal.search"
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" (ngModelChange)="searchModalChange(levelListFilter())">
data-hs-overlay="#user-settings-component-modal-add"> <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">
</button> <i class="ri-search-line text-gray"></i>
<a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#user-settings-component-alert-modal">
บันทึกข้อมูล
</a>
</div>
</div>
</div>
</div> </div>
</div>
<div id="user-settings-component-alert-edit-modal" class="hs-overlay hidden ti-modal">
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)] flex items-center">
<div class="max-h-full overflow-hidden ti-modal-content-alert w-full">
<div class="ti-modal-header">
<h3 class="text-xxl font-bold text-primary">
แจ้งเตือน
</h3>
<div class="flex justify-end">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#user-settings-component-alert-edit-modal">
<span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i>
</button>
</div> </div>
</div> </div>
<div class="ti-modal-body ">
<p class="mt-1 text-gray-800 dark:text-white/70">
ยืนยันการเเก้ไขข้อมูลหรือไม่
</p>
<div class="flex justify-end mt-2rem mb-1rem">
<button type="button"
class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
data-hs-overlay="#user-settings-component-modal-edit">
ย้อนกลับ
</button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#user-settings-component-alert-edit-modal">
บันทึกข้อมูล
</a>
</div> </div>
<div class="page px-rem">
<div class="overflow-auto table-bordered rounded-t-md">
<div class="overflow-auto shadow-md rounded-t-md">
<table class="ti-custom-table ti-custom-table-head ti-custom-table-hover">
<thead>
<tr>
<ng-container
*ngFor="let item of ['รหัสระดับ','ชื่อ']; let f = first; let l = last; let i = index">
<th scope="col"
class=" px-10px py-10px bg-soft-secondary text-primary !text-center">
<span class="font-size-12px font-weight-700">{{ item }}</span>
<div class="absolute top-1/2 transform -translate-y-1/2 right-0">
<i class="ti ti-dots-vertical fs-l"></i>
</div> </div>
</th>
</ng-container>
</tr>
</thead>
<tbody *ngIf="level.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> </div>
</td>
</tr>
</tbody>
<tbody *ngIf="!level.loading&&!levelListFilter().length">
<tr>
<td class="text-center" colspan="100%">
ไม่พบข้อมูล
</td>
</tr>
</tbody>
<tbody *ngIf="!level.loading&&levelListFilter().length">
<tr *ngFor="let item of levelListFilter() | slice:((modal.currentPage-1) * 10) : (((modal.currentPage-1) * 10) + 10);let i = index"
class="cursor-pointer" (click)="selectLevel(item.data)"
data-hs-overlay="#user-setting-modal">
<td class="text-center">
{{item.data.userLevel}}
</td>
<td>{{item.data.tdesc}}</td>
</tr>
</tbody>
</table>
</div> </div>
</div>
<div id="user-settings-component-alert-delete-modal" class="hs-overlay hidden ti-modal">
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)] flex items-center">
<div class="max-h-full overflow-hidden ti-modal-content-alert w-full">
<div class="ti-modal-header">
<h3 class="text-xxl font-bold text-primary">
แจ้งเตือน
</h3>
<div class="flex justify-end">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#user-settings-component-alert-delete-modal">
<span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i>
</button>
</div> </div>
<nav class="pagination-style-3 overflow-auto 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 {{levelListFilter().length<10
?levelListFilter().length: (modal.currentPage==modal.page.length ?
((modal.currentPage * 10) - ((modal.currentPage * 10) - levelListFilter().length) )
:(modal.currentPage * 10) ) }} of {{levelListFilter().length}} items</span>
</ul>
</nav>
</div> </div>
<div class="ti-modal-body "> <div class="flex justify-end mt-2rem mb-1rem space-x-4">
<p class="mt-1 text-gray-800 dark:text-white/70">
ยืนยันการลบข้อมูลหรือไม่!
</p>
<div class="flex justify-end mt-2rem mb-1rem">
<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="#user-settings-component-alert-delete-modal"> data-hs-overlay="#user-setting-modal">
ย้อนกลับ ย้อนกลับ
</button> </button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#user-settings-component-alert-delete-modal">
ลบข้อมูล
</a>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> --> </div>
<div id="user-setting-upload-modal" class="hs-overlay hidden ti-modal"> <div id="user-setting-upload-modal" class="hs-overlay hidden ti-modal">
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out rounded-md"> <div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out rounded-md">
...@@ -621,3 +735,66 @@ ...@@ -621,3 +735,66 @@
</div> </div>
</div> </div>
</div> </div>
<div id="user-setting-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="currentModal == 'add'||currentModal == 'edit'">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#user-setting-modal">
<span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i>
</button>
</ng-container>
<ng-container *ngIf="currentModal == 'delete'||currentModal == 'deleteGroup'">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#user-setting-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="currentModal == 'add'||currentModal == 'edit'">
ยืนยันการบันทึกข้อมูลหรือไม่!
</ng-container>
<ng-container *ngIf="currentModal == 'delete'||currentModal == 'deleteGroup'">
ยืนยันการลบข้อมูลหรือไม่!
</ng-container>
</p>
<div class="flex justify-end mt-2rem mb-1rem">
<ng-container *ngIf="currentModal == 'add'||currentModal == 'edit'">
<button type="button"
class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
data-hs-overlay="#user-setting-modal">
ย้อนกลับ
</button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#user-setting-alert-modal" (click)="updateUser('post')">
บันทึกข้อมูล
</a>
</ng-container>
<ng-container *ngIf="currentModal == 'delete'||currentModal == 'deleteGroup'">
<button type="button"
class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
data-hs-overlay="#user-setting-alert-modal">
ย้อนกลับ
</button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#user-setting-alert-modal" (click)="updateUser('delete')">
ลบข้อมูล
</a>
</ng-container>
</div>
</div>
</div>
</div>
</div>
\ No newline at end of file
import { ChangeDetectorRef, Component, EventEmitter, Input, Output } from '@angular/core'; import { ChangeDetectorRef, Component, EventEmitter, Input, Output } from '@angular/core';
import { ToastrService } from 'ngx-toastr'; import { ToastrService } from 'ngx-toastr';
import { EmployeeModel, MyEmployeeModel } from 'src/app/shared/model/employee.model'; import { EmployeeModel, MyEmployeeModel } from 'src/app/shared/model/employee.model';
import { LevelModel, MyLevelModel } from 'src/app/shared/model/level.model';
import { MyRoleModel, RoleModel } from 'src/app/shared/model/role.model';
import { MyUserModel, UserModel } from 'src/app/shared/model/user.model'; import { MyUserModel, UserModel } from 'src/app/shared/model/user.model';
import { EmployeeService } from 'src/app/shared/services/employee.service'; import { EmployeeService } from 'src/app/shared/services/employee.service';
import { FileService } from 'src/app/shared/services/file.service'; import { FileService } from 'src/app/shared/services/file.service';
import { UserService } from 'src/app/shared/services/user.service'; import { UserService } from 'src/app/shared/services/user.service';
export interface DataModal {
search: string,
currentPage: number,
page: number[]
}
@Component({ @Component({
selector: 'app-user-settings', selector: 'app-user-settings',
templateUrl: './user-settings.component.html', templateUrl: './user-settings.component.html',
...@@ -14,45 +20,151 @@ import { UserService } from 'src/app/shared/services/user.service'; ...@@ -14,45 +20,151 @@ import { UserService } from 'src/app/shared/services/user.service';
export class UserSettingsComponent { export class UserSettingsComponent {
selectedFile: File | null = null; selectedFile: File | null = null;
selectedFileName: string = 'กรุณาเลือกไฟล์'; selectedFileName: string = 'กรุณาเลือกไฟล์';
currentModal: 'add' | 'edit' = "add" currentModal: 'add' | 'edit' | 'delete' | 'deleteGroup' = "add"
currentPage = 1
page = Array.from({ length: 1 }, (_, i) => i + 1);
modal: DataModal = {
search: "",
currentPage: 1,
page: Array.from({ length: 1 }, (_, i) => i + 1)
}
numDataListChecked = 0
isDataListChecked = false
isDataListCheckedAll = false
companyId = ""
user: { loading: boolean, select: UserModel, dataList: { check: boolean, data: UserModel }[] } = { loading: false, select: new MyUserModel(), dataList: [] } user: { loading: boolean, select: UserModel, dataList: { check: boolean, data: UserModel }[] } = { loading: false, select: new MyUserModel(), dataList: [] }
employee: { loading: boolean, select: EmployeeModel, dataList: { check: boolean, data: EmployeeModel }[] } = { loading: false, select: new MyEmployeeModel(), dataList: [] } employee: { loading: boolean, select: EmployeeModel, dataList: { check: boolean, data: EmployeeModel }[] } = { loading: false, select: new MyEmployeeModel(), dataList: [] }
role: { loading: boolean, select: RoleModel, dataList: { check: boolean, data: RoleModel }[] } = { loading: false, select: new MyRoleModel(), dataList: [] }
level: { loading: boolean, select: LevelModel, dataList: { check: boolean, data: LevelModel }[] } = { loading: false, select: new MyLevelModel(), dataList: [] }
search = ""
constructor(private toastr: ToastrService, constructor(private toastr: ToastrService,
private cdr: ChangeDetectorRef, private cdr: ChangeDetectorRef,
private userService: UserService, private userService: UserService,
private employeeService: EmployeeService, private employeeService: EmployeeService,
private fileService: FileService) { } private fileService: FileService) {
this.companyId = this.decodeJWT(sessionStorage.getItem("accessToken") || '').companyid
}
ngOnInit(): void { ngOnInit(): void {
this.getUserList() this.getUserList()
this.getEmployeeList() this.getEmployeeList()
this.getRoleList()
this.getLevelList()
}
decodeJWT(token: string) {
let base64Url = token.split('.')[1]; // ดึงส่วนที่เป็น Payload
let base64 = base64Url.replace('-', '+').replace('_', '/'); // แก้ไข base64 ให้ถูกต้อง
let jsonPayload = decodeURIComponent(atob(base64).split('').map(function (c) {
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
}).join(''));
return JSON.parse(jsonPayload);
}
getLevelList() {
this.level.loading = true
this.userService.getLevelList().subscribe({
next: response => {
this.level.dataList = response.map(x => ({ check: false, data: new MyLevelModel(x) }))
this.level.loading = false
this.searchChange()
this.cdr.detectChanges()
}, error: error => {
this.level.loading = false
this.cdr.detectChanges()
}
})
}
levelListFilter() {
return this.level.dataList.filter(x => {
const data = x.data
const match = data.userLevel.toLowerCase().includes(this.modal.search.toLowerCase()) ||
data.tdesc.toLowerCase().includes(this.modal.search.toLowerCase())
return match
})
}
selectLevel(data?: LevelModel) {
this.user.select.level = new MyLevelModel(data)
}
getRoleList() {
this.role.loading = true
this.userService.getRoleList().subscribe({
next: response => {
this.role.dataList = response.map(x => ({ check: false, data: new MyRoleModel(x) }))
this.role.loading = false
this.searchChange()
this.cdr.detectChanges()
}, error: error => {
this.role.loading = false
this.cdr.detectChanges()
} }
})
}
roleListFilter() {
return this.role.dataList.filter(x => {
const data = x.data
const match = data.roleId.toLowerCase().includes(this.modal.search.toLowerCase()) ||
data.tdesc.toLowerCase().includes(this.modal.search.toLowerCase())
return match
})
}
selectRole(data?: RoleModel) {
this.user.select.role = new MyRoleModel(data)
}
getEmployeeList() { getEmployeeList() {
this.employee.loading = true this.employee.loading = true
this.employeeService.getList().subscribe(response => { this.employeeService.getList().subscribe({
next: response => {
this.employee.dataList = response.map(x => ({ check: false, data: new MyEmployeeModel(x) })) this.employee.dataList = response.map(x => ({ check: false, data: new MyEmployeeModel(x) }))
this.employee.loading = false this.employee.loading = false
this.searchChange()
this.cdr.detectChanges() this.cdr.detectChanges()
}, error => { }, error: error => {
this.employee.loading = false this.employee.loading = false
this.cdr.detectChanges() this.cdr.detectChanges()
}
})
}
employeeListFilter() {
return this.employee.dataList.filter(x => {
const data = x.data
const match = data.employeeId.toLowerCase().includes(this.modal.search.toLowerCase()) ||
data.thFullName.toLowerCase().includes(this.modal.search.toLowerCase())
return match
}) })
} }
selectEmployee(data?: EmployeeModel) {
this.user.select.employee = new MyEmployeeModel(data)
}
getUserList() { getUserList() {
this.user.loading = true this.user.loading = true
this.userService.getList().subscribe(response => { this.userService.getList().subscribe({
next: response => {
this.user.dataList = response.map(x => ({ check: false, data: new MyUserModel(x) })) this.user.dataList = response.map(x => ({ check: false, data: new MyUserModel(x) }))
this.isDataListCheckedAll = false
this.dataListCheckAll()
this.user.loading = false this.user.loading = false
this.searchChange()
this.cdr.detectChanges() this.cdr.detectChanges()
}, error => { }, error: error => {
this.user.loading = false this.user.loading = false
this.cdr.detectChanges() this.cdr.detectChanges()
}
}) })
} }
userListFilter() {
selectData(filed: string, data: any) { return this.user.dataList.filter(x => {
(this as any)[filed] = data const data = x.data
const match = data.usernameId.toLowerCase().includes(this.search.toLowerCase()) ||
data.empId.toLowerCase().includes(this.search.toLowerCase()) ||
data.employee.thFullName.toLowerCase().includes(this.search.toLowerCase())
return match
})
}
selectUser(data?: UserModel) {
this.user.select = new MyUserModel({ ...data, companyId: data?.companyId || this.companyId, status: data?.status || '0' })
} }
onFileSelected(event: any) { onFileSelected(event: any) {
this.selectedFile = event.target.files.length > 0 ? event.target.files[0] : null; this.selectedFile = event.target.files.length > 0 ? event.target.files[0] : null;
...@@ -70,6 +182,7 @@ export class UserSettingsComponent { ...@@ -70,6 +182,7 @@ export class UserSettingsComponent {
next: response => { next: response => {
if (response.success) { if (response.success) {
this.showAlert(response.message, 'success') this.showAlert(response.message, 'success')
this.getUserList()
} else { } else {
this.showAlert(response.message, 'error') this.showAlert(response.message, 'error')
this.user.loading = false this.user.loading = false
...@@ -80,9 +193,6 @@ export class UserSettingsComponent { ...@@ -80,9 +193,6 @@ export class UserSettingsComponent {
} }
}) })
} }
selectUser() {
}
downloadFile() { downloadFile() {
const fileName = 'IMPORT_USER.xlsx' const fileName = 'IMPORT_USER.xlsx'
this.fileService.download(fileName).subscribe({ this.fileService.download(fileName).subscribe({
...@@ -102,10 +212,111 @@ export class UserSettingsComponent { ...@@ -102,10 +212,111 @@ export class UserSettingsComponent {
} }
updateUser(typeApi: 'post' | 'delete') {
if (this.currentModal == 'add') {
this.user.loading = true
this.userService.checkUser(this.user.select.usernameId).subscribe({
next: response => {
if (response.success) {
this.updateUserApi(typeApi)
} else {
this.showAlert(response.message, 'error')
this.user.loading = false
}
this.cdr.detectChanges()
}, error: error => {
this.showAlert(error.message, 'error')
this.user.loading = false
this.cdr.detectChanges()
}
})
} else {
this.updateUserApi(typeApi)
}
}
updateUserApi(typeApi: 'post' | 'delete') {
this.user.loading = true
let body: UserModel | UserModel[]
switch (this.currentModal) {
case ('delete'): {
body = [new MyUserModel(this.user.select)]
break;
}
case ('deleteGroup'): {
body = this.user.dataList.filter(x => x.check).map(x => new MyUserModel(x.data))
break;
}
default: {
body = new MyUserModel(this.user.select)
}
}
this.userService[typeApi]((body as any)).subscribe({
next: response => {
if (response.success) {
this.showAlert(response.message, 'success')
this.getUserList()
this.searchChange()
} else {
this.showAlert(response.message, 'error')
this.user.loading = false
}
this.cdr.detectChanges()
}, error: error => {
this.showAlert(error.message, 'error')
this.user.loading = false
this.cdr.detectChanges()
}
})
}
searchChange() {
this.currentPage = 1
this.page = Array.from({ length: Math.ceil(this.userListFilter().length / 10) }, (_, i) => i + 1);
this.dataListCheck()
}
searchModalChange(dataList: any[]) {
this.modal.currentPage = 1
this.modal.page = Array.from({ length: Math.ceil(dataList.length / 10) }, (_, i) => i + 1);
this.cdr.markForCheck()
}
selectDataModal(target: { [key: string]: any }, field: string, data: any) {
target[field] = JSON.parse(JSON.stringify(data))
}
clearDataUser(currentModal: string) {
if (currentModal == 'add') {
this.user.select.usernameId = ''
this.user.select.employee.employeeId = ''
this.user.select.role.roleId = ''
this.user.select.level.userLevel = ''
} else if (currentModal == 'edit') {
this.user.select.employee.employeeId = ''
this.user.select.role.roleId = ''
this.user.select.level.userLevel = ''
}
}
showAlert(text: string, type: 'success' | 'error') { showAlert(text: string, type: 'success' | 'error') {
this.toastr[type](text, 'แจ้งเตือน', { this.toastr[type](text, 'แจ้งเตือน', {
timeOut: 3000, timeOut: 3000,
positionClass: 'toast-top-right', positionClass: 'toast-top-right',
}) })
} }
dataListCheckAll() {
const selectAll = this.isDataListCheckedAll;
this.user.dataList.filter(x => {
const data = x.data
const match = data.usernameId.toLowerCase().includes(this.search.toLowerCase()) ||
data.empId.toLowerCase().includes(this.search.toLowerCase()) ||
data.employee.thFullName.toLowerCase().includes(this.search.toLowerCase())
return match
}).forEach(x => x.check = selectAll);
this.dataListCheck();
}
dataListCheck() {
const dataCheck = this.userListFilter();
this.isDataListCheckedAll = dataCheck.length ? dataCheck.every(x => x.check) : false;
this.numDataListChecked = this.user.dataList.filter(x => x.check).length;
this.isDataListChecked = Boolean(this.numDataListChecked)
}
} }
<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 pr-2 pb-2rem">
<div class="flex">
<div class="flex items-center">
<input type="checkbox" class="ti-form-checkbox pointer-events-none" id="hs-default-checkbox"
[(ngModel)]="isDataListChecked">
<label for="hs-default-checkbox" class="text-sm text-gray-500 mx-2 pointer-events-none">
{{numDataListChecked}} Selected</label>
</div>
<div class="mx-1 flex items-center">
<button (click)="isDataListCheckedAll = !isDataListCheckedAll;dataListCheckAll()"
class="focus:ring-2 focus:ring-primary rounded-sm flex item-center">
<i class="fs-l transition-all duration-200"
[ngClass]="{'ri-checkbox-multiple-line text-gray-500': !isDataListCheckedAll, 'ri-checkbox-multiple-fill text-primary': isDataListCheckedAll}"></i>
</button>
<label class="text-sm text-gray-500 ml-2">Select All</label>
</div>
</div>
</div>
<div class="flex justify-between"> <div class="flex justify-between">
<div class="flex pr-2"> <div class="flex pr-2">
<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="#employee-categories-upload-modal"> data-hs-overlay="#employee-categories-upload-modal"
(click)="fileInput.value = '';selectedFile=null;selectedFileName = 'กรุณาเลือกไฟล์'">
<i class="ri-add-line"></i> <i class="ri-add-line"></i>
นำเข้าข้อมูล นำเข้าข้อมูล
</button> </button>
...@@ -34,7 +53,8 @@ ...@@ -34,7 +53,8 @@
</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="#employee-categories-page-alert-modal" (click)="modalStatus='deleteGroup';setData()"> data-hs-overlay="#employee-categories-page-alert-modal"
(click)="modalStatus='deleteGroup';setData()">
<i class="ri-delete-bin-6-line"></i> <i class="ri-delete-bin-6-line"></i>
Delete Delete
</button> </button>
...@@ -70,8 +90,8 @@ ...@@ -70,8 +90,8 @@
<tbody *ngIf="dataLoading"> <tbody *ngIf="dataLoading">
<tr> <tr>
<td class="text-center" colspan="100%"> <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" <div *ngFor="let item of [1,2,3]" class="ti-spinner w-8 h-8 text-secondary mx-1"
aria-label="loading"> role="status" aria-label="loading">
<span class="sr-only">Loading...</span> <span class="sr-only">Loading...</span>
</div> </div>
</td> </td>
...@@ -88,14 +108,16 @@ ...@@ -88,14 +108,16 @@
<tr <tr
*ngFor="let item of emp_typeListFilter() | slice:((currentPage-1) * 10) : (((currentPage-1) * 10) + 10);let i = index"> *ngFor="let item of emp_typeListFilter() | slice:((currentPage-1) * 10) : (((currentPage-1) * 10) + 10);let i = index">
<td class="text-center"> <td class="text-center">
<input *ngIf="item.data.codeId!='100'" type="checkbox" class="ti-form-checkbox cursor-pointer" id="checkbox-{{item.data.codeId}}" <input *ngIf="item.data.codeId!='100'" type="checkbox"
[(ngModel)]="item.check"> class="ti-form-checkbox cursor-pointer" id="checkbox-{{item.data.codeId}}"
[(ngModel)]="item.check" (ngModelChange)="dataListCheck()">
<label for="checkbox-{{item.data.codeId}}">&nbsp;{{item.data.codeId}}</label> <label for="checkbox-{{item.data.codeId}}">&nbsp;{{item.data.codeId}}</label>
</td> </td>
<td>{{item.data.tdesc}}</td> <td>{{item.data.tdesc}}</td>
<td>{{item.data.edesc}}</td> <td>{{item.data.edesc}}</td>
<td class="flex justify-center"> <td class="flex justify-center">
<i class="ti ti-edit cursor-pointer i-gray fs-l px-1" (click)="modalStatus='edit';setData(item.data)" <i class="ti ti-edit cursor-pointer i-gray fs-l px-1"
(click)="modalStatus='edit';setData(item.data)"
data-hs-overlay="#employee-categories-page-modal"></i> data-hs-overlay="#employee-categories-page-modal"></i>
<i class="ti ti-trash cursor-pointer i-gray fs-l px-1" *ngIf="item.data.codeId!='100'" <i class="ti ti-trash cursor-pointer i-gray fs-l px-1" *ngIf="item.data.codeId!='100'"
(click)="modalStatus='delete';setData(item.data)" (click)="modalStatus='delete';setData(item.data)"
...@@ -139,8 +161,8 @@ ...@@ -139,8 +161,8 @@
</ul> </ul>
<ul class="nav-tabs mt-3"> <ul class="nav-tabs mt-3">
<span>Show {{((currentPage-1) * 10)+1}} to {{emp_typeListFilter().length<10 ?emp_typeListFilter().length: <span>Show {{((currentPage-1) * 10)+1}} to {{emp_typeListFilter().length<10 ?emp_typeListFilter().length:
(currentPage==page.length ? ((currentPage * 10) - ((currentPage * 10) - emp_typeListFilter().length) ) (currentPage==page.length ? ((currentPage * 10) - ((currentPage * 10) - emp_typeListFilter().length)
:(currentPage * 10) ) }} of {{emp_typeListFilter().length}} items</span> ) :(currentPage * 10) ) }} of {{emp_typeListFilter().length}} items</span>
</ul> </ul>
</nav> </nav>
</div> </div>
...@@ -164,7 +186,8 @@ ...@@ -164,7 +186,8 @@
<div class="ti-modal-center"> <div class="ti-modal-center">
<div class="flex justify-end" style="padding-right: 1rem;"> <div class="flex justify-end" style="padding-right: 1rem;">
<div class="px-1"> <div class="px-1">
<button type="button" class="ti-btn ti-btn-soft-indigo h-45px m-0 shadow-md"> <button type="button" class="ti-btn ti-btn-soft-indigo h-45px m-0 shadow-md"
(click)="clearEmp_type(modalStatus)">
<svg class="svg-indigo" width="16" height="16" viewBox="0 0 64.00 64.00" <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" 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)"> transform="rotate(45)matrix(-1, 0, 0, 1, 0, 0)">
...@@ -189,9 +212,11 @@ ...@@ -189,9 +212,11 @@
</div> </div>
</div> </div>
<div class="ti-modal-body" style="margin-top: 40px;"> <div class="ti-modal-body" style="margin-top: 40px;">
<label for="input-label" class="ti-form-label">รหัสประเภทพนักงาน</label> <label for="input-label" class="ti-form-label">รหัสประเภทพนักงาน*</label>
<input type="text" id="input-label" class="ti-form-input w-1/2" [ngClass]="{'bg-input-readonly':modalStatus=='edit'}" [readonly]="modalStatus=='edit'" [(ngModel)]="dataSelect.codeId"> <input type="text" id="input-label" class="ti-form-input w-1/2"
<label for="detail_th" class="ti-form-label mt-2rem">รายละเอียด (ไทย)</label> [ngClass]="{'bg-input-readonly':modalStatus=='edit'}" [readonly]="modalStatus=='edit'"
[(ngModel)]="dataSelect.codeId">
<label for="detail_th" class="ti-form-label mt-2rem">รายละเอียด (ไทย)*</label>
<input type="text" id="detail_th" class="ti-form-input h-16" [(ngModel)]="dataSelect.tdesc"> <input type="text" id="detail_th" class="ti-form-input h-16" [(ngModel)]="dataSelect.tdesc">
<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" [(ngModel)]="dataSelect.edesc"> <input type="text" id="detail_eng" class="ti-form-input h-16" [(ngModel)]="dataSelect.edesc">
...@@ -201,10 +226,12 @@ ...@@ -201,10 +226,12 @@
data-hs-overlay="#employee-categories-page-modal"> data-hs-overlay="#employee-categories-page-modal">
ย้อนกลับ ย้อนกลับ
</button> </button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);" <button type="button" class="ti-btn ti-btn-success"
data-hs-overlay="#employee-categories-page-alert-modal"> data-hs-overlay="#employee-categories-page-alert-modal"
[class.ti-btn-disabled]="!dataSelect.codeId||!dataSelect.tdesc"
[disabled]="!dataSelect.codeId||!dataSelect.tdesc">
บันทึกข้อมูล บันทึกข้อมูล
</a> </button>
</div> </div>
</div> </div>
</div> </div>
...@@ -221,7 +248,7 @@ ...@@ -221,7 +248,7 @@
<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="#employee-categories-page-alert-modal"> data-hs-overlay="#employee-categories-page-modal">
<span class="sr-only">Close</span> <span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i> <i class="ti ti-circle-x fs-xxl"></i>
</button> </button>
...@@ -285,7 +312,7 @@ ...@@ -285,7 +312,7 @@
<h1 class="mt-2" style="text-align: center;">ไฟล์</h1> <h1 class="mt-2" style="text-align: center;">ไฟล์</h1>
<div class="mt-2 p-2"> <div class="mt-2 p-2">
<div class="flex rounded-md"> <div class="flex rounded-md">
<input #fileInput type="file" (change)="onFileSelected($event)" hidden> <input #fileInput id="fileInput" type="file" (change)="onFileSelected($event)" hidden>
<input type="text" [value]="selectedFileName" readonly (click)="fileInput.click()" <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"> 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()" <button type="button" (click)="fileInput.click()"
...@@ -294,8 +321,9 @@ ...@@ -294,8 +321,9 @@
</button> </button>
</div> </div>
<div class="flex justify-center mt-2rem mb-1rem space-x-4"> <div class="flex justify-center mt-2rem mb-1rem space-x-4">
<button type="submit" class="ti-btn ti-btn-secondary" (click)="uploadFile()" <button type="submit" class="ti-btn ti-btn-secondary"
[disabled]="!selectedFile"> data-hs-overlay="#employee-categories-upload-modal" [class.ti-btn-disabled]="!selectedFile"
(click)="uploadFile()" [disabled]="!selectedFile" [disabled]="!selectedFile">
อัปโหลด อัปโหลด
</button> </button>
</div> </div>
......
...@@ -16,16 +16,6 @@ export interface DataModel { ...@@ -16,16 +16,6 @@ export interface DataModel {
styleUrls: ['./employee-categories.component.scss'] styleUrls: ['./employee-categories.component.scss']
}) })
export class EmployeeCategories { export class EmployeeCategories {
@Input() pathTitle = ['การจัดการข้อมูลองค์กร', 'ข้อมูลลักษณะงาน', 'กลุ่มพนักงาน']
@Output() sendPathTitle: EventEmitter<string[]> = new EventEmitter<string[]>();
activeTab: string = 'tab1'; // กำหนด tab เริ่มต้น
// ฟังก์ชันในการเปลี่ยนแท็บ
changeTab(tab: { id: string, text: string }) {
this.sendPathTitle.emit(['การจัดการข้อมูลองค์กร', 'ข้อมูลลักษณะงาน', tab.text])
this.activeTab = tab.id;
}
currentPage = 1 currentPage = 1
page = Array.from({ length: 1 }, (_, i) => i + 1); page = Array.from({ length: 1 }, (_, i) => i + 1);
search = "" search = ""
...@@ -39,6 +29,9 @@ export class EmployeeCategories { ...@@ -39,6 +29,9 @@ export class EmployeeCategories {
selectedFile: File | null = null; selectedFile: File | null = null;
selectedFileName: string = 'กรุณาเลือกไฟล์'; selectedFileName: string = 'กรุณาเลือกไฟล์';
numDataListChecked = 0
isDataListChecked = false
isDataListCheckedAll = false
constructor(private empTypeService: EmpTypeService, constructor(private empTypeService: EmpTypeService,
private toastr: ToastrService, private toastr: ToastrService,
private cdr: ChangeDetectorRef, private cdr: ChangeDetectorRef,
...@@ -59,6 +52,7 @@ export class EmployeeCategories { ...@@ -59,6 +52,7 @@ export class EmployeeCategories {
return return
} }
const formData = new FormData(); const formData = new FormData();
this.dataLoading = true
formData.append('file', this.selectedFile); formData.append('file', this.selectedFile);
this.fileService.upload(formData, 'employment_type').subscribe({ this.fileService.upload(formData, 'employment_type').subscribe({
next: response => { next: response => {
...@@ -67,9 +61,13 @@ export class EmployeeCategories { ...@@ -67,9 +61,13 @@ export class EmployeeCategories {
this.getEmpTypeList() this.getEmpTypeList()
} else { } else {
this.showAlert(response.message, 'error') this.showAlert(response.message, 'error')
this.dataLoading = false
this.cdr.detectChanges();
} }
}, error: error => { }, error: error => {
this.showAlert(error.message, 'error') this.showAlert(error.message, 'error')
this.dataLoading = false
this.cdr.detectChanges();
} }
}) })
} }
...@@ -99,6 +97,8 @@ export class EmployeeCategories { ...@@ -99,6 +97,8 @@ export class EmployeeCategories {
next: response => { next: response => {
this.emp_typelist = response.map(x => ({ check: false, data: { codeId: x.codeId, tdesc: x.tdesc, edesc: x.edesc, companyId: x.companyId } })) this.emp_typelist = response.map(x => ({ check: false, data: { codeId: x.codeId, tdesc: x.tdesc, edesc: x.edesc, companyId: x.companyId } }))
this.dataLoading = false this.dataLoading = false
this.isDataListCheckedAll = false
this.dataListCheckAll()
this.searchChange(); this.searchChange();
this.cdr.detectChanges(); this.cdr.detectChanges();
}, error: error => { }, error: error => {
...@@ -112,11 +112,12 @@ export class EmployeeCategories { ...@@ -112,11 +112,12 @@ export class EmployeeCategories {
searchChange() { searchChange() {
this.currentPage = 1 this.currentPage = 1
this.page = Array.from({ length: Math.ceil(this.emp_typeListFilter().length / 10) }, (_, i) => i + 1); this.page = Array.from({ length: Math.ceil(this.emp_typeListFilter().length / 10) }, (_, i) => i + 1);
this.dataListCheck()
} }
emp_typeListFilter() { emp_typeListFilter() {
return this.emp_typelist.filter(x => { return this.emp_typelist.filter(x => {
const data = x.data const data = x.data
const match = data.codeId.toLowerCase().includes(this.search) || data.tdesc.toLowerCase().includes(this.search) || data.edesc.toLowerCase().includes(this.search); const match = data.codeId.toLowerCase().includes(this.search.toLowerCase()) || data.tdesc.toLowerCase().includes(this.search.toLowerCase()) || data.edesc.toLowerCase().includes(this.search.toLowerCase());
return match; return match;
}); });
} }
...@@ -126,6 +127,7 @@ export class EmployeeCategories { ...@@ -126,6 +127,7 @@ export class EmployeeCategories {
addEmp_type() { addEmp_type() {
const body = new MyEmpTypeModel({ codeId: this.dataSelect.codeId, tdesc: this.dataSelect.tdesc, edesc: this.dataSelect.edesc, companyId: this.dataSelect.companyId }) const body = new MyEmpTypeModel({ codeId: this.dataSelect.codeId, tdesc: this.dataSelect.tdesc, edesc: this.dataSelect.edesc, companyId: this.dataSelect.companyId })
this.dataLoading = true
this.empTypeService.post(body).subscribe({ this.empTypeService.post(body).subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
...@@ -133,9 +135,13 @@ export class EmployeeCategories { ...@@ -133,9 +135,13 @@ export class EmployeeCategories {
this.getEmpTypeList() this.getEmpTypeList()
} else { } else {
this.showAlert(response.message, 'error') this.showAlert(response.message, 'error')
this.dataLoading = false
this.cdr.detectChanges()
} }
}, error: error => { }, error: error => {
this.showAlert(error.message, 'error') this.showAlert(error.message, 'error')
this.dataLoading = false
this.cdr.detectChanges()
} }
}) })
} }
...@@ -147,6 +153,7 @@ export class EmployeeCategories { ...@@ -147,6 +153,7 @@ export class EmployeeCategories {
} else { } else {
body = this.emp_typelist.filter(x => x.check).map(x => new MyEmpTypeModel({ codeId: x.data.codeId, tdesc: x.data.tdesc, edesc: x.data.edesc, companyId: x.data.companyId })) body = this.emp_typelist.filter(x => x.check).map(x => new MyEmpTypeModel({ codeId: x.data.codeId, tdesc: x.data.tdesc, edesc: x.data.edesc, companyId: x.data.companyId }))
} }
this.dataLoading = true
this.empTypeService.delete(body).subscribe({ this.empTypeService.delete(body).subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
...@@ -154,9 +161,13 @@ export class EmployeeCategories { ...@@ -154,9 +161,13 @@ export class EmployeeCategories {
this.getEmpTypeList() this.getEmpTypeList()
} else { } else {
this.showAlert(response.message, 'error') this.showAlert(response.message, 'error')
this.dataLoading = false
this.cdr.detectChanges()
} }
}, error: error => { }, error: error => {
this.showAlert(error.message, 'error') this.showAlert(error.message, 'error')
this.dataLoading = false
this.cdr.detectChanges()
} }
}) })
} }
...@@ -167,4 +178,32 @@ export class EmployeeCategories { ...@@ -167,4 +178,32 @@ export class EmployeeCategories {
positionClass: 'toast-top-right', positionClass: 'toast-top-right',
}); });
} }
dataListCheckAll() {
const selectAll = this.isDataListCheckedAll;
this.emp_typelist.filter(x => {
const data = x.data
const match = data.codeId.toLowerCase().includes(this.search.toLowerCase()) || data.tdesc.toLowerCase().includes(this.search.toLowerCase()) || data.edesc.toLowerCase().includes(this.search.toLowerCase());
return match;
}).forEach(x => x.check = selectAll);
this.dataListCheck();
}
dataListCheck() {
const dataCheck = this.emp_typeListFilter();
this.isDataListCheckedAll = dataCheck.length ? dataCheck.every(x => x.check) : false;
this.numDataListChecked = this.emp_typelist.filter(x => x.check).length;
this.isDataListChecked = Boolean(this.numDataListChecked)
}
clearEmp_type(modalStatus: string) {
if (modalStatus == 'add') {
this.dataSelect.codeId = ''
this.dataSelect.tdesc = ''
this.dataSelect.edesc = ''
} else if (modalStatus == 'edit') {
this.dataSelect.tdesc = ''
this.dataSelect.edesc = ''
}
}
} }
<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 pr-2 pb-2rem">
<div class="flex">
<div class="flex items-center">
<input type="checkbox" class="ti-form-checkbox pointer-events-none" id="hs-default-checkbox"
[(ngModel)]="isDataListChecked">
<label for="hs-default-checkbox" class="text-sm text-gray-500 mx-2 pointer-events-none">
{{numDataListChecked}} Selected</label>
</div>
<div class="mx-1 flex items-center">
<button (click)="isDataListCheckedAll = !isDataListCheckedAll;dataListCheckAll()"
class="focus:ring-2 focus:ring-primary rounded-sm flex item-center">
<i class="fs-l transition-all duration-200"
[ngClass]="{'ri-checkbox-multiple-line text-gray-500': !isDataListCheckedAll, 'ri-checkbox-multiple-fill text-primary': isDataListCheckedAll}"></i>
</button>
<label class="text-sm text-gray-500 ml-2">Select All</label>
</div>
</div>
</div>
<div class="flex justify-between"> <div class="flex justify-between">
<div class="flex pr-2"> <div class="flex pr-2">
<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="#employee-group-unit-component-upload-modal"> data-hs-overlay="#employee-group-unit-component-upload-modal"
(click)="fileInput.value = '';selectedFile=null;selectedFileName = 'กรุณาเลือกไฟล์'">
<i class="ri-add-line"></i> <i class="ri-add-line"></i>
นำเข้าข้อมูล นำเข้าข้อมูล
</button> </button>
...@@ -34,7 +53,8 @@ ...@@ -34,7 +53,8 @@
</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="#employee-group-unit-component-page-alert-modal" (click)="modalStatus='deleteGroup';setData()"> data-hs-overlay="#employee-group-unit-component-page-alert-modal"
(click)="modalStatus='deleteGroup';setData()">
<i class="ri-delete-bin-6-line"></i> <i class="ri-delete-bin-6-line"></i>
Delete Delete
</button> </button>
...@@ -56,11 +76,6 @@ ...@@ -56,11 +76,6 @@
<ng-container <ng-container
*ngFor="let item of ['รหัสกลุ่มพนักงาน','รายละเอียด(ไทย) ','รายละเอียด(อังกฤษ)','การจัดการ']; let f = first; let l = last; let i = index"> *ngFor="let item of ['รหัสกลุ่มพนักงาน','รายละเอียด(ไทย) ','รายละเอียด(อังกฤษ)','การจัดการ']; let f = first; let l = last; let i = index">
<th scope="col" class="relative px-10px py-10px bg-soft-secondary text-primary !text-center"> <th scope="col" class="relative px-10px py-10px bg-soft-secondary text-primary !text-center">
<span class="font-size-12px font-weight-700">
<ng-container *ngIf="i === 0">
<input type="checkbox" class="ti-form-checkbox cursor-pointer" (change)="toggleSelectAll($event)" style="margin-right: 10px;">
</ng-container>
</span>
<span class="font-size-12px font-weight-700">{{ item }}</span> <span class="font-size-12px font-weight-700">{{ item }}</span>
<div class="absolute top-1/2 transform -translate-y-1/2 right-0" *ngIf="!l"> <div class="absolute top-1/2 transform -translate-y-1/2 right-0" *ngIf="!l">
<i class="ti ti-dots-vertical fs-l"></i> <i class="ti ti-dots-vertical fs-l"></i>
...@@ -90,17 +105,20 @@ ...@@ -90,17 +105,20 @@
<tr <tr
*ngFor="let item of emp_groupListFilter() | slice:((currentPage-1) * 10) : (((currentPage-1) * 10) + 10);let i = index"> *ngFor="let item of emp_groupListFilter() | slice:((currentPage-1) * 10) : (((currentPage-1) * 10) + 10);let i = index">
<td class="text-center"> <td class="text-center">
<input *ngIf="item.data.groupId!='100'" type="checkbox" class="ti-form-checkbox cursor-pointer" id="checkbox-{{item.data.groupId}}" [(ngModel)]="item.check"> <input *ngIf="item.data.groupId!='100'" type="checkbox" class="ti-form-checkbox cursor-pointer"
id="checkbox-{{item.data.groupId}}" [(ngModel)]="item.check"
(ngModelChange)="dataListCheck()">
<label for="checkbox-{{item.data.groupId}}">&nbsp;{{item.data.groupId}}</label> <label for="checkbox-{{item.data.groupId}}">&nbsp;{{item.data.groupId}}</label>
</td> </td>
<td>{{item.data.tdesc}}</td> <td>{{item.data.tdesc}}</td>
<td>{{item.data.edesc}}</td> <td>{{item.data.edesc}}</td>
<td class="flex justify-center"> <td class="flex justify-center">
<i class="ti ti-edit cursor-pointer i-gray fs-l px-1" (click)="modalStatus='edit';setData(item.data)" <i class="ti ti-edit cursor-pointer i-gray fs-l px-1"
(click)="modalStatus='edit';setData(item.data)"
data-hs-overlay="#employee-group-unit-component-page-modal"></i> data-hs-overlay="#employee-group-unit-component-page-modal"></i>
<i class="ti ti-trash cursor-pointer i-gray fs-l px-1" *ngIf="item.data.groupId!='100'" <i class="ti ti-trash cursor-pointer i-gray fs-l px-1" *ngIf="item.data.groupId!='100'"
(click)="modalStatus='delete';setData(item.data)" (click)="modalStatus='delete';setData(item.data)"
data-hs-overlay="#employee-group-unit-component-page-alert-modal" ></i> data-hs-overlay="#employee-group-unit-component-page-alert-modal"></i>
</td> </td>
</tr> </tr>
</tbody> </tbody>
...@@ -139,8 +157,9 @@ ...@@ -139,8 +157,9 @@
</ul> </ul>
<ul class="nav-tabs mt-3"> <ul class="nav-tabs mt-3">
<span>Show {{((currentPage-1) * 10)+1}} to {{emp_groupListFilter().length<10 ?emp_groupListFilter().length: <span>Show {{((currentPage-1) * 10)+1}} to {{emp_groupListFilter().length<10 ?emp_groupListFilter().length:
(currentPage==page.length ? ((currentPage * 10) - ((currentPage * 10) - emp_groupListFilter().length) ) (currentPage==page.length ? ((currentPage * 10) - ((currentPage * 10) -
:(currentPage * 10) ) }} of {{emp_groupListFilter().length}} items</span> emp_groupListFilter().length) ) :(currentPage * 10) ) }} of {{emp_groupListFilter().length}}
items</span>
</ul> </ul>
</nav> </nav>
...@@ -165,7 +184,8 @@ ...@@ -165,7 +184,8 @@
<div class="ti-modal-center"> <div class="ti-modal-center">
<div class="flex justify-end" style="padding-right: 1rem;"> <div class="flex justify-end" style="padding-right: 1rem;">
<div class="px-1"> <div class="px-1">
<button type="button" class="ti-btn ti-btn-soft-indigo h-45px m-0 shadow-md"> <button type="button" class="ti-btn ti-btn-soft-indigo h-45px m-0 shadow-md"
(click)="clearEmp_group(modalStatus)">
<svg class="svg-indigo" width="16" height="16" viewBox="0 0 64.00 64.00" <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" 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)"> transform="rotate(45)matrix(-1, 0, 0, 1, 0, 0)">
...@@ -190,11 +210,13 @@ ...@@ -190,11 +210,13 @@
</div> </div>
</div> </div>
<div class="ti-modal-body "> <div class="ti-modal-body ">
<label for="input-label" class="ti-form-label mt-2rem">รหัสกลุ่มพนักงาน</label> <label for="input-label" class="ti-form-label mt-2rem">รหัสกลุ่มพนักงาน*</label>
<input type="text" id="input-label" class="ti-form-input w-1/2" [ngClass]="{'bg-input-readonly':modalStatus=='edit'}" [readonly]="modalStatus=='edit'" [(ngModel)]="dataSelect.groupId"> <input type="text" id="input-label" class="ti-form-input w-1/2"
<label for="detail_th" class="ti-form-label mt-2rem">รายละเอียดฝ่าย (ไทย)</label> [ngClass]="{'bg-input-readonly':modalStatus=='edit'}" [readonly]="modalStatus=='edit'"
[(ngModel)]="dataSelect.groupId">
<label for="detail_th" class="ti-form-label mt-2rem">รายละเอียดฝ่าย (ไทย)*</label>
<input type="text" id="detail_th" class="ti-form-input h-16" [(ngModel)]="dataSelect.tdesc"> <input type="text" id="detail_th" class="ti-form-input h-16" [(ngModel)]="dataSelect.tdesc">
<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" [(ngModel)]="dataSelect.edesc"> <input type="text" id="detail_eng" class="ti-form-input h-16" [(ngModel)]="dataSelect.edesc">
<div class="flex justify-end mt-2rem mb-1rem space-x-2"> <div class="flex justify-end mt-2rem mb-1rem space-x-2">
<button type="button" <button type="button"
...@@ -202,10 +224,12 @@ ...@@ -202,10 +224,12 @@
data-hs-overlay="#employee-group-unit-component-page-modal"> data-hs-overlay="#employee-group-unit-component-page-modal">
ย้อนกลับ ย้อนกลับ
</button> </button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);" <button type="button" class="ti-btn ti-btn-success"
data-hs-overlay="#employee-group-unit-component-page-alert-modal"> data-hs-overlay="#employee-group-unit-component-page-alert-modal"
[class.ti-btn-disabled]="!dataSelect.groupId||!dataSelect.tdesc"
[disabled]="!dataSelect.groupId||!dataSelect.tdesc">
บันทึกข้อมูล บันทึกข้อมูล
</a> </button>
</div> </div>
</div> </div>
</div> </div>
...@@ -222,7 +246,7 @@ ...@@ -222,7 +246,7 @@
<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="#employee-group-unit-component-page-alert-modal"> data-hs-overlay="#employee-group-unit-component-page-modal">
<span class="sr-only">Close</span> <span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i> <i class="ti ti-circle-x fs-xxl"></i>
</button> </button>
...@@ -265,7 +289,8 @@ ...@@ -265,7 +289,8 @@
ย้อนกลับ ย้อนกลับ
</button> </button>
<a class="ti-btn ti-btn-danger" href="javascript:void(0);" <a class="ti-btn ti-btn-danger" href="javascript:void(0);"
data-hs-overlay="#employee-group-unit-component-page-alert-modal" (click)="deleteEmp_group()"> data-hs-overlay="#employee-group-unit-component-page-alert-modal"
(click)="deleteEmp_group()">
ลบข้อมูล ลบข้อมูล
</a> </a>
</ng-container> </ng-container>
...@@ -286,7 +311,7 @@ ...@@ -286,7 +311,7 @@
<h1 class="mt-2" style="text-align: center;">ไฟล์</h1> <h1 class="mt-2" style="text-align: center;">ไฟล์</h1>
<div class="mt-2 p-2"> <div class="mt-2 p-2">
<div class="flex rounded-md"> <div class="flex rounded-md">
<input #fileInput type="file" (change)="onFileSelected($event)" hidden> <input #fileInput id="fileInput" type="file" (change)="onFileSelected($event)" hidden>
<input type="text" [value]="selectedFileName" readonly (click)="fileInput.click()" <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"> 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()" <button type="button" (click)="fileInput.click()"
...@@ -295,7 +320,9 @@ ...@@ -295,7 +320,9 @@
</button> </button>
</div> </div>
<div class="flex justify-center mt-2rem mb-1rem space-x-4"> <div class="flex justify-center mt-2rem mb-1rem space-x-4">
<button type="submit" class="ti-btn ti-btn-secondary" (click)="uploadFile()" <button type="submit" class="ti-btn ti-btn-secondary"
data-hs-overlay="#employee-group-unit-component-upload-modal"
[class.ti-btn-disabled]="!selectedFile" (click)="uploadFile()" [disabled]="!selectedFile"
[disabled]="!selectedFile"> [disabled]="!selectedFile">
อัปโหลด อัปโหลด
</button> </button>
......
...@@ -17,19 +17,9 @@ export interface DataModel { ...@@ -17,19 +17,9 @@ export interface DataModel {
styleUrls: ['./employee-group-unit.component.scss'] styleUrls: ['./employee-group-unit.component.scss']
}) })
export class EmployeeGroupUnit implements OnInit { export class EmployeeGroupUnit implements OnInit {
@Input() pathTitle = ['การจัดการข้อมูลองค์กร', 'ข้อมูลลักษณะงาน', 'กลุ่มพนักงาน']
@Output() sendPathTitle: EventEmitter<string[]> = new EventEmitter<string[]>();
activeTab: string = 'tab1'; // กำหนด tab เริ่มต้น
// ฟังก์ชันในการเปลี่ยนแท็บ
changeTab(tab: { id: string, text: string }) {
this.sendPathTitle.emit(['การจัดการข้อมูลองค์กร', 'ข้อมูลลักษณะงาน', tab.text])
this.activeTab = tab.id;
}
currentPage = 1 currentPage = 1
selectedItems: string[] = []; selectedItems: string[] = [];
modalStatus = 'add' modalStatus: 'add' | 'edit' | 'delete' | 'deleteGroup' = 'add'
page = Array.from({ length: 1 }, (_, i) => i + 1); page = Array.from({ length: 1 }, (_, i) => i + 1);
dataLoading = false dataLoading = false
dataSelect: DataModel = { groupId: "", tdesc: "", edesc: "", companyId: "", checked: false } dataSelect: DataModel = { groupId: "", tdesc: "", edesc: "", companyId: "", checked: false }
...@@ -39,6 +29,9 @@ export class EmployeeGroupUnit implements OnInit { ...@@ -39,6 +29,9 @@ export class EmployeeGroupUnit implements OnInit {
selectedFile: File | null = null; selectedFile: File | null = null;
selectedFileName: string = 'กรุณาเลือกไฟล์'; selectedFileName: string = 'กรุณาเลือกไฟล์';
numDataListChecked = 0
isDataListChecked = false
isDataListCheckedAll = false
constructor(private empGroupService: EmpGroupService, constructor(private empGroupService: EmpGroupService,
private toastr: ToastrService, private toastr: ToastrService,
private cdr: ChangeDetectorRef, private cdr: ChangeDetectorRef,
...@@ -61,6 +54,7 @@ export class EmployeeGroupUnit implements OnInit { ...@@ -61,6 +54,7 @@ export class EmployeeGroupUnit implements OnInit {
} }
const formData = new FormData(); const formData = new FormData();
formData.append('file', this.selectedFile); formData.append('file', this.selectedFile);
this.dataLoading = true
this.fileService.upload(formData, 'mgroup').subscribe({ this.fileService.upload(formData, 'mgroup').subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
...@@ -68,9 +62,11 @@ export class EmployeeGroupUnit implements OnInit { ...@@ -68,9 +62,11 @@ export class EmployeeGroupUnit implements OnInit {
this.getEmpGroupList() this.getEmpGroupList()
} else { } else {
this.showAlert(response.message, 'error') this.showAlert(response.message, 'error')
this.dataLoading = false
} }
}, error: error => { }, error: error => {
this.showAlert(error.message, 'error') this.showAlert(error.message, 'error')
this.dataLoading = false
} }
}) })
} }
...@@ -101,6 +97,8 @@ export class EmployeeGroupUnit implements OnInit { ...@@ -101,6 +97,8 @@ export class EmployeeGroupUnit implements OnInit {
this.emp_groupList = response.map(x => ({ check: false, data: { groupId: x.groupId, tdesc: x.tdesc, edesc: x.edesc, companyId: x.companyId, checked: false } })) this.emp_groupList = response.map(x => ({ check: false, data: { groupId: x.groupId, tdesc: x.tdesc, edesc: x.edesc, companyId: x.companyId, checked: false } }))
this.dataLoading = false this.dataLoading = false
this.searchChange() this.searchChange()
this.isDataListCheckedAll = false
this.dataListCheckAll()
this.cdr.detectChanges() this.cdr.detectChanges()
}, error: error => { }, error: error => {
this.dataLoading = false this.dataLoading = false
...@@ -112,11 +110,12 @@ export class EmployeeGroupUnit implements OnInit { ...@@ -112,11 +110,12 @@ export class EmployeeGroupUnit implements OnInit {
searchChange() { searchChange() {
this.currentPage = 1 this.currentPage = 1
this.page = Array.from({ length: Math.ceil(this.emp_groupListFilter().length / 10) }, (_, i) => i + 1); this.page = Array.from({ length: Math.ceil(this.emp_groupListFilter().length / 10) }, (_, i) => i + 1);
this.dataListCheck()
} }
emp_groupListFilter() { emp_groupListFilter() {
return this.emp_groupList.filter(x => { return this.emp_groupList.filter(x => {
const data = x.data const data = x.data
const match = data.groupId.toLowerCase().includes(this.search) || data.tdesc.toLowerCase().includes(this.search) || data.edesc.toLowerCase().includes(this.search); const match = data.groupId.toLowerCase().includes(this.search.toLowerCase()) || data.tdesc.toLowerCase().includes(this.search.toLowerCase()) || data.edesc.toLowerCase().includes(this.search.toLowerCase());
return match; return match;
}); });
} }
...@@ -126,6 +125,7 @@ export class EmployeeGroupUnit implements OnInit { ...@@ -126,6 +125,7 @@ export class EmployeeGroupUnit implements OnInit {
addEmp_group() { addEmp_group() {
const body = new MyEmpGroupModel({ groupId: this.dataSelect.groupId, tdesc: this.dataSelect.tdesc, edesc: this.dataSelect.edesc, companyId: this.dataSelect.companyId }) const body = new MyEmpGroupModel({ groupId: this.dataSelect.groupId, tdesc: this.dataSelect.tdesc, edesc: this.dataSelect.edesc, companyId: this.dataSelect.companyId })
this.dataLoading = true
this.empGroupService.post(body).subscribe({ this.empGroupService.post(body).subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
...@@ -133,20 +133,24 @@ export class EmployeeGroupUnit implements OnInit { ...@@ -133,20 +133,24 @@ export class EmployeeGroupUnit implements OnInit {
this.getEmpGroupList() this.getEmpGroupList()
} else { } else {
this.showAlert(response.message, 'error') this.showAlert(response.message, 'error')
this.dataLoading = false
this.cdr.detectChanges()
} }
}, error: error => { }, error: error => {
this.showAlert(error.message, 'error') this.showAlert(error.message, 'error')
this.dataLoading = false
this.cdr.detectChanges()
} }
}) })
} }
deleteEmp_group() { deleteEmp_group() {
let body: EmpGroupModel | EmpGroupModel[] = []; let body: EmpGroupModel | EmpGroupModel[] = [];
if (this.dataSelect.groupId) { if (this.dataSelect.groupId) {
body = new MyEmpGroupModel({groupId: this.dataSelect.groupId, tdesc: this.dataSelect.tdesc, edesc: this.dataSelect.edesc, companyId: this.dataSelect.companyId }); body = new MyEmpGroupModel({ groupId: this.dataSelect.groupId, tdesc: this.dataSelect.tdesc, edesc: this.dataSelect.edesc, companyId: this.dataSelect.companyId });
} else { } else {
body = this.emp_groupList.filter(x => x.check).map(x => new MyEmpGroupModel({ groupId: x.data.groupId, tdesc: x.data.tdesc, edesc: x.data.edesc, companyId: x.data.companyId })); body = this.emp_groupList.filter(x => x.check).map(x => new MyEmpGroupModel({ groupId: x.data.groupId, tdesc: x.data.tdesc, edesc: x.data.edesc, companyId: x.data.companyId }));
} }
this.dataLoading = true
this.empGroupService.delete(body).subscribe({ this.empGroupService.delete(body).subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
...@@ -154,28 +158,34 @@ export class EmployeeGroupUnit implements OnInit { ...@@ -154,28 +158,34 @@ export class EmployeeGroupUnit implements OnInit {
this.getEmpGroupList(); this.getEmpGroupList();
} else { } else {
this.showAlert(response.message, 'error'); this.showAlert(response.message, 'error');
this.dataLoading = false
this.cdr.detectChanges()
} }
}, },
error: error => { error: error => {
this.showAlert(error.message, 'error') this.showAlert(error.message, 'error')
this.dataLoading = false
this.cdr.detectChanges()
} }
}); });
} }
dataListCheckAll() {
toggleSelectAll(event: Event) { const selectAll = this.isDataListCheckedAll;
const checked = (event.target as HTMLInputElement).checked; this.emp_groupList.filter(x => {
const data = x.data
this.emp_groupList.forEach(item => { const match = data.groupId.toLowerCase().includes(this.search.toLowerCase()) || data.tdesc.toLowerCase().includes(this.search.toLowerCase()) || data.edesc.toLowerCase().includes(this.search.toLowerCase());
item.check = checked; // อัปเดตค่า check ใน emp_groupList return match;
}); }).forEach(x => x.check = selectAll);
this.dataListCheck();
// อัปเดตรายการ selectedItems ด้วย groupId ของรายการที่ถูกเลือก
this.selectedItems = checked ? this.emp_groupList.map(item => item.data.groupId) : [];
this.cdr.detectChanges(); // แจ้ง Angular ให้รีเฟรช UI
} }
dataListCheck() {
const dataCheck = this.emp_groupListFilter();
this.isDataListCheckedAll = dataCheck.length ? dataCheck.every(x => x.check) : false;
this.numDataListChecked = this.emp_groupList.filter(x => x.check).length;
this.isDataListChecked = Boolean(this.numDataListChecked)
}
showAlert(text: string, type: 'success' | 'error') { showAlert(text: string, type: 'success' | 'error') {
this.toastr[type](text, 'แจ้งเตือน', { this.toastr[type](text, 'แจ้งเตือน', {
...@@ -183,4 +193,15 @@ export class EmployeeGroupUnit implements OnInit { ...@@ -183,4 +193,15 @@ export class EmployeeGroupUnit implements OnInit {
positionClass: 'toast-top-right', positionClass: 'toast-top-right',
}) })
} }
clearEmp_group(modalStatus: string) {
if (modalStatus == 'add') {
this.dataSelect.groupId = ''
this.dataSelect.tdesc = ''
this.dataSelect.edesc = ''
} else if (modalStatus == 'edit') {
this.dataSelect.tdesc = ''
this.dataSelect.edesc = ''
}
}
} }
<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 pr-2 pb-2rem">
<div class="flex">
<div class="flex items-center">
<input type="checkbox" class="ti-form-checkbox pointer-events-none" id="hs-default-checkbox"
[(ngModel)]="isDataListChecked">
<label for="hs-default-checkbox" class="text-sm text-gray-500 mx-2 pointer-events-none">
{{numDataListChecked}} Selected</label>
</div>
<div class="mx-1 flex items-center">
<button (click)="isDataListCheckedAll = !isDataListCheckedAll;dataListCheckAll()"
class="focus:ring-2 focus:ring-primary rounded-sm flex item-center">
<i class="fs-l transition-all duration-200"
[ngClass]="{'ri-checkbox-multiple-line text-gray-500': !isDataListCheckedAll, 'ri-checkbox-multiple-fill text-primary': isDataListCheckedAll}"></i>
</button>
<label class="text-sm text-gray-500 ml-2">Select All</label>
</div>
</div>
</div>
<div class="flex justify-between"> <div class="flex justify-between">
<div class="flex pr-2"> <div class="flex pr-2">
<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="#employee-level-upload-modal"> data-hs-overlay="#employee-level-upload-modal"
(click)="fileInput.value = '';selectedFile=null;selectedFileName = 'กรุณาเลือกไฟล์'">
<i class="ri-add-line"></i> <i class="ri-add-line"></i>
นำเข้าข้อมูล นำเข้าข้อมูล
</button> </button>
...@@ -88,7 +107,7 @@ ...@@ -88,7 +107,7 @@
*ngFor="let item of plListFilter() | slice:((currentPage-1) * 10) : (((currentPage-1) * 10) + 10);let i = index"> *ngFor="let item of plListFilter() | slice:((currentPage-1) * 10) : (((currentPage-1) * 10) + 10);let i = index">
<td class="text-center"> <td class="text-center">
<input *ngIf="item.data.plId!='100'" type="checkbox" class="ti-form-checkbox cursor-pointer" <input *ngIf="item.data.plId!='100'" type="checkbox" class="ti-form-checkbox cursor-pointer"
id="checkbox-{{item.data.plId}}" [(ngModel)]="item.check"> id="checkbox-{{item.data.plId}}" [(ngModel)]="item.check" (ngModelChange)="dataListCheck()">
<label for="checkbox-{{item.data.plId}}">&nbsp;{{item.data.plId}}</label> <label for="checkbox-{{item.data.plId}}">&nbsp;{{item.data.plId}}</label>
</td> </td>
...@@ -139,8 +158,8 @@ ...@@ -139,8 +158,8 @@
</ul> </ul>
<ul class="nav-tabs mt-3"> <ul class="nav-tabs mt-3">
<span>Show {{((currentPage-1) * 10)+1}} to {{plListFilter().length<10 ?plListFilter().length: <span>Show {{((currentPage-1) * 10)+1}} to {{plListFilter().length<10 ?plListFilter().length:
(currentPage==page.length ? ((currentPage * 10) - ((currentPage * 10) - plListFilter().length) ) (currentPage==page.length ? ((currentPage * 10) - ((currentPage * 10) - plListFilter().length) ) :(currentPage
:(currentPage * 10) ) }} of {{plListFilter().length}} items</span> * 10) ) }} of {{plListFilter().length}} items</span>
</ul> </ul>
</nav> </nav>
</div> </div>
...@@ -151,7 +170,7 @@ ...@@ -151,7 +170,7 @@
<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">
<h3 class="text-xxl font-bold text-primary"> <h3 class="text-xxl font-bold text-primary">
{{modalStatus=='add'?'เพิ่มข้อมูลประเภทพนักงาน(PL)':'แก้ไขข้อมูลประเภทพนักงาน(PL)'}} {{modalStatus=='add'?'เพิ่มข้อมูลระดับพนักงาน(PL)':'แก้ไขข้อมูลระดับพนักงาน(PL)'}}
</h3> </h3>
<div class="flex justify-end"> <div class="flex justify-end">
<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"
...@@ -164,7 +183,7 @@ ...@@ -164,7 +183,7 @@
<div class="ti-modal-center"> <div class="ti-modal-center">
<div class="flex justify-end" style="padding-right: 1rem;"> <div class="flex justify-end" style="padding-right: 1rem;">
<div class="px-1"> <div class="px-1">
<button type="button" class="ti-btn ti-btn-soft-indigo h-45px m-0 shadow-md"> <button type="button" class="ti-btn ti-btn-soft-indigo h-45px m-0 shadow-md" (click)="clearPl(modalStatus)">
<svg class="svg-indigo" width="16" height="16" viewBox="0 0 64.00 64.00" <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" 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)"> transform="rotate(45)matrix(-1, 0, 0, 1, 0, 0)">
...@@ -189,9 +208,11 @@ ...@@ -189,9 +208,11 @@
</div> </div>
</div> </div>
<div class="ti-modal-body" style="margin-top: 40px;"> <div class="ti-modal-body" style="margin-top: 40px;">
<label for="input-label" class="ti-form-label">รหัสระดับพนักงาน(PL)</label> <label for="input-label" class="ti-form-label">รหัสระดับพนักงาน(PL)*</label>
<input type="text" id="input-label" class="ti-form-input w-1/2" [ngClass]="{'bg-input-readonly':modalStatus=='edit'}" [readonly]="modalStatus=='edit'" [(ngModel)]="dataSelect.plId"> <input type="text" id="input-label" class="ti-form-input w-1/2"
<label for="detail_th" class="ti-form-label mt-2rem">รายละเอียด (ไทย)</label> [ngClass]="{'bg-input-readonly':modalStatus=='edit'}" [readonly]="modalStatus=='edit'"
[(ngModel)]="dataSelect.plId">
<label for="detail_th" class="ti-form-label mt-2rem">รายละเอียด (ไทย)*</label>
<input type="text" id="detail_th" class="ti-form-input h-16" [(ngModel)]="dataSelect.tdesc"> <input type="text" id="detail_th" class="ti-form-input h-16" [(ngModel)]="dataSelect.tdesc">
<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" [(ngModel)]="dataSelect.edesc"> <input type="text" id="detail_eng" class="ti-form-input h-16" [(ngModel)]="dataSelect.edesc">
...@@ -201,9 +222,11 @@ ...@@ -201,9 +222,11 @@
data-hs-overlay="#employee-level-page-modal"> data-hs-overlay="#employee-level-page-modal">
ย้อนกลับ ย้อนกลับ
</button> </button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);" data-hs-overlay="#employee-level-page-alert-modal"> <button type="button" class="ti-btn ti-btn-success" data-hs-overlay="#employee-level-page-alert-modal"
[class.ti-btn-disabled]="!dataSelect.plId||!dataSelect.tdesc"
[disabled]="!dataSelect.plId||!dataSelect.tdesc">
บันทึกข้อมูล บันทึกข้อมูล
</a> </button>
</div> </div>
</div> </div>
</div> </div>
...@@ -214,14 +237,14 @@ ...@@ -214,14 +237,14 @@
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out rounded-md"> <div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out rounded-md">
<div class="ti-modal-header bg-primary !rounded-none !rounded-t-sm"> <div class="ti-modal-header bg-primary !rounded-none !rounded-t-sm">
<h5 class="text-xxl font-bold text-white"> <h5 class="text-xxl font-bold text-white">
นำเข้าระดับพนักงาน (PL) นำเข้าระดับพนักงาน(PL)
</h5> </h5>
</div> </div>
<div class="ti-modal-body max-h-full overflow-hidden ti-modal-content !rounded-t-none !rounded-b-sm"> <div class="ti-modal-body max-h-full overflow-hidden ti-modal-content !rounded-t-none !rounded-b-sm">
<h1 class="mt-2" style="text-align: center;">ไฟล์</h1> <h1 class="mt-2" style="text-align: center;">ไฟล์</h1>
<div class="mt-2 p-2"> <div class="mt-2 p-2">
<div class="flex rounded-md"> <div class="flex rounded-md">
<input #fileInput type="file" (change)="onFileSelected($event)" hidden> <input #fileInput id="fileInput" type="file" (change)="onFileSelected($event)" hidden>
<input type="text" [value]="selectedFileName" readonly (click)="fileInput.click()" <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"> 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()" <button type="button" (click)="fileInput.click()"
...@@ -230,7 +253,8 @@ ...@@ -230,7 +253,8 @@
</button> </button>
</div> </div>
<div class="flex justify-center mt-2rem mb-1rem space-x-4"> <div class="flex justify-center mt-2rem mb-1rem space-x-4">
<button type="submit" class="ti-btn ti-btn-secondary" (click)="uploadFile()" <button type="submit" class="ti-btn ti-btn-secondary" data-hs-overlay="#employee-level-upload-modal"
[class.ti-btn-disabled]="!selectedFile" (click)="uploadFile()" [disabled]="!selectedFile"
[disabled]="!selectedFile"> [disabled]="!selectedFile">
อัปโหลด อัปโหลด
</button> </button>
...@@ -250,7 +274,7 @@ ...@@ -250,7 +274,7 @@
<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="#employee-level-page-alert-modal"> data-hs-overlay="#employee-level-page-modal">
<span class="sr-only">Close</span> <span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i> <i class="ti ti-circle-x fs-xxl"></i>
</button> </button>
......
...@@ -16,15 +16,6 @@ export interface DataModel { ...@@ -16,15 +16,6 @@ export interface DataModel {
styleUrls: ['./employee-level.component.scss'] styleUrls: ['./employee-level.component.scss']
}) })
export class EmployeeLevel implements OnInit { export class EmployeeLevel implements OnInit {
@Input() pathTitle = ['การจัดการข้อมูลองค์กร', 'ข้อมูลลักษณะงาน', 'กลุ่มพนักงาน']
@Output() sendPathTitle: EventEmitter<string[]> = new EventEmitter<string[]>();
activeTab: string = 'tab1'; // กำหนด tab เริ่มต้น
// ฟังก์ชันในการเปลี่ยนแท็บ
changeTab(tab: { id: string, text: string }) {
this.sendPathTitle.emit(['การจัดการข้อมูลองค์กร', 'ข้อมูลลักษณะงาน', tab.text])
this.activeTab = tab.id;
}
currentPage = 1 currentPage = 1
page = Array.from({ length: 1 }, (_, i) => i + 1); page = Array.from({ length: 1 }, (_, i) => i + 1);
search = "" search = ""
...@@ -38,6 +29,10 @@ export class EmployeeLevel implements OnInit { ...@@ -38,6 +29,10 @@ export class EmployeeLevel implements OnInit {
selectedFile: File | null = null; selectedFile: File | null = null;
selectedFileName: string = 'กรุณาเลือกไฟล์'; selectedFileName: string = 'กรุณาเลือกไฟล์';
numDataListChecked = 0
isDataListChecked = false
isDataListCheckedAll = false
constructor(private plService: PLService, constructor(private plService: PLService,
private toastr: ToastrService, private toastr: ToastrService,
private cdr: ChangeDetectorRef, private cdr: ChangeDetectorRef,
...@@ -60,6 +55,7 @@ export class EmployeeLevel implements OnInit { ...@@ -60,6 +55,7 @@ export class EmployeeLevel implements OnInit {
} }
const formData = new FormData(); const formData = new FormData();
formData.append('file', this.selectedFile); formData.append('file', this.selectedFile);
this.dataLoading = true
this.fileService.upload(formData, 'pl').subscribe({ this.fileService.upload(formData, 'pl').subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
...@@ -67,9 +63,13 @@ export class EmployeeLevel implements OnInit { ...@@ -67,9 +63,13 @@ export class EmployeeLevel implements OnInit {
this.getPLList() this.getPLList()
} else { } else {
this.showAlert(response.message, 'error') this.showAlert(response.message, 'error')
this.dataLoading = false
this.cdr.detectChanges()
} }
}, error: error => { }, error: error => {
this.showAlert(error.message, 'error') this.showAlert(error.message, 'error')
this.dataLoading = false
this.cdr.detectChanges()
} }
}) })
} }
...@@ -99,6 +99,8 @@ export class EmployeeLevel implements OnInit { ...@@ -99,6 +99,8 @@ export class EmployeeLevel implements OnInit {
next: response => { next: response => {
this.plList = response.map(x => ({ check: false, data: { plId: x.plId, tdesc: x.tdesc, edesc: x.edesc, companyId: x.companyId } })) this.plList = response.map(x => ({ check: false, data: { plId: x.plId, tdesc: x.tdesc, edesc: x.edesc, companyId: x.companyId } }))
this.dataLoading = false this.dataLoading = false
this.isDataListCheckedAll = false
this.dataListCheckAll()
this.searchChange(); this.searchChange();
this.cdr.detectChanges(); this.cdr.detectChanges();
}, error: error => { }, error: error => {
...@@ -112,12 +114,14 @@ export class EmployeeLevel implements OnInit { ...@@ -112,12 +114,14 @@ export class EmployeeLevel implements OnInit {
searchChange() { searchChange() {
this.currentPage = 1 this.currentPage = 1
this.page = Array.from({ length: Math.ceil(this.plListFilter().length / 10) }, (_, i) => i + 1); this.page = Array.from({ length: Math.ceil(this.plListFilter().length / 10) }, (_, i) => i + 1);
this.dataListCheck();
this.cdr.detectChanges()
} }
plListFilter() { plListFilter() {
return this.plList.filter(x => { return this.plList.filter(x => {
const data = x.data const data = x.data
const match = data.plId.toLowerCase().includes(this.search) || data.tdesc.toLowerCase().includes(this.search) || data.edesc.toLowerCase().includes(this.search); const match = data.plId.toLowerCase().includes(this.search.toLowerCase()) || data.tdesc.toLowerCase().includes(this.search.toLowerCase()) || data.edesc.toLowerCase().includes(this.search.toLowerCase());
return match; return match;
}); });
} }
...@@ -128,6 +132,7 @@ export class EmployeeLevel implements OnInit { ...@@ -128,6 +132,7 @@ export class EmployeeLevel implements OnInit {
addPL() { addPL() {
const body = new MyPLModel({ plId: this.dataSelect.plId, tdesc: this.dataSelect.tdesc, edesc: this.dataSelect.edesc, companyId: this.dataSelect.companyId }) const body = new MyPLModel({ plId: this.dataSelect.plId, tdesc: this.dataSelect.tdesc, edesc: this.dataSelect.edesc, companyId: this.dataSelect.companyId })
this.dataLoading = true
this.plService.post(body).subscribe({ this.plService.post(body).subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
...@@ -135,9 +140,13 @@ export class EmployeeLevel implements OnInit { ...@@ -135,9 +140,13 @@ export class EmployeeLevel implements OnInit {
this.getPLList() this.getPLList()
} else { } else {
this.showAlert(response.message, 'error') this.showAlert(response.message, 'error')
this.dataLoading = true
this.cdr.detectChanges()
} }
}, error: error => { }, error: error => {
this.showAlert(error.message, 'error') this.showAlert(error.message, 'error')
this.dataLoading = true
this.cdr.detectChanges()
} }
}) })
} }
...@@ -149,6 +158,7 @@ export class EmployeeLevel implements OnInit { ...@@ -149,6 +158,7 @@ export class EmployeeLevel implements OnInit {
} else { } else {
body = this.plList.filter(x => x.check).map(x => new MyPLModel({ plId: x.data.plId, tdesc: x.data.tdesc, edesc: x.data.edesc, companyId: x.data.companyId })) body = this.plList.filter(x => x.check).map(x => new MyPLModel({ plId: x.data.plId, tdesc: x.data.tdesc, edesc: x.data.edesc, companyId: x.data.companyId }))
} }
this.dataLoading = true
this.plService.delete(body).subscribe({ this.plService.delete(body).subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
...@@ -156,9 +166,13 @@ export class EmployeeLevel implements OnInit { ...@@ -156,9 +166,13 @@ export class EmployeeLevel implements OnInit {
this.getPLList() this.getPLList()
} else { } else {
this.showAlert(response.message, 'error') this.showAlert(response.message, 'error')
this.dataLoading = true
this.cdr.detectChanges()
} }
}, error: error => { }, error: error => {
this.showAlert(error.message, 'error') this.showAlert(error.message, 'error')
this.dataLoading = true
this.cdr.detectChanges()
} }
}) })
} }
...@@ -169,4 +183,32 @@ export class EmployeeLevel implements OnInit { ...@@ -169,4 +183,32 @@ export class EmployeeLevel implements OnInit {
positionClass: 'toast-top-right', positionClass: 'toast-top-right',
}); });
} }
dataListCheckAll() {
const selectAll = this.isDataListCheckedAll;
this.plList.filter(x => {
const data = x.data
const match = data.plId.toLowerCase().includes(this.search.toLowerCase()) || data.tdesc.toLowerCase().includes(this.search.toLowerCase()) || data.edesc.toLowerCase().includes(this.search.toLowerCase());
return match;
}).forEach(x => x.check = selectAll);
this.dataListCheck();
}
dataListCheck() {
const dataCheck = this.plListFilter();
this.isDataListCheckedAll = dataCheck.length ? dataCheck.every(x => x.check) : false;
this.numDataListChecked = this.plList.filter(x => x.check).length
this.isDataListChecked = Boolean(this.numDataListChecked)
}
clearPl(modalStatus: string) {
if (modalStatus == 'add') {
this.dataSelect.plId = ''
this.dataSelect.tdesc = ''
this.dataSelect.edesc = ''
} else if (modalStatus == 'edit') {
this.dataSelect.tdesc = ''
this.dataSelect.edesc = ''
}
}
} }
...@@ -10,43 +10,55 @@ ...@@ -10,43 +10,55 @@
<nav class="-mb-0.5 flex space-x-6 rtl:space-x-reverse"> <nav class="-mb-0.5 flex space-x-6 rtl:space-x-reverse">
<a class="text-base font-medium hs-tab-active:text-lg hs-tab-active:font-bold hs-tab-active:border-secondary hs-tab-active:text-secondary pb-3 inline-flex items-center gap-2 border-b-[3px] border-transparent whitespace-nowrap text-gray-500 dark:text-white/70 hover:text-secondary active" <a class="text-base font-medium hs-tab-active:text-lg hs-tab-active:font-bold hs-tab-active:border-secondary hs-tab-active:text-secondary pb-3 inline-flex items-center gap-2 border-b-[3px] border-transparent whitespace-nowrap text-gray-500 dark:text-white/70 hover:text-secondary active"
href="javascript:void(0);" id="underline-item-1" data-hs-tab="#underline-1" href="javascript:void(0);" id="underline-item-1" data-hs-tab="#underline-1"
aria-controls="underline-1" (click)="pathTitle = ['การจัดการข้อมูลองค์กร','ข้อมูลลักษณะงาน','กลุ่มพนักงาน']"> aria-controls="underline-1"
(click)="currentPath = 1;pathTitle = ['การจัดการข้อมูลองค์กร','ข้อมูลลักษณะงาน','กลุ่มพนักงาน']">
กลุ่มพนักงาน กลุ่มพนักงาน
</a> </a>
<a class="text-base font-medium hs-tab-active:text-lg hs-tab-active:font-bold 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 dark:text-white/70 hover:text-secondary" <a class="text-base font-medium hs-tab-active:text-lg hs-tab-active:font-bold 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 dark:text-white/70 hover:text-secondary"
href="javascript:void(0);" id="underline-item-2" data-hs-tab="#underline-2" href="javascript:void(0);" id="underline-item-2" data-hs-tab="#underline-2"
aria-controls="underline-2" (click)="pathTitle = ['การจัดการข้อมูลองค์กร','ข้อมูลลักษณะงาน','ตำเเหน่ง']"> aria-controls="underline-2"
(click)="currentPath = 2;pathTitle = ['การจัดการข้อมูลองค์กร','ข้อมูลลักษณะงาน','ตำเเหน่ง']">
ตำเเหน่ง ตำเเหน่ง
</a> </a>
<!-- <a class="text-base font-medium hs-tab-active:text-lg hs-tab-active:font-bold 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 dark:text-white/70 hover:text-secondary"
href="javascript:void(0);" id="underline-item-3" data-hs-tab="#underline-3"
aria-controls="underline-3"
(click)="currentPath = 3;pathTitle = ['การจัดการข้อมูลองค์กร','ข้อมูลลักษณะงาน','ลักษณะงาน']">
ลักษณะงาน
</a> -->
<a class="text-base font-medium hs-tab-active:text-lg hs-tab-active:font-bold 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 dark:text-white/70 hover:text-secondary" <a class="text-base font-medium hs-tab-active:text-lg hs-tab-active:font-bold 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 dark:text-white/70 hover:text-secondary"
href="javascript:void(0);" id="underline-item-4" data-hs-tab="#underline-4" href="javascript:void(0);" id="underline-item-4" data-hs-tab="#underline-4"
aria-controls="underline-4" (click)="pathTitle = ['การจัดการข้อมูลองค์กร','ข้อมูลลักษณะงาน','ประเภทพนักงาน']"> aria-controls="underline-4"
(click)="currentPath = 4;pathTitle = ['การจัดการข้อมูลองค์กร','ข้อมูลลักษณะงาน','ประเภทพนักงาน']">
ประเภทพนักงาน ประเภทพนักงาน
</a> </a>
<a class="text-base font-medium hs-tab-active:text-lg hs-tab-active:font-bold 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 dark:text-white/70 hover:text-secondary" <a class="text-base font-medium hs-tab-active:text-lg hs-tab-active:font-bold 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 dark:text-white/70 hover:text-secondary"
href="javascript:void(0);" id="underline-item-5" data-hs-tab="#underline-5" href="javascript:void(0);" id="underline-item-5" data-hs-tab="#underline-5"
aria-controls="underline-5" (click)="pathTitle = ['การจัดการข้อมูลองค์กร','ข้อมูลลักษณะงาน','ระดับพนักงาน (PL)']"> aria-controls="underline-5"
(click)="currentPath = 5;pathTitle = ['การจัดการข้อมูลองค์กร','ข้อมูลลักษณะงาน','ระดับพนักงาน (PL)']">
ระดับพนักงาน (PL) ระดับพนักงาน (PL)
</a> </a>
</nav> </nav>
</div> </div>
<div class="mt-3 px-3rem !-mt-3 pt-50px"> <div class="mt-3 px-2rem !-mt-3 pt-50px">
<div id="underline-1" role="tabpanel" aria-labelledby="underline-item-1" > <div *ngIf="currentPath == 1" id="underline-1" role="tabpanel" aria-labelledby="underline-item-1">
<app-employee-group-unit [pathTitle]="pathTitle" <app-employee-group-unit></app-employee-group-unit>
(sendPathTitle)="pathTitle=$event"></app-employee-group-unit>
</div> </div>
<div id="underline-2" class="hidden" role="tabpanel" aria-labelledby="underline-item-2"> <div *ngIf="currentPath == 2" id="underline-2" class="hidden" role="tabpanel"
<app-position-unit [pathTitle]="pathTitle" (sendPathTitle)="pathTitle=$event"></app-position-unit> aria-labelledby="underline-item-2">
<app-position-unit></app-position-unit>
</div> </div>
<div id="underline-3" class="hidden" role="tabpanel" aria-labelledby="underline-item-3"> <div *ngIf="currentPath == 3" id="underline-3" class="hidden" role="tabpanel"
aria-labelledby="underline-item-3">
ลักษณะงาน ลักษณะงาน
</div> </div>
<div id="underline-4" class="hidden" role="tabpanel" aria-labelledby="underline-item-4"> <div *ngIf="currentPath == 4" id="underline-4" class="hidden" role="tabpanel"
<app-employee-categories [pathTitle]="pathTitle" aria-labelledby="underline-item-4">
(sendPathTitle)="pathTitle=$event"></app-employee-categories> <app-employee-categories></app-employee-categories>
</div> </div>
<div id="underline-5" class="hidden" role="tabpanel" aria-labelledby="underline-item-5"> <div *ngIf="currentPath == 5" id="underline-5" class="hidden" role="tabpanel"
<app-employee-level [pathTitle]="pathTitle" (sendPathTitle)="pathTitle=$event"></app-employee-level> aria-labelledby="underline-item-5">
<app-employee-level></app-employee-level>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -6,5 +6,6 @@ import { Component } from '@angular/core'; ...@@ -6,5 +6,6 @@ import { Component } from '@angular/core';
styleUrls: ['./job-description.component.scss'] styleUrls: ['./job-description.component.scss']
}) })
export class JobDescriptionComponent { export class JobDescriptionComponent {
pathTitle = ['การจัดการข้อมูลองค์กร','ข้อมูลลักษณะงาน', 'กลุ่มพนักงาน'] pathTitle = ['การจัดการข้อมูลองค์กร', 'ข้อมูลลักษณะงาน', 'กลุ่มพนักงาน']
currentPath = 1
} }
<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 pr-2 pb-2rem">
<div class="flex">
<div class="flex items-center">
<input type="checkbox" class="ti-form-checkbox pointer-events-none" id="hs-default-checkbox"
[(ngModel)]="isDataListChecked">
<label for="hs-default-checkbox" class="text-sm text-gray-500 mx-2 pointer-events-none">
{{numDataListChecked}} Selected</label>
</div>
<div class="mx-1 flex items-center">
<button (click)="isDataListCheckedAll = !isDataListCheckedAll;dataListCheckAll()"
class="focus:ring-2 focus:ring-primary rounded-sm flex item-center">
<i class="fs-l transition-all duration-200"
[ngClass]="{'ri-checkbox-multiple-line text-gray-500': !isDataListCheckedAll, 'ri-checkbox-multiple-fill text-primary': isDataListCheckedAll}"></i>
</button>
<label class="text-sm text-gray-500 ml-2">Select All</label>
</div>
</div>
</div>
<div class="flex justify-between"> <div class="flex justify-between">
<div class="flex pr-2"> <div class="flex pr-2">
<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="#position-unit-component-upload-modal"> data-hs-overlay="#position-unit-component-upload-modal"
(click)="fileInput.value = '';selectedFile=null;selectedFileName = 'กรุณาเลือกไฟล์'">
<i class="ri-add-line"></i> <i class="ri-add-line"></i>
นำเข้าข้อมูล นำเข้าข้อมูล
</button> </button>
...@@ -34,7 +53,8 @@ ...@@ -34,7 +53,8 @@
</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="#position-unit-component-page-alert-modal" (click)="modalStatus='deleteGroup';setData()"> data-hs-overlay="#position-unit-component-page-alert-modal"
(click)="modalStatus='deleteGroup';setData()">
<i class="ri-delete-bin-6-line"></i> <i class="ri-delete-bin-6-line"></i>
Delete Delete
</button> </button>
...@@ -86,14 +106,16 @@ ...@@ -86,14 +106,16 @@
<tr <tr
*ngFor="let item of positionListFilter() | slice:((currentPage-1) * 10) : (((currentPage-1) * 10) + 10);let i = index"> *ngFor="let item of positionListFilter() | slice:((currentPage-1) * 10) : (((currentPage-1) * 10) + 10);let i = index">
<td class="text-center"> <td class="text-center">
<input *ngIf="item.data.positionId!='100'" type="checkbox" class="ti-form-checkbox cursor-pointer" <input *ngIf="item.data.positionId!='100'" type="checkbox"
id="checkbox-{{item.data.positionId}}" [(ngModel)]="item.check"> class="ti-form-checkbox cursor-pointer" id="checkbox-{{item.data.positionId}}"
[(ngModel)]="item.check" (ngModelChange)="dataListCheck()">
<label for="checkbox-{{item.data.positionId}}">&nbsp;{{item.data.positionId}}</label> <label for="checkbox-{{item.data.positionId}}">&nbsp;{{item.data.positionId}}</label>
</td> </td>
<td>{{item.data.tdesc}}</td> <td>{{item.data.tdesc}}</td>
<td>{{item.data.edesc}}</td> <td>{{item.data.edesc}}</td>
<td class="flex justify-center"> <td class="flex justify-center">
<i class="ti ti-edit cursor-pointer i-gray fs-l px-1" (click)="modalStatus='edit';setData(item.data)" <i class="ti ti-edit cursor-pointer i-gray fs-l px-1"
(click)="modalStatus='edit';setData(item.data)"
data-hs-overlay="#position-unit-component-page-modal"></i> data-hs-overlay="#position-unit-component-page-modal"></i>
<i class="ti ti-trash cursor-pointer i-gray fs-l px-1" *ngIf="item.data.positionId!='100'" <i class="ti ti-trash cursor-pointer i-gray fs-l px-1" *ngIf="item.data.positionId!='100'"
(click)="modalStatus='delete';setData(item.data)" (click)="modalStatus='delete';setData(item.data)"
...@@ -136,8 +158,8 @@ ...@@ -136,8 +158,8 @@
</ul> </ul>
<ul class="nav-tabs mt-3"> <ul class="nav-tabs mt-3">
<span>Show {{((currentPage-1) * 10)+1}} to {{positionListFilter().length<10 ?positionListFilter().length: <span>Show {{((currentPage-1) * 10)+1}} to {{positionListFilter().length<10 ?positionListFilter().length:
(currentPage==page.length ? ((currentPage * 10) - ((currentPage * 10) - positionListFilter().length) ) (currentPage==page.length ? ((currentPage * 10) - ((currentPage * 10) - positionListFilter().length)
:(currentPage * 10) ) }} of {{positionListFilter().length}} items</span> ) :(currentPage * 10) ) }} of {{positionListFilter().length}} items</span>
</ul> </ul>
</nav> </nav>
</div> </div>
...@@ -161,7 +183,8 @@ ...@@ -161,7 +183,8 @@
<div class="ti-modal-center"> <div class="ti-modal-center">
<div class="flex justify-end" style="padding-right: 1rem;"> <div class="flex justify-end" style="padding-right: 1rem;">
<div class="px-1"> <div class="px-1">
<button type="button" class="ti-btn ti-btn-soft-indigo h-45px m-0 shadow-md"> <button type="button" class="ti-btn ti-btn-soft-indigo h-45px m-0 shadow-md"
(click)="clearPosition(modalStatus)">
<svg class="svg-indigo" width="16" height="16" viewBox="0 0 64.00 64.00" <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" 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)"> transform="rotate(45)matrix(-1, 0, 0, 1, 0, 0)">
...@@ -186,11 +209,13 @@ ...@@ -186,11 +209,13 @@
</div> </div>
</div> </div>
<div class="ti-modal-body "> <div class="ti-modal-body ">
<label for="input-label" class="ti-form-label mt-2rem">รหัสตำเเหน่ง</label> <label for="input-label" class="ti-form-label mt-2rem">รหัสตำแหน่ง*</label>
<input type="text" id="input-label" class="ti-form-input w-1/2 " [ngClass]="{'bg-input-readonly':modalStatus=='edit'}" [readonly]="modalStatus=='edit'" [(ngModel)]="dataSelect.positionId"> <input type="text" id="input-label" class="ti-form-input w-1/2 "
<label for="detail_th" class="ti-form-label mt-2rem">รายละเอียดฝ่าย (ไทย)</label> [ngClass]="{'bg-input-readonly':modalStatus=='edit'}" [readonly]="modalStatus=='edit'"
[(ngModel)]="dataSelect.positionId">
<label for="detail_th" class="ti-form-label mt-2rem">รายละเอียดฝ่าย (ไทย)*</label>
<input type="text" id="detail_th" class="ti-form-input h-16" [(ngModel)]="dataSelect.tdesc"> <input type="text" id="detail_th" class="ti-form-input h-16" [(ngModel)]="dataSelect.tdesc">
<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" [(ngModel)]="dataSelect.edesc"> <input type="text" id="detail_eng" class="ti-form-input h-16" [(ngModel)]="dataSelect.edesc">
<div class="flex justify-end mt-2rem mb-1rem space-x-2"> <div class="flex justify-end mt-2rem mb-1rem space-x-2">
<button type="button" <button type="button"
...@@ -198,10 +223,12 @@ ...@@ -198,10 +223,12 @@
data-hs-overlay="#position-unit-component-page-modal"> data-hs-overlay="#position-unit-component-page-modal">
ย้อนกลับ ย้อนกลับ
</button> </button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);" <button type="button" class="ti-btn ti-btn-success"
data-hs-overlay="#position-unit-component-page-alert-modal"> data-hs-overlay="#position-unit-component-page-alert-modal"
[class.ti-btn-disabled]="!dataSelect.positionId||!dataSelect.tdesc"
[disabled]="!dataSelect.positionId||!dataSelect.tdesc">
บันทึกข้อมูล บันทึกข้อมูล
</a> </button>
</div> </div>
</div> </div>
</div> </div>
...@@ -218,7 +245,7 @@ ...@@ -218,7 +245,7 @@
<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="#position-unit-component-page-alert-modal"> data-hs-overlay="#position-unit-component-page-modal">
<span class="sr-only">Close</span> <span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i> <i class="ti ti-circle-x fs-xxl"></i>
</button> </button>
...@@ -282,7 +309,7 @@ ...@@ -282,7 +309,7 @@
<h1 class="mt-2" style="text-align: center;">ไฟล์</h1> <h1 class="mt-2" style="text-align: center;">ไฟล์</h1>
<div class="mt-2 p-2"> <div class="mt-2 p-2">
<div class="flex rounded-md"> <div class="flex rounded-md">
<input #fileInput type="file" (change)="onFileSelected($event)" hidden> <input #fileInput id="fileInput" type="file" (change)="onFileSelected($event)" hidden>
<input type="text" [value]="selectedFileName" readonly (click)="fileInput.click()" <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"> 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()" <button type="button" (click)="fileInput.click()"
...@@ -291,8 +318,9 @@ ...@@ -291,8 +318,9 @@
</button> </button>
</div> </div>
<div class="flex justify-center mt-2rem mb-1rem space-x-4"> <div class="flex justify-center mt-2rem mb-1rem space-x-4">
<button type="submit" class="ti-btn ti-btn-secondary" (click)="uploadFile()" <button type="submit" class="ti-btn ti-btn-secondary"
[disabled]="!selectedFile"> data-hs-overlay="#position-unit-component-upload-modal" [class.ti-btn-disabled]="!selectedFile"
(click)="uploadFile()" [disabled]="!selectedFile" [disabled]="!selectedFile">
อัปโหลด อัปโหลด
</button> </button>
</div> </div>
......
...@@ -18,15 +18,6 @@ export interface DataModel { ...@@ -18,15 +18,6 @@ export interface DataModel {
styleUrls: ['./position-unit.component.scss'] styleUrls: ['./position-unit.component.scss']
}) })
export class PositionUnitComponent implements OnInit { export class PositionUnitComponent implements OnInit {
@Input() pathTitle = ['การจัดการข้อมูลองค์กร', 'ข้อมูลลักษณะงาน', 'กลุ่มพนักงาน']
@Output() sendPathTitle: EventEmitter<string[]> = new EventEmitter<string[]>();
activeTab: string = 'tab1'; // กำหนด tab เริ่มต้น
// ฟังก์ชันในการเปลี่ยนแท็บ
changeTab(tab: { id: string, text: string }) {
this.sendPathTitle.emit(['การจัดการข้อมูลองค์กร', 'ข้อมูลลักษณะงาน', tab.text])
this.activeTab = tab.id;
}
currentPage = 1 currentPage = 1
selectedItems: string[] = []; selectedItems: string[] = [];
search = "" search = ""
...@@ -39,6 +30,9 @@ export class PositionUnitComponent implements OnInit { ...@@ -39,6 +30,9 @@ export class PositionUnitComponent implements OnInit {
dataLoading = false dataLoading = false
dataSelect: DataModel = { positionId: "", tdesc: "", edesc: "", consolidate: "", shortName: "", companyId: "" } dataSelect: DataModel = { positionId: "", tdesc: "", edesc: "", consolidate: "", shortName: "", companyId: "" }
numDataListChecked = 0
isDataListChecked = false
isDataListCheckedAll = false
constructor(private positionService: PositionService, constructor(private positionService: PositionService,
private toastr: ToastrService, private toastr: ToastrService,
private cdr: ChangeDetectorRef, private cdr: ChangeDetectorRef,
...@@ -60,6 +54,7 @@ export class PositionUnitComponent implements OnInit { ...@@ -60,6 +54,7 @@ export class PositionUnitComponent implements OnInit {
} }
const formData = new FormData(); const formData = new FormData();
formData.append('file', this.selectedFile); formData.append('file', this.selectedFile);
this.dataLoading = true
this.fileService.upload(formData, 'mposition').subscribe({ this.fileService.upload(formData, 'mposition').subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
...@@ -67,9 +62,13 @@ export class PositionUnitComponent implements OnInit { ...@@ -67,9 +62,13 @@ export class PositionUnitComponent implements OnInit {
this.getPositionList() this.getPositionList()
} else { } else {
this.showAlert(response.message, 'error') this.showAlert(response.message, 'error')
this.dataLoading = false
this.cdr.detectChanges();
} }
}, error: error => { }, error: error => {
this.showAlert(error.message, 'error') this.showAlert(error.message, 'error')
this.dataLoading = false
this.cdr.detectChanges();
} }
}) })
} }
...@@ -96,8 +95,10 @@ export class PositionUnitComponent implements OnInit { ...@@ -96,8 +95,10 @@ export class PositionUnitComponent implements OnInit {
this.dataLoading = true this.dataLoading = true
this.positionService.getList().subscribe({ this.positionService.getList().subscribe({
next: response => { next: response => {
this.positionList = response.map(x => ({ check: false, data: { positionId: x.positionId, tdesc: x.tdesc, edesc: x.edesc, consolidate: x.consolidate, shortName: x.shortName, companyId: x.companyId } })) this.positionList = response.map(x => new MyPositionModel(x)).map(x => ({ check: false, data: { positionId: x.positionId, tdesc: x.tdesc, edesc: x.edesc, consolidate: x.consolidate, shortName: x.shortName, companyId: x.companyId } }))
this.dataLoading = false this.dataLoading = false
this.isDataListCheckedAll = false
this.dataListCheckAll()
this.searchChange() this.searchChange()
this.cdr.detectChanges(); this.cdr.detectChanges();
}, error: error => { }, error: error => {
...@@ -110,19 +111,13 @@ export class PositionUnitComponent implements OnInit { ...@@ -110,19 +111,13 @@ export class PositionUnitComponent implements OnInit {
searchChange() { searchChange() {
this.currentPage = 1 this.currentPage = 1
this.page = Array.from({ length: Math.ceil(this.positionListFilter().length / 10) }, (_, i) => i + 1); this.page = Array.from({ length: Math.ceil(this.positionListFilter().length / 10) }, (_, i) => i + 1);
this.dataListCheck()
} }
positionListFilter() { positionListFilter() {
return this.positionList.filter(x => { return this.positionList.filter(x => {
const data = x.data; const data = x.data
const searchLower = this.search.toLowerCase(); const match = data.positionId.toLowerCase().includes(this.search.toLowerCase()) || data.tdesc.toLowerCase().includes(this.search.toLowerCase()) || data.edesc.toLowerCase().includes(this.search.toLowerCase());
return match;
return (
(data.positionId?.toLowerCase() || '').includes(searchLower) ||
(data.tdesc?.toLowerCase() || '').includes(searchLower) ||
(data.edesc?.toLowerCase() || '').includes(searchLower) ||
(data.consolidate?.toLowerCase() || '').includes(searchLower) ||
(data.shortName?.toLowerCase() || '').includes(searchLower)
);
}); });
} }
...@@ -132,6 +127,7 @@ export class PositionUnitComponent implements OnInit { ...@@ -132,6 +127,7 @@ export class PositionUnitComponent implements OnInit {
addPosition() { addPosition() {
const body = new MyPositionModel({ positionId: this.dataSelect.positionId, tdesc: this.dataSelect.tdesc, edesc: this.dataSelect.edesc, consolidate: this.dataSelect.consolidate, shortName: this.dataSelect.shortName, companyId: this.dataSelect.companyId }) const body = new MyPositionModel({ positionId: this.dataSelect.positionId, tdesc: this.dataSelect.tdesc, edesc: this.dataSelect.edesc, consolidate: this.dataSelect.consolidate, shortName: this.dataSelect.shortName, companyId: this.dataSelect.companyId })
this.dataLoading = true
this.positionService.post(body).subscribe({ this.positionService.post(body).subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
...@@ -139,9 +135,13 @@ export class PositionUnitComponent implements OnInit { ...@@ -139,9 +135,13 @@ export class PositionUnitComponent implements OnInit {
this.getPositionList() this.getPositionList()
} else { } else {
this.showAlert(response.message, 'error') this.showAlert(response.message, 'error')
this.dataLoading = false
this.cdr.detectChanges()
} }
}, error: error => { }, error: error => {
this.showAlert(error.message, 'error') this.showAlert(error.message, 'error')
this.dataLoading = false
this.cdr.detectChanges()
} }
}) })
} }
...@@ -152,6 +152,7 @@ export class PositionUnitComponent implements OnInit { ...@@ -152,6 +152,7 @@ export class PositionUnitComponent implements OnInit {
} else { } else {
body = this.positionList.filter(x => x.check).map(x => new MyPositionModel({ positionId: x.data.positionId, tdesc: x.data.tdesc, edesc: x.data.edesc, consolidate: x.data.consolidate, shortName: x.data.shortName, companyId: x.data.companyId })) body = this.positionList.filter(x => x.check).map(x => new MyPositionModel({ positionId: x.data.positionId, tdesc: x.data.tdesc, edesc: x.data.edesc, consolidate: x.data.consolidate, shortName: x.data.shortName, companyId: x.data.companyId }))
} }
this.dataLoading = true
this.positionService.delete(body).subscribe({ this.positionService.delete(body).subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
...@@ -159,9 +160,13 @@ export class PositionUnitComponent implements OnInit { ...@@ -159,9 +160,13 @@ export class PositionUnitComponent implements OnInit {
this.getPositionList() this.getPositionList()
} else { } else {
this.showAlert(response.message, 'error') this.showAlert(response.message, 'error')
this.dataLoading = false
this.cdr.detectChanges()
} }
}, error: error => { }, error: error => {
this.showAlert(error.message, 'error') this.showAlert(error.message, 'error')
this.dataLoading = false
this.cdr.detectChanges()
} }
}) })
} }
...@@ -171,5 +176,33 @@ export class PositionUnitComponent implements OnInit { ...@@ -171,5 +176,33 @@ export class PositionUnitComponent implements OnInit {
positionClass: 'toast-top-right', positionClass: 'toast-top-right',
}); });
} }
dataListCheckAll() {
const selectAll = this.isDataListCheckedAll;
this.positionList.filter(x => {
const data = x.data
const match = data.positionId.toLowerCase().includes(this.search.toLowerCase()) || data.tdesc.toLowerCase().includes(this.search.toLowerCase()) || data.edesc.toLowerCase().includes(this.search.toLowerCase());
return match;
}).forEach(x => x.check = selectAll);
this.dataListCheck();
}
dataListCheck() {
const dataCheck = this.positionListFilter();
this.isDataListCheckedAll = dataCheck.length ? dataCheck.every(x => x.check) : false;
this.numDataListChecked = this.positionList.filter(x => x.check).length;
this.isDataListChecked = Boolean(this.numDataListChecked)
}
clearPosition(modalStatus: string) {
if (modalStatus == 'add') {
this.dataSelect.positionId = ''
this.dataSelect.tdesc = ''
this.dataSelect.edesc = ''
} else if (modalStatus == 'edit') {
this.dataSelect.tdesc = ''
this.dataSelect.edesc = ''
}
}
} }
...@@ -4,6 +4,7 @@ import { Observable } from 'rxjs'; ...@@ -4,6 +4,7 @@ import { Observable } from 'rxjs';
import { environment } from 'src/environments/environment'; import { environment } from 'src/environments/environment';
import { AlertModel } from '../model/alert.model'; import { AlertModel } from '../model/alert.model';
import { UserModel } from '../model/user.model'; import { UserModel } from '../model/user.model';
import { RoleModel } from '../model/role.model';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
}) })
...@@ -15,9 +16,24 @@ export class UserService { ...@@ -15,9 +16,24 @@ export class UserService {
getList(): Observable<UserModel[]> { getList(): Observable<UserModel[]> {
return this.http.get<UserModel[]>(this.urlApi + "/lists") return this.http.get<UserModel[]>(this.urlApi + "/lists")
} }
getRoleList(): Observable<RoleModel[]> {
return this.http.get<RoleModel[]>(this.urlApi + "/role/lists")
}
getLevelList(): Observable<RoleModel[]> {
return this.http.get<RoleModel[]>(this.urlApi + "/level/lists")
}
checkUser(username: string): Observable<AlertModel> { checkUser(username: string): Observable<AlertModel> {
return this.http.get<AlertModel>(this.urlApi + "/validate-username/" + username) return this.http.get<AlertModel>(this.urlApi + "/validate-username/" + username)
} }
changePassword(body: {
usernameId: string,
empId: string,
companyId: string,
oldPassword: string,
newPassword: string,
}): Observable<AlertModel> {
return this.http.post<AlertModel>(this.urlApi + "/change-password", body)
}
post(body: UserModel): Observable<AlertModel> { post(body: UserModel): Observable<AlertModel> {
return this.http.post<AlertModel>(this.urlApi + "/create", body) return this.http.post<AlertModel>(this.urlApi + "/create", body)
} }
...@@ -28,6 +44,6 @@ export class UserService { ...@@ -28,6 +44,6 @@ export class UserService {
}), }),
body: body body: body
}; };
return this.http.delete<AlertModel>(this.urlApi+'/delete', options) return this.http.delete<AlertModel>(this.urlApi + '/delete', options)
} }
} }
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