Commit 20f8a69a by Natthaphat Pankiang

แก้ชน

parents 1ffef9dc e113ec9a
...@@ -8,7 +8,8 @@ ...@@ -8,7 +8,8 @@
"watch": "ng build --watch --configuration development", "watch": "ng build --watch --configuration development",
"test": "ng test", "test": "ng test",
"sass": "sass ./src/assets/scss:./src/assets/css/", "sass": "sass ./src/assets/scss:./src/assets/css/",
"sass-min": "sass ./src/assets/scss:./src/assets/css/ --style compressed" "sass-min": "sass ./src/assets/scss:./src/assets/css/ --style compressed",
"build-serve":"node --max_old_space_size=8048 ./node_modules/@angular/cli/bin/ng build --aot --configuration production --output-hashing none"
}, },
"private": true, "private": true,
"dependencies": { "dependencies": {
......
...@@ -10,28 +10,35 @@ ...@@ -10,28 +10,35 @@
<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)="currentPage =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)="currentPage =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" <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" href="javascript:void(0);" id="underline-item-3" data-hs-tab="#underline-3"
aria-controls="underline-3" (click)="pathTitle = ['การจัดการข้อมูลองค์กร', 'ตั้งค่าผู้ใช้งาน','จัดการผู้ใช้งาน']"> aria-controls="underline-3"
(click)="currentPage =3 ;pathTitle = ['การจัดการข้อมูลองค์กร', 'ตั้งค่าผู้ใช้งาน','จัดการผู้ใช้งาน']">
จัดการผู้ใช้งาน จัดการผู้ใช้งาน
</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="currentPage==1" id="underline-1" role="tabpanel" aria-labelledby="underline-item-1">
<app-user-settings [pathTitle]="pathTitle" <app-user-settings></app-user-settings>
(sendPathTitle)="pathTitle=$event"></app-user-settings>
</div> </div>
<div id="underline-2" class="hidden" role="tabpanel" aria-labelledby="underline-item-2"> <div *ngIf="currentPage==2" id="underline-2" class="hidden" role="tabpanel"
<app-set-a-password [pathTitle]="pathTitle" (sendPathTitle)="pathTitle=$event"></app-set-a-password> aria-labelledby="underline-item-2">
<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">
<app-manage-user></app-manage-user>
</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: ['./account-settings.component.scss'] styleUrls: ['./account-settings.component.scss']
}) })
export class AccountSettingsComponent { export class AccountSettingsComponent {
pathTitle = ['การจัดการข้อมูลองค์กร','ตั้งค่าผู้ใช้งาน', 'สร้างชื่อผู้ใช้งาน'] pathTitle = ['การจัดการข้อมูลองค์กร', 'ตั้งค่าผู้ใช้งาน', 'สร้างชื่อผู้ใช้งาน']
currentPage = 1
} }
<div class="w-full min-height-50px mb-10px justify-between items-center">
<div class="flex justify-end">
<div class="px-1">
<div class="relative shadow-md">
<input type="text" class="ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 "
placeholder="Search by No. or Name" style="height: 40px;" [(ngModel)]="search"
(ngModelChange)="searchChange()">
<div
class="absolute inset-y-0 ltr:left-0 rtl:right-0 flex items-center pointer-events-none z-20 ltr:pl-4 rtl:pr-4">
<i class="ri-search-line text-gray"></i>
</div>
</div>
</div>
<div class="px-1">
<button type="button" class="ti-btn ti-btn-soft-warning h-20px m-0 shadow-md">
<i class="ti ti-book fs-l"></i>
Help
</button>
</div>
</div>
</div>
<div class="page px-rem">
<div class="overflow-auto shadow-md rounded-t-md">
<table class="ti-custom-table ti-custom-table-head ti-custom-table-hover table-bordered">
<thead>
<tr>
<ng-container
*ngFor="let item of ['ชื่อล็อคอิน','รหัสพนักงาน','ชื่อ','นามสกุล','สถานะ','การจัดการ']; let f = first; let l = last; let i = index">
<th scope="col" class="relative px-10px py-10px bg-soft-secondary text-primary !text-center">
<span class="font-size-12px font-weight-700">{{ item }}</span>
<div class="absolute top-1/2 transform -translate-y-1/2 right-0" *ngIf="!l">
<i class="ti ti-dots-vertical fs-l"></i>
</div>
</th>
</ng-container>
</tr>
</thead>
<tbody *ngIf="user.loading">
<tr>
<td class="text-center" colspan="100%">
<div *ngFor="let item of [1,2,3]" class="ti-spinner w-8 h-8 text-secondary mx-1" role="status"
aria-label="loading">
<span class="sr-only">Loading...</span>
</div>
</td>
</tr>
</tbody>
<tbody *ngIf="!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">{{item.data.usernameId}} </td>
<td class="text-center">{{item.data.empId}}</td>
<td>{{item.data.employee.fname}}</td>
<td>{{item.data.employee.lname}}</td>
<td class="text-center">{{item.data.status=='0'?'ไม่ใช้งาน':'ใช้งาน'}}</td>
<td class="flex justify-center">
<i class="ti ti-edit cursor-pointer i-gray fs-l px-1" (click)="selectUser(item.data)"
data-hs-overlay="#manage-user-modal"></i>
</td>
</tr>
</tbody>
</table>
</div>
<nav class="pagination-style-3 overflow-auto my-5" *ngIf="page.length">
<ul class="ti-pagination">
<li>
<a aria-label="anchor" class="page-link" href="javascript:void(0);"
(click)="currentPage = (currentPage-1 || 1)">
<i class="ri-arrow-left-s-line align-middle rtl:rotate-180"></i>
</a>
</li>
<li *ngFor="let item of page;let f = first;let l = last">
<ng-container *ngIf="item==3&&currentPage!=1&&currentPage!=2&&currentPage!=3">
<a aria-label="anchor" class="page-link" href="javascript:void(0);"><i class="ri-more-line"></i>
</a>
</ng-container>
<ng-container *ngIf="(f||l)||(item==currentPage-1||item==currentPage||item==currentPage+1)">
<a class="page-link" href="javascript:void(0);" [class.active]="item==currentPage"
(click)="currentPage=item">{{item}}
</a>
</ng-container>
<ng-container
*ngIf="item==page.length-2&&currentPage!=page.length&&currentPage!=page.length-1&&currentPage!=page.length-2">
<a aria-label="anchor" class="page-link" href="javascript:void(0);"><i class="ri-more-line"></i>
</a>
</ng-container>
</li>
<li>
<a aria-label="anchor" class="page-link" href="javascript:void(0);"
(click)="currentPage = (currentPage > page.length-1 ? currentPage: currentPage+1 )">
<i class="ri-arrow-right-s-line align-middle rtl:rotate-180"></i>
</a>
</li>
</ul>
<ul class="nav-tabs mt-3">
<span>Show {{((currentPage-1) * 10)+1}} to {{userListFilter().length<10 ?userListFilter().length:
(currentPage==page.length ? ((currentPage * 10) - ((currentPage * 10) - userListFilter().length) )
:(currentPage * 10) ) }} of {{userListFilter().length}} items</span>
</ul>
</nav>
</div>
<div id="manage-user-modal" class="hs-overlay hidden ti-modal">
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)]">
<div class="max-h-full overflow-hidden ti-modal-content">
<div class="ti-modal-header">
<h3 class="text-xxl font-bold text-primary">
จัดการผู้ใช้งาน
</h3>
<div class="flex justify-end">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#manage-user-modal">
<span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i>
</button>
</div>
</div>
<div class="w-full flex justify-end">
<div class="absolute flex">
<div class="px-1">
<button type="button" class="ti-btn ti-btn-soft-indigo h-45px m-0 shadow-md"
(click)="userPassword.oldPassword='';userPassword.newPassword=''">
<svg class="svg-indigo" width="16" height="16" viewBox="0 0 64.00 64.00"
xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#595BEA" stroke-width="3.84"
transform="rotate(45)matrix(-1, 0, 0, 1, 0, 0)">
<g id="SVGRepo_bgCarrier" stroke-width="0"></g>
<g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g>
<g id="SVGRepo_iconCarrier">
<path d="M15 49A24 24 0 0 1 32 8"></path>
<path d="M49 15a24 24 0 0 1-17 41"></path>
<polyline points="15.03 40 15.03 48.97 8 48.97"></polyline>
<polyline points="48.97 24 48.97 15.03 56 15.03"></polyline>
</g>
</svg>
Clear
</button>
</div>
<div class="px-1">
<button href="javascript:void(0);" class="ti-btn ti-btn-soft-warning h-45px m-0 shadow-md">
<i class="ti ti-book fs-l"></i>
Help
</button>
</div>
</div>
</div>
<div class="ti-modal-body padding-16px pt-0 overflow-y-0">
<label class="ti-form-label mt-2rem">ชื่อล็อคอิน</label>
<input type="text" class="ti-form-input bg-input-readonly" readonly
[(ngModel)]="userPassword.usernameId">
<label class="ti-form-label mt-2rem">รหัสพนักงาน</label>
<input type="text" class="ti-form-input bg-input-readonly" readonly [(ngModel)]="userPassword.empId">
<div class="mt-2rem grid grid-cols-5 gap-6">
<div class="flex">
<input type="radio" name="hs-default-radio" class="ti-form-radio" [value]="'0'"
[(ngModel)]="user.select.status" id="hs-default-radio">
<label for="hs-default-radio"
class="text-sm text-gray-500 ltr:ml-2 rtl:mr-2 dark:text-white/70">ไม่ใช้งาน</label>
</div>
<div class="flex">
<input type="radio" name="hs-default-radio" class="ti-form-radio" [value]="'1'"
[(ngModel)]="user.select.status" id="hs-checked-radio" checked>
<label for="hs-checked-radio"
class="text-sm text-gray-500 ltr:ml-2 rtl:mr-2 dark:text-white/70">ใช้งาน</label>
</div>
</div>
<div class="mt-2rem">
<div class="flex">
<input type="checkbox" class="ti-form-checkbox mt-0.5" id="hs-default-checkbox"
[(ngModel)]="changePassword">
<label for="hs-default-checkbox"
class="text-sm text-gray-500 ltr:ml-2 rtl:mr-2 dark:text-white/70">เปลี่ยนรหัสผ่าน</label>
</div>
</div>
<ng-container *ngIf="changePassword">
<label class="ti-form-label mt-2rem">รหัสผ่านเก่า*</label>
<input type="password" class="ti-form-input" [(ngModel)]="userPassword.oldPassword">
<label class="ti-form-label mt-2rem">รหัสผ่านใหม่*</label>
<input type="password" class="ti-form-input" [(ngModel)]="userPassword.newPassword">
</ng-container>
<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="#manage-user-modal">
ย้อนกลับ
</button>
<button type="button" class="ti-btn ti-btn-success" data-hs-overlay="#manage-user-alert-modal"
[class.ti-btn-disabled]="changePassword&&(!userPassword.newPassword || !userPassword.oldPassword)"
[disabled]="changePassword&&(!userPassword.newPassword||!userPassword.oldPassword)">
บันทึกข้อมูล
</button>
</div>
</div>
</div>
</div>
</div>
<div id="manage-user-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">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#manage-user-modal">
<span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i>
</button>
</div>
</div>
<div class="ti-modal-body ">
<p class="mt-1 text-gray-800 dark:text-white/70">
ยืนยันการบันทึกข้อมูลหรือไม่
</p>
<div class="flex justify-end mt-2rem mb-1rem">
<button type="button"
class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
data-hs-overlay="#manage-user-modal">
ย้อนกลับ
</button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#manage-user-alert-modal" (click)="updateUserPassword()">
บันทึกข้อมูล
</a>
</div>
</div>
</div>
</div>
</div>
\ No newline at end of file
import { ChangeDetectorRef, Component, EventEmitter, Input, Output } from '@angular/core';
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({
selector: 'app-manage-user',
templateUrl: './manage-user.component.html',
styleUrls: ['./manage-user.component.scss']
})
export class ManageUserComponent {
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 = {
usernameId: "",
empId: "",
companyId: "",
oldPassword: "",
newPassword: "",
}
changePassword = false
constructor(private toastr: ToastrService,
private cdr: ChangeDetectorRef,
private userService: UserService) {
this.companyId = this.decodeJWT(sessionStorage.getItem("accessToken") || '').companyid
}
ngOnInit(): void {
this.getUserList()
}
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);
}
getUserList() {
this.user.loading = true
this.userService.getList("false").subscribe({
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)
this.userPassword = {
usernameId: this.user.select.usernameId,
empId: this.user.select.empId,
companyId: this.user.select.companyId,
oldPassword: "",
newPassword: "",
}
}
updateUserPassword() {
if (this.changePassword) {
this.user.loading = true
this.userService.changePassword(this.userPassword).subscribe({
next: response => {
if (response.success) {
this.updateUser()
} 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.updateUser()
}
}
updateUser() {
this.user.loading = true
this.userService.post(new MyUserModel(this.user.select)).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);
}
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,
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 justify-between"> <div class="flex justify-end">
<div class="flex pr-2"> <div class="px-1">
<div class="px-1"> <div class="relative shadow-md">
<button type="button" class="ti-btn ti-btn-soft-secondary h-20px m-0 shadow-md" <input type="text" class="ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 "
data-hs-overlay="#company-registration-page-upload-modal"> placeholder="Search by No. or Name" style="height: 40px;" [(ngModel)]="search"
<i class="ri-add-line"></i> (ngModelChange)="searchChange()">
นำเข้าข้อมูล <div
</button> 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">
<a class="mx-2 justify-center -mb-px inline-flex items-center gap-2 font-weight-500 font-size-12px text-center text-secondary border-secondary border-b-2 align-items-end" <i class="ri-search-line text-gray"></i>
href="javascript:void(0);"> </div>
ดาวน์โหลดตัวอย่างไฟล์
</a>
</div> </div>
</div> </div>
<div class="flex justify-end"> <div class="px-1">
<div class="px-1"> <button type="button" class="ti-btn ti-btn-soft-warning h-20px m-0 shadow-md">
<div class="relative shadow-md"> <i class="ti ti-book fs-l"></i>
<input type="text" id="hs-leading-icon" name="hs-leading-icon" Help
class="ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 " placeholder="Search by No. or Name" style="height: 40px;"> </button>
<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"> </div>
<i class="ri-search-line text-gray"></i> </div>
</div>
</div>
</div>
<div class="px-1">
<button type="button" class="ti-btn ti-btn-soft-secondary h-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>
Help
</button>
</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>
<tr> <tr>
<ng-container <ng-container
*ngFor="let item of ['ชื่อล็อคอิน','รหัสพนักงาน','ชื่อ','นามสกุล','สถานะ','การจัดการ']; let f = first; let l = last; let i = index"> *ngFor="let item of ['ชื่อล็อคอิน','รหัสพนักงาน','ชื่อ','นามสกุล','สถานะ','การจัดการ']; let f = first; let l = last; 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">{{ 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>
</div> </div>
</th> </th>
</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>
<td class="text-center"> </tbody>
<input type="checkbox" class="ti-form-checkbox cursor-pointer" id="checkbox-{{item[0]}}"> <tbody *ngIf="!user.loading&&!userListFilter().length">
<label for="checkbox-{{item[0]}}">&nbsp;{{item[0]}}</label> <tr>
</td> <td class="text-center" colspan="100%">
<td class="text-center">{{item[1]}}</td> ไม่พบข้อมูล
<td>{{item[2]}}</td> </td>
<td>{{item[3]}}</td> </tr>
<td class="text-center">{{item[4]}}</td> </tbody>
<tbody *ngIf="!user.loading&&userListFilter().length">
<td class="flex justify-center"> <tr
<i class="ti ti-edit cursor-pointer i-gray fs-l px-1" data-hs-overlay="#set-a-password-modal-edit"></i> *ngFor="let item of userListFilter() | slice:((currentPage-1) * 10) : (((currentPage-1) * 10) + 10);let i = index">
<i class="ti ti-trash cursor-pointer i-gray fs-l px-1" data-hs-overlay="#set-a-password-alert-delete-modal"></i> <td class="text-center">{{item.data.usernameId}} </td>
</td> <td class="text-center">{{item.data.empId}}</td>
</tr> <td>{{item.data.employee.fname}}</td>
</tbody> <td>{{item.data.employee.lname}}</td>
</table> <td class="text-center">{{item.data.status=='0'?'ไม่ใช้งาน':'ใช้งาน'}}</td>
</div> <td class="flex justify-center">
<i class="ti ti-edit cursor-pointer i-gray fs-l px-1" (click)="selectUser(item.data)"
<div class="body-content" style="margin-top: 20px;"> data-hs-overlay="#user-setting-modal"></i>
<ul class="nav-tabs"> </td>
<div class="px-1 py-1 bg-white rounded-2 shadow justify-content-center align-items-center"> </tr>
<div class="box-body"> </tbody>
<nav class="pagination-style-3 overflow-auto"> </table>
<ul class="ti-pagination"> </div>
<li> <nav class="pagination-style-3 overflow-auto my-5" *ngIf="page.length">
<a aria-label="anchor" class="page-link" href="javascript:void(0);"> <ul class="ti-pagination">
<i class="ri-arrow-left-s-line align-middle rtl:rotate-180"></i> <li>
</a> <a aria-label="anchor" class="page-link" href="javascript:void(0);"
</li> (click)="currentPage = (currentPage-1 || 1)">
<li><a class="page-link active" href="javascript:void(0);" aria-current="page">1</a></li> <i class="ri-arrow-left-s-line align-middle rtl:rotate-180"></i>
<li><a class="page-link" href="javascript:void(0);">2</a></li> </a>
<li><a class="page-link" href="javascript:void(0);">3</a></li> </li>
<li><a class="page-link" href="javascript:void(0);">4</a></li> <li *ngFor="let item of page;let f = first;let l = last">
<li><a class="page-link" href="javascript:void(0);">5</a></li> <ng-container *ngIf="item==3&&currentPage!=1&&currentPage!=2&&currentPage!=3">
<li><a class="page-link" href="javascript:void(0);">...</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);">31</a></li> </a>
<li> </ng-container>
<a aria-label="anchor" class="page-link" href="javascript:void(0);"> <ng-container *ngIf="(f||l)||(item==currentPage-1||item==currentPage||item==currentPage+1)">
<i class="ri-arrow-right-s-line align-middle rtl:rotate-180"></i> <a class="page-link" href="javascript:void(0);" [class.active]="item==currentPage"
</a> (click)="currentPage=item">{{item}}
</li> </a>
</ul> </ng-container>
</nav> <ng-container
</div> *ngIf="item==page.length-2&&currentPage!=page.length&&currentPage!=page.length-1&&currentPage!=page.length-2">
</div> <a aria-label="anchor" class="page-link" href="javascript:void(0);"><i class="ri-more-line"></i>
</a>
</ng-container>
</li>
<li>
<a aria-label="anchor" class="page-link" href="javascript:void(0);"
(click)="currentPage = (currentPage > page.length-1 ? currentPage: currentPage+1 )">
<i class="ri-arrow-right-s-line align-middle rtl:rotate-180"></i>
</a>
</li>
</ul> </ul>
<ul class="nav-tabs"> <ul class="nav-tabs mt-3">
<p>Show 1 to 10 of 50 items</p> <span>Show {{((currentPage-1) * 10)+1}} to {{userListFilter().length<10 ?userListFilter().length:
(currentPage==page.length ? ((currentPage * 10) - ((currentPage * 10) - userListFilter().length) )
:(currentPage * 10) ) }} of {{userListFilter().length}} items</span>
</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"
xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#595BEA" stroke-width="3.84"
transform="rotate(45)matrix(-1, 0, 0, 1, 0, 0)">
<g id="SVGRepo_bgCarrier" stroke-width="0"></g>
<g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g>
<g id="SVGRepo_iconCarrier">
<path d="M15 49A24 24 0 0 1 32 8"></path>
<path d="M49 15a24 24 0 0 1-17 41"></path>
<polyline points="15.03 40 15.03 48.97 8 48.97"></polyline>
<polyline points="48.97 24 48.97 15.03 56 15.03"></polyline>
</g>
</svg>
Clear
</button> </button>
</div> </div>
</div>
</div>
<div class="ti-modal-body-new">
<form class="space-y-5">
<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>
<div class="col-span-6 sm:col-span-6 relative">
<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-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>
</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: 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>
</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,119 +152,31 @@ ...@@ -218,119 +152,31 @@
</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="password" class="ti-form-input" [(ngModel)]="userPassword.newPassword">
<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 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);" <button type="button" class="ti-btn ti-btn-success" data-hs-overlay="#user-setting-alert-modal"
data-hs-overlay="#set-a-password-alert-add-modal" (click)="showSuccessAdd()"> [class.ti-btn-disabled]="!userPassword.newPassword" [disabled]="!userPassword.newPassword">
บันทึกข้อมูล บันทึกข้อมูล
</a>
</div>
</div>
</div>
</div>
</div>
<div id="set-a-password-alert-edit-modal" class="hs-overlay hidden ti-modal">
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)] flex items-center">
<div class="max-h-full overflow-hidden ti-modal-content w-full">
<div class="ti-modal-header">
<h3 class="text-xxl font-bold text-primary">
แจ้งเตือน
</h3>
<div class="flex justify-end">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#set-a-password-alert-edit-modal">
<span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i>
</button>
</div>
</div>
<div class="ti-modal-body ">
<p class="mt-1 text-gray-800 dark:text-white/70">
ยืนยันการแก้ไขข้อมูลหรือไม่
</p>
<div class="flex justify-end mt-2rem mb-1rem">
<button type="button"
class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
data-hs-overlay="#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 +185,7 @@ ...@@ -339,7 +185,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 +193,17 @@ ...@@ -347,18 +193,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: "",
newPassword: "",
}
constructor(private toastr: ToastrService,
private cdr: ChangeDetectorRef,
private userService: UserService,
private fileService: FileService) {
this.companyId = this.decodeJWT(sessionStorage.getItem("accessToken") || '').companyid
}
ngOnInit(): void {
this.getUserList()
} }
modalOptions: {
[nameModal: string]: { // ชื่อตรวจสอบการเปิดปิด
isModalOpen: boolean; // เปิด/ปิด
modalSize: string; // ขนาดของ Modal (s,m,l,vw10-vw100 )
backdropClose: boolean; // (คลิก Backdrop แล้ว true ปิด false ไม่ปิด )
}
} = {
"add": {
isModalOpen: false,
modalSize: 'm',
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("true").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: "",
} }
} }
isAnyModalOpen(): boolean { updateUserPassword() {
// Logic ตรวจสอบว่า Modal อื่นยังเปิดอยู่หรือไม่ this.user.loading = true
return Object.values(this.modalOptions).some(modal => modal.isModalOpen); // หากไม่มี Modal อื่นเปิด this.userService.changePassword(this.userPassword).subscribe({
next: response => {
if (response.success) {
this.updateUser()
} 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()
}
})
} }
showSuccessAdd() {
this.toastr.success('บันทึกข้อมูลสำเร็จ', 'แจ้งเตือน', { updateUser() {
timeOut: 3000, this.user.loading = true
positionClass: 'toast-top-right', this.userService.post(new MyUserModel({ ...this.user.select, status: '1' })).subscribe({
}); next: response => {
if (response.success) {
this.showAlert(response.message, 'success')
this.getUserList()
} 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()
}
})
} }
showSuccessEdit() { searchChange() {
this.toastr.success('แก้ไขข้อมูลสำเร็จ', 'แจ้งเตือน', { this.currentPage = 1
timeOut: 3000, this.page = Array.from({ length: Math.ceil(this.userListFilter().length / 10) }, (_, i) => i + 1);
positionClass: 'toast-top-right', }
}); selectDataModal(target: { [key: string]: any }, field: string, data: any) {
target[field] = JSON.parse(JSON.stringify(data))
} }
showSuccessDelete() { showAlert(text: string, type: 'success' | 'error') {
this.toastr.success('ลบข้อมูลสำเร็จ', 'แจ้งเตือน', { 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">
<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>
<a class="mx-2 justify-center -mb-px inline-flex items-center gap-2 font-weight-500 font-size-12px text-center text-secondary border-secondary border-b-2 align-items-end" <a class="mx-2 justify-center -mb-px inline-flex items-center gap-2 font-weight-500 font-size-12px text-center text-secondary border-secondary border-b-2 align-items-end"
href="javascript:void(0);"> href="javascript:void(0);" (click)="downloadFile()">
ดาวน์โหลดตัวอย่างไฟล์ ดาวน์โหลดตัวอย่างไฟล์
</a> </a>
</div> </div>
</div> </div>
<div class="flex justify-end"> <div class="flex justify-end">
<div class="px-1"> <div class="px-1">
<div class="relative shadow-md"> <div class="relative shadow-md">
<input type="text" id="hs-leading-icon" name="hs-leading-icon" <input type="text" 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"
<div (ngModelChange)="searchChange()">
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"> <div
<i class="ri-search-line text-gray"></i> 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">
</div> <i class="ri-search-line text-gray"></i>
</div> </div>
</div> </div>
<div class="px-1"> </div>
<button type="button" class="ti-btn ti-btn-soft-secondary h-20px m-0 shadow-md" <div class="px-1">
data-hs-overlay="#user-settings-component-modal-add"> <button type="button" class="ti-btn ti-btn-soft-secondary h-20px m-0 shadow-md"
<i class="ri-add-line"></i> data-hs-overlay="#user-setting-modal" (click)="currentModal='add';selectUser()">
Add <i class="ri-add-line"></i>
</button> Add
</div> </button>
<div class="px-1"> </div>
<button href="javascript:void(0);" class="ti-btn ti-btn-soft-danger h-20px m-0 shadow-md" <div class="px-1">
data-hs-overlay="#user-settings-component-alert-delete-modal"> <button type="button" class="ti-btn ti-btn-soft-danger h-20px m-0 shadow-md"
<i class="ri-delete-bin-6-line"></i> data-hs-overlay="#user-setting-alert-modal" (click)="currentModal='deleteGroup'">
Delete <i class="ri-delete-bin-6-line"></i>
</button> Delete
</div> </button>
<div class="px-1"> </div>
<button href="javascript:void(0);" class="ti-btn ti-btn-soft-warning h-20px m-0 shadow-md"> <div class="px-1">
<i class="ti ti-book fs-l"></i> <button type="button" class="ti-btn ti-btn-soft-warning h-20px m-0 shadow-md">
Help <i class="ti ti-book fs-l"></i>
</button> Help
</div> </button>
</div> </div>
</div> </div>
</div> </div>
</div>
<div class="page px-rem"> <div class="page px-rem">
<div class="overflow-auto shadow-md rounded-t-md"> <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>
<tr> <tr>
<ng-container <ng-container
*ngFor="let item of ['ชื่อล็อคอิน','รหัสพนักงาน','ชื่อ','นามสกุล','สถานะ','การจัดการ']; let f = first; let l = last; let i = index"> *ngFor="let item of ['ชื่อล็อคอิน','รหัสพนักงาน','ชื่อ','นามสกุล','สถานะ','การจัดการ']; let f = first; let l = last; 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">{{ 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>
</div> </div>
</th> </th>
</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>
<td class="text-center"> </tbody>
<input type="checkbox" class="ti-form-checkbox cursor-pointer" id="checkbox-{{item[0]}}"> <tbody *ngIf="!user.loading&&!userListFilter().length">
<label for="checkbox-{{item[0]}}">&nbsp;{{item[0]}}</label> <tr>
</td> <td class="text-center" colspan="100%">
<td class="text-center">{{item[1]}}</td> ไม่พบข้อมูล
<td>{{item[2]}}</td> </td>
<td>{{item[3]}}</td> </tr>
<td class="text-center">{{item[4]}}</td> </tbody>
<td class="flex justify-center"> <tbody *ngIf="!user.loading&&userListFilter().length">
<i class="ti ti-edit cursor-pointer i-gray fs-l px-1" data-hs-overlay="#user-settings-component-modal-edit"></i> <tr
<i class="ti ti-trash cursor-pointer i-gray fs-l px-1" data-hs-overlay="#user-settings-component-alert-delete-modal"></i> *ngFor="let item of userListFilter() | slice:((currentPage-1) * 10) : (((currentPage-1) * 10) + 10);let i = index">
</td> <td class="text-center">
</tr> <input type="checkbox" class="ti-form-checkbox cursor-pointer"
</tbody> id="checkbox-{{item.data.usernameId}}" [(ngModel)]="item.check"
</table> (ngModelChange)="dataListCheck()">
</div> <label for="checkbox-{{item.data.usernameId}}">&nbsp;{{item.data.usernameId}}</label>
</div> </td>
<div class="body-content" style="margin-top: 20px;"> <td class="text-center">{{item.data.empId}}</td>
<ul class="nav-tabs"> <td>{{item.data.employee.fname}}</td>
<div class="px-1 py-1 bg-white rounded-2 shadow justify-content-center align-items-center"> <td>{{item.data.employee.lname}}</td>
<div class="box-body"> <td class="text-center">{{item.data.status=='0'?'ไม่ใช้งาน':'ใช้งาน'}}</td>
<nav class="pagination-style-3 overflow-auto"> <td class="flex justify-center">
<ul class="ti-pagination"> <i class="ti ti-edit cursor-pointer i-gray fs-l px-1"
<li> (click)="currentModal='edit';selectUser(item.data)"
<a aria-label="anchor" class="page-link" href="javascript:void(0);"> data-hs-overlay="#user-setting-modal"></i>
<i class="ri-arrow-left-s-line align-middle rtl:rotate-180"></i> <i class="ti ti-trash cursor-pointer i-gray fs-l px-1"
</a> data-hs-overlay="#user-setting-alert-modal"
</li> (click)="currentModal='delete';selectUser(item.data)"></i>
<li><a class="page-link active" href="javascript:void(0);" aria-current="page">1</a></li> </td>
<li><a class="page-link" href="javascript:void(0);">2</a></li> </tr>
<li><a class="page-link" href="javascript:void(0);">3</a></li> </tbody>
<li><a class="page-link" href="javascript:void(0);">4</a></li> </table>
<li><a class="page-link" href="javascript:void(0);">5</a></li> </div>
<li><a class="page-link" href="javascript:void(0);">...</a></li> <nav class="pagination-style-3 overflow-auto my-5" *ngIf="page.length">
<li><a class="page-link" href="javascript:void(0);">31</a></li> <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);"
<i class="ri-arrow-right-s-line align-middle rtl:rotate-180"></i> (click)="currentPage = (currentPage-1 || 1)">
</a> <i class="ri-arrow-left-s-line align-middle rtl:rotate-180"></i>
</li> </a>
</ul> </li>
</nav> <li *ngFor="let item of page;let f = first;let l = last">
</div> <ng-container *ngIf="item==3&&currentPage!=1&&currentPage!=2&&currentPage!=3">
</div> <a aria-label="anchor" class="page-link" href="javascript:void(0);"><i class="ri-more-line"></i>
</a>
</ng-container>
<ng-container *ngIf="(f||l)||(item==currentPage-1||item==currentPage||item==currentPage+1)">
<a class="page-link" href="javascript:void(0);" [class.active]="item==currentPage"
(click)="currentPage=item">{{item}}
</a>
</ng-container>
<ng-container
*ngIf="item==page.length-2&&currentPage!=page.length&&currentPage!=page.length-1&&currentPage!=page.length-2">
<a aria-label="anchor" class="page-link" href="javascript:void(0);"><i class="ri-more-line"></i>
</a>
</ng-container>
</li>
<li>
<a aria-label="anchor" class="page-link" href="javascript:void(0);"
(click)="currentPage = (currentPage > page.length-1 ? currentPage: currentPage+1 )">
<i class="ri-arrow-right-s-line align-middle rtl:rotate-180"></i>
</a>
</li>
</ul> </ul>
<ul class="nav-tabs"> <ul class="nav-tabs mt-3">
<p>Show 1 to 10 of 50 items</p> <span>Show {{((currentPage-1) * 10)+1}} to {{userListFilter().length<10 ?userListFilter().length:
(currentPage==page.length ? ((currentPage * 10) - ((currentPage * 10) - userListFilter().length) )
:(currentPage * 10) ) }} of {{userListFilter().length}} items</span>
</ul> </ul>
</div> </nav>
</div>
<div id="user-settings-component-modal-add" 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">
<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">
กำหนดค่าผู้ใช้งานระบบ {{currentModal=='add'?'กำหนดค่าผู้ใช้งานระบบ':'แก้ไขข้อมูลผู้ใช้งานระบบ'}}
</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="w-full flex justify-end">
<div class="checkbox-container text-primary" style="display: flex; justify-content: flex-end; gap: 3px; margin-bottom: 10px;"> <div class="absolute flex">
<label style="display: flex; align-items: center; margin-right: 20px;"> <div class="px-1">
<input type="checkbox" style="transform: scale(0.6); margin-right: 2px;">ใช้งาน <button type="button" class="ti-btn ti-btn-soft-indigo h-45px m-0 shadow-md"
</label> (click)="clearDataUser(currentModal)">
<label style="display: flex; align-items: center;"> <svg class="svg-indigo" width="16" height="16" viewBox="0 0 64.00 64.00"
<input type="checkbox" style="transform: scale(0.6); margin-right: 2px;">ไม่ใช้งาน xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#595BEA" stroke-width="3.84"
</label> transform="rotate(45)matrix(-1, 0, 0, 1, 0, 0)">
</div> <g id="SVGRepo_bgCarrier" stroke-width="0"></g>
<form class="space-y-3"> <g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g>
<div class="sm:grid grid-cols-12 gap-x-6"> <g id="SVGRepo_iconCarrier">
<label class="col-span-3 ti-form-label text-primary mt-2">ชื่อล็อคอิน</label> <path d="M15 49A24 24 0 0 1 32 8"></path>
<input type="email" class="sm:col-span-4 ti-form-input" placeholder=""> <path d="M49 15a24 24 0 0 1-17 41"></path>
<polyline points="15.03 40 15.03 48.97 8 48.97"></polyline>
<polyline points="48.97 24 48.97 15.03 56 15.03"></polyline>
</g>
</svg>
Clear
</button>
</div> </div>
<div class="sm:grid grid-cols-12 gap-x-6"> <div class="px-1">
<label class="col-span-3 ti-form-label text-primary mt-4">รหัสพนักงาน</label> <button href="javascript:void(0);" class="ti-btn ti-btn-soft-warning h-45px m-0 shadow-md">
<div class="col-span-3 relative mt-2"> <i class="ti ti-book fs-l"></i>
<div> Help
<div class="relative flex rounded-md"> </button>
<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>
<div class="sm:grid grid-cols-12 gap-x-6"> </div>
<label class="col-span-3 ti-form-label text-primary mt-4">บทบาท</label> </div>
<div class="col-span-3 relative mt-2"> <div class="ti-modal-body padding-16px pt-0 overflow-y-0">
<div> <label class="ti-form-label mt-2rem">ชื่อล็อคอิน*</label>
<div class="relative flex rounded-md"> <input type="text" class="ti-form-input"
<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"> oninput="this.value = this.value.replace(/[\u0E00-\u0E7F]/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"> [ngClass]="{'bg-input-readonly':currentModal=='edit'}" [readonly]="currentModal=='edit'"
<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"> [(ngModel)]="user.select.usernameId" [maxLength]="20">
<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> <div class="grid grid-cols-2 gap-2">
</div> <div class="relative flex rounded-md">
</div> <input type="text" class="ti-form-input" readonly [(ngModel)]="user.select.employee.employeeId">
</div> <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">
<div class="flex col-span-4 relative mt-2"> <button type="button" class="flex items-center text-red-500" (click)="selectEmployee()">
<input type="password" class="ti-form-input bg-input-readonly" disabled placeholder=""> <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-employee-table-modal"
(click)="modal.search='';modal.currentPage=1;searchModalChange(employeeListFilter())">
<i class="ri-search-line cursor-pointer text-gray"></i>
</button>
</div> </div>
</div> </div>
<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-3 ti-form-label text-primary mt-4">ระดับ</label> [(ngModel)]="user.select.employee.thFullName">
<div class="col-span-3 relative mt-2"> </div>
<div> <label class="ti-form-label mt-2rem">บทบาท*</label>
<div class="relative flex rounded-md"> <div class="grid grid-cols-2 gap-2">
<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="relative flex rounded-md">
<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"> <input type="text" class="ti-form-input" readonly [(ngModel)]="user.select.role.roleId">
<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"> <div
<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"/> 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">
</svg> <button type="button" class="flex items-center text-red-500" (click)="selectRole()">
</div> <i class=" ti ti-circle-x cursor-pointer"></i>
</div> </button>
</div> <button type="button" class="flex items-center text-gray-500 dark:text-white/70"
</div> data-hs-overlay="#user-setting-role-table-modal"
<div class="flex col-span-4 relative mt-2"> (click)="modal.search='';modal.currentPage=1;searchModalChange(roleListFilter())">
<input type="password" class="ti-form-input bg-input-readonly" disabled placeholder=""> <i class="ri-search-line cursor-pointer text-gray"></i>
</button>
</div> </div>
</div> </div>
<div class="sm:grid grid-cols-12 gap-x-6 mt-4"> <input type="text" class="ti-form-input bg-input-readonly" readonly
<label class="col-span-3 ti-form-label text-primary mt-2">สถานะรหัสผ่าน</label> [(ngModel)]="user.select.role.tdesc">
<div class="col-span-6 mt-2 flex"> </div>
<select class="ti-form-input flex" > <label class="ti-form-label mt-2rem">ระดับ*</label>
<option value="1">รหัสผ่านถูกตั้งใหม่เเล้ว</option> <div class="grid grid-cols-2 gap-2">
</select> <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>
</div> </div>
</form> <input type="text" class="ti-form-input bg-input-readonly" readonly
<div class="flex justify-end mt-2rem mb-1rem space-x-2" style="margin-top: 75px;"> [(ngModel)]="user.select.level.tdesc">
</div>
<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-modal-add"> data-hs-overlay="#user-setting-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="#user-setting-alert-modal"
data-hs-overlay="#user-settings-component-alert-modal"> [class.ti-btn-disabled]="!user.select.usernameId||!user.select.employee.employeeId||!user.select.role.roleId||!user.select.level.userLevel"
[disabled]="!user.select.usernameId||!user.select.employee.employeeId||!user.select.role.roleId||!user.select.level.userLevel">
บันทึกข้อมูล บันทึกข้อมูล
</a> </button>
</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-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-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" style="display: flex; justify-content: flex-end; gap: 3px; margin-bottom: 10px;"> <div class="flex justify-end pb-1rem">
<label style="display: flex; align-items: center; margin-right: 20px;"> <div class="px-1">
<input type="checkbox" style="transform: scale(0.6); margin-right: 2px;">ใช้งาน <div class="relative shadow-md">
</label> <input type="text" id="hs-leading-icon" name="hs-leading-icon"
<label style="display: flex; align-items: center;"> class="ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 "
<input type="checkbox" style="transform: scale(0.6); margin-right: 2px;">ไม่ใช้งาน placeholder="Search by No. or Name" [(ngModel)]="modal.search"
</label> (ngModelChange)="searchModalChange(employeeListFilter())">
</div> <div
<form class="space-y-3"> 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">
<div class="sm:grid grid-cols-12 gap-x-6"> <i class="ri-search-line text-gray"></i>
<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> </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"> </div>
<label class="col-span-3 ti-form-label text-primary mt-4">บทบาท</label> <div class="page px-rem">
<div class="col-span-3 relative mt-2"> <div class="overflow-auto table-bordered rounded-t-md">
<div> <div class="overflow-auto shadow-md rounded-t-md">
<div class="relative flex rounded-md"> <table class="ti-custom-table ti-custom-table-head ti-custom-table-hover">
<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"> <thead>
<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"> <tr>
<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"> <ng-container
<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"/> *ngFor="let item of ['รหัสพนักงาน','ชื่อ','นามสกุล','ตำแหน่ง','หน่วยงาน']; let f = first; let l = last; let i = index">
</svg> <th scope="col"
</div> class=" px-10px py-10px bg-soft-secondary text-primary !text-center">
</div> <span class="font-size-12px font-weight-700">{{ item }}</span>
</div> <div class="absolute top-1/2 transform -translate-y-1/2 right-0">
</div> <i class="ti ti-dots-vertical fs-l"></i>
<div class="flex col-span-4 relative mt-2"> </div>
<input type="password" class="ti-form-input bg-input-readonly" disabled placeholder=""> </th>
</div> </ng-container>
</div> </tr>
<div class="sm:grid grid-cols-12 gap-x-6"> </thead>
<label class="col-span-3 ti-form-label text-primary mt-4">ระดับ</label> <tbody *ngIf="employee.loading">
<div class="col-span-3 relative mt-2"> <tr>
<div> <td class="text-center" colspan="100%">
<div class="relative flex rounded-md"> <div *ngFor="let item of [1,2,3]"
<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"> class="ti-spinner w-8 h-8 text-secondary mx-1" role="status"
<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"> aria-label="loading">
<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"> <span class="sr-only">Loading...</span>
<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"/> </div>
</svg> </td>
</div> </tr>
</div> </tbody>
</div> <tbody *ngIf="!employee.loading&&!employeeListFilter().length">
</div> <tr>
<div class="flex col-span-4 relative mt-2"> <td class="text-center" colspan="100%">
<input type="password" class="ti-form-input bg-input-readonly" disabled placeholder=""> ไม่พบข้อมูล
</div> </td>
</div> </tr>
<div class="sm:grid grid-cols-12 gap-x-6 mt-4"> </tbody>
<label class="col-span-3 ti-form-label text-primary mt-2">สถานะรหัสผ่าน</label> <tbody *ngIf="!employee.loading&&employeeListFilter().length">
<div class="col-span-6 mt-2 flex"> <tr *ngFor="let item of employeeListFilter() | slice:((modal.currentPage-1) * 10) : (((modal.currentPage-1) * 10) + 10);let i = index"
<select class="ti-form-input flex" > class="cursor-pointer" (click)="selectEmployee(item.data)"
<option value="1">รหัสผ่านถูกตั้งใหม่เเล้ว</option> data-hs-overlay="#user-setting-modal">
</select> <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> </div>
</form> <nav class="pagination-style-3 overflow-auto my-5" *ngIf="modal.page.length">
<div class="flex justify-end mt-2rem mb-1rem space-x-2" style="margin-top: 75px;"> <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 class="flex justify-end mt-2rem mb-1rem space-x-4">
<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-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)] 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"
class="ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 "
placeholder="Search by No. or Name" [(ngModel)]="modal.search"
(ngModelChange)="searchModalChange(roleListFilter())">
<div
class="absolute inset-y-0 ltr:left-0 rtl:right-0 flex items-center pointer-events-none z-20 ltr:pl-4 rtl:pr-4">
<i class="ri-search-line text-gray"></i>
</div>
</div>
</div>
</div>
<div class="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>
</th>
</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>
</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>
<div class="flex justify-end mt-2rem mb-1rem"> </tr>
</tbody>
</table>
</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 class="flex justify-end mt-2rem mb-1rem space-x-4">
<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" (click)="addUser();showSuccess()">
บันทึกข้อมูล
</a>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div id="user-settings-component-alert-edit-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-edit-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 "
placeholder="Search by No. or Name" [(ngModel)]="modal.search"
(ngModelChange)="searchModalChange(levelListFilter())">
<div
class="absolute inset-y-0 ltr:left-0 rtl:right-0 flex items-center pointer-events-none z-20 ltr:pl-4 rtl:pr-4">
<i class="ri-search-line text-gray"></i>
</div>
</div>
</div>
</div>
<div class="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>
</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>
</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>
<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 class="flex justify-end mt-2rem mb-1rem space-x-4">
<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" (click)="addUser();showSuccessEdit()">
บันทึกข้อมูล
</a>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div id="user-settings-component-alert-delete-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="ti-modal-header bg-primary !rounded-none !rounded-t-sm">
<h5 class="text-xxl font-bold text-white">
นำเข้าผู้ใช้งาน
</h5>
</div>
<div class="ti-modal-body max-h-full overflow-hidden ti-modal-content !rounded-t-none !rounded-b-sm">
<h1 class="mt-2" style="text-align: center;">ไฟล์</h1>
<div class="mt-2 p-2">
<div class="flex rounded-md">
<input #fileInput id="fileInput" type="file" (change)="onFileSelected($event)" hidden>
<input type="text" [value]="selectedFileName" readonly (click)="fileInput.click()"
class="ti-form-input rounded-none ltr:rounded-l-md rtl:rounded-r-md focus:z-10 cursor-pointer">
<button type="button" (click)="fileInput.click()"
class="inline-flex flex-shrink-0 justify-center items-center h-[2.875rem] w-[2.875rem] ltr:rounded-r-md rtl:rounded-l-md border border-transparent font-semibold bg-secondary text-white hover:bg-secondary focus:z-10 focus:outline-none focus:ring-0 focus:ring-secondary transition-all text-sm">
<i class="ti ti-upload"></i>
</button>
</div>
<div class="flex justify-center mt-2rem mb-1rem space-x-4">
<button type="submit" data-hs-overlay="#user-setting-upload-modal" class="ti-btn ti-btn-secondary"
[class.ti-btn-disabled]="!selectedFile" (click)="uploadFile()" [disabled]="!selectedFile">
อัปโหลด
</button>
</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="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="max-h-full overflow-hidden ti-modal-content w-full">
<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" <ng-container *ngIf="currentModal == 'add'||currentModal == 'edit'">
data-hs-overlay="#user-settings-component-alert-delete-modal"> <button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
<span class="sr-only">Close</span> data-hs-overlay="#user-setting-modal">
<i class="ti ti-circle-x fs-xxl"></i> <span class="sr-only">Close</span>
</button> <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> </div>
<div class="ti-modal-body "> <div class="ti-modal-body ">
<p class="mt-1 text-gray-800 dark:text-white/70"> <p class="mt-1 text-gray-800 dark:text-white/70">
ยืนยันการลบข้อมูลหรือไม่! <ng-container *ngIf="currentModal == 'add'||currentModal == 'edit'">
ยืนยันการบันทึกข้อมูลหรือไม่!
</ng-container>
<ng-container *ngIf="currentModal == 'delete'||currentModal == 'deleteGroup'">
ยืนยันการลบข้อมูลหรือไม่!
</ng-container>
</p> </p>
<div class="flex justify-end mt-2rem mb-1rem"> <div class="flex justify-end mt-2rem mb-1rem">
<button type="button" <ng-container *ngIf="currentModal == 'add'||currentModal == 'edit'">
class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10" <button type="button"
data-hs-overlay="#user-settings-component-alert-delete-modal"> class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
ย้อนกลับ data-hs-overlay="#user-setting-modal">
</button> ย้อนกลับ
<a class="ti-btn ti-btn-success" href="javascript:void(0);" </button>
data-hs-overlay="#user-settings-component-alert-delete-modal" (click)="addUser();showSuccessDelete()"> <a class="ti-btn ti-btn-success" href="javascript:void(0);"
ลบข้อมูล data-hs-overlay="#user-setting-alert-modal" (click)="updateUser('post')">
</a> บันทึกข้อมูล
</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-danger" href="javascript:void(0);"
data-hs-overlay="#user-setting-alert-modal" (click)="updateUser('delete')">
ลบข้อมูล
</a>
</ng-container>
</div> </div>
</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 { 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 { EmployeeService } from 'src/app/shared/services/employee.service';
import { FileService } from 'src/app/shared/services/file.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',
styleUrls: ['./user-settings.component.scss'] styleUrls: ['./user-settings.component.scss']
}) })
export class UserSettingsComponent { export class UserSettingsComponent {
@Input() pathTitle = ['การจัดการข้อมูลองค์กร', 'ตั้งค่าผู้ใช้งาน', 'สร้างรหัสผู้ใช้งาน']; selectedFile: File | null = null;
@Output() sendPathTitle: EventEmitter<string[]> = new EventEmitter<string[]>(); selectedFileName: string = 'กรุณาเลือกไฟล์';
activeTab: string = 'tab1'; // กำหนด tab เริ่มต้น 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: [] }
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 = ""
changeTab(tab: { id: string, text: string }) { constructor(private toastr: ToastrService,
this.sendPathTitle.emit(['การจัดการข้อมูลองค์กร', 'ตั้งค่าผู้ใช้งาน', tab.text]); private cdr: ChangeDetectorRef,
this.activeTab = tab.id; private userService: UserService,
private employeeService: EmployeeService,
private fileService: FileService) {
this.companyId = this.decodeJWT(sessionStorage.getItem("accessToken") || '').companyid
}
ngOnInit(): void {
this.getUserList()
this.getEmployeeList()
this.getRoleList()
this.getLevelList()
} }
// การจัดการการเปิดปิด modal decodeJWT(token: string) {
modalOptions: { let base64Url = token.split('.')[1]; // ดึงส่วนที่เป็น Payload
[nameModal: string]: { let base64 = base64Url.replace('-', '+').replace('_', '/'); // แก้ไข base64 ให้ถูกต้อง
isModalOpen: boolean; let jsonPayload = decodeURIComponent(atob(base64).split('').map(function (c) {
modalSize: string; return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
backdropClose: boolean; }).join(''));
}; return JSON.parse(jsonPayload);
} = { }
"add": { getLevelList() {
isModalOpen: false, this.level.loading = true
modalSize: 'm', this.userService.getLevelList().subscribe({
backdropClose: true, next: response => {
}, this.level.dataList = response.map(x => ({ check: false, data: new MyLevelModel(x) }))
"edit": { this.level.loading = false
isModalOpen: false, this.searchChange()
modalSize: 'm', this.cdr.detectChanges()
backdropClose: true, }, 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)
}
openModal(name: string, size: string, closeOnBackdrop?: boolean) { getRoleList() {
this.modalOptions[name].modalSize = size; this.role.loading = true
this.modalOptions[name].backdropClose = closeOnBackdrop || false; this.userService.getRoleList().subscribe({
this.modalOptions[name].isModalOpen = true; next: response => {
this.currentModal = name; // ตั้งค่าค่าของ currentModal เป็น 'add' หรือ 'edit' this.role.dataList = response.map(x => ({ check: false, data: new MyRoleModel(x) }))
document.body.style.overflow = 'hidden'; 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)
} }
closeModal(name: string) { getEmployeeList() {
this.modalOptions[name].isModalOpen = false; this.employee.loading = true
if (!this.isAnyModalOpen()) { this.employeeService.getList().subscribe({
document.body.style.overflow = ''; // คืนค่าการ Scroll เฉพาะเมื่อ Modal ทั้งหมดปิดแล้ว next: response => {
} this.employee.dataList = response.map(x => ({ check: false, data: new MyEmployeeModel(x) }))
this.employee.loading = false
this.searchChange()
this.cdr.detectChanges()
}, error: error => {
this.employee.loading = false
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)
} }
isAnyModalOpen(): boolean { getUserList() {
return Object.values(this.modalOptions).some(modal => modal.isModalOpen); // ตรวจสอบว่า modal อื่นยังเปิดอยู่หรือไม่ this.user.loading = true
this.userService.getList().subscribe({
next: response => {
this.user.dataList = response.map(x => ({ check: false, data: new MyUserModel(x) }))
this.isDataListCheckedAll = false
this.dataListCheckAll()
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' })
}
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, 'muser').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')
}
})
// ฟังก์ชันสำหรับการเพิ่ม ลบ หรือแก้ไข ข้อมูล
addUser() {
// ฟังก์ชันสำหรับการเพิ่มผู้ใช้งาน
console.log('เพิ่มผู้ใช้งาน');
} }
deleteUser() { updateUser(typeApi: 'post' | 'delete') {
// ฟังก์ชันสำหรับการลบผู้ใช้งาน if (this.currentModal == 'add') {
console.log('ลบผู้ใช้งาน'); 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))
} }
editUser() { clearDataUser(currentModal: string) {
// ฟังก์ชันสำหรับการแก้ไขผู้ใช้งาน if (currentModal == 'add') {
console.log('แก้ไขผู้ใช้งาน'); this.user.select.usernameId = ''
} this.user.select.employee.employeeId = ''
currentModal = "" this.user.select.role.roleId = ''
constructor(private toastr: ToastrService) { } this.user.select.level.userLevel = ''
showSuccess() { } else if (currentModal == 'edit') {
this.toastr.success('บันทึกข้อมูลสำเร็จ', 'เเจ้งเตือน', { this.user.select.employee.employeeId = ''
timeOut: 3000, this.user.select.role.roleId = ''
positionClass: 'toast-top-right', this.user.select.level.userLevel = ''
}); }
} }
showSuccessEdit() { showAlert(text: string, type: 'success' | 'error') {
this.toastr.success('เเก้ไขข้อมูลสำเร็จ', 'เเจ้งเตือน', { this.toastr[type](text, 'แจ้งเตือน', {
timeOut: 3000, timeOut: 3000,
positionClass: 'toast-top-right', positionClass: 'toast-top-right',
}); })
} }
showSuccessDelete() {
this.toastr.success('ลบข้อมูลสำเร็จ', 'เเจ้งเตือน', { dataListCheckAll() {
timeOut: 3000, const selectAll = this.isDataListCheckedAll;
positionClass: 'toast-top-right', 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)
} }
} }
...@@ -191,8 +191,9 @@ ...@@ -191,8 +191,9 @@
<div class="relative flex rounded-md"> <div class="relative flex rounded-md">
<input type="text" id="hs-leading-button-add-on-with-icon-and-button" <input type="text" id="hs-leading-button-add-on-with-icon-and-button"
name="hs-leading-button-add-on-with-icon-and-button" name="hs-leading-button-add-on-with-icon-and-button"
class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10" class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10" readonly
style="padding-right: 3.5rem;" [(ngModel)]="bu1.bu1id" (ngModelChange)="bu1idChange()"> style="padding-right: 3.5rem;" [(ngModel)]="bu1.bu1id"
(ngModelChange)="bu1idChange()">
<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" (click)="selectBu1()"> <button type="button" class="flex items-center text-red-500" (click)="selectBu1()">
...@@ -293,7 +294,7 @@ ...@@ -293,7 +294,7 @@
<div class="relative flex rounded-md"> <div class="relative flex rounded-md">
<input type="text" id="hs-leading-button-add-on-with-icon-and-button" <input type="text" id="hs-leading-button-add-on-with-icon-and-button"
name="hs-leading-button-add-on-with-icon-and-button" name="hs-leading-button-add-on-with-icon-and-button"
class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10" class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10" readonly
style="padding-right: 3.5rem;" [(ngModel)]="bu1.bu1id" (ngModelChange)="bu1idChange()"> style="padding-right: 3.5rem;" [(ngModel)]="bu1.bu1id" (ngModelChange)="bu1idChange()">
<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">
...@@ -678,7 +679,7 @@ ...@@ -678,7 +679,7 @@
</div> </div>
<div id="department-list-upload-modal" class="hs-overlay hidden ti-modal"> <div id="department-list-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)] 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">
นำเข้าทะเบียนแผนก นำเข้าทะเบียนแผนก
......
...@@ -104,7 +104,7 @@ export class DepartmentListComponent implements OnInit { ...@@ -104,7 +104,7 @@ export class DepartmentListComponent implements OnInit {
this.bu2ListLoading = true this.bu2ListLoading = true
this.bu2Service.getList().subscribe({ this.bu2Service.getList().subscribe({
next: response => { next: response => {
this.bu2List = response this.bu2List = response.map(x => new MyBu2Model(x))
this.bu2ListLoading = false this.bu2ListLoading = false
this.onBu2TableSearchChange() this.onBu2TableSearchChange()
this.cdr.detectChanges() this.cdr.detectChanges()
...@@ -150,7 +150,7 @@ export class DepartmentListComponent implements OnInit { ...@@ -150,7 +150,7 @@ export class DepartmentListComponent implements OnInit {
getBu1List() { getBu1List() {
this.bu1Service.getList().subscribe(response => { this.bu1Service.getList().subscribe(response => {
this.bu1List = response this.bu1List = response.map(x => new MyBu1Model(x))
this.onBu1ModalSearchChange() this.onBu1ModalSearchChange()
}) })
} }
......
...@@ -344,7 +344,7 @@ ...@@ -344,7 +344,7 @@
</div> </div>
<div id="department-register-upload-modal" class="hs-overlay hidden ti-modal"> <div id="department-register-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)] 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">
นำเข้าทะเบียนฝ่าย นำเข้าทะเบียนฝ่าย
......
...@@ -82,7 +82,7 @@ export class DepartmentRegisterComponent implements OnInit { ...@@ -82,7 +82,7 @@ export class DepartmentRegisterComponent implements OnInit {
this.bu1ListLoading = true this.bu1ListLoading = true
this.bu1Service.getList().subscribe({ this.bu1Service.getList().subscribe({
next: response => { next: response => {
this.bu1List = response this.bu1List = response.map(x => new MyBu1Model(x))
this.bu1ListLoading = false this.bu1ListLoading = false
this.searchChange() this.searchChange()
this.cdr.detectChanges() this.cdr.detectChanges()
......
...@@ -190,7 +190,7 @@ ...@@ -190,7 +190,7 @@
<div class="relative flex rounded-md"> <div class="relative flex rounded-md">
<input type="text" id="hs-leading-button-add-on-with-icon-and-button" <input type="text" id="hs-leading-button-add-on-with-icon-and-button"
name="hs-leading-button-add-on-with-icon-and-button" name="hs-leading-button-add-on-with-icon-and-button"
class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10" class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10" readonly
style="padding-right: 3.5rem;" [(ngModel)]="bu2.bu2id" (ngModelChange)="bu2idChange()"> style="padding-right: 3.5rem;" [(ngModel)]="bu2.bu2id" (ngModelChange)="bu2idChange()">
<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">
...@@ -297,7 +297,7 @@ ...@@ -297,7 +297,7 @@
<div class="relative flex rounded-md"> <div class="relative flex rounded-md">
<input type="text" id="hs-leading-button-add-on-with-icon-and-button" <input type="text" id="hs-leading-button-add-on-with-icon-and-button"
name="hs-leading-button-add-on-with-icon-and-button" name="hs-leading-button-add-on-with-icon-and-button"
class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10" class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10" readonly
style="padding-right: 3.5rem;" [(ngModel)]="bu2.bu2id" (ngModelChange)="bu2idChange()"> style="padding-right: 3.5rem;" [(ngModel)]="bu2.bu2id" (ngModelChange)="bu2idChange()">
<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">
...@@ -683,7 +683,7 @@ ...@@ -683,7 +683,7 @@
</div> </div>
<div id="section-registration-upload-modal" class="hs-overlay hidden ti-modal"> <div id="section-registration-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)] 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">
นำเข้าทะเบียนส่วน นำเข้าทะเบียนส่วน
......
...@@ -105,7 +105,7 @@ export class SectionRegistrationComponent implements OnInit { ...@@ -105,7 +105,7 @@ export class SectionRegistrationComponent implements OnInit {
this.bu3ListLoading = true this.bu3ListLoading = true
this.bu3Service.getList().subscribe({ this.bu3Service.getList().subscribe({
next: response => { next: response => {
this.bu3List = response this.bu3List = response.map(x => new MyBu3Model(x))
this.bu3ListLoading = false this.bu3ListLoading = false
this.onBu3TableSearchChange() this.onBu3TableSearchChange()
this.cdr.detectChanges() this.cdr.detectChanges()
...@@ -184,7 +184,7 @@ export class SectionRegistrationComponent implements OnInit { ...@@ -184,7 +184,7 @@ export class SectionRegistrationComponent implements OnInit {
getBu2List() { getBu2List() {
this.bu2Service.getList().subscribe(response => { this.bu2Service.getList().subscribe(response => {
this.bu2List = response this.bu2List = response.map(x => new MyBu2Model(x))
this.onBu2ModalSearchChange() this.onBu2ModalSearchChange()
}) })
} }
......
...@@ -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="#sub-department-four-upload-modal"> data-hs-overlay="#sub-department-four-upload-modal"
(click)="fileInput.value = '';selectedFile=null;selectedFileName = 'กรุณาเลือกไฟล์'">
<i class="ri-add-line"></i> <i class="ri-add-line"></i>
นำเข้าข้อมูล นำเข้าข้อมูล
</button> </button>
...@@ -13,22 +14,23 @@ ...@@ -13,22 +14,23 @@
</a> </a>
</div> </div>
</div> </div>
<div class="flex justify-end"> <div class="flex justify-end">
<div class="px-1"> <div class="px-1">
<div class="relative shadow-md"> <div class="relative shadow-md">
<input type="text" id="hs-leading-icon" name="hs-leading-icon" <input type="text" id="hs-leading-icon" name="hs-leading-icon"
class="ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 " placeholder="Search by No. or Name" class="ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 " placeholder="Search by No. or Name"
[(ngModel)]="bu7Table.search" (ngModelChange)="onBu7TableSearchChange()"> [(ngModel)]="bu7Table.search" (ngModelChange)="onBu7TableSearchChange()">
<div <div
class="absolute inset-y-0 ltr:left-0 rtl:right-0 flex items-center pointer-events-none z-20 ltr:pl-4 rtl:pr-4"> class="absolute inset-y-0 ltr:left-0 rtl:right-0 flex items-center pointer-events-none z-20 ltr:pl-4 rtl:pr-4">
<i class="ri-search-line text-gray"></i> <i class="ri-search-line text-gray"></i>
</div> </div>
</div> </div>
</div> </div>
<div class="px-1"> <div class="px-1">
<button type="button" class="ti-btn ti-btn-soft-secondary h-45px m-0 shadow-md" <button type="button" class="ti-btn ti-btn-soft-secondary h-45px m-0 shadow-md"
(click)="currentModal='add';selectBu6();selectBu7()" data-hs-overlay="#sub-department-four-modal-add"> (click)="currentModal='add';selectBu6();selectBu7()"
data-hs-overlay="#sub-department-four-modal-add">
<i class="ri-add-line"></i> <i class="ri-add-line"></i>
Add Add
</button> </button>
...@@ -45,95 +47,97 @@ ...@@ -45,95 +47,97 @@
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>
<tr> <tr>
<ng-container <ng-container
*ngFor="let item of ['ลำดับ','รหัสส่วนย่อย4','รายละเอียดส่วนย่อย4 (ไทย)','รายละเอียดส่วนย่อย4 (อังกฤษ)','การจัดการ']; let f = first; let l = last"> *ngFor="let item of ['ลำดับ','รหัสส่วนย่อย4','รายละเอียดส่วนย่อย4 (ไทย)','รายละเอียดส่วนย่อย4 (อังกฤษ)','การจัดการ']; let f = first; let l = last">
<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">{{ 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>
</div>
</th>
</ng-container>
</tr>
</thead>
<tbody *ngIf="bu7ListLoading">
<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> </th>
</tr> </ng-container>
</tbody> </tr>
<tbody *ngIf="!bu7ListLoading&&!filterBu7Table().length"> </thead>
<tr> <tbody *ngIf="bu7ListLoading">
<td class="text-center" colspan="100%"> <tr>
ไม่พบข้อมูล <td class="text-center" colspan="100%">
</td> <div *ngFor="let item of [1,2,3]" class="ti-spinner w-8 h-8 text-secondary mx-1" role="status"
</tr> aria-label="loading">
</tbody> <span class="sr-only">Loading...</span>
<tbody *ngIf="!bu7ListLoading&&filterBu7Table().length"> </div>
<tr </td>
*ngFor="let item of filterBu7Table() | slice:((bu7Table.currentPage-1) * 10) : (((bu7Table.currentPage-1) * 10) + 10);let i = index"> </tr>
<td class="text-center"> </tbody>
{{((bu7Table.currentPage-1) * 10)+(i+1)}} <tbody *ngIf="!bu7ListLoading&&!filterBu7Table().length">
</td> <tr>
<td class="text-center">{{item.bu7id}}</td> <td class="text-center" colspan="100%">
<td>{{item.tdesc}}</td> ไม่พบข้อมูล
<td>{{item.edesc}}</td> </td>
<td class="flex justify-center"> </tr>
<i class="ti ti-edit cursor-pointer i-gray fs-l px-1" </tbody>
(click)="selectBu7(item);currentModal='edit'" <tbody *ngIf="!bu7ListLoading&&filterBu7Table().length">
data-hs-overlay="#sub-department-four-modal-edit"></i> <tr
<i class="ti ti-trash cursor-pointer i-gray fs-l px-1" (click)="selectBu7(item)" *ngFor="let item of filterBu7Table() | slice:((bu7Table.currentPage-1) * 10) : (((bu7Table.currentPage-1) * 10) + 10);let i = index">
<td class="text-center">
{{((bu7Table.currentPage-1) * 10)+(i+1)}}
</td>
<td class="text-center">{{item.bu7id}}</td>
<td>{{item.tdesc}}</td>
<td>{{item.edesc}}</td>
<td class="flex justify-center">
<i class="ti ti-edit cursor-pointer i-gray fs-l px-1"
(click)="selectBu7(item);currentModal='edit'"
data-hs-overlay="#sub-department-four-modal-edit"></i>
<i class="ti ti-trash cursor-pointer i-gray fs-l px-1" (click)="selectBu7(item)"
data-hs-overlay="#sub-department-four-alert-delete-modal"></i> data-hs-overlay="#sub-department-four-alert-delete-modal"></i>
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</div> </div>
<nav class="pagination-style-3 overflow-auto my-5" *ngIf="bu7Table.page.length"> <nav class="pagination-style-3 overflow-auto my-5" *ngIf="bu7Table.page.length">
<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)="bu7Table.currentPage = (bu7Table.currentPage-1 || 1)"> (click)="bu7Table.currentPage = (bu7Table.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>
</li>
<li *ngFor="let item of bu7Table.page;let f = first;let l = last">
<ng-container
*ngIf="item==3&&bu7Table.currentPage!=1&&bu7Table.currentPage!=2&&bu7Table.currentPage!=3">
<a aria-label="anchor" class="page-link" href="javascript:void(0);"><i class="ri-more-line"></i>
</a> </a>
</li> </ng-container>
<li *ngFor="let item of bu7Table.page;let f = first;let l = last"> <ng-container
<ng-container *ngIf="item==3&&bu7Table.currentPage!=1&&bu7Table.currentPage!=2&&bu7Table.currentPage!=3"> *ngIf="(f||l)||(item==bu7Table.currentPage-1||item==bu7Table.currentPage||item==bu7Table.currentPage+1)">
<a aria-label="anchor" class="page-link" href="javascript:void(0);"><i class="ri-more-line"></i> <a class="page-link" href="javascript:void(0);" [class.active]="item==bu7Table.currentPage"
</a> (click)="bu7Table.currentPage=item">{{item}}
</ng-container> </a>
<ng-container *ngIf="(f||l)||(item==bu7Table.currentPage-1||item==bu7Table.currentPage||item==bu7Table.currentPage+1)"> </ng-container>
<a class="page-link" href="javascript:void(0);" [class.active]="item==bu7Table.currentPage" <ng-container
(click)="bu7Table.currentPage=item">{{item}} *ngIf="item==bu7Table.page.length-2&&bu7Table.currentPage!=bu7Table.page.length&&bu7Table.currentPage!=bu7Table.page.length-1&&bu7Table.currentPage!=bu7Table.page.length-2">
</a> <a aria-label="anchor" class="page-link" href="javascript:void(0);"><i class="ri-more-line"></i>
</ng-container>
<ng-container
*ngIf="item==bu7Table.page.length-2&&bu7Table.currentPage!=bu7Table.page.length&&bu7Table.currentPage!=bu7Table.page.length-1&&bu7Table.currentPage!=bu7Table.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)="bu7Table.currentPage = (bu7Table.currentPage > bu7Table.page.length-1 ? bu7Table.currentPage: bu7Table.currentPage+1 )">
<i class="ri-arrow-right-s-line align-middle rtl:rotate-180"></i>
</a> </a>
</li> </ng-container>
</ul> </li>
</nav> <li>
<a aria-label="anchor" class="page-link" href="javascript:void(0);"
(click)="bu7Table.currentPage = (bu7Table.currentPage > bu7Table.page.length-1 ? bu7Table.currentPage: bu7Table.currentPage+1 )">
<i class="ri-arrow-right-s-line align-middle rtl:rotate-180"></i>
</a>
</li>
</ul>
</nav>
</div> </div>
...@@ -181,16 +185,20 @@ ...@@ -181,16 +185,20 @@
</div> </div>
</div> </div>
<div class="ti-modal-body"> <div class="ti-modal-body">
<label class="ti-form-label ">อยู่ภายใต้หน่วยงาน</label> <label class="ti-form-label ">อยู่ภายใต้หน่วยงาน*</label>
<div class="flex"> <div class="flex">
<div class="relative flex rounded-md"> <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 rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10" style="padding-right: 3.5rem;" <input type="text" id="hs-leading-button-add-on-with-icon-and-button"
[(ngModel)]="bu6.bu6id" (ngModelChange)="bu6idChange()"> name="hs-leading-button-add-on-with-icon-and-button"
<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="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10" readonly
<button type="button" class="flex items-center text-red-500" (click)="selectBu6()"> style="padding-right: 3.5rem;" [(ngModel)]="bu6.bu6id" (ngModelChange)="bu6idChange()">
<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)="selectBu6()">
<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" data-hs-overlay="#sub-department-four-bu6-table-modal"> <button type="button" class="flex items-center text-gray-500 dark:text-white/70"
data-hs-overlay="#sub-department-four-bu6-table-modal">
<i class="ri-search-line cursor-pointer text-gray"></i> <i class="ri-search-line cursor-pointer text-gray"></i>
</button> </button>
</div> </div>
...@@ -200,20 +208,25 @@ ...@@ -200,20 +208,25 @@
readonly [value]="bu6.tdesc"> readonly [value]="bu6.tdesc">
</div> </div>
</div> </div>
<label class="ti-form-label mt-2rem">ส่วนย่อย4</label> <label class="ti-form-label mt-2rem">ส่วนย่อย4*</label>
<div class="relative flex rounded-md w-1/2"> <div class="relative flex rounded-md w-1/2">
<input type="text" id="hs-leading-button-add-on-with-icon-and-button" name="hs-leading-button-add-on-with-icon-and-button" class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10" style="padding-right: 3.5rem;" <input type="text" class="ti-form-input h-16" [(ngModel)]="bu7.bu7id">
[(ngModel)]="bu7.bu7id" (ngModelChange)="bu7idChange()"> <!-- <input type="text" id="hs-leading-button-add-on-with-icon-and-button"
<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"> name="hs-leading-button-add-on-with-icon-and-button"
<button type="button" class="flex items-center text-red-500" (click)="selectBu7()"> class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10"
style="padding-right: 3.5rem;" [(ngModel)]="bu7.bu7id" (ngModelChange)="bu7idChange()">
<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)="selectBu7()">
<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" data-hs-overlay="#sub-department-four-bu7-table-modal"> <button type="button" class="flex items-center text-gray-500 dark:text-white/70"
data-hs-overlay="#sub-department-four-bu7-table-modal">
<i class="ri-search-line cursor-pointer text-gray"></i> <i class="ri-search-line cursor-pointer text-gray"></i>
</button> </button>
</div> </div> -->
</div> </div>
<label for="detail_th" class="ti-form-label mt-2rem">รายละเอียด (ไทย)</label> <label for="detail_th" class="ti-form-label mt-2rem">รายละเอียด (ไทย)*</label>
<input type="text" id="detail_th" class="ti-form-input h-16" [(ngModel)]="bu7.tdesc"> <input type="text" id="detail_th" class="ti-form-input h-16" [(ngModel)]="bu7.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)]="bu7.edesc"> <input type="text" id="detail_eng" class="ti-form-input h-16" [(ngModel)]="bu7.edesc">
...@@ -223,10 +236,12 @@ ...@@ -223,10 +236,12 @@
data-hs-overlay="#sub-department-four-modal-add"> data-hs-overlay="#sub-department-four-modal-add">
ย้อนกลับ ย้อนกลับ
</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="#sub-department-four-alert-add-modal"> data-hs-overlay="#sub-department-four-alert-add-modal"
[class.ti-btn-disabled]="!bu6.bu6id||!bu7.bu7id||!bu7.tdesc"
[disabled]="!bu6.bu6id||!bu7.bu7id||!bu7.tdesc">
บันทึกข้อมูล บันทึกข้อมูล
</a> </button>
</div> </div>
</div> </div>
</div> </div>
...@@ -252,7 +267,7 @@ ...@@ -252,7 +267,7 @@
<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)="selectBu6();bu7.tdesc='';bu7.edesc=''"> (click)="selectBu6();bu7.tdesc='';bu7.edesc=''">
<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)">
...@@ -277,34 +292,37 @@ ...@@ -277,34 +292,37 @@
</div> </div>
</div> </div>
<div class="ti-modal-body"> <div class="ti-modal-body">
<label for="hs-trailing-button-add-on-with-icon" <label for="hs-trailing-button-add-on-with-icon" class="ti-form-label">อยู่ภายใต้หน่วยงาน*</label>
class="ti-form-label">อยู่ภายใต้หน่วยงาน</label> <div class="flex">
<div class="flex"> <div class="relative flex rounded-md">
<div class="relative flex rounded-md"> <input type="text" id="hs-leading-button-add-on-with-icon-and-button"
<input type="text" id="hs-leading-button-add-on-with-icon-and-button" name="hs-leading-button-add-on-with-icon-and-button" class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10" style="padding-right: 3.5rem;" name="hs-leading-button-add-on-with-icon-and-button"
[(ngModel)]="bu6.bu6id" (ngModelChange)="bu6idChange()"> class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10" readonly
<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"> style="padding-right: 3.5rem;" [(ngModel)]="bu6.bu6id" (ngModelChange)="bu6idChange()">
<button type="button" class="flex items-center text-red-500" (click)="selectBu6()"> <div
<i class="ti ti-circle-x cursor-pointer"></i> 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> <button type="button" class="flex items-center text-red-500" (click)="selectBu6()">
<button type="button" class="flex items-center text-gray-500 dark:text-white/70" data-hs-overlay="#sub-department-four-bu6-table-modal"> <i class="ti ti-circle-x cursor-pointer"></i>
<i class="ri-search-line cursor-pointer text-gray"></i> </button>
</button> <button type="button" class="flex items-center text-gray-500 dark:text-white/70"
</div> data-hs-overlay="#sub-department-four-bu6-table-modal">
</div> <i class="ri-search-line cursor-pointer text-gray"></i>
<div class="flex rounded-md w-1/2 pl-1rem"> </button>
<input type="text" id="input-label" class="ti-form-input w-full pr-10 bg-input-readonly"
readonly [value]="bu6.tdesc">
</div> </div>
</div> </div>
<label for="input-label" class="ti-form-label mt-2rem">ส่วนย่อย4</label> <div class="flex rounded-md w-1/2 pl-1rem">
<input type="text" id="input-label" class="ti-form-input w-full pr-10 bg-input-readonly"
readonly [value]="bu6.tdesc">
</div>
</div>
<label for="input-label" class="ti-form-label mt-2rem">ส่วนย่อย4*</label>
<div class="sm:grid grid-cols-2 gap-1"> <div class="sm:grid grid-cols-2 gap-1">
<div class="relative w-full"> <div class="relative w-full">
<input type="text" id="input-label" class="ti-form-input w-full pr-10 bg-input-readonly" <input type="text" id="input-label" class="ti-form-input w-full pr-10 bg-input-readonly"
readonly [value]="bu7.bu7id"> readonly [value]="bu7.bu7id">
</div> </div>
</div> </div>
<label for="detail_th" class="ti-form-label mt-2rem">รายละเอียด (ไทย)</label> <label for="detail_th" class="ti-form-label mt-2rem">รายละเอียด (ไทย)*</label>
<input type="text" id="detail_th" class="ti-form-input h-16" [(ngModel)]="bu7.tdesc"> <input type="text" id="detail_th" class="ti-form-input h-16" [(ngModel)]="bu7.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)]="bu7.edesc"> <input type="text" id="detail_eng" class="ti-form-input h-16" [(ngModel)]="bu7.edesc">
...@@ -314,10 +332,12 @@ ...@@ -314,10 +332,12 @@
data-hs-overlay="#sub-department-four-modal-edit"> data-hs-overlay="#sub-department-four-modal-edit">
ย้อนกลับ ย้อนกลับ
</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="#sub-department-four-alert-edit-modal"> data-hs-overlay="#sub-department-four-alert-edit-modal"
[class.ti-btn-disabled]="!bu6.bu6id||!bu7.bu7id||!bu7.tdesc"
[disabled]="!bu6.bu6id||!bu7.bu7id||!bu7.tdesc">
บันทึกข้อมูล บันทึกข้อมูล
</a> </button>
</div> </div>
</div> </div>
</div> </div>
...@@ -563,7 +583,7 @@ ...@@ -563,7 +583,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="#sub-department-four-alert-add-modal"> data-hs-overlay="#sub-department-four-modal-add">
<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>
...@@ -575,16 +595,11 @@ ...@@ -575,16 +595,11 @@
</p> </p>
<div class="flex justify-end mt-2rem mb-1rem"> <div class="flex justify-end mt-2rem mb-1rem">
<button type="button" *ngIf="currentModal=='add'" <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="#sub-department-four-modal-add"> data-hs-overlay="#sub-department-four-modal-add">
ย้อนกลับ ย้อนกลับ
</button> </button>
<button type="button" *ngIf="currentModal=='edit'"
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="#sub-department-four-modal-edit">
ย้อนกลับ
</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="#sub-department-four-alert-add-modal" (click)="addBu7();"> data-hs-overlay="#sub-department-four-alert-add-modal" (click)="addBu7();">
บันทึกข้อมูล บันทึกข้อมูล
...@@ -604,7 +619,7 @@ ...@@ -604,7 +619,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="#sub-department-four-alert-edit-modal"> data-hs-overlay="#sub-department-four-modal-edit">
<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>
...@@ -616,12 +631,7 @@ ...@@ -616,12 +631,7 @@
</p> </p>
<div class="flex justify-end mt-2rem mb-1rem"> <div class="flex justify-end mt-2rem mb-1rem">
<button type="button" *ngIf="currentModal=='add'" <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="#sub-department-four-modal-add">
ย้อนกลับ
</button>
<button type="button" *ngIf="currentModal=='edit'"
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="#sub-department-four-modal-edit"> data-hs-overlay="#sub-department-four-modal-edit">
ย้อนกลับ ย้อนกลับ
...@@ -673,7 +683,7 @@ ...@@ -673,7 +683,7 @@
</div> </div>
<div id="sub-department-four-upload-modal" class="hs-overlay hidden ti-modal"> <div id="sub-department-four-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)] 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">
นำเข้าทะเบียนส่วนย่อย4 นำเข้าทะเบียนส่วนย่อย4
...@@ -683,7 +693,7 @@ ...@@ -683,7 +693,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()"
...@@ -693,6 +703,7 @@ ...@@ -693,6 +703,7 @@
</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" (click)="uploadFile()"
data-hs-overlay="#sub-department-four-upload-modal" [class.ti-btn-disabled]="!selectedFile"
[disabled]="!selectedFile"> [disabled]="!selectedFile">
อัปโหลด อัปโหลด
</button> </button>
......
...@@ -19,7 +19,7 @@ interface table { ...@@ -19,7 +19,7 @@ interface table {
export class SubDepartmentFourComponent implements OnInit { export class SubDepartmentFourComponent implements OnInit {
bu7List: Bu7Model[] = [] bu7List: Bu7Model[] = []
bu7ListLoading = false bu7ListLoading = false
bu7: Bu7Model = new MyBu7Model({}) bu7: Bu7Model = new MyBu7Model()
bu7Table: table = { bu7Table: table = {
currentPage: 1, currentPage: 1,
page: Array.from({ length: 1 }, (_, i) => i + 1), page: Array.from({ length: 1 }, (_, i) => i + 1),
...@@ -35,13 +35,13 @@ export class SubDepartmentFourComponent implements OnInit { ...@@ -35,13 +35,13 @@ export class SubDepartmentFourComponent implements OnInit {
search: "" search: ""
} }
bu6List: Bu6Model[] = [] bu6List: Bu6Model[] = []
bu6: Bu6Model = new MyBu6Model({}) bu6: Bu6Model = new MyBu6Model()
bu6Modal: table = { bu6Modal: table = {
currentPage: 1, currentPage: 1,
page: Array.from({ length: 1 }, (_, i) => i + 1), page: Array.from({ length: 1 }, (_, i) => i + 1),
search: "" search: ""
} }
currentModal = "" currentModal: 'add' | 'edit' | 'delete' = "add"
constructor(private bu7Service: Bu7Service, constructor(private bu7Service: Bu7Service,
private bu6Service: Bu6Service, private bu6Service: Bu6Service,
private toastr: ToastrService, private toastr: ToastrService,
...@@ -65,6 +65,7 @@ export class SubDepartmentFourComponent implements OnInit { ...@@ -65,6 +65,7 @@ export class SubDepartmentFourComponent implements OnInit {
} }
const formData = new FormData(); const formData = new FormData();
formData.append('file', this.selectedFile); formData.append('file', this.selectedFile);
this.bu7ListLoading = true
this.fileService.upload(formData, 'mbu7').subscribe({ this.fileService.upload(formData, 'mbu7').subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
...@@ -72,9 +73,11 @@ export class SubDepartmentFourComponent implements OnInit { ...@@ -72,9 +73,11 @@ export class SubDepartmentFourComponent implements OnInit {
this.getBu7List() this.getBu7List()
} else { } else {
this.showAlert(response.message, 'error') this.showAlert(response.message, 'error')
this.bu7ListLoading = false
} }
}, error: error => { }, error: error => {
this.showAlert(error.message, 'error') this.showAlert(error.message, 'error')
this.bu7ListLoading = false
} }
}) })
} }
...@@ -102,7 +105,7 @@ export class SubDepartmentFourComponent implements OnInit { ...@@ -102,7 +105,7 @@ export class SubDepartmentFourComponent implements OnInit {
this.bu7ListLoading = true this.bu7ListLoading = true
this.bu7Service.getList().subscribe({ this.bu7Service.getList().subscribe({
next: response => { next: response => {
this.bu7List = response this.bu7List = response.map(x => new MyBu7Model(x))
this.bu7ListLoading = false this.bu7ListLoading = false
this.onBu7TableSearchChange() this.onBu7TableSearchChange()
this.cdr.detectChanges() this.cdr.detectChanges()
...@@ -118,8 +121,8 @@ export class SubDepartmentFourComponent implements OnInit { ...@@ -118,8 +121,8 @@ export class SubDepartmentFourComponent implements OnInit {
} }
filterBu7Table() { filterBu7Table() {
return this.bu7List.filter(x => x.bu7id.toLowerCase().includes(this.bu7Table.search.toLowerCase()) || return this.bu7List.filter(x => x.bu7id.toLowerCase().includes(this.bu7Table.search.toLowerCase()) ||
x.tdesc.toLowerCase().includes(this.bu7Table.search.toLowerCase()) || x.tdesc.toLowerCase().includes(this.bu7Table.search.toLowerCase()) ||
x.edesc.toLowerCase().includes(this.bu7Table.search.toLowerCase())) x.edesc.toLowerCase().includes(this.bu7Table.search.toLowerCase()))
} }
selectBu7(bu7?: Bu7Model) { selectBu7(bu7?: Bu7Model) {
this.bu7 = new MyBu7Model(bu7 || {}) this.bu7 = new MyBu7Model(bu7 || {})
...@@ -141,10 +144,11 @@ export class SubDepartmentFourComponent implements OnInit { ...@@ -141,10 +144,11 @@ export class SubDepartmentFourComponent implements OnInit {
} }
filterBu7Modal() { filterBu7Modal() {
return this.bu7List.filter(x => x.bu7id.toLowerCase().includes(this.bu7Modal.search.toLowerCase()) || return this.bu7List.filter(x => x.bu7id.toLowerCase().includes(this.bu7Modal.search.toLowerCase()) ||
x.tdesc.toLowerCase().includes(this.bu7Modal.search.toLowerCase()) || x.tdesc.toLowerCase().includes(this.bu7Modal.search.toLowerCase()) ||
x.edesc.toLowerCase().includes(this.bu7Modal.search.toLowerCase())) x.edesc.toLowerCase().includes(this.bu7Modal.search.toLowerCase()))
} }
addBu7() { addBu7() {
this.bu7ListLoading = true
this.bu7Service.post({ ...this.bu7, parent: this.bu6.bu6id }).subscribe({ this.bu7Service.post({ ...this.bu7, parent: this.bu6.bu6id }).subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
...@@ -152,13 +156,16 @@ export class SubDepartmentFourComponent implements OnInit { ...@@ -152,13 +156,16 @@ export class SubDepartmentFourComponent implements OnInit {
this.getBu7List() this.getBu7List()
} else { } else {
this.showAlert(response.message, 'error') this.showAlert(response.message, 'error')
this.bu7ListLoading = false
} }
}, error: error => { }, error: error => {
this.showAlert(error.message, 'error') this.showAlert(error.message, 'error')
this.bu7ListLoading = false
} }
}) })
} }
deleteBu7() { deleteBu7() {
this.bu7ListLoading = true
this.bu7Service.delete(this.bu7).subscribe({ this.bu7Service.delete(this.bu7).subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
...@@ -166,16 +173,18 @@ export class SubDepartmentFourComponent implements OnInit { ...@@ -166,16 +173,18 @@ export class SubDepartmentFourComponent implements OnInit {
this.getBu7List() this.getBu7List()
} else { } else {
this.showAlert(response.message, 'error') this.showAlert(response.message, 'error')
this.bu7ListLoading = false
} }
}, error: error => { }, error: error => {
this.showAlert(error.message, 'error') this.showAlert(error.message, 'error')
this.bu7ListLoading = false
} }
}) })
} }
getBu6List() { getBu6List() {
this.bu6Service.getList().subscribe(response => { this.bu6Service.getList().subscribe(response => {
this.bu6List = response this.bu6List = response.map(x => new MyBu6Model(x))
this.onBu6ModalSearchChange() this.onBu6ModalSearchChange()
}) })
} }
...@@ -189,8 +198,8 @@ export class SubDepartmentFourComponent implements OnInit { ...@@ -189,8 +198,8 @@ export class SubDepartmentFourComponent implements OnInit {
} }
filterBu6Modal() { filterBu6Modal() {
return this.bu6List.filter(x => x.bu6id.toLowerCase().includes(this.bu6Modal.search.toLowerCase()) || return this.bu6List.filter(x => x.bu6id.toLowerCase().includes(this.bu6Modal.search.toLowerCase()) ||
x.tdesc.toLowerCase().includes(this.bu6Modal.search.toLowerCase()) || x.tdesc.toLowerCase().includes(this.bu6Modal.search.toLowerCase()) ||
x.edesc.toLowerCase().includes(this.bu6Modal.search.toLowerCase())) x.edesc.toLowerCase().includes(this.bu6Modal.search.toLowerCase()))
} }
selectBu6(bu6?: Bu6Model) { selectBu6(bu6?: Bu6Model) {
this.bu6 = new MyBu6Model(bu6 || {}) this.bu6 = new MyBu6Model(bu6 || {})
......
...@@ -192,7 +192,7 @@ ...@@ -192,7 +192,7 @@
<div class="relative flex rounded-md"> <div class="relative flex rounded-md">
<input type="text" id="hs-leading-button-add-on-with-icon-and-button" <input type="text" id="hs-leading-button-add-on-with-icon-and-button"
name="hs-leading-button-add-on-with-icon-and-button" name="hs-leading-button-add-on-with-icon-and-button"
class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10" class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10" readonly
style="padding-right: 3.5rem;" [(ngModel)]="bu3.bu3id" (ngModelChange)="bu3idChange()"> style="padding-right: 3.5rem;" [(ngModel)]="bu3.bu3id" (ngModelChange)="bu3idChange()">
<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">
...@@ -299,7 +299,7 @@ ...@@ -299,7 +299,7 @@
<div class="relative flex rounded-md"> <div class="relative flex rounded-md">
<input type="text" id="hs-leading-button-add-on-with-icon-and-button" <input type="text" id="hs-leading-button-add-on-with-icon-and-button"
name="hs-leading-button-add-on-with-icon-and-button" name="hs-leading-button-add-on-with-icon-and-button"
class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10" class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10" readonly
style="padding-right: 3.5rem;" [(ngModel)]="bu3.bu3id" (ngModelChange)="bu3idChange()"> style="padding-right: 3.5rem;" [(ngModel)]="bu3.bu3id" (ngModelChange)="bu3idChange()">
<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">
...@@ -690,7 +690,7 @@ ...@@ -690,7 +690,7 @@
</div> </div>
<div id="sub-department-one-upload-modal" class="hs-overlay hidden ti-modal"> <div id="sub-department-one-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)] 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">
นำเข้าทะเบียนส่วนย่อย1 นำเข้าทะเบียนส่วนย่อย1
......
...@@ -104,7 +104,7 @@ export class SubDepartmentOneComponent implements OnInit { ...@@ -104,7 +104,7 @@ export class SubDepartmentOneComponent implements OnInit {
this.bu4ListLoading = true this.bu4ListLoading = true
this.bu4Service.getList().subscribe({ this.bu4Service.getList().subscribe({
next: response => { next: response => {
this.bu4List = response this.bu4List = response.map(x => new MyBu4Model(x))
this.bu4ListLoading = false this.bu4ListLoading = false
this.onBu4TableSearchChange() this.onBu4TableSearchChange()
this.cdr.detectChanges() this.cdr.detectChanges()
...@@ -183,7 +183,7 @@ export class SubDepartmentOneComponent implements OnInit { ...@@ -183,7 +183,7 @@ export class SubDepartmentOneComponent implements OnInit {
getBu3List() { getBu3List() {
this.bu3Service.getList().subscribe(response => { this.bu3Service.getList().subscribe(response => {
this.bu3List = response this.bu3List = response.map(x => new MyBu3Model(x))
this.onBu3ModalSearchChange() this.onBu3ModalSearchChange()
}) })
} }
......
...@@ -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="#sub-department-three-upload-modal"> data-hs-overlay="#sub-department-three-upload-modal"
(click)="fileInput.value = '';selectedFile=null;selectedFileName = 'กรุณาเลือกไฟล์'">
<i class="ri-add-line"></i> <i class="ri-add-line"></i>
นำเข้าข้อมูล นำเข้าข้อมูล
</button> </button>
...@@ -13,22 +14,23 @@ ...@@ -13,22 +14,23 @@
</a> </a>
</div> </div>
</div> </div>
<div class="flex justify-end"> <div class="flex justify-end">
<div class="px-1"> <div class="px-1">
<div class="relative shadow-md"> <div class="relative shadow-md">
<input type="text" id="hs-leading-icon" name="hs-leading-icon" <input type="text" id="hs-leading-icon" name="hs-leading-icon"
class="ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 " placeholder="Search by No. or Name" class="ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 " placeholder="Search by No. or Name"
[(ngModel)]="bu6Table.search" (ngModelChange)="onBu6TableSearchChange()"> [(ngModel)]="bu6Table.search" (ngModelChange)="onBu6TableSearchChange()">
<div <div
class="absolute inset-y-0 ltr:left-0 rtl:right-0 flex items-center pointer-events-none z-20 ltr:pl-4 rtl:pr-4"> class="absolute inset-y-0 ltr:left-0 rtl:right-0 flex items-center pointer-events-none z-20 ltr:pl-4 rtl:pr-4">
<i class="ri-search-line text-gray"></i> <i class="ri-search-line text-gray"></i>
</div> </div>
</div> </div>
</div> </div>
<div class="px-1"> <div class="px-1">
<button type="button" class="ti-btn ti-btn-soft-secondary h-45px m-0 shadow-md" <button type="button" class="ti-btn ti-btn-soft-secondary h-45px m-0 shadow-md"
(click)="currentModal='add';selectBu5();selectBu6()" data-hs-overlay="#sub-department-three-modal-add"> (click)="currentModal='add';selectBu5();selectBu6()"
data-hs-overlay="#sub-department-three-modal-add">
<i class="ri-add-line"></i> <i class="ri-add-line"></i>
Add Add
</button> </button>
...@@ -45,95 +47,97 @@ ...@@ -45,95 +47,97 @@
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>
<tr> <tr>
<ng-container <ng-container
*ngFor="let item of ['ลำดับ','รหัสส่วนย่อย3','รายละเอียดส่วนย่อย3 (ไทย)','รายละเอียดส่วนย่อย3 (อังกฤษ)','การจัดการ']; let f = first; let l = last"> *ngFor="let item of ['ลำดับ','รหัสส่วนย่อย3','รายละเอียดส่วนย่อย3 (ไทย)','รายละเอียดส่วนย่อย3 (อังกฤษ)','การจัดการ']; let f = first; let l = last">
<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">{{ 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>
</div>
</th>
</ng-container>
</tr>
</thead>
<tbody *ngIf="bu6ListLoading">
<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> </th>
</tr> </ng-container>
</tbody> </tr>
<tbody *ngIf="!bu6ListLoading&&!filterBu6Table().length"> </thead>
<tr> <tbody *ngIf="bu6ListLoading">
<td class="text-center" colspan="100%"> <tr>
ไม่พบข้อมูล <td class="text-center" colspan="100%">
</td> <div *ngFor="let item of [1,2,3]" class="ti-spinner w-8 h-8 text-secondary mx-1" role="status"
</tr> aria-label="loading">
</tbody> <span class="sr-only">Loading...</span>
<tbody *ngIf="!bu6ListLoading&&filterBu6Table().length"> </div>
<tr </td>
*ngFor="let item of filterBu6Table() | slice:((bu6Table.currentPage-1) * 10) : (((bu6Table.currentPage-1) * 10) + 10);let i = index"> </tr>
<td class="text-center"> </tbody>
{{((bu6Table.currentPage-1) * 10)+(i+1)}} <tbody *ngIf="!bu6ListLoading&&!filterBu6Table().length">
</td> <tr>
<td class="text-center">{{item.bu6id}}</td> <td class="text-center" colspan="100%">
<td>{{item.tdesc}}</td> ไม่พบข้อมูล
<td>{{item.edesc}}</td> </td>
<td class="flex justify-center"> </tr>
<i class="ti ti-edit cursor-pointer i-gray fs-l px-1" </tbody>
(click)="selectBu6(item);currentModal='edit'" <tbody *ngIf="!bu6ListLoading&&filterBu6Table().length">
data-hs-overlay="#sub-department-three-modal-edit"></i> <tr
<i class="ti ti-trash cursor-pointer i-gray fs-l px-1" (click)="selectBu6(item)" *ngFor="let item of filterBu6Table() | slice:((bu6Table.currentPage-1) * 10) : (((bu6Table.currentPage-1) * 10) + 10);let i = index">
<td class="text-center">
{{((bu6Table.currentPage-1) * 10)+(i+1)}}
</td>
<td class="text-center">{{item.bu6id}}</td>
<td>{{item.tdesc}}</td>
<td>{{item.edesc}}</td>
<td class="flex justify-center">
<i class="ti ti-edit cursor-pointer i-gray fs-l px-1"
(click)="selectBu6(item);currentModal='edit'"
data-hs-overlay="#sub-department-three-modal-edit"></i>
<i class="ti ti-trash cursor-pointer i-gray fs-l px-1" (click)="selectBu6(item)"
data-hs-overlay="#sub-department-three-alert-delete-modal"></i> data-hs-overlay="#sub-department-three-alert-delete-modal"></i>
</td> </td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</div> </div>
<nav class="pagination-style-3 overflow-auto my-5" *ngIf="bu6Table.page.length"> <nav class="pagination-style-3 overflow-auto my-5" *ngIf="bu6Table.page.length">
<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)="bu6Table.currentPage = (bu6Table.currentPage-1 || 1)"> (click)="bu6Table.currentPage = (bu6Table.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>
</li>
<li *ngFor="let item of bu6Table.page;let f = first;let l = last">
<ng-container
*ngIf="item==3&&bu6Table.currentPage!=1&&bu6Table.currentPage!=2&&bu6Table.currentPage!=3">
<a aria-label="anchor" class="page-link" href="javascript:void(0);"><i class="ri-more-line"></i>
</a> </a>
</li> </ng-container>
<li *ngFor="let item of bu6Table.page;let f = first;let l = last"> <ng-container
<ng-container *ngIf="item==3&&bu6Table.currentPage!=1&&bu6Table.currentPage!=2&&bu6Table.currentPage!=3"> *ngIf="(f||l)||(item==bu6Table.currentPage-1||item==bu6Table.currentPage||item==bu6Table.currentPage+1)">
<a aria-label="anchor" class="page-link" href="javascript:void(0);"><i class="ri-more-line"></i> <a class="page-link" href="javascript:void(0);" [class.active]="item==bu6Table.currentPage"
</a> (click)="bu6Table.currentPage=item">{{item}}
</ng-container> </a>
<ng-container *ngIf="(f||l)||(item==bu6Table.currentPage-1||item==bu6Table.currentPage||item==bu6Table.currentPage+1)"> </ng-container>
<a class="page-link" href="javascript:void(0);" [class.active]="item==bu6Table.currentPage" <ng-container
(click)="bu6Table.currentPage=item">{{item}} *ngIf="item==bu6Table.page.length-2&&bu6Table.currentPage!=bu6Table.page.length&&bu6Table.currentPage!=bu6Table.page.length-1&&bu6Table.currentPage!=bu6Table.page.length-2">
</a> <a aria-label="anchor" class="page-link" href="javascript:void(0);"><i class="ri-more-line"></i>
</ng-container>
<ng-container
*ngIf="item==bu6Table.page.length-2&&bu6Table.currentPage!=bu6Table.page.length&&bu6Table.currentPage!=bu6Table.page.length-1&&bu6Table.currentPage!=bu6Table.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)="bu6Table.currentPage = (bu6Table.currentPage > bu6Table.page.length-1 ? bu6Table.currentPage: bu6Table.currentPage+1 )">
<i class="ri-arrow-right-s-line align-middle rtl:rotate-180"></i>
</a> </a>
</li> </ng-container>
</ul> </li>
</nav> <li>
<a aria-label="anchor" class="page-link" href="javascript:void(0);"
(click)="bu6Table.currentPage = (bu6Table.currentPage > bu6Table.page.length-1 ? bu6Table.currentPage: bu6Table.currentPage+1 )">
<i class="ri-arrow-right-s-line align-middle rtl:rotate-180"></i>
</a>
</li>
</ul>
</nav>
</div> </div>
...@@ -181,16 +185,20 @@ ...@@ -181,16 +185,20 @@
</div> </div>
</div> </div>
<div class="ti-modal-body"> <div class="ti-modal-body">
<label class="ti-form-label ">อยู่ภายใต้หน่วยงาน</label> <label class="ti-form-label ">อยู่ภายใต้หน่วยงาน*</label>
<div class="flex"> <div class="flex">
<div class="relative flex rounded-md"> <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 rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10" style="padding-right: 3.5rem;" <input type="text" id="hs-leading-button-add-on-with-icon-and-button"
[(ngModel)]="bu5.bu5id" (ngModelChange)="bu5idChange()"> name="hs-leading-button-add-on-with-icon-and-button"
<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="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10" readonly
<button type="button" class="flex items-center text-red-500" (click)="selectBu5()"> style="padding-right: 3.5rem;" [(ngModel)]="bu5.bu5id" (ngModelChange)="bu5idChange()">
<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)="selectBu5()">
<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" data-hs-overlay="#sub-department-three-bu5-table-modal"> <button type="button" class="flex items-center text-gray-500 dark:text-white/70"
data-hs-overlay="#sub-department-three-bu5-table-modal">
<i class="ri-search-line cursor-pointer text-gray"></i> <i class="ri-search-line cursor-pointer text-gray"></i>
</button> </button>
</div> </div>
...@@ -200,22 +208,27 @@ ...@@ -200,22 +208,27 @@
readonly [value]="bu5.tdesc"> readonly [value]="bu5.tdesc">
</div> </div>
</div> </div>
<label class="ti-form-label mt-2rem">ส่วนย่อย3</label> <label class="ti-form-label mt-2rem">ส่วนย่อย3*</label>
<div class="relative flex rounded-md w-1/2"> <div class="relative flex rounded-md w-1/2">
<input type="text" id="hs-leading-button-add-on-with-icon-and-button" name="hs-leading-button-add-on-with-icon-and-button" class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10" style="padding-right: 3.5rem;" <input type="text" class="ti-form-input h-16" [(ngModel)]="bu6.bu6id">
[(ngModel)]="bu6.bu6id" (ngModelChange)="bu6idChange()"> <!-- <input type="text" id="hs-leading-button-add-on-with-icon-and-button"
<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"> name="hs-leading-button-add-on-with-icon-and-button"
<button type="button" class="flex items-center text-red-500" (click)="selectBu6()"> class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10"
style="padding-right: 3.5rem;" [(ngModel)]="bu6.bu6id" (ngModelChange)="bu6idChange()">
<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)="selectBu6()">
<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" data-hs-overlay="#sub-department-three-bu6-table-modal"> <button type="button" class="flex items-center text-gray-500 dark:text-white/70"
data-hs-overlay="#sub-department-three-bu6-table-modal">
<i class="ri-search-line cursor-pointer text-gray"></i> <i class="ri-search-line cursor-pointer text-gray"></i>
</button> </button>
</div> </div> -->
</div> </div>
<label for="detail_th" class="ti-form-label mt-2rem">รายละเอียด (ไทย)</label> <label for="detail_th" class="ti-form-label mt-2rem">รายละเอียดส่วนย่อย3 (ไทย)*</label>
<input type="text" id="detail_th" class="ti-form-input h-16" [(ngModel)]="bu6.tdesc"> <input type="text" id="detail_th" class="ti-form-input h-16" [(ngModel)]="bu6.tdesc">
<label for="detail_eng" class="ti-form-label mt-2rem">รายละเอียด (อังกฤษ)</label> <label for="detail_eng" class="ti-form-label mt-2rem">รายละเอียดส่วนย่อย3 (อังกฤษ)</label>
<input type="text" id="detail_eng" class="ti-form-input h-16" [(ngModel)]="bu6.edesc"> <input type="text" id="detail_eng" class="ti-form-input h-16" [(ngModel)]="bu6.edesc">
<div class="flex justify-end mt-2rem mb-1rem space-x-4"> <div class="flex justify-end mt-2rem mb-1rem space-x-4">
<button type="button" <button type="button"
...@@ -223,10 +236,12 @@ ...@@ -223,10 +236,12 @@
data-hs-overlay="#sub-department-three-modal-add"> data-hs-overlay="#sub-department-three-modal-add">
ย้อนกลับ ย้อนกลับ
</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="#sub-department-three-alert-add-modal"> data-hs-overlay="#sub-department-three-alert-add-modal"
[class.ti-btn-disabled]="!bu5.bu5id||!bu6.bu6id||!bu6.tdesc"
[disabled]="!bu5.bu5id||!bu6.bu6id||!bu6.tdesc">
บันทึกข้อมูล บันทึกข้อมูล
</a> </button>
</div> </div>
</div> </div>
</div> </div>
...@@ -252,7 +267,7 @@ ...@@ -252,7 +267,7 @@
<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)="selectBu5();bu6.tdesc='';bu6.edesc=''"> (click)="selectBu5();bu6.tdesc='';bu6.edesc=''">
<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)">
...@@ -277,36 +292,41 @@ ...@@ -277,36 +292,41 @@
</div> </div>
</div> </div>
<div class="ti-modal-body"> <div class="ti-modal-body">
<label for="hs-trailing-button-add-on-with-icon" <label for="hs-trailing-button-add-on-with-icon" class="ti-form-label ">อยู่ภายใต้หน่วยงาน*</label>
class="ti-form-label ">อยู่ภายใต้หน่วยงาน</label> <div class="flex">
<div class="flex"> <div class="relative flex rounded-md">
<div class="relative flex rounded-md"> <input type="text" id="hs-leading-button-add-on-with-icon-and-button"
<input type="text" id="hs-leading-button-add-on-with-icon-and-button" name="hs-leading-button-add-on-with-icon-and-button" class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10" style="padding-right: 3.5rem;" name="hs-leading-button-add-on-with-icon-and-button"
[(ngModel)]="bu5.bu5id" (ngModelChange)="bu5idChange()"> class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10" readonly
<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"> style="padding-right: 3.5rem;" [(ngModel)]="bu5.bu5id" (ngModelChange)="bu5idChange()">
<button type="button" class="flex items-center text-red-500" (click)="selectBu5()"> <div
<i class="ti ti-circle-x cursor-pointer"></i> 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> <button type="button" class="flex items-center text-red-500" (click)="selectBu5()">
<button type="button" class="flex items-center text-gray-500 dark:text-white/70" data-hs-overlay="#sub-department-three-bu5-table-modal"> <i class="ti ti-circle-x cursor-pointer"></i>
<i class="ri-search-line cursor-pointer text-gray"></i> </button>
</button> <button type="button" class="flex items-center text-gray-500 dark:text-white/70"
</div> data-hs-overlay="#sub-department-three-bu5-table-modal">
</div> <i class="ri-search-line cursor-pointer text-gray"></i>
<div class="flex rounded-md w-1/2 pl-1rem"> </button>
<input type="text" id="input-label" class="ti-form-input w-full pr-10 bg-input-readonly"
readonly [value]="bu5.tdesc">
</div> </div>
</div> </div>
<label for="input-label" class="ti-form-label mt-2rem">ส่วนย่อย3</label> <div class="flex rounded-md w-1/2 pl-1rem">
<input type="text" id="input-label" class="ti-form-input w-full pr-10 bg-input-readonly"
readonly [value]="bu5.tdesc">
</div>
</div>
<label for="input-label" class="ti-form-label mt-2rem">ส่วนย่อย3*</label>
<div class="sm:grid grid-cols-2 gap-1"> <div class="sm:grid grid-cols-2 gap-1">
<div class="relative w-full"> <div class="relative w-full">
<input type="text" id="input-label" class="ti-form-input w-full pr-10 bg-input-readonly" <input type="text" id="input-label" class="ti-form-input w-full pr-10 bg-input-readonly"
readonly [value]="bu6.bu6id"> readonly [value]="bu6.bu6id">
</div> </div>
</div> </div>
<label for="detail_th" class="ti-form-label mt-2rem">รายละเอียด (ไทย)</label> <label for="detail_th" class="ti-form-label mt-2rem">รายละเอียดส่วนย่อย3
(ไทย)*</label>
<input type="text" id="detail_th" class="ti-form-input h-16" [(ngModel)]="bu6.tdesc"> <input type="text" id="detail_th" class="ti-form-input h-16" [(ngModel)]="bu6.tdesc">
<label for="detail_eng" class="ti-form-label mt-2rem">รายละเอียด (อังกฤษ)</label> <label for="detail_eng" class="ti-form-label mt-2rem">รายละเอียดส่วนย่อย3
(อังกฤษ)</label>
<input type="text" id="detail_eng" class="ti-form-input h-16" [(ngModel)]="bu6.edesc"> <input type="text" id="detail_eng" class="ti-form-input h-16" [(ngModel)]="bu6.edesc">
<div class="flex justify-end mt-2rem mb-1rem space-x-4 "> <div class="flex justify-end mt-2rem mb-1rem space-x-4 ">
<button type="button" <button type="button"
...@@ -314,10 +334,12 @@ ...@@ -314,10 +334,12 @@
data-hs-overlay="#sub-department-three-modal-edit"> data-hs-overlay="#sub-department-three-modal-edit">
ย้อนกลับ ย้อนกลับ
</button> </button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);" <button class="ti-btn ti-btn-success" type="button"
data-hs-overlay="#sub-department-three-alert-edit-modal"> data-hs-overlay="#sub-department-three-alert-edit-modal"
[class.ti-btn-disabled]="!bu5.bu5id||!bu6.bu6id||!bu6.tdesc"
[disabled]="!bu5.bu5id||!bu6.bu6id||!bu6.tdesc">
บันทึกข้อมูล บันทึกข้อมูล
</a> </button>
</div> </div>
</div> </div>
</div> </div>
...@@ -563,7 +585,7 @@ ...@@ -563,7 +585,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="#sub-department-three-alert-add-modal"> data-hs-overlay="#sub-department-three-modal-add">
<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>
...@@ -575,16 +597,11 @@ ...@@ -575,16 +597,11 @@
</p> </p>
<div class="flex justify-end mt-2rem mb-1rem"> <div class="flex justify-end mt-2rem mb-1rem">
<button type="button" *ngIf="currentModal=='add'" <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="#sub-department-three-modal-add"> data-hs-overlay="#sub-department-three-modal-add">
ย้อนกลับ ย้อนกลับ
</button> </button>
<button type="button" *ngIf="currentModal=='edit'"
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="#sub-department-three-modal-edit">
ย้อนกลับ
</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="#sub-department-three-alert-add-modal" (click)="addBu6();"> data-hs-overlay="#sub-department-three-alert-add-modal" (click)="addBu6();">
บันทึกข้อมูล บันทึกข้อมูล
...@@ -604,7 +621,7 @@ ...@@ -604,7 +621,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="#sub-department-three-alert-edit-modal"> data-hs-overlay="#sub-department-three-modal-edit">
<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>
...@@ -616,12 +633,7 @@ ...@@ -616,12 +633,7 @@
</p> </p>
<div class="flex justify-end mt-2rem mb-1rem"> <div class="flex justify-end mt-2rem mb-1rem">
<button type="button" *ngIf="currentModal=='add'" <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="#sub-department-three-modal-add">
ย้อนกลับ
</button>
<button type="button" *ngIf="currentModal=='edit'"
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="#sub-department-three-modal-edit"> data-hs-overlay="#sub-department-three-modal-edit">
ย้อนกลับ ย้อนกลับ
...@@ -673,7 +685,7 @@ ...@@ -673,7 +685,7 @@
</div> </div>
<div id="sub-department-three-upload-modal" class="hs-overlay hidden ti-modal"> <div id="sub-department-three-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)] 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">
นำเข้าทะเบียนส่วนย่อย3 นำเข้าทะเบียนส่วนย่อย3
...@@ -683,7 +695,7 @@ ...@@ -683,7 +695,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()"
...@@ -693,6 +705,7 @@ ...@@ -693,6 +705,7 @@
</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" (click)="uploadFile()"
data-hs-overlay="#sub-department-three-upload-modal" [class.ti-btn-disabled]="!selectedFile"
[disabled]="!selectedFile"> [disabled]="!selectedFile">
อัปโหลด อัปโหลด
</button> </button>
......
...@@ -19,7 +19,7 @@ interface table { ...@@ -19,7 +19,7 @@ interface table {
export class SubDepartmentThreeComponent implements OnInit { export class SubDepartmentThreeComponent implements OnInit {
bu6List: Bu6Model[] = [] bu6List: Bu6Model[] = []
bu6ListLoading = false bu6ListLoading = false
bu6: Bu6Model = new MyBu6Model({}) bu6: Bu6Model = new MyBu6Model()
bu6Table: table = { bu6Table: table = {
currentPage: 1, currentPage: 1,
page: Array.from({ length: 1 }, (_, i) => i + 1), page: Array.from({ length: 1 }, (_, i) => i + 1),
...@@ -41,7 +41,7 @@ export class SubDepartmentThreeComponent implements OnInit { ...@@ -41,7 +41,7 @@ export class SubDepartmentThreeComponent implements OnInit {
page: Array.from({ length: 1 }, (_, i) => i + 1), page: Array.from({ length: 1 }, (_, i) => i + 1),
search: "" search: ""
} }
currentModal = "" currentModal: 'add' | 'edit' | 'detele' = "add"
constructor(private bu6Service: Bu6Service, constructor(private bu6Service: Bu6Service,
private bu5Service: Bu5Service, private bu5Service: Bu5Service,
private toastr: ToastrService, private toastr: ToastrService,
...@@ -65,6 +65,7 @@ export class SubDepartmentThreeComponent implements OnInit { ...@@ -65,6 +65,7 @@ export class SubDepartmentThreeComponent implements OnInit {
} }
const formData = new FormData(); const formData = new FormData();
formData.append('file', this.selectedFile); formData.append('file', this.selectedFile);
this.bu6ListLoading = true
this.fileService.upload(formData, 'mbu6').subscribe({ this.fileService.upload(formData, 'mbu6').subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
...@@ -72,9 +73,11 @@ export class SubDepartmentThreeComponent implements OnInit { ...@@ -72,9 +73,11 @@ export class SubDepartmentThreeComponent implements OnInit {
this.getBu6List() this.getBu6List()
} else { } else {
this.showAlert(response.message, 'error') this.showAlert(response.message, 'error')
this.bu6ListLoading = false
} }
}, error: error => { }, error: error => {
this.showAlert(error.message, 'error') this.showAlert(error.message, 'error')
this.bu6ListLoading = false
} }
}) })
} }
...@@ -102,7 +105,7 @@ export class SubDepartmentThreeComponent implements OnInit { ...@@ -102,7 +105,7 @@ export class SubDepartmentThreeComponent implements OnInit {
this.bu6ListLoading = true this.bu6ListLoading = true
this.bu6Service.getList().subscribe({ this.bu6Service.getList().subscribe({
next: response => { next: response => {
this.bu6List = response this.bu6List = response.map(x => new MyBu6Model(x))
this.bu6ListLoading = false this.bu6ListLoading = false
this.onBu6TableSearchChange() this.onBu6TableSearchChange()
this.cdr.detectChanges() this.cdr.detectChanges()
...@@ -118,11 +121,11 @@ export class SubDepartmentThreeComponent implements OnInit { ...@@ -118,11 +121,11 @@ export class SubDepartmentThreeComponent implements OnInit {
} }
filterBu6Table() { filterBu6Table() {
return this.bu6List.filter(x => x.bu6id.toLowerCase().includes(this.bu6Table.search.toLowerCase()) || return this.bu6List.filter(x => x.bu6id.toLowerCase().includes(this.bu6Table.search.toLowerCase()) ||
x.tdesc.toLowerCase().includes(this.bu6Table.search.toLowerCase()) || x.tdesc.toLowerCase().includes(this.bu6Table.search.toLowerCase()) ||
x.edesc.toLowerCase().includes(this.bu6Table.search.toLowerCase())) x.edesc.toLowerCase().includes(this.bu6Table.search.toLowerCase()))
} }
selectBu6(bu6?: Bu6Model) { selectBu6(bu6?: Bu6Model) {
this.bu6 = new MyBu6Model(bu6 || {}) this.bu6 = new MyBu6Model(bu6)
this.selectBu5() this.selectBu5()
if (this.bu6.parent) { if (this.bu6.parent) {
this.bu5Service.getById(this.bu6.parent).subscribe(response => { this.bu5Service.getById(this.bu6.parent).subscribe(response => {
...@@ -141,10 +144,11 @@ export class SubDepartmentThreeComponent implements OnInit { ...@@ -141,10 +144,11 @@ export class SubDepartmentThreeComponent implements OnInit {
} }
filterBu6Modal() { filterBu6Modal() {
return this.bu6List.filter(x => x.bu6id.toLowerCase().includes(this.bu6Modal.search.toLowerCase()) || return this.bu6List.filter(x => x.bu6id.toLowerCase().includes(this.bu6Modal.search.toLowerCase()) ||
x.tdesc.toLowerCase().includes(this.bu6Modal.search.toLowerCase()) || x.tdesc.toLowerCase().includes(this.bu6Modal.search.toLowerCase()) ||
x.edesc.toLowerCase().includes(this.bu6Modal.search.toLowerCase())) x.edesc.toLowerCase().includes(this.bu6Modal.search.toLowerCase()))
} }
addBu6() { addBu6() {
this.bu6ListLoading = true
this.bu6Service.post({ ...this.bu6, parent: this.bu5.bu5id }).subscribe({ this.bu6Service.post({ ...this.bu6, parent: this.bu5.bu5id }).subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
...@@ -152,13 +156,16 @@ export class SubDepartmentThreeComponent implements OnInit { ...@@ -152,13 +156,16 @@ export class SubDepartmentThreeComponent implements OnInit {
this.getBu6List() this.getBu6List()
} else { } else {
this.showAlert(response.message, 'error') this.showAlert(response.message, 'error')
this.bu6ListLoading = false
} }
}, error: error => { }, error: error => {
this.showAlert(error.message, 'error') this.showAlert(error.message, 'error')
this.bu6ListLoading = false
} }
}) })
} }
deleteBu6() { deleteBu6() {
this.bu6ListLoading = true
this.bu6Service.delete(this.bu6).subscribe({ this.bu6Service.delete(this.bu6).subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
...@@ -166,16 +173,18 @@ export class SubDepartmentThreeComponent implements OnInit { ...@@ -166,16 +173,18 @@ export class SubDepartmentThreeComponent implements OnInit {
this.getBu6List() this.getBu6List()
} else { } else {
this.showAlert(response.message, 'error') this.showAlert(response.message, 'error')
this.bu6ListLoading = false
} }
}, error: error => { }, error: error => {
this.showAlert(error.message, 'error') this.showAlert(error.message, 'error')
this.bu6ListLoading = false
} }
}) })
} }
getBu5List() { getBu5List() {
this.bu5Service.getList().subscribe(response => { this.bu5Service.getList().subscribe(response => {
this.bu5List = response this.bu5List = response.map(x => new MyBu5Model(x))
this.onBu5ModalSearchChange() this.onBu5ModalSearchChange()
}) })
} }
...@@ -189,11 +198,11 @@ export class SubDepartmentThreeComponent implements OnInit { ...@@ -189,11 +198,11 @@ export class SubDepartmentThreeComponent implements OnInit {
} }
filterBu5Modal() { filterBu5Modal() {
return this.bu5List.filter(x => x.bu5id.toLowerCase().includes(this.bu5Modal.search.toLowerCase()) || return this.bu5List.filter(x => x.bu5id.toLowerCase().includes(this.bu5Modal.search.toLowerCase()) ||
x.tdesc.toLowerCase().includes(this.bu5Modal.search.toLowerCase()) || x.tdesc.toLowerCase().includes(this.bu5Modal.search.toLowerCase()) ||
x.edesc.toLowerCase().includes(this.bu5Modal.search.toLowerCase())) x.edesc.toLowerCase().includes(this.bu5Modal.search.toLowerCase()))
} }
selectBu5(bu5?: Bu5Model) { selectBu5(bu5?: Bu5Model) {
this.bu5 = new MyBu5Model(bu5 || {}) this.bu5 = new MyBu5Model(bu5)
} }
showAlert(text: string, type: 'success' | 'error') { showAlert(text: string, type: 'success' | 'error') {
......
...@@ -191,7 +191,8 @@ ...@@ -191,7 +191,8 @@
<input type="text" id="hs-leading-button-add-on-with-icon-and-button" <input type="text" id="hs-leading-button-add-on-with-icon-and-button"
name="hs-leading-button-add-on-with-icon-and-button" name="hs-leading-button-add-on-with-icon-and-button"
class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10" class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10"
style="padding-right: 3.5rem;" [(ngModel)]="bu4.bu4id" (ngModelChange)="bu4idChange()"> readonly style="padding-right: 3.5rem;" [(ngModel)]="bu4.bu4id"
(ngModelChange)="bu4idChange()">
<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" (click)="selectBu4()"> <button type="button" class="flex items-center text-red-500" (click)="selectBu4()">
...@@ -298,7 +299,8 @@ ...@@ -298,7 +299,8 @@
<input type="text" id="hs-leading-button-add-on-with-icon-and-button" <input type="text" id="hs-leading-button-add-on-with-icon-and-button"
name="hs-leading-button-add-on-with-icon-and-button" name="hs-leading-button-add-on-with-icon-and-button"
class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10" class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10"
style="padding-right: 3.5rem;" [(ngModel)]="bu4.bu4id" (ngModelChange)="bu4idChange()"> readonly style="padding-right: 3.5rem;" [(ngModel)]="bu4.bu4id"
(ngModelChange)="bu4idChange()">
<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" (click)="selectBu4()"> <button type="button" class="flex items-center text-red-500" (click)="selectBu4()">
...@@ -680,7 +682,7 @@ ...@@ -680,7 +682,7 @@
</div> </div>
<div id="sub-department-two-upload-modal" class="hs-overlay hidden ti-modal"> <div id="sub-department-two-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)] 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">
นำเข้าทะเบียนส่วนย่อย2 นำเข้าทะเบียนส่วนย่อย2
......
...@@ -104,7 +104,7 @@ export class SubDepartmentTwoComponent implements OnInit { ...@@ -104,7 +104,7 @@ export class SubDepartmentTwoComponent implements OnInit {
this.bu5ListLoading = true this.bu5ListLoading = true
this.bu5Service.getList().subscribe({ this.bu5Service.getList().subscribe({
next: response => { next: response => {
this.bu5List = response this.bu5List = response.map(x => new MyBu5Model(x))
this.bu5ListLoading = false this.bu5ListLoading = false
this.onBu5TableSearchChange() this.onBu5TableSearchChange()
this.cdr.detectChanges() this.cdr.detectChanges()
...@@ -183,7 +183,7 @@ export class SubDepartmentTwoComponent implements OnInit { ...@@ -183,7 +183,7 @@ export class SubDepartmentTwoComponent implements OnInit {
getBu4List() { getBu4List() {
this.bu4Service.getList().subscribe(response => { this.bu4Service.getList().subscribe(response => {
this.bu4List = response this.bu4List = response.map(x => new MyBu4Model(x))
this.onBu4ModalSearchChange() this.onBu4ModalSearchChange()
}) })
} }
......
<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="#company-registration-page-upload-modal"> data-hs-overlay="#company-registration-page-upload-modal"
(click)="fileInput.value = '';selectedFile=null;selectedFileName = 'กรุณาเลือกไฟล์'">
<i class="ri-add-line"></i> <i class="ri-add-line"></i>
นำเข้าข้อมูล นำเข้าข้อมูล
</button> </button>
<a class="mx-2 justify-center -mb-px inline-flex items-center gap-2 font-weight-500 font-size-12px text-center text-secondary border-secondary border-b-2 align-items-end" <a class="mx-2 justify-center -mb-px inline-flex items-center gap-2 font-weight-500 font-size-12px text-center text-secondary border-secondary border-b-2 align-items-end"
href="javascript:void(0);"> href="javascript:void(0);" (click)="downloadFile()">
ดาวน์โหลดตัวอย่างไฟล์ ดาวน์โหลดตัวอย่างไฟล์
</a> </a>
</div> </div>
...@@ -88,7 +107,7 @@ ...@@ -88,7 +107,7 @@
*ngFor="let item of dataListFilter() | slice:((currentPage-1) * 10) : (((currentPage-1) * 10) + 10);let i = index"> *ngFor="let item of dataListFilter() | slice:((currentPage-1) * 10) : (((currentPage-1) * 10) + 10);let i = index">
<td class="text-center"> <td class="text-center">
<input *ngIf="item.data.code!='100'" type="checkbox" class="ti-form-checkbox cursor-pointer" <input *ngIf="item.data.code!='100'" type="checkbox" class="ti-form-checkbox cursor-pointer"
id="checkbox-{{item.data.code}}" [(ngModel)]="item.check"> id="checkbox-{{item.data.code}}" [(ngModel)]="item.check" (ngModelChange)="dataListCheck()">
<label for="checkbox-{{item.data.code}}">&nbsp;{{item.data.code}}</label> <label for="checkbox-{{item.data.code}}">&nbsp;{{item.data.code}}</label>
</td> </td>
<td>{{item.data.tdesc}}</td> <td>{{item.data.tdesc}}</td>
...@@ -164,7 +183,7 @@ ...@@ -164,7 +183,7 @@
<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)="clearData()">
<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,11 +208,11 @@ ...@@ -189,11 +208,11 @@
</div> </div>
</div> </div>
<div class="ti-modal-body padding-16px pt-0 overflow-y-0"> <div class="ti-modal-body padding-16px pt-0 overflow-y-0">
<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" <input type="text" id="input-label" class="ti-form-input w-1/2"
[ngClass]="{'bg-input-readonly':modalStatus=='edit'}" [readonly]="modalStatus=='edit'" [ngClass]="{'bg-input-readonly':modalStatus=='edit'}" [readonly]="modalStatus=='edit'"
[(ngModel)]="dataSelect.code" [maxLength]="5"> [(ngModel)]="dataSelect.code" [maxLength]="5">
<label for="detail_th" class="ti-form-label mt-2rem">รายละเอียด (ไทย) *</label> <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">
...@@ -207,10 +226,12 @@ ...@@ -207,10 +226,12 @@
data-hs-overlay="#company-registration-page-modal"> data-hs-overlay="#company-registration-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="#company-registration-page-alert-modal"> data-hs-overlay="#company-registration-page-alert-modal"
[class.ti-btn-disabled]="!dataSelect.code||!dataSelect.tdesc"
[disabled]="!dataSelect.code||!dataSelect.tdesc">
บันทึกข้อมูล บันทึกข้อมูล
</a> </button>
</div> </div>
</div> </div>
</div> </div>
...@@ -281,7 +302,7 @@ ...@@ -281,7 +302,7 @@
</div> </div>
<div id="company-registration-page-upload-modal" class="hs-overlay hidden ti-modal"> <div id="company-registration-page-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)] 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">
นำเข้าข้อมูลบริษัท นำเข้าข้อมูลบริษัท
...@@ -291,18 +312,20 @@ ...@@ -291,18 +312,20 @@
<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 type="text" id="hs-trailing-button-add-on-with-icon" <input #fileInput id="fileInput" type="file" (change)="onFileSelected($event)" hidden>
name="hs-trailing-button-add-on-with-icon" <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"> class="ti-form-input rounded-none ltr:rounded-l-md rtl:rounded-r-md focus:z-10 cursor-pointer">
<button aria-label="button" type="button" <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"> 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> <i class="ti ti-upload"></i>
</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">
<a class="ti-btn ti-btn-secondary" href="javascript:void(0);"> <button type="submit" class="ti-btn ti-btn-secondary"
data-hs-overlay="#position-unit-component-upload-modal" [class.ti-btn-disabled]="!selectedFile"
(click)="uploadFile()" [disabled]="!selectedFile" [disabled]="!selectedFile">
อัปโหลด อัปโหลด
</a> </button>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -2,6 +2,7 @@ import { ChangeDetectorRef, Component } from '@angular/core'; ...@@ -2,6 +2,7 @@ import { ChangeDetectorRef, Component } from '@angular/core';
import { ToastrService } from 'ngx-toastr'; import { ToastrService } from 'ngx-toastr';
import { CompanyModel, MyCompanyModel } from 'src/app/shared/model/company.model'; import { CompanyModel, MyCompanyModel } from 'src/app/shared/model/company.model';
import { CompanyService } from 'src/app/shared/services/company.service'; import { CompanyService } from 'src/app/shared/services/company.service';
import { FileService } from 'src/app/shared/services/file.service';
export interface DataModel { export interface DataModel {
code: string code: string
tdesc: string tdesc: string
...@@ -23,11 +24,16 @@ export class CompanyRegistrationPageComponent { ...@@ -23,11 +24,16 @@ export class CompanyRegistrationPageComponent {
dataLoading = false dataLoading = false
dataSelect: DataModel = { code: "", tdesc: "", edesc: "", address: "", contact: "" } dataSelect: DataModel = { code: "", tdesc: "", edesc: "", address: "", contact: "" }
numDataListChecked = 0
isDataListChecked = false
isDataListCheckedAll = false
selectedFile: File | null = null;
selectedFileName: string = 'กรุณาเลือกไฟล์';
constructor(private toastr: ToastrService, constructor(private toastr: ToastrService,
private companyService: CompanyService, private companyService: CompanyService,
private cdr: ChangeDetectorRef private cdr: ChangeDetectorRef,
) { private fileService: FileService) { }
}
ngOnInit(): void { ngOnInit(): void {
this.getCompanyList() this.getCompanyList()
} }
...@@ -38,6 +44,8 @@ export class CompanyRegistrationPageComponent { ...@@ -38,6 +44,8 @@ export class CompanyRegistrationPageComponent {
next: response => { next: response => {
this.dataList = response.map(x => ({ check: false, data: { code: x.companyId, tdesc: x.tdesc, edesc: x.edesc, address: x.addressText, contact: x.descOther } })) this.dataList = response.map(x => ({ check: false, data: { code: x.companyId, tdesc: x.tdesc, edesc: x.edesc, address: x.addressText, contact: x.descOther } }))
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 => {
...@@ -50,6 +58,7 @@ export class CompanyRegistrationPageComponent { ...@@ -50,6 +58,7 @@ export class CompanyRegistrationPageComponent {
searchChange() { searchChange() {
this.currentPage = 1 this.currentPage = 1
this.page = Array.from({ length: Math.ceil(this.dataListFilter().length / 10) }, (_, i) => i + 1); this.page = Array.from({ length: Math.ceil(this.dataListFilter().length / 10) }, (_, i) => i + 1);
this.dataListCheck()
} }
dataListFilter() { dataListFilter() {
return this.dataList.filter(x => { return this.dataList.filter(x => {
...@@ -82,7 +91,7 @@ export class CompanyRegistrationPageComponent { ...@@ -82,7 +91,7 @@ export class CompanyRegistrationPageComponent {
if (this.dataSelect.code) { if (this.dataSelect.code) {
body = new MyCompanyModel({ companyId: this.dataSelect.code, tdesc: this.dataSelect.tdesc, edesc: this.dataSelect.edesc, addressText: this.dataSelect.address, descOther: this.dataSelect.contact }) body = new MyCompanyModel({ companyId: this.dataSelect.code, tdesc: this.dataSelect.tdesc, edesc: this.dataSelect.edesc, addressText: this.dataSelect.address, descOther: this.dataSelect.contact })
} else { } else {
body = this.dataList.filter(x => x.check).map(x => new MyCompanyModel({ companyId: x.data.code, tdesc: x.data.tdesc, edesc: x.data.edesc, addressText: x.data.address, descOther: x.data.contact })) body = this.dataList.filter(x => x.check && x.data.code != '100').map(x => new MyCompanyModel({ companyId: x.data.code, tdesc: x.data.tdesc, edesc: x.data.edesc, addressText: x.data.address, descOther: x.data.contact }))
} }
this.companyService.delete(body).subscribe({ this.companyService.delete(body).subscribe({
next: response => { next: response => {
...@@ -105,4 +114,73 @@ export class CompanyRegistrationPageComponent { ...@@ -105,4 +114,73 @@ export class CompanyRegistrationPageComponent {
}); });
} }
dataListCheckAll() {
const selectAll = this.isDataListCheckedAll;
this.dataList.filter(x => {
const data = x.data
const match = data.code.includes(this.search) || data.tdesc.includes(this.search) || data.edesc.includes(this.search);
return match;
}).forEach(x => x.check = selectAll);
this.dataListCheck();
}
dataListCheck() {
const dataCheck = this.dataListFilter();
this.isDataListCheckedAll = dataCheck.length ? dataCheck.every(x => x.check) : false;
this.numDataListChecked = this.dataList.filter(x => x.check).length;
this.isDataListChecked = Boolean(this.numDataListChecked)
}
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.dataLoading = true
this.fileService.upload(formData, '').subscribe({
next: response => {
if (response.success) {
this.showAlert(response.message, 'success')
this.getCompanyList()
} else {
this.showAlert(response.message, 'error')
this.dataLoading = false
this.cdr.detectChanges();
}
}, error: error => {
this.showAlert(error.message, 'error')
this.dataLoading = false
this.cdr.detectChanges();
}
})
}
downloadFile() {
const fileName = '.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')
}
})
}
clearData() {
if (this.modalStatus == 'add') {
this.setData()
} else {
this.setData({ code: this.dataSelect.code, tdesc: "", edesc: "", address: "", contact: "" })
}
}
} }
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
</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 id="underline-1" role="tabpanel" aria-labelledby="underline-item-1">
<app-sub-employee-registration></app-sub-employee-registration> <app-sub-employee-registration></app-sub-employee-registration>
</div> </div>
......
<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="#sub-employee-registration-modal-upload"> data-hs-overlay="#sub-employee-registration-modal-upload"
(click)="fileInput.value = '';selectedFile=null;selectedFileName = 'กรุณาเลือกไฟล์'">
<i class="ri-add-line"></i> <i class="ri-add-line"></i>
นำเข้าข้อมูล นำเข้าข้อมูล
</button> </button>
<a class="mx-2 justify-center -mb-px inline-flex items-center gap-2 font-weight-500 font-size-12px text-center text-secondary border-secondary border-b-2 align-items-end" <a class="mx-2 justify-center -mb-px inline-flex items-center gap-2 font-weight-500 font-size-12px text-center text-secondary border-secondary border-b-2 align-items-end"
href="javascript:void(0);"> href="javascript:void(0);" (click)="downloadFile()">
ดาวน์โหลดตัวอย่างไฟล์ ดาวน์โหลดตัวอย่างไฟล์
</a> </a>
</div> </div>
...@@ -33,13 +52,21 @@ ...@@ -33,13 +52,21 @@
</button> </button>
</div> </div>
<div class="px-1"> <div class="px-1">
<button href="javascript:void(0);" class="ti-btn ti-btn-soft-info h-45px m-0 shadow-md"> <button class="ti-btn ti-btn-soft-danger h-45px m-0 shadow-md"
data-hs-overlay="#sub-employee-registration-alert-delete-modal"
(click)="modalType='deleteGroup';selectEmployee()">
<i class="ri-delete-bin-6-line"></i>
Delete
</button>
</div>
<div class="px-1">
<button class="ti-btn ti-btn-soft-info h-45px m-0 shadow-md">
<i class="ri-printer-line"></i> <i class="ri-printer-line"></i>
Print Print
</button> </button>
</div> </div>
<div class="px-1"> <div class="px-1">
<button href="javascript:void(0);" class="ti-btn ti-btn-soft-warning h-45px m-0 shadow-md"> <button class="ti-btn ti-btn-soft-warning h-45px m-0 shadow-md">
<i class="ti ti-book fs-l"></i> <i class="ti ti-book fs-l"></i>
Help Help
</button> </button>
...@@ -87,7 +114,7 @@ ...@@ -87,7 +114,7 @@
*ngFor="let item of employeeFilter() | slice:((currentPage-1) * 10) : (((currentPage-1) * 10) + 10);let i = index"> *ngFor="let item of employeeFilter() | 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.data.employeeId}}" <input type="checkbox" class="ti-form-checkbox cursor-pointer" id="checkbox-{{item.data.employeeId}}"
[(ngModel)]="item.check"> [(ngModel)]="item.check" (ngModelChange)="dataListCheck()">
<label for="checkbox-{{item.data.employeeId}}">&nbsp;{{item.data.employeeId}}</label> <label for="checkbox-{{item.data.employeeId}}">&nbsp;{{item.data.employeeId}}</label>
</td> </td>
<td>{{item.data.fname}}</td> <td>{{item.data.fname}}</td>
...@@ -347,7 +374,7 @@ ...@@ -347,7 +374,7 @@
</div> </div>
<div id="sub-employee-registration-modal-upload" class="hs-overlay hidden ti-modal"> <div id="sub-employee-registration-modal-upload" 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)] 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">
นำเข้าข้อมูลพนักงาน นำเข้าข้อมูลพนักงาน
...@@ -357,17 +384,20 @@ ...@@ -357,17 +384,20 @@
<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 type="text" id="hs-trailing-button-add-on-with-icon" name="hs-trailing-button-add-on-with-icon" <input #fileInput id="fileInput" type="file" (change)="onFileSelected($event)" hidden>
class="ti-form-input rounded-none ltr:rounded-l-md rtl:rounded-r-md "> <input type="text" [value]="selectedFileName" readonly (click)="fileInput.click()"
<button aria-label="button" type="button" class="ti-form-input rounded-none ltr:rounded-l-md rtl:rounded-r-md focus:z-10 cursor-pointer">
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:outline-none focus:ring-0 focus:ring-secondary transition-all text-sm"> <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> <i class="ti ti-upload"></i>
</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">
<a class="ti-btn ti-btn-secondary" href="javascript:void(0);"> <button type="submit" class="ti-btn ti-btn-secondary" data-hs-overlay="#position-unit-component-upload-modal"
[class.ti-btn-disabled]="!selectedFile" (click)="uploadFile()" [disabled]="!selectedFile"
[disabled]="!selectedFile">
อัปโหลด อัปโหลด
</a> </button>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -12,10 +12,11 @@ import { Bu1Service } from 'src/app/shared/services/bu1.service'; ...@@ -12,10 +12,11 @@ import { Bu1Service } from 'src/app/shared/services/bu1.service';
import { EmpGroupService } from 'src/app/shared/services/emp-group.service'; import { EmpGroupService } from 'src/app/shared/services/emp-group.service';
import { EmpTypeService } from 'src/app/shared/services/employee-type.service'; import { EmpTypeService } from 'src/app/shared/services/employee-type.service';
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 { PLService } from 'src/app/shared/services/pl.service'; import { PLService } from 'src/app/shared/services/pl.service';
import { PositionService } from 'src/app/shared/services/position.service'; import { PositionService } from 'src/app/shared/services/position.service';
import { BranchService } from 'src/app/shared/services/่branch.service'; import { BranchService } from 'src/app/shared/services/่branch.service';
import { JobCodeService } from 'src/app/shared/services/job-code.service'; import { JobCodeService } from 'src/app/shared/services/job-code.service';
export interface DataEmployee { export interface DataEmployee {
loading: boolean loading: boolean
select: EmployeeModel | any select: EmployeeModel | any
...@@ -41,7 +42,7 @@ export class SubEmployeeRegistrationComponent { ...@@ -41,7 +42,7 @@ export class SubEmployeeRegistrationComponent {
currentPage = 1 currentPage = 1
page = Array.from({ length: 1 }, (_, i) => i + 1); page = Array.from({ length: 1 }, (_, i) => i + 1);
search = "" search = ""
modalType: 'add' | 'update' | 'delete' = 'add' modalType: 'add' | 'update' | 'delete' | 'deleteGroup' = 'add'
modal: DataModal = { modal: DataModal = {
search: "", search: "",
...@@ -49,6 +50,13 @@ export class SubEmployeeRegistrationComponent { ...@@ -49,6 +50,13 @@ export class SubEmployeeRegistrationComponent {
page: Array.from({ length: 1 }, (_, i) => i + 1) page: Array.from({ length: 1 }, (_, i) => i + 1)
} }
numDataListChecked = 0
isDataListChecked = false
isDataListCheckedAll = false
selectedFile: File | null = null;
selectedFileName: string = 'กรุณาเลือกไฟล์';
empGroup: { loading: boolean, dataList: EmpGroupModel[] } = { loading: false, dataList: [] } empGroup: { loading: boolean, dataList: EmpGroupModel[] } = { loading: false, dataList: [] }
bu1: { loading: boolean, dataList: Bu1Model[] } = { loading: false, dataList: [] } bu1: { loading: boolean, dataList: Bu1Model[] } = { loading: false, dataList: [] }
position: { loading: boolean, dataList: PositionModel[] } = { loading: false, dataList: [] } position: { loading: boolean, dataList: PositionModel[] } = { loading: false, dataList: [] }
...@@ -65,6 +73,7 @@ export class SubEmployeeRegistrationComponent { ...@@ -65,6 +73,7 @@ export class SubEmployeeRegistrationComponent {
private jobcodeService: JobCodeService, private jobcodeService: JobCodeService,
private branchService: BranchService, private branchService: BranchService,
private empTypeService: EmpTypeService, private empTypeService: EmpTypeService,
private fileService: FileService,
private pLService: PLService) { } private pLService: PLService) { }
ngOnInit(): void { ngOnInit(): void {
...@@ -77,6 +86,53 @@ export class SubEmployeeRegistrationComponent { ...@@ -77,6 +86,53 @@ export class SubEmployeeRegistrationComponent {
this.getEmpTypeList() this.getEmpTypeList()
this.getPlList() this.getPlList()
} }
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.employee.loading = true
this.fileService.upload(formData, '').subscribe({
next: response => {
if (response.success) {
this.showAlert(response.message, 'success')
this.getEmployeeList()
} else {
this.showAlert(response.message, 'error')
this.employee.loading = false
this.cdr.detectChanges();
}
}, error: error => {
this.showAlert(error.message, 'error')
this.employee.loading = false
this.cdr.detectChanges();
}
})
}
downloadFile() {
const fileName = 'IMPORT_MPOSITION.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')
}
})
}
getPlList() { getPlList() {
this.pl.loading = false this.pl.loading = false
this.pLService.getList().subscribe({ this.pLService.getList().subscribe({
...@@ -225,6 +281,8 @@ export class SubEmployeeRegistrationComponent { ...@@ -225,6 +281,8 @@ export class SubEmployeeRegistrationComponent {
next: response => { next: response => {
this.employee.dataList = response.map((x: any) => ({ check: false, data: new MyEmployeeModel(x) })) this.employee.dataList = response.map((x: any) => ({ check: false, data: new MyEmployeeModel(x) }))
this.employee.loading = false this.employee.loading = false
this.isDataListCheckedAll = false
this.dataListCheckAll()
this.searchChange() this.searchChange()
this.cdr.detectChanges() this.cdr.detectChanges()
}, error: error => { }, error: error => {
...@@ -233,10 +291,18 @@ export class SubEmployeeRegistrationComponent { ...@@ -233,10 +291,18 @@ export class SubEmployeeRegistrationComponent {
} }
}) })
} }
updateEmployeeList(type: 'add' | 'update' | 'delete') { updateEmployeeList(type: 'add' | 'update' | 'delete' | 'deleteGroup') {
let body = this.employee.select let body = this.employee.select
if (type == 'delete') { switch (type) {
body = [this.employee.select] case 'delete': {
body = [this.employee.select]
break;
}
case 'deleteGroup': {
body = this.employee.dataList.filter(x => x.check).map(x => new MyEmployeeModel(x.data))
type = 'delete'
break;
}
} }
this.employeeService[type](body).subscribe({ this.employeeService[type](body).subscribe({
next: response => { next: response => {
...@@ -254,6 +320,7 @@ export class SubEmployeeRegistrationComponent { ...@@ -254,6 +320,7 @@ export class SubEmployeeRegistrationComponent {
searchChange() { searchChange() {
this.currentPage = 1 this.currentPage = 1
this.page = Array.from({ length: Math.ceil(this.employeeFilter().length / 10) }, (_, i) => i + 1); this.page = Array.from({ length: Math.ceil(this.employeeFilter().length / 10) }, (_, i) => i + 1);
this.dataListCheck()
} }
employeeFilter() { employeeFilter() {
return this.employee.dataList.filter(x => return this.employee.dataList.filter(x =>
...@@ -300,4 +367,22 @@ export class SubEmployeeRegistrationComponent { ...@@ -300,4 +367,22 @@ export class SubEmployeeRegistrationComponent {
positionClass: 'toast-top-right', positionClass: 'toast-top-right',
}) })
} }
dataListCheckAll() {
const selectAll = this.isDataListCheckedAll;
this.employee.dataList.filter(x =>
x.data.employeeId.toLowerCase().includes(this.search.toLowerCase()) ||
x.data.fname.toLowerCase().includes(this.search.toLowerCase()) ||
x.data.lname.toLowerCase().includes(this.search.toLowerCase()) ||
x.data.position.tdesc.toLowerCase().includes(this.search.toLowerCase()) ||
x.data.jobCode.tdesc.toLowerCase().includes(this.search.toLowerCase())).forEach(x => x.check = selectAll);
this.dataListCheck();
}
dataListCheck() {
const dataCheck = this.employeeFilter();
this.isDataListCheckedAll = dataCheck.length ? dataCheck.every(x => x.check) : false;
this.numDataListChecked = this.employee.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,17 +108,19 @@ ...@@ -88,17 +108,19 @@
<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 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"
(click)="modalStatus='delete';setData(item.data)" (click)="modalStatus='delete';setData(item.data)"
data-hs-overlay="#employee-categories-page-alert-modal"></i> data-hs-overlay="#employee-categories-page-alert-modal"></i>
</td> </td>
</tr> </tr>
...@@ -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,11 +212,13 @@ ...@@ -189,11 +212,13 @@
</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">
<div class="flex justify-end mt-2rem mb-1rem space-x-4"> <div class="flex justify-end mt-2rem mb-1rem space-x-4">
<button type="button" <button type="button"
...@@ -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>
...@@ -275,7 +302,7 @@ ...@@ -275,7 +302,7 @@
</div> </div>
<div id="employee-categories-upload-modal" class="hs-overlay hidden ti-modal"> <div id="employee-categories-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)] 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">
นำเข้าประเภทพนักงาน นำเข้าประเภทพนักงาน
...@@ -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,12 +321,13 @@ ...@@ -294,12 +321,13 @@
</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>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
\ No newline at end of file
...@@ -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 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"
(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>
...@@ -276,7 +301,7 @@ ...@@ -276,7 +301,7 @@
</div> </div>
<div id="employee-group-unit-component-upload-modal" class="hs-overlay hidden ti-modal"> <div id="employee-group-unit-component-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)] 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">
นำเข้ากลุ่มพนักงาน นำเข้ากลุ่มพนักงาน
...@@ -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()
} }
}); });
} }
toggleSelectAll(event: Event) { dataListCheckAll() {
const checked = (event.target as HTMLInputElement).checked; const selectAll = this.isDataListCheckedAll;
this.emp_groupList.filter(x => {
this.emp_groupList.forEach(item => { const data = x.data
item.check = checked; // อัปเดตค่า check ใน emp_groupList 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;
}).forEach(x => x.check = selectAll);
// อัปเดตรายการ selectedItems ด้วย groupId ของรายการที่ถูกเลือก this.dataListCheck();
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>
...@@ -34,10 +53,10 @@ ...@@ -34,10 +53,10 @@
</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-level-page-alert-modal" (click)="modalStatus='deleteGroup';setData()"> data-hs-overlay="#employee-level-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>
</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 href="javascript:void(0);" class="ti-btn ti-btn-soft-warning h-20px m-0 shadow-md">
...@@ -68,14 +87,14 @@ ...@@ -68,14 +87,14 @@
</thead> </thead>
<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" role="status"
aria-label="loading"> aria-label="loading">
<span class="sr-only">Loading...</span> <span class="sr-only">Loading...</span>
</div> </div>
</td> </td>
</tr> </tr>
</tbody> </tbody>
<tbody *ngIf="!dataLoading&&!plListFilter().length"> <tbody *ngIf="!dataLoading&&!plListFilter().length">
<tr> <tr>
<td class="text-center" colspan="100%"> <td class="text-center" colspan="100%">
...@@ -87,8 +106,8 @@ ...@@ -87,8 +106,8 @@
<tr <tr
*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 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>
...@@ -97,7 +116,7 @@ ...@@ -97,7 +116,7 @@
<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-level-page-modal"></i> data-hs-overlay="#employee-level-page-modal"></i>
<i class="ti ti-trash cursor-pointer i-gray fs-l px-1" *ngIf="item.data.plId!='100'" <i class="ti ti-trash cursor-pointer i-gray fs-l px-1"
(click)="modalStatus='delete';setData(item.data)" (click)="modalStatus='delete';setData(item.data)"
data-hs-overlay="#employee-level-page-alert-modal"></i> data-hs-overlay="#employee-level-page-alert-modal"></i>
</td> </td>
...@@ -108,39 +127,39 @@ ...@@ -108,39 +127,39 @@
</div> </div>
<nav class="pagination-style-3 overflow-auto my-5" *ngIf="page.length"> <nav class="pagination-style-3 overflow-auto my-5" *ngIf="page.length">
<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)"> (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 *ngFor="let item of page;let f = first;let l = last"> <li *ngFor="let item of page;let f = first;let l = last">
<ng-container *ngIf="item==3&&currentPage!=1&&currentPage!=2&&currentPage!=3"> <ng-container *ngIf="item==3&&currentPage!=1&&currentPage!=2&&currentPage!=3">
<a aria-label="anchor" class="page-link" href="javascript:void(0);"><i class="ri-more-line"></i> <a aria-label="anchor" class="page-link" href="javascript:void(0);"><i class="ri-more-line"></i>
</a> </a>
</ng-container> </ng-container>
<ng-container *ngIf="(f||l)||(item==currentPage-1||item==currentPage||item==currentPage+1)"> <ng-container *ngIf="(f||l)||(item==currentPage-1||item==currentPage||item==currentPage+1)">
<a class="page-link" href="javascript:void(0);" [class.active]="item==currentPage" <a class="page-link" href="javascript:void(0);" [class.active]="item==currentPage"
(click)="currentPage=item">{{item}} (click)="currentPage=item">{{item}}
</a> </a>
</ng-container> </ng-container>
<ng-container <ng-container
*ngIf="item==page.length-2&&currentPage!=page.length&&currentPage!=page.length-1&&currentPage!=page.length-2"> *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 aria-label="anchor" class="page-link" href="javascript:void(0);"><i class="ri-more-line"></i>
</a> </a>
</ng-container> </ng-container>
</li> </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 )"> (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>
<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,11 +208,13 @@ ...@@ -189,11 +208,13 @@
</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">รายละเอียดระดับพนักงาน(PL) (ไทย)*</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">รายละเอียดระดับพนักงาน(PL) (อังกฤษ)</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-4"> <div class="flex justify-end mt-2rem mb-1rem space-x-4">
<button type="button" <button type="button"
...@@ -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>
...@@ -211,94 +234,95 @@ ...@@ -211,94 +234,95 @@
</div> </div>
<div id="employee-level-upload-modal" class="hs-overlay hidden ti-modal"> <div id="employee-level-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)] 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()"
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"> 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> <i class="ti ti-upload"></i>
</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"
[disabled]="!selectedFile"> [class.ti-btn-disabled]="!selectedFile" (click)="uploadFile()" [disabled]="!selectedFile"
อัปโหลด [disabled]="!selectedFile">
</button> อัปโหลด
</div> </button>
</div> </div>
</div> </div>
</div>
</div> </div>
</div> </div>
<div id="employee-level-page-alert-modal" class="hs-overlay hidden ti-modal"> <div id="employee-level-page-alert-modal" class="hs-overlay hidden ti-modal">
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)] flex items-center"> <div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)] flex items-center">
<div class="max-h-full overflow-hidden ti-modal-content w-full"> <div class="max-h-full overflow-hidden ti-modal-content w-full">
<div class="ti-modal-header"> <div class="ti-modal-header">
<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">
<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>
</ng-container> </ng-container>
<ng-container *ngIf="modalStatus=='delete'||modalStatus=='deleteGroup'"> <ng-container *ngIf="modalStatus=='delete'||modalStatus=='deleteGroup'">
<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-alert-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>
</ng-container> </ng-container>
</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"> <p class="mt-1 text-gray-800 dark:text-white/70">
<ng-container *ngIf="modalStatus=='add'||modalStatus=='edit'"> <ng-container *ngIf="modalStatus=='add'||modalStatus=='edit'">
ยืนยันการบันทึกข้อมูลหรือไม่ ยืนยันการบันทึกข้อมูลหรือไม่
</ng-container> </ng-container>
<ng-container *ngIf="modalStatus=='delete'||modalStatus=='deleteGroup'"> <ng-container *ngIf="modalStatus=='delete'||modalStatus=='deleteGroup'">
ยืนยันการลบข้อมูลหรือไม่ ยืนยันการลบข้อมูลหรือไม่
</ng-container> </ng-container>
</p> </p>
<div class="flex justify-end mt-2rem mb-1rem"> <div class="flex justify-end mt-2rem mb-1rem">
<ng-container *ngIf="modalStatus=='add'||modalStatus=='edit'"> <ng-container *ngIf="modalStatus=='add'||modalStatus=='edit'">
<button type="button" <button type="button"
class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10" class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
data-hs-overlay="#employee-level-page-modal"> data-hs-overlay="#employee-level-page-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="#employee-level-page-alert-modal" (click)="addPL()"> data-hs-overlay="#employee-level-page-alert-modal" (click)="addPL()">
บันทึกข้อมูล บันทึกข้อมูล
</a> </a>
</ng-container> </ng-container>
<ng-container *ngIf="modalStatus=='delete'||modalStatus=='deleteGroup'"> <ng-container *ngIf="modalStatus=='delete'||modalStatus=='deleteGroup'">
<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="#employee-level-page-alert-modal"> data-hs-overlay="#employee-level-page-alert-modal">
ย้อนกลับ ย้อนกลับ
</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-level-page-alert-modal" (click)="deletePL()"> data-hs-overlay="#employee-level-page-alert-modal" (click)="deletePL()">
ลบข้อมูล ลบข้อมูล
</a> </a>
</ng-container> </ng-container>
</div> </div>
</div>
</div> </div>
</div>
</div> </div>
</div> </div>
\ No newline at end of file
...@@ -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,44 +10,56 @@ ...@@ -10,44 +10,56 @@
<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>
</div> </div>
\ No newline at end of file
...@@ -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,17 +106,19 @@ ...@@ -86,17 +106,19 @@
<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 type="checkbox" class="ti-form-checkbox cursor-pointer"
id="checkbox-{{item.data.positionId}}" [(ngModel)]="item.check"> 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"
(click)="modalStatus='delete';setData(item.data)" (click)="modalStatus='delete';setData(item.data)"
data-hs-overlay="#position-unit-component-page-alert-modal"></i> data-hs-overlay="#position-unit-component-page-alert-modal"></i>
</td> </td>
</tr> </tr>
...@@ -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>
...@@ -272,7 +299,7 @@ ...@@ -272,7 +299,7 @@
</div> </div>
<div id="position-unit-component-upload-modal" class="hs-overlay hidden ti-modal"> <div id="position-unit-component-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)] 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">
นำเข้าตำแหน่ง นำเข้าตำแหน่ง
...@@ -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,28 +111,23 @@ export class PositionUnitComponent implements OnInit { ...@@ -110,28 +111,23 @@ 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)
);
}); });
} }
setData(data?: DataModel) { setData(data?: DataModel) {
this.dataSelect = JSON.parse(JSON.stringify(data || { positionId: "", tdesc: "", edesc: "", consolidate: "", shortName: "", companyId: "" })); this.dataSelect = JSON.parse(JSON.stringify(data || { positionId: "", tdesc: "", edesc: "", consolidate: "", shortName: "", companyId: "" }));
} }
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 = ''
}
}
} }
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
<div class="px-1"> <div class="px-1">
<div class="relative shadow-md"> <div class="relative shadow-md">
<input type="text" id="hs-leading-icon" name="hs-leading-icon" <input type="text" id="hs-leading-icon" name="hs-leading-icon"
class="ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 " placeholder="Search by No. or Name"> class="ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 " placeholder="Search by No. or Name"
[(ngModel)]="search" (ngModelChange)="searchEMP()">
<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>
...@@ -31,73 +32,86 @@ ...@@ -31,73 +32,86 @@
<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>
<tr> <tr>
<ng-container <ng-container
*ngFor="let item of ['ชื่อพนักงาน','ลำดับที่ 1','ลำดับที่ 2','ลำดับที่ 3','ลำดับที่ 4','ลำดับที่ 5','การจัดการ']; let f = first; let l = last; let i = index"> *ngFor="let item of ['ชื่อพนักงาน','ลำดับที่ 1','ลำดับที่ 2','ลำดับที่ 3','ลำดับที่ 4','ลำดับที่ 5','การจัดการ']; 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">{{ 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>
</div> </div>
</th> </th>
</ng-container> </ng-container>
</tr> </tr>
</thead> </thead>
<tbody> <tbody *ngIf="groupapprove_listLoading">
<tr *ngFor="let item of[ <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>
['กสินธร สีปัญญา','อุทุมพร ประชาดี','ชุมพล น้อยพิทักษ์','','','']];let i = index"> </td>
<td >{{item[0]}}</td> </tr>
<td >{{item[1]}}</td> </tbody>
<td >{{item[2]}}</td> <tbody *ngIf="!groupapprove_listLoading&&!groupapprove_listFilter().length">
<td >{{item[3]}}</td> <tr>
<td >{{item[4]}}</td> <td class="text-center" colspan="100%">
<td >{{item[5]}}</td> ไม่พบข้อมูล
<td class="flex justify-center"> </td>
<i class="ti ti-edit cursor-pointer i-gray fs-l px-1" </tr>
data-hs-overlay="#set-approvers-modal-edit"></i> </tbody>
</td> <tbody *ngIf="!groupapprove_listLoading&&groupapprove_listFilter().length">
</tr> <tr
</tbody> *ngFor="let item of groupapprove_listFilter() | slice:((currentPage-1) * 10) : (((currentPage-1) * 10) + 10);let i = index">
</table> <td>{{item.apsassessy.fname}} {{item.apsassessy.lname}}</td>
</div> <td>{{item.apsapprove1.fname}} {{item.apsapprove1.lname}}</td>
<div class="body-content" style="margin-top: 20px;"> <td>{{item.apsapprove2.fname}} {{item.apsapprove2.lname}}</td>
<ul class="nav-tabs"> <td>{{item.apsapprove3.fname}} {{item.apsapprove3.lname}}</td>
<div class="px-1 py-1 bg-white rounded-2 shadow justify-content-center align-items-center"> <td>{{item.apsapprove4.fname}} {{item.apsapprove4.lname}}</td>
<div class="box-body"> <td>{{item.apsapprove5.fname}} {{item.apsapprove5.lname}}</td>
<nav class="pagination-style-3 overflow-auto"> <td class="flex justify-center">
<ul class="ti-pagination"> <i class="ti ti-edit cursor-pointer i-gray fs-l px-1"
<li> (click)="currentModel='edit';selectGroupapprove(item)"
<a aria-label="anchor" class="page-link" href="javascript:void(0);"> data-hs-overlay="#set-approvers-modal-edit"></i>
<i class="ri-arrow-left-s-line align-middle rtl:rotate-180"></i> </td>
</a> </tr>
</li> </tbody>
<li><a class="page-link active" href="javascript:void(0);" aria-current="page">1</a></li> </table>
<li><a class="page-link" href="javascript:void(0);">2</a></li>
<li><a class="page-link" href="javascript:void(0);">3</a></li>
<li><a class="page-link" href="javascript:void(0);">4</a></li>
<li><a class="page-link" href="javascript:void(0);">5</a></li>
<li><a class="page-link" href="javascript:void(0);">...</a></li>
<li><a class="page-link" href="javascript:void(0);">31</a></li>
<li>
<a aria-label="anchor" class="page-link" href="javascript:void(0);">
<i class="ri-arrow-right-s-line align-middle rtl:rotate-180"></i>
</a>
</li>
</ul>
</nav>
</div>
</div>
</ul>
<ul class="nav-tabs mt-1">
<p>Show 1 to 10 of 50 items</p>
</ul>
</div> </div>
<nav class="pagination-style-3 overflow-auto my-5" *ngIf="page.length">
<ul class="ti-pagination">
<li>
<a aria-label="anchor" class="page-link" href="javascript:void(0);"
(click)="currentPage = (currentPage-1 || 1)">
<i class="ri-arrow-left-s-line align-middle rtl:rotate-180"></i>
</a>
</li>
<li *ngFor="let item of page;let f = first;let l = last">
<ng-container *ngIf="item==3&&currentPage!=1&&currentPage!=2&&currentPage!=3">
<a aria-label="anchor" class="page-link" href="javascript:void(0);"><i class="ri-more-line"></i>
</a>
</ng-container>
<ng-container *ngIf="(f||l)||(item==currentPage-1||item==currentPage||item==currentPage+1)">
<a class="page-link" href="javascript:void(0);" [class.active]="item==currentPage"
(click)="currentPage=item">{{item}}
</a>
</ng-container>
<ng-container
*ngIf="item==page.length-2&&currentPage!=page.length&&currentPage!=page.length-1&&currentPage!=page.length-2">
<a aria-label="anchor" class="page-link" href="javascript:void(0);"><i class="ri-more-line"></i>
</a>
</ng-container>
</li>
<li>
<a aria-label="anchor" class="page-link" href="javascript:void(0);"
(click)="currentPage = (currentPage > page.length-1 ? currentPage: currentPage+1 )">
<i class="ri-arrow-right-s-line align-middle rtl:rotate-180"></i>
</a>
</li>
</ul>
</nav>
</div> </div>
...@@ -145,20 +159,25 @@ ...@@ -145,20 +159,25 @@
</div> </div>
</div> </div>
<div class="ti-modal-body mt-1"> <div class="ti-modal-body mt-1">
<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 bg-input-readonly" readonly
[value]="groupapprove.apsassessy.fname + ' ' + groupapprove.apsassessy.lname">
<label for="input-label" class="ti-form-label mt-2rem">ระดับพนักงาน</label>
<input type="text" id="input-label" class="ti-form-input w-1/2 bg-input-readonly" readonly <input type="text" id="input-label" class="ti-form-input w-1/2 bg-input-readonly" readonly
value="พนักงานระดับ 01-02"> [value]="groupapprove.personalLevel.tdesc">
<label class="ti-form-label mt-2rem">ผู้ประเมินลำดับที่ 1</label> <label class="ti-form-label mt-2rem">ผู้ประเมินลำดับที่ 1</label>
<div class="flex"> <div class="flex">
<div class="relative flex rounded-md w-2/3"> <div class="relative flex rounded-md w-2/3">
<input type="text" id="hs-leading-button-add-on-with-icon-and-button" <input type="text" name="hs-leading-button-add-on-with-icon-and-button"
name="hs-leading-button-add-on-with-icon-and-button" class="ti-form-input rounded-md ltr:rounded-r-md rtl:rounded-l-md focus:z-10 bg-input-readonly"
class="ti-form-input rounded-md ltr:rounded-r-md rtl:rounded-l-md focus:z-10" readonly style="padding-right: 2.5rem;" [(ngModel)]="groupapprove.apsapprove1.fname">
style="padding-right: 2.5rem;" value="">
<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" (click)="selectEMP()">
<i class="ti ti-circle-x cursor-pointer"></i>
</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="#set-approvers-table-modal-edit"> (click)="empnumber = 1" data-hs-overlay="#set-approvers-table-modal-edit">
<i class="ri-search-line cursor-pointer text-gray"></i> <i class="ri-search-line cursor-pointer text-gray"></i>
</button> </button>
</div> </div>
...@@ -167,14 +186,16 @@ ...@@ -167,14 +186,16 @@
<label class="ti-form-label mt-2rem">ผู้ประเมินลำดับที่ 2</label> <label class="ti-form-label mt-2rem">ผู้ประเมินลำดับที่ 2</label>
<div class="flex"> <div class="flex">
<div class="relative flex rounded-md w-2/3"> <div class="relative flex rounded-md w-2/3">
<input type="text" id="hs-leading-button-add-on-with-icon-and-button" <input type="text" name="hs-leading-button-add-on-with-icon-and-button"
name="hs-leading-button-add-on-with-icon-and-button" class="ti-form-input rounded-md ltr:rounded-r-md rtl:rounded-l-md focus:z-10 bg-input-readonly"
class="ti-form-input rounded-md ltr:rounded-r-md rtl:rounded-l-md focus:z-10" readonly style="padding-right: 2.5rem;" [(ngModel)]="groupapprove.apsapprove2.fname">
style="padding-right: 2.5rem;" value="">
<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" (click)="selectEMP()">
<i class="ti ti-circle-x cursor-pointer"></i>
</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="#set-approvers-table-modal-edit"> data-hs-overlay="#set-approvers-table-modal-edit" (click)="empnumber = 2">
<i class="ri-search-line cursor-pointer text-gray"></i> <i class="ri-search-line cursor-pointer text-gray"></i>
</button> </button>
</div> </div>
...@@ -183,14 +204,16 @@ ...@@ -183,14 +204,16 @@
<label class="ti-form-label mt-2rem">ผู้ประเมินลำดับที่ 3</label> <label class="ti-form-label mt-2rem">ผู้ประเมินลำดับที่ 3</label>
<div class="flex"> <div class="flex">
<div class="relative flex rounded-md w-2/3"> <div class="relative flex rounded-md w-2/3">
<input type="text" id="hs-leading-button-add-on-with-icon-and-button" <input type="text" name="hs-leading-button-add-on-with-icon-and-button"
name="hs-leading-button-add-on-with-icon-and-button" class="ti-form-input rounded-md ltr:rounded-r-md rtl:rounded-l-md focus:z-10 bg-input-readonly"
class="ti-form-input rounded-md ltr:rounded-r-md rtl:rounded-l-md focus:z-10" readonly style="padding-right: 2.5rem;" [(ngModel)]="groupapprove.apsapprove3.fname">
style="padding-right: 2.5rem;" value="">
<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">
<i class="ti ti-circle-x cursor-pointer"></i>
</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="#set-approvers-table-modal-edit"> data-hs-overlay="#set-approvers-table-modal-edit" (click)="empnumber = 3">
<i class="ri-search-line cursor-pointer text-gray"></i> <i class="ri-search-line cursor-pointer text-gray"></i>
</button> </button>
</div> </div>
...@@ -199,14 +222,16 @@ ...@@ -199,14 +222,16 @@
<label class="ti-form-label mt-2rem">ผู้ประเมินลำดับที่ 4</label> <label class="ti-form-label mt-2rem">ผู้ประเมินลำดับที่ 4</label>
<div class="flex"> <div class="flex">
<div class="relative flex rounded-md w-2/3"> <div class="relative flex rounded-md w-2/3">
<input type="text" id="hs-leading-button-add-on-with-icon-and-button" <input type="text" name="hs-leading-button-add-on-with-icon-and-button"
name="hs-leading-button-add-on-with-icon-and-button" class="ti-form-input rounded-md ltr:rounded-r-md rtl:rounded-l-md focus:z-10 bg-input-readonly"
class="ti-form-input rounded-md ltr:rounded-r-md rtl:rounded-l-md focus:z-10" readonly style="padding-right: 2.5rem;" [(ngModel)]="groupapprove.apsapprove4.fname">
style="padding-right: 2.5rem;" value="">
<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">
<i class="ti ti-circle-x cursor-pointer"></i>
</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="#set-approvers-table-modal-edit"> data-hs-overlay="#set-approvers-table-modal-edit" (click)="empnumber = 4">
<i class="ri-search-line cursor-pointer text-gray"></i> <i class="ri-search-line cursor-pointer text-gray"></i>
</button> </button>
</div> </div>
...@@ -215,14 +240,16 @@ ...@@ -215,14 +240,16 @@
<label class="ti-form-label mt-2rem">ผู้ประเมินลำดับที่ 5</label> <label class="ti-form-label mt-2rem">ผู้ประเมินลำดับที่ 5</label>
<div class="flex"> <div class="flex">
<div class="relative flex rounded-md w-2/3"> <div class="relative flex rounded-md w-2/3">
<input type="text" id="hs-leading-button-add-on-with-icon-and-button" <input type="text" name="hs-leading-button-add-on-with-icon-and-button"
name="hs-leading-button-add-on-with-icon-and-button" class="ti-form-input rounded-md ltr:rounded-r-md rtl:rounded-l-md focus:z-10 bg-input-readonly"
class="ti-form-input rounded-md ltr:rounded-r-md rtl:rounded-l-md focus:z-10" readonly style="padding-right: 2.5rem;" [(ngModel)]="groupapprove.apsapprove5.fname">
style="padding-right: 2.5rem;" value="">
<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">
<i class="ti ti-circle-x cursor-pointer"></i>
</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="#set-approvers-table-modal-edit"> data-hs-overlay="#set-approvers-table-modal-edit" (click)="empnumber = 5">
<i class="ri-search-line cursor-pointer text-gray"></i> <i class="ri-search-line cursor-pointer text-gray"></i>
</button> </button>
</div> </div>
...@@ -264,8 +291,8 @@ ...@@ -264,8 +291,8 @@
<div class="px-1"> <div class="px-1">
<div class="relative shadow-md"> <div class="relative shadow-md">
<input type="text" id="hs-leading-icon" name="hs-leading-icon" <input type="text" id="hs-leading-icon" name="hs-leading-icon"
class="ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 " class="ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 " placeholder="Search by No. or Name"
placeholder="Search by No. or Name"> [(ngModel)]="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>
...@@ -311,71 +338,64 @@ ...@@ -311,71 +338,64 @@
</ng-container> </ng-container>
</tr> </tr>
</thead> </thead>
<tbody> <tbody *ngIf="!employee_listFilter().length">
<tr <tr>
*ngFor="let item of[ <td class="text-center" colspan="100%">
['10001', 'สามารถ','พยัคร้าย','Human Resource Development Officer','BU5'], ไม่พบข้อมูล
['10002', 'สมหวัง','ฟันหลุด','Human Resource Development Officer','BU5'],
['10003', 'สามารถ','พยัคร้าย','Human Resource Development Officer','BU5'],
['10004', 'สมหวัง','ฟันหลุด','Human Resource Development Officer','BU5'],
['10005', 'สามารถ','พยัคร้าย','Human Resource Development Officer','BU5'],
['10006', 'สมจิต','ฟันหลอ','Human Resource Development Officer','BU5'],];let i = index">
<td class="flex justify-center" style="font-size: 12px;">{{item[0]}}</td>
<td style="font-size: 12px; width: 20%;">{{item[1]}}</td>
<td style="font-size: 12px; width: 20%;">{{item[2]}}</td>
<td
style="font-size: 12px; width: 20%; word-break: break-word; white-space: normal;">
{{item[3]}}
</td>
<td style="font-size: 12px; width: 20%;">{{item[4]}}</td>
<td class="flex justify-center">
<div class="px-1">
<button type="button"
class="ti-btn ti-btn-soft-secondary h-20px m-0 shadow-md"
data-hs-overlay="#set-approvers-modal-edit">
<i class="ri-add-line"></i>
Select
</button>
</div>
</td> </td>
</tr> </tr>
</tbody> </tbody>
<tbody *ngIf="employee_listFilter().length">
<ng-container *ngIf="currentModel=='edit'">
<tr *ngFor="let item of employee_listFilter() | slice:((employeeModal.currentPage-1) * 10) : (((employeeModal.currentPage-1) * 10) + 10);let i = index"
class="cursor-pointer">
<td style="font-size: 12px;">{{item.employeeId}}</td>
<td style="font-size: 12px; width: 20%;">{{item.fname}}</td>
<td style="font-size: 12px; width: 20%;">{{item.lname}}</td>
<td
style="font-size: 12px; width: 20%; word-break: break-word; white-space: normal;">
{{item.position.tdesc}}
</td>
<td style="font-size: 12px; width: 10%;">{{item.bu1.bu1id}}</td>
<td class="flex justify-center">
<div class="px-1">
<button type="button"
class="ti-btn ti-btn-soft-secondary h-20px m-0 shadow-md"
(click)="selectEMP(item)"
data-hs-overlay="#set-approvers-modal-edit">
<i class="ri-add-line"></i>
Select
</button>
</div>
</td>
</tr>
</ng-container>
</tbody>
</table> </table>
</div> </div>
</div> </div>
<div class="body-content" style="margin-top: 20px;"> <nav class="pagination-style-3 overflow-auto my-5" *ngIf="employeeModal.page.length">
<ul class="nav-tabs"> <ul class="ti-pagination">
<div class="px-1 bg-white rounded-2 shadow justify-content-center align-items-center"> <li>
<div class="box-body"> <a aria-label="anchor" class="page-link" href="javascript:void(0);"
<nav class="pagination-style-3 overflow-auto"> (click)="employeeModal.currentPage = (employeeModal.currentPage-1 || 1)">
<ul class="ti-pagination"> <i class="ri-arrow-left-s-line align-middle rtl:rotate-180"></i>
<li> </a>
<a aria-label="anchor" class="page-link" href="javascript:void(0);"> </li>
<i class="ri-arrow-left-s-line align-middle rtl:rotate-180"></i> <li *ngFor="let item of employeeModal.page">
</a> <a class="page-link" href="javascript:void(0);"
</li> [class.active]="item==employeeModal.currentPage"
<li><a class="page-link active" href="javascript:void(0);" (click)="employeeModal.currentPage=item">{{item}}
aria-current="page">1</a></li> </a>
<li><a class="page-link" href="javascript:void(0);">2</a></li> </li>
<li><a class="page-link" href="javascript:void(0);">3</a></li> <li>
<li><a class="page-link" href="javascript:void(0);">4</a></li> <a aria-label="anchor" class="page-link" href="javascript:void(0);"
<li><a class="page-link" href="javascript:void(0);">5</a></li> (click)="employeeModal.currentPage = (employeeModal.currentPage > employeeModal.page.length-1 ? employeeModal.currentPage: employeeModal.currentPage+1 )">
<li><a class="page-link" href="javascript:void(0);">...</a></li> <i class="ri-arrow-right-s-line align-middle rtl:rotate-180"></i>
<li><a class="page-link" href="javascript:void(0);">31</a></li> </a>
<li> </li>
<a aria-label="anchor" class="page-link" href="javascript:void(0);">
<i class="ri-arrow-right-s-line align-middle rtl:rotate-180"></i>
</a>
</li>
</ul>
</nav>
</div>
</div>
</ul> </ul>
<ul class="nav-tabs mt-1"> </nav>
<p>Show 1 to 10 of 50 items</p>
</ul>
</div>
</div> </div>
</div> </div>
</div> </div>
...@@ -408,11 +428,11 @@ ...@@ -408,11 +428,11 @@
ย้อนกลับ ย้อนกลับ
</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-approvers-alert-edit-modal" (click)="addUser();showSuccessEdit()"> data-hs-overlay="#set-approvers-alert-edit-modal" (click)="addgroupapprove();showSuccessEdit()">
บันทึกข้อมูล บันทึกข้อมูล
</a> </a>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
\ No newline at end of file
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 { EmployeeModel, MyEmployeeModel } from 'src/app/shared/model/employee.model';
import { GroupApproveModel, MyGroupApproveModel } from 'src/app/shared/model/group-approve.model';
import { EmployeeService } from 'src/app/shared/services/employee.service';
import { GroupApproveService } from 'src/app/shared/services/group-approve.service';
interface table {
currentPage: number,
page: number[],
search: string
}
@Component({ @Component({
selector: 'app-set-approvers', selector: 'app-set-approvers',
templateUrl: './set-approvers.component.html', templateUrl: './set-approvers.component.html',
styleUrls: ['./set-approvers.component.scss'] styleUrls: ['./set-approvers.component.scss']
}) })
export class SetApproversComponent { export class SetApproversComponent {
@Input() pathTitle = ['การประเมินจัดประเมินสมรรถนะ', 'การจัดการสมรรถนะ', 'กำหนดผู้ประเมิน']; @Input() pathTitle = ['การประเมินจัดประเมินสมรรถนะ', 'การจัดการสมรรถนะ', 'กำหนดผู้ประเมิน'];
@Output() sendPathTitle: EventEmitter<string[]> = new EventEmitter<string[]>(); @Output() sendPathTitle: EventEmitter<string[]> = new EventEmitter<string[]>();
activeTab: string = 'tab1'; // กำหนด tab เริ่มต้น activeTab: string = 'tab1';
// ฟังก์ชันในการเปลี่ยนแท็บ
changeTab(tab: { id: string, text: string }) { changeTab(tab: { id: string, text: string }) {
this.sendPathTitle.emit(['การสมรรถนะจัดประเมินสมรรถนะ', 'การจัดการประเมิน', tab.text]); this.sendPathTitle.emit(['การสมรรถนะจัดประเมินสมรรถนะ', 'การจัดการประเมิน', tab.text]);
this.activeTab = tab.id; this.activeTab = tab.id;
} }
// การจัดการการเปิดปิด modal currentPage = 1
modalOptions: { page = Array.from({ length: 1 }, (_, i) => i + 1);
[nameModal: string]: { groupapprove_list: GroupApproveModel[] = []
isModalOpen: boolean; groupapprove_listLoading = false
modalSize: string; groupapprove: GroupApproveModel = new MyGroupApproveModel()
backdropClose: boolean; search = ""
};
} = { employee_list: EmployeeModel[] = []
"add": { employee_listLoading = false
isModalOpen: false, employee: EmployeeModel = new MyEmployeeModel({})
modalSize: 'm', employeeModal: table = {
backdropClose: true, currentPage: 1,
}, page: Array.from({ length: 1 }, (_, i) => i + 1),
"edit": { search: ""
isModalOpen: false,
modalSize: 'm',
backdropClose: true,
}
};
openModal(name: string, size: string, closeOnBackdrop?: boolean) {
this.modalOptions[name].modalSize = size;
this.modalOptions[name].backdropClose = closeOnBackdrop || false;
this.modalOptions[name].isModalOpen = true;
this.currentModal = name; // ตั้งค่าค่าของ currentModal เป็น 'add' หรือ 'edit'
document.body.style.overflow = 'hidden';
} }
empnumber = 0
closeModal(name: string) {
this.modalOptions[name].isModalOpen = false; currentModel: 'add' | 'edit' | 'delete' = "add"
if (!this.isAnyModalOpen()) { constructor(private groupapproveService: GroupApproveService,
document.body.style.overflow = ''; // คืนค่าการ Scroll เฉพาะเมื่อ Modal ทั้งหมดปิดแล้ว private toastr: ToastrService,
} private cdr: ChangeDetectorRef,
private employeeService: EmployeeService,
) { }
ngOnInit(): void {
this.getGroupapprove_list()
this.getEemployeeList()
} }
isAnyModalOpen(): boolean { getEemployeeList() {
return Object.values(this.modalOptions).some(modal => modal.isModalOpen); // ตรวจสอบว่า modal อื่นยังเปิดอยู่หรือไม่ this.employee_listLoading = true
this.employeeService.getList().subscribe({
next: response => {
this.employee_list = response.map(x => {
return new MyEmployeeModel(x)
})
this.employee_listLoading = false
this.searchEMP()
this.cdr.detectChanges()
}, error: error => {
this.employee_listLoading = false
this.cdr.detectChanges()
}
})
} }
employee_listFilter() {
// ฟังก์ชัน toggle checkbox return this.employee_list.filter(x => x.fname.toLowerCase().includes(this.search.toLowerCase()) ||
isChecked: boolean = false; // ใช้สำหรับตรวจสอบสถานะของ checkbox x.lname.toLowerCase().includes(this.search.toLowerCase()))
toggleCheckbox() {
this.isChecked = !this.isChecked; // สลับสถานะ
} }
searchEMP() {
// ฟังก์ชันสำหรับการเพิ่ม ลบ หรือแก้ไข ข้อมูล this.employeeModal.currentPage = 1
addUser() { this.employeeModal.page = Array.from({ length: Math.ceil(this.employee_listFilter().length / 10) }, (_, i) => i + 1);
console.log('เพิ่มผู้ใช้งาน');
} }
empChange() {
deleteUser() { const employee = this.employee_list.find(x => x.employeeId == this.employee.employeeId)
console.log('ลบผู้ใช้งาน'); this.selectEMP(employee || new MyEmployeeModel({ employeeId: this.employee.employeeId }))
} }
selectEMP(employee?: EmployeeModel) {
const data = new MyEmployeeModel(employee || {});
if (this.empnumber == 1) {
this.groupapprove.apsapprove1 = data
} else if (this.empnumber == 2) {
this.groupapprove.apsapprove2 = data
} else if (this.empnumber == 3) {
this.groupapprove.apsapprove3 = data
} else if (this.empnumber == 4) {
this.groupapprove.apsapprove4 = data
} else if (this.empnumber == 5) {
this.groupapprove.apsapprove5 = data
}
editUser() { }
console.log('แก้ไขผู้ใช้งาน'); getGroupapprove_list() {
this.groupapprove_listLoading = true
this.groupapproveService.getList().subscribe({
next: response => {
this.groupapprove_list = response.map(x => new MyGroupApproveModel(x))
this.groupapprove_listLoading = false
this.searchChange()
this.cdr.detectChanges()
}, error: error => {
this.groupapprove_listLoading = false
this.cdr.detectChanges()
}
})
}
searchChange() {
this.currentPage = 1
this.page = Array.from({ length: Math.ceil(this.groupapprove_listFilter().length / 10) }, (_, i) => i + 1);
}
groupapprove_listFilter() {
return this.groupapprove_list.filter(x => x.apsapprove1.employeeId||x.apsapprove2.employeeId||x.apsapprove3.employeeId||x.apsapprove4.employeeId||x.apsapprove5.employeeId.toLowerCase().includes(this.search.toLowerCase()) ||
x.apsapprove1.fname || x.apsapprove1.lname.toLowerCase().includes(this.search.toLowerCase()) ||
x.apsapprove2.fname || x.apsapprove2.lname.toLowerCase().includes(this.search.toLowerCase()) ||
x.apsapprove3.fname || x.apsapprove3.lname.toLowerCase().includes(this.search.toLowerCase()) ||
x.apsapprove4.fname || x.apsapprove4.lname.toLowerCase().includes(this.search.toLowerCase()) ||
x.apsapprove5.fname || x.apsapprove5.lname.toLowerCase().includes(this.search.toLowerCase()))
} }
currentModal = ""; selectGroupapprove(groupapprove?: GroupApproveModel) {
this.groupapprove = new MyGroupApproveModel(groupapprove)
}
constructor(private toastr: ToastrService) { } showAlert(text: string, type: 'success' | 'error') {
this.toastr[type](text, 'แจ้งเตือน', {
timeOut: 3000,
positionClass: 'toast-top-right',
})
}
addgroupapprove() {
this.groupapprove_listLoading = true
this.groupapproveService.post(this.groupapprove).subscribe({
next: response => {
if (response.success) {
this.getGroupapprove_list()
} else {
this.showAlert(response.message, 'error')
this.groupapprove_listLoading = false
}
}, error: error => {
this.showAlert(error.message, 'error')
this.groupapprove_listLoading = false
}
})
}
deletegroupapprove() {
this.groupapprove_listLoading = true
this.groupapproveService.delete(this.groupapprove).subscribe({
next: response => {
if (response.success) {
this.getGroupapprove_list()
} else {
this.showAlert(response.message, 'error')
this.groupapprove_listLoading = false
}
}, error: error => {
this.showAlert(error.message, 'error')
this.groupapprove_listLoading = false
}
})
}
showSuccess() { showSuccess() {
this.toastr.success('บันทึกข้อมูลสำเร็จ', 'เเจ้งเตือน', { this.toastr.success('บันทึกข้อมูลสำเร็จ', 'เเจ้งเตือน', {
...@@ -101,4 +186,4 @@ export class SetApproversComponent { ...@@ -101,4 +186,4 @@ export class SetApproversComponent {
positionClass: 'toast-top-right', positionClass: 'toast-top-right',
}); });
} }
} }
\ No newline at end of file
...@@ -217,6 +217,8 @@ ...@@ -217,6 +217,8 @@
<label for="detail_eng" class="ti-form-label mt-2rem">หัวข้อเรื่อง</label> <label for="detail_eng" class="ti-form-label mt-2rem">หัวข้อเรื่อง</label>
<textarea type="text" id="detail_eng" class="ti-form-input" rows="4" cols="50" <textarea type="text" id="detail_eng" class="ti-form-input" rows="4" cols="50"
[(ngModel)]="dataSelect.topic"> </textarea> [(ngModel)]="dataSelect.topic"> </textarea>
<label for="input-label" class="ti-form-label">Link myLearn</label>
<input type="text" id="input-label" class="ti-form-input h-10" [(ngModel)]="dataSelect.courseLinkMylearn">
<div class="flex justify-end mt-3rem mb-1rem space-x-4"> <div class="flex justify-end mt-3rem mb-1rem space-x-4">
<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"
...@@ -289,6 +291,8 @@ ...@@ -289,6 +291,8 @@
<label for="detail_eng" class="ti-form-label mt-2rem">หัวข้อเรื่อง</label> <label for="detail_eng" class="ti-form-label mt-2rem">หัวข้อเรื่อง</label>
<textarea type="text" id="detail_eng" class="ti-form-input" rows="4" cols="50" <textarea type="text" id="detail_eng" class="ti-form-input" rows="4" cols="50"
[(ngModel)]="dataSelect.topic"> </textarea> [(ngModel)]="dataSelect.topic"> </textarea>
<label for="input-label" class="ti-form-label">Link myLearn</label>
<input type="text" id="input-label" class="ti-form-input h-10" [(ngModel)]="dataSelect.courseLinkMylearn">
<div class="flex justify-end mt-3rem mb-1rem space-x-4"> <div class="flex justify-end mt-3rem mb-1rem space-x-4">
<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"
......
...@@ -8,6 +8,7 @@ export interface DataModel { ...@@ -8,6 +8,7 @@ export interface DataModel {
edesc: string edesc: string
detail: string detail: string
topic: string topic: string
courseLinkMylearn: string
checked: boolean checked: boolean
} }
@Component({ @Component({
...@@ -82,7 +83,7 @@ export class DevelopmentCourseComponent { ...@@ -82,7 +83,7 @@ export class DevelopmentCourseComponent {
// ฟังก์ชันสำหรับการเพิ่ม ลบ หรือแก้ไข ข้อมูล // ฟังก์ชันสำหรับการเพิ่ม ลบ หรือแก้ไข ข้อมูล
addUser() { addUser() {
const body = new MyCompetencycourseModel({ competencyCourseId: this.dataSelect.id, tdesc: this.dataSelect.name, edesc: this.dataSelect.edesc, courseTopic: this.dataSelect.topic, courseDetail: this.dataSelect.detail }) const body = new MyCompetencycourseModel({ competencyCourseId: this.dataSelect.id, tdesc: this.dataSelect.name, edesc: this.dataSelect.edesc, courseTopic: this.dataSelect.topic, courseDetail: this.dataSelect.detail, courseLinkMylearn: this.dataSelect.courseLinkMylearn })
this.competencycourseService.post(body).subscribe((response: any) => { this.competencycourseService.post(body).subscribe((response: any) => {
if (response.success) { if (response.success) {
this.showSuccess() this.showSuccess()
...@@ -91,7 +92,7 @@ export class DevelopmentCourseComponent { ...@@ -91,7 +92,7 @@ export class DevelopmentCourseComponent {
}) })
} }
deleteUser() { deleteUser() {
const body = new MyCompetencycourseModel({ competencyCourseId: this.dataSelect.id, tdesc: this.dataSelect.name, edesc: this.dataSelect.edesc, courseTopic: this.dataSelect.topic, courseDetail: this.dataSelect.detail }) const body = new MyCompetencycourseModel({ competencyCourseId: this.dataSelect.id, tdesc: this.dataSelect.name, edesc: this.dataSelect.edesc, courseTopic: this.dataSelect.topic, courseDetail: this.dataSelect.detail,courseLinkMylearn: this.dataSelect.courseLinkMylearn })
this.competencycourseService.delete(body).subscribe((response: any) => { this.competencycourseService.delete(body).subscribe((response: any) => {
if (response.success) { if (response.success) {
this.showSuccessDelete() this.showSuccessDelete()
...@@ -104,7 +105,7 @@ export class DevelopmentCourseComponent { ...@@ -104,7 +105,7 @@ export class DevelopmentCourseComponent {
mockData: DataModel[] = [] mockData: DataModel[] = []
dataLoading = false dataLoading = false
dataSelect: DataModel = { id: "", name: "", edesc: "", topic: "", detail: "", checked: false } dataSelect: DataModel = { id: "", name: "", edesc: "", topic: "", detail: "",courseLinkMylearn:"", checked: false }
mockDataSelect: any = [] mockDataSelect: any = []
...@@ -119,7 +120,7 @@ export class DevelopmentCourseComponent { ...@@ -119,7 +120,7 @@ export class DevelopmentCourseComponent {
this.dataLoading = true this.dataLoading = true
this.competencycourseService.getList().subscribe({ this.competencycourseService.getList().subscribe({
next: response => { next: response => {
this.mockData = response.map(x => ({ id: x.competencyCourseId, name: x.tdesc, edesc: x.edesc, topic: x.courseTopic, detail: x.courseDetail, checked: false })) this.mockData = response.map(x => ({ id: x.competencyCourseId, name: x.tdesc, edesc: x.edesc, topic: x.courseTopic, detail: x.courseDetail,courseLinkMylearn:x.courseLinkMylearn, checked: false }))
this.dataLoading = false this.dataLoading = false
this.searchChange() this.searchChange()
this.cdr.detectChanges() this.cdr.detectChanges()
......
...@@ -91,7 +91,7 @@ ...@@ -91,7 +91,7 @@
<tr <tr
*ngFor="let item of evaluation_cycleListFilter() | slice:((currentPage-1) * 10) : (((currentPage-1) * 10) + 10);let i = index"> *ngFor="let item of evaluation_cycleListFilter() | slice:((currentPage-1) * 10) : (((currentPage-1) * 10) + 10);let i = index">
<td class="text-center"> <td class="text-center">
<input *ngIf="item.data.evaluationRoundId!='100'" type="checkbox" class="ti-form-checkbox cursor-pointer" <input type="checkbox" class="ti-form-checkbox cursor-pointer"
id="checkbox-{{item.data.evaluationRoundId}}" [(ngModel)]="item.check" (ngModelChange)="dataListCheck()"> id="checkbox-{{item.data.evaluationRoundId}}" [(ngModel)]="item.check" (ngModelChange)="dataListCheck()">
<label for="checkbox-{{item.data.evaluationRoundId}}">&nbsp;{{item.data.evaluationRoundId}}</label> <label for="checkbox-{{item.data.evaluationRoundId}}">&nbsp;{{item.data.evaluationRoundId}}</label>
</td> </td>
......
...@@ -109,10 +109,11 @@ ...@@ -109,10 +109,11 @@
<td>{{item.data.name}}</td> <td>{{item.data.name}}</td>
<td class="text-center">{{item.data.code}}</td> <td class="text-center">{{item.data.code}}</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="#competency-topic-page-modal"></i> data-hs-overlay="#competency-topic-page-modal"></i>
<i class="ti ti-trash cursor-pointer i-gray fs-l px-1" *ngIf="item.data.id!='100'" <i class="ti ti-trash cursor-pointer i-gray fs-l px-1"
(click)="modalStatus='delete';setData(item.data)" (click)="modalStatus='delete';setData(item.data)"
data-hs-overlay="#competency-topic-page-alert-modal"></i> data-hs-overlay="#competency-topic-page-alert-modal"></i>
</td> </td>
</tr> </tr>
...@@ -204,7 +205,9 @@ ...@@ -204,7 +205,9 @@
</div> </div>
<div class="ti-modal-body mt-1"> <div class="ti-modal-body mt-1">
<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.id"> <input type="text" id="input-label" class="ti-form-input w-1/2"
[ngClass]="{'bg-input-readonly':modalStatus=='edit'}" [readonly]="modalStatus=='edit'"
[(ngModel)]="dataSelect.id">
<label for="detail_th" class="ti-form-label mt-2rem">ชื่อหัวข้อ (ไทย)</label> <label for="detail_th" class="ti-form-label mt-2rem">ชื่อหัวข้อ (ไทย)</label>
<input type="text" id="detail_th" class="ti-form-input h-10" [(ngModel)]="dataSelect.name"> <input type="text" id="detail_th" class="ti-form-input h-10" [(ngModel)]="dataSelect.name">
<label for="detail_eng" class="ti-form-label mt-2rem">ชื่อหัวข้อ (อังกฤษ)</label> <label for="detail_eng" class="ti-form-label mt-2rem">ชื่อหัวข้อ (อังกฤษ)</label>
...@@ -608,7 +611,7 @@ ...@@ -608,7 +611,7 @@
</div> </div>
<div id="competency-topic-upload-modal" class="hs-overlay hidden ti-modal"> <div id="competency-topic-upload-modal" class="hs-overlay hidden ti-modal">
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)] 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">
นำเข้าหัวข้อสมรรถนะ นำเข้าหัวข้อสมรรถนะ
......
...@@ -10,24 +10,25 @@ ...@@ -10,24 +10,25 @@
<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: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: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)=" currentPage = 1;pathTitle = ['การประเมินสมรรถนะ','ทะเบียนกำหนดชื่อ','ประเภทสมรรถนะ']"> aria-controls="underline-1"
(click)=" currentPage = 1;pathTitle = ['การประเมินสมรรถนะ','ทะเบียนกำหนดชื่อ','ประเภทสมรรถนะ']">
ประเภทสมรรถนะ ประเภทสมรรถนะ
</a> </a>
<a class="text-base font-medium hs-tab-active:border-secondary hs-tab-active:text-secondary pb-3 inline-flex items-center gap-2 border-b-[3px] border-transparent whitespace-nowrap text-gray-500 dark:text-white/70 hover:text-secondary" <a class="text-base font-medium hs-tab-active:border-secondary hs-tab-active:text-secondary pb-3 inline-flex items-center gap-2 border-b-[3px] border-transparent whitespace-nowrap text-gray-500 dark:text-white/70 hover:text-secondary"
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)="currentPage = 2;pathTitle = ['การประเมินสมรรถนะ','ทะเบียนกำหนดชื่อ','หัวข้อสมรรถนะ']"> aria-controls="underline-2"
(click)="currentPage = 2;pathTitle = ['การประเมินสมรรถนะ','ทะเบียนกำหนดชื่อ','หัวข้อสมรรถนะ']">
หัวข้อสมรรถนะ หัวข้อสมรรถนะ
</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-type-registration [pathTitle]="pathTitle" <app-type-registration></app-type-registration>
(sendPathTitle)="pathTitle=$event"></app-type-registration>
</div> </div>
<div *ngIf="currentPage == 2" id="underline-2" class="hidden" role="tabpanel" aria-labelledby="underline-item-2"> <div *ngIf="currentPage == 2" id="underline-2" class="hidden" role="tabpanel"
<app-competency-topic [pathTitle]="pathTitle" aria-labelledby="underline-item-2">
(sendPathTitle)="pathTitle=$event"></app-competency-topic> <app-competency-topic [pathTitle]="pathTitle" (sendPathTitle)="pathTitle=$event"></app-competency-topic>
</div> </div>
</div> </div>
</div> </div>
......
<div class="w-full min-height-50px mb-10px justify-between items-center"> <div class="w-full min-height-50px mb-10px justify-between items-center">
<div class="flex justify-between"> <div class="flex justify-between">
<div class="flex pr-2"> <div class="flex">
<!-- Content ของ div แรก --> <div class="flex items-center">
<div class="flex gap-x-6"> <input type="checkbox" class="ti-form-checkbox pointer-events-none" id="hs-default-checkbox"
<div class="flex items-center"> [(ngModel)]="isDataListChecked">
<label for="hs-checkbox-group-1" <label for="hs-default-checkbox" class="text-sm text-gray-500 mx-2 pointer-events-none">
class="text-sm text-gray-500 ltr:ml-2 rtl:mr-2 dark:text-white/70">{{dataSelectList.length}} {{numDataListChecked}} Selected</label>
Selected</label> </div>
</div> <div class="mx-1 flex items-center">
<button (click)="isDataListCheckedAll = !isDataListCheckedAll;dataListCheckAll()"
<div class="flex items-center"> class="focus:ring-2 focus:ring-primary rounded-sm flex item-center">
<i (click)="toggleCheckbox()" <i class="fs-l transition-all duration-200"
[ngClass]="{'ri-checkbox-multiple-line': !isChecked, 'ri-checkbox-multiple-fill': isChecked}" [ngClass]="{'ri-checkbox-multiple-line text-gray-500': !isDataListCheckedAll, 'ri-checkbox-multiple-fill text-primary': isDataListCheckedAll}"></i>
class="ri-checkbox-multiple-line text-gray-500 dark:text-white/70"></i> </button>
<label for="hs-checkbox-group-2" class="text-sm text-gray-500 ltr:ml-2 rtl:mr-2 dark:text-white/70" <label class="text-sm text-gray-500 ml-2">Select All</label>
(click)="toggleCheckbox()">Select All</label>
</div>
</div> </div>
</div> </div>
...@@ -35,7 +32,8 @@ ...@@ -35,7 +32,8 @@
<div class="px-1"> <div class="px-1">
<button type="button" <button type="button"
class="ti-btn ti-btn bg-pink-500/10 text-pink-500 hover:text-white hover:bg-pink-500 ring-offset-white focus:ring-pink-500 dark:focus:ring-offset-white/10 h-10 m-0 shadow-md" class="ti-btn ti-btn bg-pink-500/10 text-pink-500 hover:text-white hover:bg-pink-500 ring-offset-white focus:ring-pink-500 dark:focus:ring-offset-white/10 h-10 m-0 shadow-md"
data-hs-overlay="#type-registration-component-upload-modal"> data-hs-overlay="#type-registration-component-upload-modal"
(click)="fileInput.value = '';selectedFile=null;selectedFileName = 'กรุณาเลือกไฟล์'">
<i class="ti ti-file-plus"></i> <i class="ti ti-file-plus"></i>
import import
</button> </button>
...@@ -49,7 +47,8 @@ ...@@ -49,7 +47,8 @@
</div> </div>
<div class="px-1"> <div class="px-1">
<button href="javascript:void(0);" class="ti-btn ti-btn-soft-danger h-10 m-0 shadow-md" <button href="javascript:void(0);" class="ti-btn ti-btn-soft-danger h-10 m-0 shadow-md"
data-hs-overlay="#type-registration-component-page-alert-modal" (click)="modalStatus='deleteGroup';setData()"> data-hs-overlay="#type-registration-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>
...@@ -101,17 +100,18 @@ ...@@ -101,17 +100,18 @@
<tr <tr
*ngFor="let item of dataListFilter()| slice:((currentPage-1) * 10) : (((currentPage-1) * 10) + 10);let i = index"> *ngFor="let item of dataListFilter()| slice:((currentPage-1) * 10) : (((currentPage-1) * 10) + 10);let i = index">
<td class="text-center"> <td class="text-center">
<input *ngIf="item.data.id!='100'" type="checkbox" class="ti-form-checkbox cursor-pointer" id="checkbox-{{item.data.id}}" <input type="checkbox" class="ti-form-checkbox cursor-pointer" id="checkbox-{{item.data.id}}"
[(ngModel)]="item.check" (change)="checkSelect()"> [(ngModel)]="item.check" (change)="dataListCheck()">
<label for="checkbox-{{item.data.id}}">&nbsp;{{item.data.id}}</label> <label for="checkbox-{{item.data.id}}">&nbsp;{{item.data.id}}</label>
</td> </td>
<td>{{item.data.name}}</td> <td>{{item.data.name}}</td>
<td class="text-center">{{item.data.code}}</td> <td class="text-center">{{item.data.code}}</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="#type-registration-component-page-modal"></i> data-hs-overlay="#type-registration-component-page-modal"></i>
<i class="ti ti-trash cursor-pointer i-gray fs-l px-1" *ngIf="item.data.id!='100'" <i class="ti ti-trash cursor-pointer i-gray fs-l px-1"
(click)="modalStatus='delete';setData(item.data)" (click)="modalStatus='delete';setData(item.data)"
data-hs-overlay="#type-registration-component-page-alert-modal"></i> data-hs-overlay="#type-registration-component-page-alert-modal"></i>
</td> </td>
</tr> </tr>
...@@ -177,7 +177,8 @@ ...@@ -177,7 +177,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)="clearData(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)">
...@@ -203,7 +204,9 @@ ...@@ -203,7 +204,9 @@
</div> </div>
<div class="ti-modal-body" style="padding-top: 0px;"> <div class="ti-modal-body" style="padding-top: 0px;">
<label for="input-label" class="ti-form-label mt-1rem">รหัส *</label> <label for="input-label" class="ti-form-label mt-1rem">รหัส *</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.id"> <input type="text" id="input-label" class="ti-form-input w-1/2"
[ngClass]="{'bg-input-readonly':modalStatus=='edit'}" [readonly]="modalStatus=='edit'"
[(ngModel)]="dataSelect.id">
<label for="detail_th" class="ti-form-label mt-1rem">ชื่อประเภท (ไทย)*</label> <label for="detail_th" class="ti-form-label mt-1rem">ชื่อประเภท (ไทย)*</label>
<input type="text" id="detail_th" class="ti-form-input w-2/3" [(ngModel)]="dataSelect.name"> <input type="text" id="detail_th" class="ti-form-input w-2/3" [(ngModel)]="dataSelect.name">
<label for="detail_eng" class="ti-form-label mt-1rem">ชื่อประเภท (อังกฤษ)</label> <label for="detail_eng" class="ti-form-label mt-1rem">ชื่อประเภท (อังกฤษ)</label>
...@@ -219,10 +222,12 @@ ...@@ -219,10 +222,12 @@
data-hs-overlay="#type-registration-component-page-modal"> data-hs-overlay="#type-registration-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="#type-registration-component-page-alert-modal"> data-hs-overlay="#type-registration-component-page-alert-modal"
[class.ti-btn-disabled]="!dataSelect.id||!dataSelect.name||!dataSelect.code||!dataSelect.level"
[disabled]="!dataSelect.id||!dataSelect.name||!dataSelect.code||!dataSelect.level">
บันทึกข้อมูล บันทึกข้อมูล
</a> </button>
</div> </div>
</div> </div>
</div> </div>
...@@ -239,7 +244,7 @@ ...@@ -239,7 +244,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="#type-registration-component-page-alert-modal"> data-hs-overlay="#type-registration-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>
...@@ -271,7 +276,8 @@ ...@@ -271,7 +276,8 @@
ย้อนกลับ ย้อนกลับ
</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="#type-registration-component-page-alert-modal" (click)="addType_registration()"> data-hs-overlay="#type-registration-component-page-alert-modal"
(click)="addType_registration()">
บันทึกข้อมูล บันทึกข้อมูล
</a> </a>
</ng-container> </ng-container>
...@@ -282,7 +288,8 @@ ...@@ -282,7 +288,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="#type-registration-component-page-alert-modal" (click)="deleteType_registration()"> data-hs-overlay="#type-registration-component-page-alert-modal"
(click)="deleteType_registration()">
ลบข้อมูล ลบข้อมูล
</a> </a>
</ng-container> </ng-container>
...@@ -293,7 +300,7 @@ ...@@ -293,7 +300,7 @@
</div> </div>
<div id="type-registration-component-upload-modal" class="hs-overlay hidden ti-modal"> <div id="type-registration-component-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)] 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">
นำเข้าประเภทสมรรถนะ นำเข้าประเภทสมรรถนะ
...@@ -303,7 +310,7 @@ ...@@ -303,7 +310,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()"
...@@ -312,8 +319,9 @@ ...@@ -312,8 +319,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="#type-registration-component-upload-modal" [class.ti-btn-disabled]="!selectedFile"
(click)="uploadFile()" [disabled]="!selectedFile" [disabled]="!selectedFile">
อัปโหลด อัปโหลด
</button> </button>
</div> </div>
......
...@@ -18,26 +18,21 @@ export interface DataModel { ...@@ -18,26 +18,21 @@ export interface DataModel {
styleUrls: ['./type-registration.component.scss'] styleUrls: ['./type-registration.component.scss']
}) })
export class TypeRegistration { export class TypeRegistration {
@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;
}
isChecked: boolean = false; isChecked: boolean = false;
currentPage = 1 currentPage = 1
selectedItems: string[] = []; selectedItems: string[] = [];
page = Array.from({ length: 1 }, (_, i) => i + 1); page = Array.from({ length: 1 }, (_, i) => i + 1);
numDataListChecked = 0
isDataListChecked = false
isDataListCheckedAll = false
dataSelectList: DataModel[] = []; dataSelectList: DataModel[] = [];
dataLoading = false dataLoading = false
dataSelect: DataModel = { id: "", companyId: "", edesc: "", name: "", code: "", level: "", checked: false } dataSelect: DataModel = { id: "", companyId: "", edesc: "", name: "", code: "", level: "", checked: false }
competoncy_typeList: { check: boolean; data: DataModel & { checked?: boolean } }[] = [] competoncy_typeList: { check: boolean; data: DataModel & { checked?: boolean } }[] = []
competoncy_type: CompetencytypeModel = new MyCompetencytypeModel({}) competoncy_type: CompetencytypeModel = new MyCompetencytypeModel({})
modalStatus = 'add' modalStatus: 'add' | 'edit' | 'delete' | 'deleteGroup' = 'add'
search = "" search = ""
selectedFile: File | null = null; selectedFile: File | null = null;
selectedFileName: string = 'กรุณาเลือกไฟล์'; selectedFileName: string = 'กรุณาเลือกไฟล์';
...@@ -52,18 +47,6 @@ export class TypeRegistration { ...@@ -52,18 +47,6 @@ export class TypeRegistration {
this.getCompetencytypeList() this.getCompetencytypeList()
} }
checkSelect() {
this.dataSelectList = this.competoncy_typeList.filter(item => item.check).map(item => item.data);
}
toggleCheckbox() {
this.isChecked = !this.isChecked; // สลับสถานะ'
this.competoncy_typeList.forEach((item) => {
item.check = this.isChecked;
});
this.checkSelect();
}
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;
this.selectedFileName = this.selectedFile?.name || "กรุณาเลือกไฟล์" this.selectedFileName = this.selectedFile?.name || "กรุณาเลือกไฟล์"
...@@ -115,11 +98,12 @@ export class TypeRegistration { ...@@ -115,11 +98,12 @@ export class TypeRegistration {
next: response => { next: response => {
this.competoncy_typeList = response.map(x => ({ check: false, data: { id: x.competencyTypeId, companyId: x.companyId, edesc: x.edesc, name: x.tdesc, code: x.shortName, level: x.expectationLevel, checked: false } })) this.competoncy_typeList = response.map(x => ({ check: false, data: { id: x.competencyTypeId, companyId: x.companyId, edesc: x.edesc, name: x.tdesc, code: x.shortName, level: x.expectationLevel, checked: false } }))
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 => {
this.dataLoading = false this.dataLoading = false
console.error('Error fetching employee types:', error);
this.cdr.detectChanges() this.cdr.detectChanges()
} }
}) })
...@@ -127,18 +111,18 @@ export class TypeRegistration { ...@@ -127,18 +111,18 @@ export class TypeRegistration {
searchChange() { searchChange() {
this.currentPage = 1 this.currentPage = 1
this.page = Array.from({ length: Math.ceil(this.dataListFilter().length / 10) }, (_, i) => i + 1); this.page = Array.from({ length: Math.ceil(this.dataListFilter().length / 10) }, (_, i) => i + 1);
this.dataListCheck()
} }
dataListFilter() { dataListFilter() {
return this.competoncy_typeList.filter(x => { return this.competoncy_typeList.filter(x => {
const data = x.data const data = x.data
const match = data.id.toLowerCase().includes(this.search) || data.name.toLowerCase().includes(this.search) || data.code.toLowerCase().includes(this.search); const match = data.id.toLowerCase().includes(this.search.toLowerCase()) || data.name.toLowerCase().includes(this.search.toLowerCase()) || data.code.toLowerCase().includes(this.search.toLowerCase());
return match; return match;
}); });
} }
setData(data?: DataModel) { setData(data?: DataModel) {
this.dataSelect = JSON.parse(JSON.stringify(data || { id: "", companyId: "", name: "", edesc: "", code: "", level: "" })); this.dataSelect = JSON.parse(JSON.stringify(data || { id: "", companyId: "", name: "", edesc: "", code: "", level: "", checked: false }));
} }
// ฟังก์ชันสำหรับการเพิ่ม ลบ หรือแก้ไข ข้อมูล // ฟังก์ชันสำหรับการเพิ่ม ลบ หรือแก้ไข ข้อมูล
addType_registration() { addType_registration() {
const body = new MyCompetencytypeModel({ competencyTypeId: this.dataSelect.id, tdesc: this.dataSelect.name, edesc: this.dataSelect.edesc, shortName: this.dataSelect.code, expectationLevel: this.dataSelect.level }) const body = new MyCompetencytypeModel({ competencyTypeId: this.dataSelect.id, tdesc: this.dataSelect.name, edesc: this.dataSelect.edesc, shortName: this.dataSelect.code, expectationLevel: this.dataSelect.level })
...@@ -184,5 +168,30 @@ export class TypeRegistration { ...@@ -184,5 +168,30 @@ export class TypeRegistration {
positionClass: 'toast-top-right', positionClass: 'toast-top-right',
}) })
} }
dataListCheckAll() {
const selectAll = this.isDataListCheckedAll;
this.competoncy_typeList.filter(x => {
const data = x.data
const match = data.id.toLowerCase().includes(this.search.toLowerCase()) || data.name.toLowerCase().includes(this.search.toLowerCase()) || data.code.toLowerCase().includes(this.search.toLowerCase());
return match;
}).forEach(x => x.check = selectAll);
this.dataListCheck();
}
dataListCheck() {
const dataCheck = this.dataListFilter();
this.isDataListCheckedAll = dataCheck.length ? dataCheck.every(x => x.check) : false;
this.numDataListChecked = this.competoncy_typeList.filter(x => x.check).length;
this.isDataListChecked = Boolean(this.numDataListChecked)
}
clearData(modalStatus: string) {
if (modalStatus == 'add') {
this.setData()
} else if (modalStatus == 'edit') {
this.setData({ id: this.dataSelect.id, companyId: "", name: "", edesc: "", code: "", level: "", checked: this.dataSelect.checked })
}
}
} }
...@@ -129,12 +129,15 @@ import { MatInputModule } from '@angular/material/input'; ...@@ -129,12 +129,15 @@ import { MatInputModule } from '@angular/material/input';
import { DateAdapter, MAT_DATE_FORMATS } from '@angular/material/core'; import { DateAdapter, MAT_DATE_FORMATS } from '@angular/material/core';
import { NativeDateAdapter } from '@angular/material/core'; import { NativeDateAdapter } from '@angular/material/core';
import { BranchService } from 'src/app/shared/services/่branch.service'; import { BranchService } from 'src/app/shared/services/่branch.service';
import { JobCodeService } from 'src/app/shared/services/job-code.service'; import { JobCodeService } from 'src/app/shared/services/job-code.service';
import { FileService } from 'src/app/shared/services/file.service'; import { FileService } from 'src/app/shared/services/file.service';
import { CompetencyGroupGradeService } from 'src/app/shared/services/competency-group-grade.service'; import { CompetencyGroupGradeService } from 'src/app/shared/services/competency-group-grade.service';
import { IndicatorsCoursesService } from 'src/app/shared/services/indicators-courses.service'; import { IndicatorsCoursesService } from 'src/app/shared/services/indicators-courses.service';
import { IdpDevelopmentService } from 'src/app/shared/services/idp-development.service'; import { IdpDevelopmentService } from 'src/app/shared/services/idp-development.service';
import { GroupAssessmentService } from 'src/app/shared/services/group-assessment.service'; import { GroupAssessmentService } from 'src/app/shared/services/group-assessment.service';
import { GroupApproveService } from 'src/app/shared/services/group-approve.service';
import { UserService } from 'src/app/shared/services/user.service';
import { ManageUserComponent } from '../company-components/account-settings/manage-user/manage-user.component';
export const MY_DATE_FORMATS = { export const MY_DATE_FORMATS = {
parse: { parse: {
...@@ -253,7 +256,8 @@ export class CustomDateAdapter extends NativeDateAdapter { ...@@ -253,7 +256,8 @@ export class CustomDateAdapter extends NativeDateAdapter {
IdpEvalutionComponent, IdpEvalutionComponent,
CompanyRegistrationPageComponent, CompanyRegistrationPageComponent,
PmsEvalutionComponent, PmsEvalutionComponent,
CEvaluationComponent CEvaluationComponent,
ManageUserComponent
], ],
imports: [ imports: [
CommonModule, CommonModule,
...@@ -300,6 +304,8 @@ export class CustomDateAdapter extends NativeDateAdapter { ...@@ -300,6 +304,8 @@ export class CustomDateAdapter extends NativeDateAdapter {
IndicatorsCoursesService, IndicatorsCoursesService,
IdpDevelopmentService, IdpDevelopmentService,
GroupAssessmentService, GroupAssessmentService,
GroupApproveService,
UserService,
{ {
provide: HTTP_INTERCEPTORS, provide: HTTP_INTERCEPTORS,
useClass: HttpRequestInterceptor, useClass: HttpRequestInterceptor,
......
...@@ -3,12 +3,12 @@ ...@@ -3,12 +3,12 @@
<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="#supjob-upload-modal" (click)="fileInput.value = '';selectedFile=null;selectedFileName = 'กรุณาเลือกไฟล์'">
<i class="ri-add-line"></i> <i class="ri-add-line"></i>
นำเข้าข้อมูล นำเข้าข้อมูล
</button> </button>
<a class="mx-2 justify-center -mb-px inline-flex items-center gap-2 font-weight-500 font-size-12px text-center text-secondary border-secondary border-b-2 align-items-end" <a class="mx-2 justify-center -mb-px inline-flex items-center gap-2 font-weight-500 font-size-12px text-center text-secondary border-secondary border-b-2 align-items-end"
href="javascript:void(0);"> href="javascript:void(0);" (click)="downloadFile()">
ดาวน์โหลดตัวอย่างไฟล์ ดาวน์โหลดตัวอย่างไฟล์
</a> </a>
</div> </div>
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
<div class="relative shadow-md"> <div class="relative shadow-md">
<input type="text" id="hs-leading-icon" name="hs-leading-icon" <input type="text" id="hs-leading-icon" name="hs-leading-icon"
class="ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 " class="ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 "
placeholder="Search by No. or Name" > placeholder="Search by No. or Name" [(ngModel)]="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">
...@@ -59,52 +59,87 @@ ...@@ -59,52 +59,87 @@
</ng-container> </ng-container>
</tr> </tr>
</thead> </thead>
<tbody> <tbody *ngIf="loading">
<tr *ngFor="let item of[ <tr>
['01', '001','Department Manager 1', 'Department Manager 1'], <td class="text-center" colspan="100%">
['02', '002','Department Manager 2', 'Department Manager 2'], <div *ngFor="let item of [1,2,3]" class="ti-spinner w-8 h-8 text-secondary mx-1" role="status"
['03', '003','Department 1-HRD', 'Department 1-HRD'], aria-label="loading">
['04', '004','Department Manager 3', 'Department Manager 3'], <span class="sr-only">Loading...</span>
['05', '005','Department Manager 4', 'Department Manager 4']];let i = index"> </div>
<td class="text-center">{{item[0]}}</td> </td>
<td class="text-center">{{item[1]}}</td> </tr>
<td>{{item[2]}}</td> </tbody>
<td>{{item[3]}}</td> <tbody *ngIf="!loading&&!jobcodeFilter().length">
<td class="flex justify-center"> <tr>
<i class="ti ti-edit cursor-pointer i-gray fs-l px-1" data-hs-overlay="#sub-job-competency-component-modal-edit"></i> <td class="text-center" colspan="100%">
<i class="ti ti-trash cursor-pointer i-gray fs-l px-1" data-hs-overlay="#sub-job-competency-component-alert-delete-modal"></i> ไม่พบข้อมูล
</td> </td>
</tr> </tr>
</tbody> </tbody>
<tbody *ngIf="!loading&&jobcodeFilter().length">
<tr
*ngFor="let item of jobcodeFilter() |slice:((currentPage-1) * pageSize) : (((currentPage-1) * pageSize) + pageSize);let i = index">
<td class="text-center">
{{((currentPage-1) * pageSize)+(i+1)}}
</td>
<td class="text-center">{{item.jobcodeId}}</td>
<td>{{item.tdesc}}</td>
<td>{{item.edesc}}</td>
<td class="flex justify-center">
<i class="ti ti-edit cursor-pointer i-gray fs-l px-1" (click)="modalStatus='edit';edit(item)"
data-hs-overlay="#sub-job-competency-component-modal-edit"></i>
<i class="ti ti-trash cursor-pointer i-gray fs-l px-1" currentModal='delete'
data-hs-overlay="#section-registration-alert-delete-modal"></i>
</td>
</tr>
</tbody>
</table> </table>
</div> </div>
<ul class="nav-tabs"> <nav class="pagination-style-3 overflow-auto my-5" *ngIf="page.length">
<div class="pagination-style-3 overflow-auto my-5"> <ul class="ti-pagination">
<div class="box-body"> <li>
<nav class="pagination-style-3 overflow-auto"> <a aria-label="anchor" class="page-link" href="javascript:void(0);"
<ul class="ti-pagination"> (click)="currentPage = (currentPage-1 || 1)">
<li> <i class="ri-arrow-left-s-line align-middle rtl:rotate-180"></i>
<a aria-label="anchor" class="page-link" href="javascript:void(0);"> </a>
<i class="ri-arrow-left-s-line align-middle rtl:rotate-180"></i> </li>
</a> <li *ngFor="let item of page;let f = first;let l = last">
</li> <ng-container *ngIf="item==3&&currentPage!=1&&currentPage!=2&&currentPage!=3">
<li><a class="page-link active" href="javascript:void(0);" aria-current="page">1</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);">2</a></li> </a>
<li><a class="page-link" href="javascript:void(0);">3</a></li> </ng-container>
<li><a class="page-link" href="javascript:void(0);">4</a></li> <ng-container *ngIf="(f||l)||(item==currentPage-1||item==currentPage||item==currentPage+1)">
<li><a class="page-link" href="javascript:void(0);">5</a></li> <a class="page-link" href="javascript:void(0);" [class.active]="item==currentPage"
<li><a class="page-link" href="javascript:void(0);">...</a></li> (click)="currentPage=item">{{item}}
<li><a class="page-link" href="javascript:void(0);">31</a></li> </a>
<li> </ng-container>
<a aria-label="anchor" class="page-link" href="javascript:void(0);"> <ng-container
<i class="ri-arrow-right-s-line align-middle rtl:rotate-180"></i> *ngIf="item==page.length-2&&currentPage!=page.length&&currentPage!=page.length-1&&currentPage!=page.length-2">
</a> <a aria-label="anchor" class="page-link" href="javascript:void(0);"><i class="ri-more-line"></i>
</li> </a>
</ul> </ng-container>
</nav> </li>
</div> <li>
</div> <a aria-label="anchor" class="page-link" href="javascript:void(0);"
(click)="currentPage = (currentPage > page.length-1 ? currentPage: currentPage+1 )">
<i class="ri-arrow-right-s-line align-middle rtl:rotate-180"></i>
</a>
</li>
<li>
<select class="ti-form-select" [(ngModel)]="pageSize" (ngModelChange)="searchChange()">
<option [value]="10">10</option>
<option [value]="20">20</option>
<option [value]="50">50</option>
<option [value]="100">100</option>
</select>
</li>
</ul> </ul>
<ul class="nav-tabs mt-3">
<span>Show {{((currentPage-1) * pageSize)+1}} to {{(jobcodeFilter().length < pageSize) ?jobcodeFilter().length:
(currentPage==page.length ? ((currentPage * pageSize) - ((currentPage * pageSize) - jobcodeFilter().length) )
:(currentPage * pageSize) ) }} of {{jobcodeFilter().length}} items</span>
</ul>
</nav>
</div> </div>
...@@ -153,27 +188,23 @@ ...@@ -153,27 +188,23 @@
</div> </div>
<div class="ti-modal-body" style="padding-top: 0px;"> <div class="ti-modal-body" style="padding-top: 0px;">
<label for="input-label" class="ti-form-label mt-1rem">รหัสงาน</label> <label for="input-label" class="ti-form-label mt-1rem">รหัสงาน</label>
<input type="text" id="input-label" class="ti-form-input w-1/2 bg-input-readonly" readonly value="001"> <input type="text" id="input-label" class="ti-form-input w-1/2 bg-input-readonly" readonly [(ngModel)]="selectJob.jobcodeId">
<label for="detail_th" class="ti-form-label mt-1rem">ชื่อลักษณะงาน (ไทย)</label> <label for="detail_th" class="ti-form-label mt-1rem">ชื่อลักษณะงาน (ไทย)</label>
<input type="text" id="detail_th" class="ti-form-input w-2/3 bg-input-readonly" readonly value="Department Manager1"> <input type="text" id="detail_th" class="ti-form-input w-2/3 bg-input-readonly" readonly [(ngModel)]="selectJob.tdesc">
<label for="detail_eng" class="ti-form-label mt-1rem">ชื่อลักษณะงาน (อังกฤษ)</label> <label for="detail_eng" class="ti-form-label mt-1rem">ชื่อลักษณะงาน (อังกฤษ)</label>
<input type="text" id="detail_eng" class="ti-form-input w-2/3 bg-input-readonly" readonly value="Department Manager1"> <input type="text" id="detail_eng" class="ti-form-input w-2/3 bg-input-readonly" readonly [(ngModel)]="selectJob.edesc">
<label for="detail_eng" class="ti-form-label mt-2rem">ความรู้ ทักษะ ความสามารถในตำเเหน่งงาน ( Job Competency)</label> <label for="detail_eng" class="ti-form-label mt-2rem">ความรู้ ทักษะ ความสามารถในตำเเหน่งงาน ( Job Competency)</label>
<textarea type="text" id="detail_eng" class="ti-form-input font-bold" rows="5" cols="50">1. <textarea type="text" id="detail_eng" class="ti-form-input font-bold" rows="5" cols="50" [(ngModel)]="selectJob.competencyWorkText"></textarea>
2.
3.
4.
5.</textarea>
<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="#sub-job-competency-component-modal-edit"> data-hs-overlay="#sub-job-competency-component-modal-edit">
ย้อนกลับ ย้อนกลับ
</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="#sub-job-competency-component-alert-edit-modal"> data-hs-overlay="#company-registration-page-alert-modal">
บันทึกข้อมูล บันทึกข้อมูล
</a> </a>
</div> </div>
</div> </div>
</div> </div>
...@@ -181,73 +212,87 @@ ...@@ -181,73 +212,87 @@
</div> </div>
</div> </div>
<div id="sub-job-competency-component-alert-edit-modal" class="hs-overlay hidden ti-modal"> <div id="company-registration-page-alert-modal" class="hs-overlay hidden ti-modal">
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)] flex items-center"> <div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)] flex items-center">
<div class="max-h-full overflow-hidden ti-modal-content-alert w-full"> <div class="max-h-full overflow-hidden ti-modal-content w-full">
<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="#sub-job-competency-component-alert-edit-modal"> data-hs-overlay="#company-registration-page-alert-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"> <p class="mt-1 text-gray-800 dark:text-white/70">
ยืนยันการเเก้ไขข้อมูลหรือไม่ <ng-container *ngIf="modalStatus=='add'||modalStatus=='edit'">
</p> ยืนยันการบันทึกข้อมูลหรือไม่
</ng-container>
<div class="flex justify-end mt-2rem mb-1rem"> <ng-container *ngIf="modalStatus=='delete'||modalStatus=='deleteGroup'">
<button type="button" ยืนยันการลบข้อมูลหรือไม่
class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10" </ng-container>
data-hs-overlay="#sub-job-competency-component-modal-edit"> </p>
ย้อนกลับ
</button> <div class="flex justify-end mt-2rem mb-1rem">
<a class="ti-btn ti-btn-success" href="javascript:void(0);" <ng-container *ngIf="modalStatus=='add'||modalStatus=='edit'">
data-hs-overlay="#sub-job-competency-component-alert-edit-modal" (click)="editBu1();showSuccessEdit()"> <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"
</a> data-hs-overlay="#company-registration-page-modal">
</div> ย้อนกลับ
</div> </button>
</div> <a class="ti-btn ti-btn-success" href="javascript:void(0);"
</div> data-hs-overlay="#company-registration-page-alert-modal" (click)="save()">
</div> บันทึกข้อมูล
<div id="sub-job-competency-component-alert-delete-modal" class="hs-overlay hidden ti-modal"> </a>
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)] flex items-center"> </ng-container>
<div class="max-h-full overflow-hidden ti-modal-content-alert w-full"> <ng-container *ngIf="modalStatus=='delete'||modalStatus=='deleteGroup'">
<div class="ti-modal-header"> <button type="button"
<h3 class="text-xxl font-bold text-primary"> 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-alert-modal">
</h3> ย้อนกลับ
<div class="flex justify-end"> </button>
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger" <a class="ti-btn ti-btn-danger" href="javascript:void(0);"
data-hs-overlay="#sub-job-competency-component-alert-delete-modal"> data-hs-overlay="#company-registration-page-alert-modal" (click)="deleteCompany()">
<span class="sr-only">Close</span> ลบข้อมูล
<i class="ti ti-circle-x fs-xxl"></i> </a>
</button> </ng-container>
</div> </div>
</div> </div>
<div class="ti-modal-body "> </div>
<p class="mt-1 text-gray-800 dark:text-white/70"> </div>
ยืนยันการลบข้อมูลหรือไม่! </div>
</p>
<div id="supjob-upload-modal" class="hs-overlay hidden ti-modal">
<div class="flex justify-end mt-2rem mb-1rem"> <div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out rounded-md">
<button type="button" <div class="ti-modal-header bg-primary !rounded-none !rounded-t-sm">
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" <h5 class="text-xxl font-bold text-white">
data-hs-overlay="#sub-job-competency-component-alert-delete-modal"> นำเข้า Job Competency
ย้อนกลับ </h5>
</button> </div>
<a class="ti-btn ti-btn-success" href="javascript:void(0);" <div class="ti-modal-body max-h-full overflow-hidden ti-modal-content !rounded-t-none !rounded-b-sm">
data-hs-overlay="#sub-job-competency-component-alert-delete-modal" (click)="editBu1();showSuccessDelete()"> <h1 class="mt-2" style="text-align: center;">ไฟล์</h1>
ลบข้อมูล <div class="mt-2 p-2">
</a> <div class="flex rounded-md">
</div> <input #fileInput id="fileInput" type="file" (change)="onFileSelected($event)" hidden>
</div> <input type="text" [value]="selectedFileName" readonly (click)="fileInput.click()"
</div> class="ti-form-input rounded-none ltr:rounded-l-md rtl:rounded-r-md focus:z-10 cursor-pointer">
</div> <button type="button" (click)="fileInput.click()"
</div> 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">
\ No newline at end of file <i class="ti ti-upload"></i>
</button>
</div>
<div class="flex justify-center mt-2rem mb-1rem space-x-4">
<button type="submit" class="ti-btn ti-btn-secondary"
data-hs-overlay="#section-registration-upload-modal" (click)="uploadFile()"
[class.ti-btn-disabled]="!selectedFile" [disabled]="!selectedFile">
อัปโหลด
</button>
</div>
</div>
</div>
</div>
</div>
\ No newline at end of file
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 { JobCodeModel, MyJobCodeModel } from 'src/app/shared/model/job-code.model';
import { JobModel, MyJobModel } from 'src/app/shared/model/job.model'; import { JobModel, MyJobModel } from 'src/app/shared/model/job.model';
import { FileService } from 'src/app/shared/services/file.service';
import { JobCodeService } from 'src/app/shared/services/job-code.service';
@Component({ @Component({
...@@ -9,31 +12,130 @@ import { JobModel, MyJobModel } from 'src/app/shared/model/job.model'; ...@@ -9,31 +12,130 @@ import { JobModel, MyJobModel } from 'src/app/shared/model/job.model';
styleUrls: ['./sub-job-competency.component.scss'] styleUrls: ['./sub-job-competency.component.scss']
}) })
export class SubJobCompetencyComponent { export class SubJobCompetencyComponent {
currentPage = 1 currentPage = 1
page = Array.from({ length: 1 }, (_, i) => i + 1); page = Array.from({ length: 1 }, (_, i) => i + 1);
jobList: JobModel[] = [] pageSize=10
job: JobModel = new MyJobModel({})
search = "" search = ""
jobCodeList:JobCodeModel[]=[]
loading = false
selectedFile: File | null = null;
selectedFileName: string = 'กรุณาเลือกไฟล์';
selectJob:JobCodeModel=new MyJobCodeModel({})
modalStatus=''
constructor( constructor(
private toastr: ToastrService private toastr: ToastrService,
private fileService: FileService,
private jobcodeService: JobCodeService,
private cdr: ChangeDetectorRef,
) { } ) { }
ngOnInit(): void { ngOnInit(): void {
this.getListJob();
}
getListJob(){
this.loading = false
this.jobcodeService.getList().subscribe({
next: response => {
this.jobCodeList = response.map((x: any) => new MyJobCodeModel(x))
this.jobCodeList = this.jobCodeList.sort((a, b) => a.jobcodeId.localeCompare(b.jobcodeId))
this.loading = false
this.searchChange()
this.cdr.detectChanges()
}, error: error => {
this.loading = false
this.cdr.detectChanges()
}
})
} }
searchChange() { searchChange() {
this.currentPage = 1 this.currentPage = 1
this.page = Array.from({ length: Math.ceil(this.jobListFilter().length / 10) }, (_, i) => i + 1); this.page = Array.from({ length: Math.ceil(this.jobcodeFilter().length / this.pageSize) }, (_, i) => i + 1);
}
edit(item :JobCodeModel){
this.selectJob = new MyJobCodeModel({})
this.selectJob = new MyJobCodeModel(item)
} }
jobListFilter() { save(){
return this.jobList.filter(x => x.jobid.includes(this.search) || this.jobcodeService.post(this.selectJob).subscribe((response:any) => {
x.tdesc.includes(this.search) || if (response.success) {
x.edesc.includes(this.search)) this.showAlert(response.message, 'success')
this.selectJob = new MyJobCodeModel({})
this.getListJob();
} else {
this.showAlert(response.message, 'error')
}
this.cdr.detectChanges()
})
} }
selectJob(job: JobModel) { deleteCompany(){
// this.showSuccess()
this.job = new MyJobModel(job) }
jobcodeFilter() {
return this.jobCodeList.filter(x =>
x.tdesc.toLowerCase().includes(this.search.toLowerCase()) ||
x.edesc.toLowerCase().includes(this.search.toLowerCase()) ||
x.jobcodeId.toLowerCase().includes(this.search.toLowerCase())
)
}
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.loading = true
this.fileService.upload(formData, 'MJOBCODE_COMPETENCY').subscribe({
next: response => {
if (response.success) {
this.showAlert(response.message, 'success')
this.getListJob();
} else {
this.showAlert(response.message, 'error')
this.loading = false
}
}, error: error => {
this.showAlert(error.message, 'error')
this.loading = false
}
})
}
downloadFile() {
const fileName = 'IMPORT_MJOBCODEV2.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')
}
})
}
showAlert(text: string, type: 'success' | 'error') {
this.toastr[type](text, 'แจ้งเตือน', {
timeOut: 3000,
positionClass: 'toast-top-right',
})
}
showSuccessAdd() { showSuccessAdd() {
this.toastr.success('บันทึกข้อมูลสำเร็จ', 'เเจ้งเตือน', { this.toastr.success('บันทึกข้อมูลสำเร็จ', 'เเจ้งเตือน', {
timeOut: 3000, timeOut: 3000,
...@@ -54,27 +156,7 @@ export class SubJobCompetencyComponent { ...@@ -54,27 +156,7 @@ export class SubJobCompetencyComponent {
positionClass: 'toast-top-right', positionClass: 'toast-top-right',
}); });
} }
addBu1() {
// this.bu1Service.post(this.bu1).subscribe((response:any) => {
// if (response.success) {
// this.getBu1List()
// }
// })
}
editBu1() {
// this.bu1Service.post(this.bu1).subscribe((response:any) => {
// if (response.success) {
// this.getBu1List()
// }
// })
}
deleteJob(job: JobModel) {
// this.bu1Service.delete(new MyBu1Model(bu1)).subscribe((response:any) => {
// if (response.success) {
// this.getBu1List()
// }
// })
}
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<div class="flex justify-between"> <div class="flex justify-between">
<div class="flex pr-2"> <div class="flex pr-2">
<div class="flex"> <div class="flex">
<div class="flex items-center"> <!-- <div class="flex items-center">
<input type="checkbox" class="ti-form-checkbox pointer-events-none" id="hs-default-checkbox" <input type="checkbox" class="ti-form-checkbox pointer-events-none" id="hs-default-checkbox"
[(ngModel)]="isDataListChecked"> [(ngModel)]="isDataListChecked">
<label for="hs-default-checkbox" class="text-sm text-gray-500 mx-2 pointer-events-none"> <label for="hs-default-checkbox" class="text-sm text-gray-500 mx-2 pointer-events-none">
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
[ngClass]="{'ri-checkbox-multiple-line text-gray-500': !isDataListCheckedAll, 'ri-checkbox-multiple-fill text-primary': isDataListCheckedAll}"></i> [ngClass]="{'ri-checkbox-multiple-line text-gray-500': !isDataListCheckedAll, 'ri-checkbox-multiple-fill text-primary': isDataListCheckedAll}"></i>
</button> </button>
<label class="text-sm text-gray-500 ml-2">Select All</label> <label class="text-sm text-gray-500 ml-2">Select All</label>
</div> </div> -->
</div> </div>
</div> </div>
<div class="flex justify-end"> <div class="flex justify-end">
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
</div> </div>
</div> </div>
</div> </div>
<div class="px-1"> <!-- <div class="px-1">
<button type="button" class="ti-btn ti-btn-soft-secondary h-45px m-0 shadow-md" <button type="button" class="ti-btn ti-btn-soft-secondary h-45px m-0 shadow-md"
(click)="modalStatus='add';dataListSelect()" data-hs-overlay="#assessment-types-modal"> (click)="modalStatus='add';dataListSelect()" data-hs-overlay="#assessment-types-modal">
<i class="ri-add-line"></i> <i class="ri-add-line"></i>
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
<i class="ti ti-trash fs-l"></i> <i class="ti ti-trash fs-l"></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-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>
...@@ -81,19 +81,20 @@ ...@@ -81,19 +81,20 @@
<tbody *ngIf="dataListFilter().length"> <tbody *ngIf="dataListFilter().length">
<tr <tr
*ngFor="let item of dataListFilter() | slice:((currentPage-1) * 10) : (((currentPage-1) * 10) + 10);let i = index"> *ngFor="let item of dataListFilter() | slice:((currentPage-1) * 10) : (((currentPage-1) * 10) + 10);let i = index">
<td class="flex justify-around"> <!-- <td class="flex justify-around">
<input type="checkbox" class="ti-form-checkbox cursor-pointer" [(ngModel)]="item.check" <input type="checkbox" class="ti-form-checkbox cursor-pointer" [(ngModel)]="item.check"
(ngModelChange)="dataListCheck()"> (ngModelChange)="dataListCheck()">
<label>{{item.code}}</label> <label>{{item.code}}</label>
</td> </td> -->
<td class="text-center">{{item.code}}</td>
<td>{{item.nameTypeTh}} ({{item.nameTypeEn}})</td> <td>{{item.nameTypeTh}} ({{item.nameTypeEn}})</td>
<td>{{item.name}}</td> <td>{{item.name}}</td>
<td class="flex justify-center items-center"> <td class="flex justify-center items-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"
(click)="modalStatus='edit';dataListSelect(item)" (click)="modalStatus='edit';dataListSelect(item)"
data-hs-overlay="#assessment-types-modal"></i> data-hs-overlay="#assessment-types-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="#assessment-types-delete-modal"></i> data-hs-overlay="#assessment-types-delete-modal"></i> -->
</td> </td>
</tr> </tr>
</tbody> </tbody>
......
...@@ -13,12 +13,12 @@ export class MyBu6Model implements Bu6Model { ...@@ -13,12 +13,12 @@ export class MyBu6Model implements Bu6Model {
edesc: string; edesc: string;
parent: string; parent: string;
companyId: string; companyId: string;
constructor(data: Partial<Bu6Model>) { constructor(data?: Partial<Bu6Model>) {
this.bu6id = data.bu6id || "" this.bu6id = data?.bu6id || ""
this.tdesc = data.tdesc || "" this.tdesc = data?.tdesc || ""
this.edesc = data.edesc || "" this.edesc = data?.edesc || ""
this.parent = data.parent || "" this.parent = data?.parent || ""
this.companyId = data.companyId || "" this.companyId = data?.companyId || ""
} }
} }
...@@ -13,12 +13,12 @@ export class MyBu7Model implements Bu7Model { ...@@ -13,12 +13,12 @@ export class MyBu7Model implements Bu7Model {
edesc: string; edesc: string;
parent: string; parent: string;
companyId: string; companyId: string;
constructor(data: Partial<Bu7Model>) { constructor(data?: Partial<Bu7Model>) {
this.bu7id = data.bu7id || "" this.bu7id = data?.bu7id || ""
this.tdesc = data.tdesc || "" this.tdesc = data?.tdesc || ""
this.edesc = data.edesc || "" this.edesc = data?.edesc || ""
this.parent = data.parent || "" this.parent = data?.parent || ""
this.companyId = data.companyId || "" this.companyId = data?.companyId || ""
} }
} }
...@@ -5,6 +5,7 @@ export interface CompetencycourseModel { ...@@ -5,6 +5,7 @@ export interface CompetencycourseModel {
tdesc: string tdesc: string
courseDetail: string courseDetail: string
courseTopic: string courseTopic: string
courseLinkMylearn: string
} }
export class MyCompetencycourseModel implements CompetencycourseModel { export class MyCompetencycourseModel implements CompetencycourseModel {
...@@ -14,6 +15,7 @@ export class MyCompetencycourseModel implements CompetencycourseModel { ...@@ -14,6 +15,7 @@ export class MyCompetencycourseModel implements CompetencycourseModel {
tdesc: string tdesc: string
courseDetail: string courseDetail: string
courseTopic: string courseTopic: string
courseLinkMylearn: string
constructor(data: Partial<CompetencycourseModel>) { constructor(data: Partial<CompetencycourseModel>) {
this.competencyCourseId = data.competencyCourseId || "" this.competencyCourseId = data.competencyCourseId || ""
this.companyId = data.companyId || "" this.companyId = data.companyId || ""
...@@ -21,6 +23,7 @@ export class MyCompetencycourseModel implements CompetencycourseModel { ...@@ -21,6 +23,7 @@ export class MyCompetencycourseModel implements CompetencycourseModel {
this.tdesc = data.tdesc || "" this.tdesc = data.tdesc || ""
this.courseDetail = data.courseDetail || "" this.courseDetail = data.courseDetail || ""
this.courseTopic = data.courseTopic || "" this.courseTopic = data.courseTopic || ""
this.courseLinkMylearn = data.courseLinkMylearn || ""
} }
} }
...@@ -198,92 +198,92 @@ export class MyEmployeeModel implements EmployeeModel { ...@@ -198,92 +198,92 @@ export class MyEmployeeModel implements EmployeeModel {
ssoFlag: string ssoFlag: string
thFullName: string thFullName: string
engFullName: string engFullName: string
constructor(data: Partial<EmployeeModel>) { constructor(data?: Partial<EmployeeModel>) {
this.employeeId = data.employeeId || "" this.employeeId = data?.employeeId || ""
this.prefix = new MyPrefixModel(data.prefix || {}) this.prefix = new MyPrefixModel(data?.prefix || {})
this.fname = data.fname || "" this.fname = data?.fname || ""
this.lname = data.lname || "" this.lname = data?.lname || ""
this.efname = data.efname || "" this.efname = data?.efname || ""
this.elname = data.elname || "" this.elname = data?.elname || ""
this.nickname = data.nickname || "" this.nickname = data?.nickname || ""
this.enickname = data.enickname || "" this.enickname = data?.enickname || ""
this.birthDate = data.birthDate || "" this.birthDate = data?.birthDate || ""
this.status = new MyStatusModel(data.status || {}) this.status = new MyStatusModel(data?.status || {})
this.age = new MyAgeModel(data.age || {}) this.age = new MyAgeModel(data?.age || {})
this.swipeCardId = data.swipeCardId || "" this.swipeCardId = data?.swipeCardId || ""
this.idPeople = data.idPeople || "" this.idPeople = data?.idPeople || ""
this.idexpdate = data.idexpdate || "" this.idexpdate = data?.idexpdate || ""
this.passport_no = data.passport_no || "" this.passport_no = data?.passport_no || ""
this.passport_expire_date = data.passport_expire_date || "" this.passport_expire_date = data?.passport_expire_date || ""
this.height = data.height || "" this.height = data?.height || ""
this.weight = data.weight || "" this.weight = data?.weight || ""
this.blood = data.blood || "" this.blood = data?.blood || ""
this.rh = data.rh || "" this.rh = data?.rh || ""
this.eyeColor = data.eyeColor || "" this.eyeColor = data?.eyeColor || ""
this.hairColor = data.hairColor || "" this.hairColor = data?.hairColor || ""
this.shirtSize = data.shirtSize || "" this.shirtSize = data?.shirtSize || ""
this.waistSize = data.waistSize || "" this.waistSize = data?.waistSize || ""
this.national = new MyNationalModel(data.national || {}) this.national = new MyNationalModel(data?.national || {})
this.nationality = new MyNationalityModel(data.nationality || {}) this.nationality = new MyNationalityModel(data?.nationality || {})
this.religion = new MyReligionModel(data.religion || {}) this.religion = new MyReligionModel(data?.religion || {})
this.sex = data.sex || "" this.sex = data?.sex || ""
this.email = data.email || "" this.email = data?.email || ""
this.emailMicrosoft365 = data.emailMicrosoft365 || "" this.emailMicrosoft365 = data?.emailMicrosoft365 || ""
this.emailPersonal = data.emailPersonal || "" this.emailPersonal = data?.emailPersonal || ""
this.picture = data.picture || "" this.picture = data?.picture || ""
this.telNo = data.telNo || "" this.telNo = data?.telNo || ""
this.mobile = data.mobile || "" this.mobile = data?.mobile || ""
this.position = new MyPositionModel(data.position || {}) this.position = new MyPositionModel(data?.position || {})
this.jobCode = new MyJobCodeModel(data.jobCode || {}) this.jobCode = new MyJobCodeModel(data?.jobCode || {})
this.personalLevel = new MyPLModel(data.personalLevel || {}) this.personalLevel = new MyPLModel(data?.personalLevel || {})
this.companyId = data.companyId || "" this.companyId = data?.companyId || ""
this.idExpireDate = data.idExpireDate || "" this.idExpireDate = data?.idExpireDate || ""
this.passportNo = data.passportNo || "" this.passportNo = data?.passportNo || ""
this.passportExpireDate = data.passportExpireDate || "" this.passportExpireDate = data?.passportExpireDate || ""
this.bossId = data.bossId || "" this.bossId = data?.bossId || ""
this.boss = new MyBossModel(data.boss || {}) this.boss = new MyBossModel(data?.boss || {})
this.bu1 = new MyBu1Model(data.bu1 || {}) this.bu1 = new MyBu1Model(data?.bu1 || {})
this.bu2 = new MyBu2Model(data.bu2 || {}) this.bu2 = new MyBu2Model(data?.bu2 || {})
this.bu3 = new MyBu3Model(data.bu3 || {}) this.bu3 = new MyBu3Model(data?.bu3 || {})
this.bu4 = new MyBu4Model(data.bu4 || {}) this.bu4 = new MyBu4Model(data?.bu4 || {})
this.bu5 = new MyBu5Model(data.bu5 || {}) this.bu5 = new MyBu5Model(data?.bu5 || {})
this.bu6 = new MyBu6Model(data.bu6 || {}) this.bu6 = new MyBu6Model(data?.bu6 || {})
this.bu7 = new MyBu7Model(data.bu7 || {}) this.bu7 = new MyBu7Model(data?.bu7 || {})
this.empGroup = new MyEmpGroupModel(data.empGroup || {}) this.empGroup = new MyEmpGroupModel(data?.empGroup || {})
this.firstHireDate = data.firstHireDate || "" this.firstHireDate = data?.firstHireDate || ""
this.startDate = data.startDate || "" this.startDate = data?.startDate || ""
this.ageWork = new MyAgeModel(data.ageWork || {}) this.ageWork = new MyAgeModel(data?.ageWork || {})
this.empType = new MyEmpTypeModel(data.empType || {}) this.empType = new MyEmpTypeModel(data?.empType || {})
this.time0 = new MyTime0Model(data.time0 || {}) this.time0 = new MyTime0Model(data?.time0 || {})
this.publicHoliday = data.publicHoliday || "" this.publicHoliday = data?.publicHoliday || ""
this.proDate = data.proDate || "" this.proDate = data?.proDate || ""
this.proEvery = data.proEvery || "" this.proEvery = data?.proEvery || ""
this.approveDate = data.approveDate || "" this.approveDate = data?.approveDate || ""
this.workarea = new MyWorkareaModel(data.workarea || {}) this.workarea = new MyWorkareaModel(data?.workarea || {})
this.telExt = data.telExt || "" this.telExt = data?.telExt || ""
this.costcenter = new MyCostcenterModel(data.costcenter || {}) this.costcenter = new MyCostcenterModel(data?.costcenter || {})
this.branch = new MyBranchModel(data.branch || {}) this.branch = new MyBranchModel(data?.branch || {})
this.zeemeLogOnName = data.zeemeLogOnName || "" this.zeemeLogOnName = data?.zeemeLogOnName || ""
this.salatype = new MySalatypeModel(data.salatype || {}) this.salatype = new MySalatypeModel(data?.salatype || {})
this.effSalatype = data.effSalatype || "" this.effSalatype = data?.effSalatype || ""
this.salary = data.salary || "" this.salary = data?.salary || ""
this.empEvery = data.empEvery || "" this.empEvery = data?.empEvery || ""
this.curchgincDate = data.curchgincDate || "" this.curchgincDate = data?.curchgincDate || ""
this.receiverBankNo = data.receiverBankNo || "" this.receiverBankNo = data?.receiverBankNo || ""
this.receiverBank = data.receiverBank || "" this.receiverBank = data?.receiverBank || ""
this.receiverBankBranch = data.receiverBankBranch || "" this.receiverBankBranch = data?.receiverBankBranch || ""
this.banks = data.banks?.map(x => new MyBanksModel(x)) || [] this.banks = data?.banks?.map(x => new MyBanksModel(x)) || []
this.taxTable = data.taxTable || "" this.taxTable = data?.taxTable || ""
this.compenTaxTable = data.compenTaxTable || "" this.compenTaxTable = data?.compenTaxTable || ""
this.idTax = data.idTax || "" this.idTax = data?.idTax || ""
this.calTax = data.calTax || "" this.calTax = data?.calTax || ""
this.fixTax = data.fixTax || "" this.fixTax = data?.fixTax || ""
this.calSoc = data.calSoc || "" this.calSoc = data?.calSoc || ""
this.calPvf = data.calPvf || "" this.calPvf = data?.calPvf || ""
this.taxMethodAct = data.taxMethodAct || "" this.taxMethodAct = data?.taxMethodAct || ""
this.ssoFlag = data.ssoFlag || "" this.ssoFlag = data?.ssoFlag || ""
this.thFullName = data.thFullName || "" this.thFullName = data?.thFullName || ""
this.engFullName = data.engFullName || "" this.engFullName = data?.engFullName || ""
} }
} }
import { EmployeeModel, MyEmployeeModel } from "./employee.model";
import { MyPLModel, PLModel } from "./pl.model";
export interface GroupApproveModel {
personalLevel: PLModel;
apsassessy: EmployeeModel;
companyId: string;
apsapprove1: EmployeeModel;
apsapprove2: EmployeeModel;
apsapprove3: EmployeeModel;
apsapprove4: EmployeeModel;
apsapprove5: EmployeeModel;
}
export class MyGroupApproveModel implements GroupApproveModel {
personalLevel: PLModel;
apsassessy: EmployeeModel
companyId: string;
apsapprove1: EmployeeModel;
apsapprove2: EmployeeModel;
apsapprove3: EmployeeModel;
apsapprove4: EmployeeModel;
apsapprove5: EmployeeModel;
constructor(data: Partial<GroupApproveModel> = {}) {
this.personalLevel = new MyPLModel(data.personalLevel || {});
this.apsassessy = new MyEmployeeModel(data.apsassessy || {})
this.companyId = data.companyId || '';
this.apsapprove1 = new MyEmployeeModel(data.apsapprove1 || {});
this.apsapprove2 = new MyEmployeeModel(data.apsapprove2 || {});
this.apsapprove3 = new MyEmployeeModel(data.apsapprove3 || {});
this.apsapprove4 = new MyEmployeeModel(data.apsapprove4 || {});
this.apsapprove5 = new MyEmployeeModel(data.apsapprove5 || {});
}
}
\ No newline at end of file
...@@ -32,6 +32,7 @@ export interface JobCodeModel { ...@@ -32,6 +32,7 @@ export interface JobCodeModel {
equalification: string equalification: string
jobObjective: string jobObjective: string
supervisor: string supervisor: string
competencyWorkText: string
} }
export class MyJobCodeModel implements JobCodeModel { export class MyJobCodeModel implements JobCodeModel {
...@@ -58,6 +59,7 @@ export class MyJobCodeModel implements JobCodeModel { ...@@ -58,6 +59,7 @@ export class MyJobCodeModel implements JobCodeModel {
equalification: string equalification: string
jobObjective: string jobObjective: string
supervisor: string supervisor: string
competencyWorkText: string
constructor(data: Partial<JobCodeModel>) { constructor(data: Partial<JobCodeModel>) {
this.jobcodeId = data.jobcodeId || "" this.jobcodeId = data.jobcodeId || ""
this.tdesc = data.tdesc || "" this.tdesc = data.tdesc || ""
...@@ -82,6 +84,7 @@ export class MyJobCodeModel implements JobCodeModel { ...@@ -82,6 +84,7 @@ export class MyJobCodeModel implements JobCodeModel {
this.equalification = data.equalification || "" this.equalification = data.equalification || ""
this.jobObjective = data.jobObjective || "" this.jobObjective = data.jobObjective || ""
this.supervisor = data.supervisor || "" this.supervisor = data.supervisor || ""
this.competencyWorkText = data.competencyWorkText || ""
} }
} }
export interface LevelModel {
userLevel: string
tdesc: string
edesc: string
}
export class MyLevelModel implements LevelModel {
userLevel: string
tdesc: string
edesc: string
constructor(data?: Partial<LevelModel>) {
this.userLevel = data?.userLevel || ""
this.tdesc = data?.tdesc || ""
this.edesc = data?.edesc || ""
}
}
export interface RoleModel {
roleId: string
tdesc: string
edesc: string
}
export class MyRoleModel implements RoleModel {
roleId: string
tdesc: string
edesc: string
constructor(data?: Partial<RoleModel>) {
this.roleId = data?.roleId || ""
this.tdesc = data?.tdesc || ""
this.edesc = data?.edesc || ""
}
}
import { LevelModel, MyLevelModel } from "./level.model";
import { EmployeeModel, MyEmployeeModel } from "./employee.model";
import { MyRoleModel, RoleModel } from "./role.model";
export interface UserModel {
usernameId: string
empId: string
companyId: string
userRole: string
userLevel: string
lang: string
passwordStatus: string
expireDate: string
adAccount: string
status: string
role: RoleModel
level: LevelModel
employee: EmployeeModel
}
export class MyUserModel implements UserModel {
usernameId: string
empId: string
companyId: string
userRole: string
userLevel: string
lang: string
passwordStatus: string
expireDate: string
adAccount: string
status: string
role: RoleModel
level: LevelModel
employee: EmployeeModel
constructor(data?: Partial<UserModel>) {
this.usernameId = data?.usernameId || ""
this.empId = data?.empId || ""
this.companyId = data?.companyId || ""
this.userRole = data?.userRole || ""
this.userLevel = data?.userLevel || ""
this.lang = data?.lang || ""
this.passwordStatus = data?.passwordStatus || ""
this.expireDate = data?.expireDate || ""
this.adAccount = data?.adAccount || ""
this.status = data?.status || ""
this.role = new MyRoleModel(data?.role)
this.level = new MyLevelModel(data?.level)
this.employee = new MyEmployeeModel(data?.employee)
}
}
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { environment } from 'src/environments/environment';
import { GroupApproveModel } from '../model/group-approve.model';
import { AlertModel } from '../model/alert.model';
@Injectable({
providedIn: 'root'
})
export class GroupApproveService {
api = "/group-approve"
urlApi = environment.baseUrl + this.api
constructor(private http: HttpClient) {
}
getByPersonalLevel(plId: string): Observable<GroupApproveModel> {
return this.http.get<GroupApproveModel>(this.urlApi + "/" + plId);
}
getList(): Observable<GroupApproveModel[]> {
return this.http.get<GroupApproveModel[]>(this.urlApi + "/lists")
}
post(body: GroupApproveModel): Observable<AlertModel> {
return this.http.post<AlertModel>(this.urlApi, body)
}
delete(body: GroupApproveModel) : Observable<AlertModel> {
const options = {
headers: new HttpHeaders({
"Content-Type": "application/json",
}),
body: body
};
return this.http.delete<AlertModel>(this.urlApi, options)
}
}
\ No newline at end of file
import { HttpClient, HttpHeaders } from '@angular/common/http'; import { HttpClient, HttpHeaders } from '@angular/common/http';
...@@ -3,6 +3,7 @@ import { Injectable } from '@angular/core'; ...@@ -3,6 +3,7 @@ import { Injectable } from '@angular/core';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { environment } from 'src/environments/environment'; import { environment } from 'src/environments/environment';
import { JobCodeModel } from '../model/job-code.model'; import { JobCodeModel } from '../model/job-code.model';
import { AlertModel } from '../model/alert.model';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
...@@ -18,9 +19,9 @@ export class JobCodeService { ...@@ -18,9 +19,9 @@ export class JobCodeService {
getById(jobcodeId: string): Observable<JobCodeModel> { getById(jobcodeId: string): Observable<JobCodeModel> {
return this.http.get<JobCodeModel>(this.urlApi + "/" + jobcodeId) return this.http.get<JobCodeModel>(this.urlApi + "/" + jobcodeId)
} }
// post(body: JobCodeModel): Observable<AlertModel> { post(body: JobCodeModel): Observable<AlertModel> {
// return this.http.post<AlertModel>(this.urlApi, body) return this.http.post<AlertModel>(this.urlApi, body)
// } }
// delete(body: JobCodeModel | JobCodeModel[]): Observable<AlertModel> { // delete(body: JobCodeModel | JobCodeModel[]): Observable<AlertModel> {
// const options = { // const options = {
// headers: new HttpHeaders({ // headers: new HttpHeaders({
......
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { environment } from 'src/environments/environment';
import { AlertModel } from '../model/alert.model';
import { UserModel } from '../model/user.model';
import { RoleModel } from '../model/role.model';
@Injectable({
providedIn: 'root'
})
export class UserService {
api = "/user"
urlApi = environment.baseUrl + this.api
constructor(private http: HttpClient) {
}
getList(pwdempty?: string): Observable<UserModel[]> {
return this.http.get<UserModel[]>(this.urlApi + "/lists" + (pwdempty ? '?pwdempty=' + pwdempty : ""))
}
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> {
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> {
return this.http.post<AlertModel>(this.urlApi + "/create", body)
}
delete(body: UserModel[]): Observable<AlertModel> {
const options = {
headers: new HttpHeaders({
"Content-Type": "application/json",
}),
body: body
};
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