Commit aaaf6be8 by Nakarin Luankla

Merge branch 'DEV' of https://mygit.myhr.co.th/angular/myAppraisal into DEV

# Conflicts:
#	src/app/authentication/login-page/login-page.component.ts
parents 976d149a a3ed4a16
...@@ -26,8 +26,8 @@ export class LoginPageComponent { ...@@ -26,8 +26,8 @@ export class LoginPageComponent {
} }
ngOnInit(): void { ngOnInit(): void {
this.loginForm = this.formBuilder.group({ this.loginForm = this.formBuilder.group({
username: ['programmer', [Validators.required, Validators.email]], username: ['', [Validators.required, Validators.email]],
password: ['147@P', Validators.required], password: ['', Validators.required],
}); });
const authe: any = document.querySelector('.auth'); const authe: any = document.querySelector('.auth');
authe.setAttribute('class', 'h-full'); authe.setAttribute('class', 'h-full');
......
...@@ -62,7 +62,8 @@ ...@@ -62,7 +62,8 @@
<td>{{item.data.employee.lname}}</td> <td>{{item.data.employee.lname}}</td>
<td class="text-center">{{item.data.status=='0'?'ไม่ใช้งาน':'ใช้งาน'}}</td> <td class="text-center">{{item.data.status=='0'?'ไม่ใช้งาน':'ใช้งาน'}}</td>
<td class="flex justify-center"> <td class="flex justify-center">
<i class="ti ti-edit cursor-pointer i-gray fs-l px-1" (click)="selectUser(item.data)" <i class="ti ti-edit cursor-pointer i-gray fs-l px-1"
(click)="changePassword=false;selectUser(item.data)"
data-hs-overlay="#manage-user-modal"></i> data-hs-overlay="#manage-user-modal"></i>
</td> </td>
</tr> </tr>
......
...@@ -322,7 +322,7 @@ ...@@ -322,7 +322,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" <button type="submit" class="ti-btn ti-btn-secondary"
data-hs-overlay="#position-unit-component-upload-modal" [class.ti-btn-disabled]="!selectedFile" data-hs-overlay="#company-registration-page-upload-modal" [class.ti-btn-disabled]="!selectedFile"
(click)="uploadFile()" [disabled]="!selectedFile" [disabled]="!selectedFile"> (click)="uploadFile()" [disabled]="!selectedFile" [disabled]="!selectedFile">
อัปโหลด อัปโหลด
</button> </button>
......
...@@ -73,6 +73,7 @@ export class CompanyRegistrationPageComponent { ...@@ -73,6 +73,7 @@ export class CompanyRegistrationPageComponent {
addCompany() { addCompany() {
const body = new MyCompanyModel({ companyId: this.dataSelect.code, tdesc: this.dataSelect.tdesc, edesc: this.dataSelect.edesc, addressText: this.dataSelect.address, contactText: this.dataSelect.contact }) const body = new MyCompanyModel({ companyId: this.dataSelect.code, tdesc: this.dataSelect.tdesc, edesc: this.dataSelect.edesc, addressText: this.dataSelect.address, contactText: this.dataSelect.contact })
this.dataLoading = true
this.companyService.post(body).subscribe({ this.companyService.post(body).subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
...@@ -80,9 +81,13 @@ export class CompanyRegistrationPageComponent { ...@@ -80,9 +81,13 @@ export class CompanyRegistrationPageComponent {
this.getCompanyList() this.getCompanyList()
} 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.cdr.detectChanges()
this.dataLoading = false
} }
}) })
} }
...@@ -93,6 +98,7 @@ export class CompanyRegistrationPageComponent { ...@@ -93,6 +98,7 @@ export class CompanyRegistrationPageComponent {
} else { } else {
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, contactText: 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, contactText: x.data.contact }))
} }
this.dataLoading = true
this.companyService.delete(body).subscribe({ this.companyService.delete(body).subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
...@@ -100,9 +106,13 @@ export class CompanyRegistrationPageComponent { ...@@ -100,9 +106,13 @@ export class CompanyRegistrationPageComponent {
this.getCompanyList() this.getCompanyList()
} 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.cdr.detectChanges()
this.dataLoading = false
} }
}) })
} }
......
...@@ -35,8 +35,7 @@ ...@@ -35,8 +35,7 @@
<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 " placeholder="Search by No. or Name"
class="ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 " placeholder="Search by No. or Name"
[(ngModel)]="search" (ngModelChange)="searchChange()"> [(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">
...@@ -203,11 +202,12 @@ ...@@ -203,11 +202,12 @@
<div class="ti-modal-body mt-5"> <div class="ti-modal-body mt-5">
<div class="space-y-3"> <div class="space-y-3">
<div class="grid grid-cols-12 gap-x-6"> <div class="grid grid-cols-12 gap-x-6">
<label class="col-span-3 ti-form-label text-primary mt-2">รหัสพนักงาน</label> <label class="col-span-3 ti-form-label text-primary mt-2">รหัสพนักงาน*</label>
<input type="text" class="sm:col-span-6 ti-form-input" [(ngModel)]="employee.select.employeeId"> <input type="text" class="sm:col-span-6 ti-form-input" [ngClass]="{'bg-input-readonly':modalType=='update'}"
[readonly]="modalType=='update'" [(ngModel)]="employee.select.employeeId">
</div> </div>
<div class="grid grid-cols-12 gap-x-6"> <div class="grid grid-cols-12 gap-x-6">
<label class="col-span-3 ti-form-label text-primary mt-4">ชื่อ-นามสกุล</label> <label class="col-span-3 ti-form-label text-primary mt-4">ชื่อ-นามสกุล*</label>
<div class="col-span-4 mt-2"> <div class="col-span-4 mt-2">
<div class=" flex rounded-md"> <div class=" flex rounded-md">
<input type="text" class="ti-form-input" [(ngModel)]="employee.select.fname"> <input type="text" class="ti-form-input" [(ngModel)]="employee.select.fname">
...@@ -218,14 +218,18 @@ ...@@ -218,14 +218,18 @@
</div> </div>
</div> </div>
<div class="grid grid-cols-12 gap-x-6"> <div class="grid grid-cols-12 gap-x-6">
<label class="col-span-3 ti-form-label text-primary mt-2">กลุ่มพนักงาน</label> <label class="col-span-3 ti-form-label text-primary mt-2">กลุ่มพนักงาน*</label>
<div class="col-span-6 sm:col-span-6 "> <div class="col-span-6 sm:col-span-6 ">
<div class="flex"> <div class="flex">
<div class="relative flex rounded-md"> <div class="relative flex rounded-md">
<input type="text" class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10" <input type="text" class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10"
style="padding-right: 3.5rem;" [(ngModel)]="employee.select.empGroup.tdesc"> readonly style="padding-right: 3.5rem;" [(ngModel)]="employee.select.empGroup.tdesc">
<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)="employee.select.empGroup.groupId='';employee.select.empGroup.tdesc=''">
<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="#sub-employee-registration-empgroup-table-modal"> data-hs-overlay="#sub-employee-registration-empgroup-table-modal">
<i class="ri-search-line cursor-pointer text-gray"></i> <i class="ri-search-line cursor-pointer text-gray"></i>
...@@ -236,11 +240,11 @@ ...@@ -236,11 +240,11 @@
</div> </div>
</div> </div>
<div class="grid grid-cols-12 gap-x-6"> <div class="grid grid-cols-12 gap-x-6">
<label class="col-span-3 ti-form-label text-primary mt-2 align-center">วันเริ่มงาน</label> <label class="col-span-3 ti-form-label text-primary mt-2 align-center">วันเริ่มงาน*</label>
<div class="col-span-6 sm:col-span-6 "> <div class="col-span-6 sm:col-span-6 ">
<mat-form-field> <mat-form-field>
<input matInput [matDatepicker]="firstHireDate" type="text" <input matInput [matDatepicker]="firstHireDate" type="text"
class="ti-form-input rounded-l-none focus:z-10 flatpickr-input !text-gray-500" id="datetime" class="ti-form-input rounded-l-none focus:z-10 flatpickr-input !text-gray-500 bg-white" id="datetime"
[(ngModel)]="employee.select.dateIso" [(ngModel)]="employee.select.dateIso"
(ngModelChange)="changeDate(this.employee.select, 'firstHireDate', employee.select.dateIso);"> (ngModelChange)="changeDate(this.employee.select, 'firstHireDate', employee.select.dateIso);">
<mat-datepicker-toggle matSuffix [for]="firstHireDate"></mat-datepicker-toggle> <mat-datepicker-toggle matSuffix [for]="firstHireDate"></mat-datepicker-toggle>
...@@ -249,14 +253,18 @@ ...@@ -249,14 +253,18 @@
</div> </div>
</div> </div>
<div class="grid grid-cols-12 gap-x-6"> <div class="grid grid-cols-12 gap-x-6">
<label class="col-span-3 ti-form-label text-primary mt-2">BU</label> <label class="col-span-3 ti-form-label text-primary mt-2">BU*</label>
<div class="col-span-6 sm:col-span-6 "> <div class="col-span-6 sm:col-span-6 ">
<div class="flex"> <div class="flex">
<div class="relative flex rounded-md"> <div class="relative flex rounded-md">
<input type="text" class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10" <input type="text" class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10"
style="padding-right: 3.5rem;" [(ngModel)]="employee.select.bu1.tdesc"> readonly style="padding-right: 3.5rem;" [(ngModel)]="employee.select.bu1.tdesc">
<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)="employee.select.bu1.bu1id='';employee.select.bu1.tdesc=''">
<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="#sub-employee-registration-bu-table-modal"> data-hs-overlay="#sub-employee-registration-bu-table-modal">
<i class="ri-search-line cursor-pointer text-gray"></i> <i class="ri-search-line cursor-pointer text-gray"></i>
...@@ -267,14 +275,18 @@ ...@@ -267,14 +275,18 @@
</div> </div>
</div> </div>
<div class="grid grid-cols-12 gap-x-6"> <div class="grid grid-cols-12 gap-x-6">
<label class="col-span-3 ti-form-label text-primary mt-2">ตำแหน่ง</label> <label class="col-span-3 ti-form-label text-primary mt-2">ตำแหน่ง*</label>
<div class="col-span-6 sm:col-span-6 "> <div class="col-span-6 sm:col-span-6 ">
<div class="flex"> <div class="flex">
<div class="relative flex rounded-md"> <div class="relative flex rounded-md">
<input type="text" class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10" <input type="text" class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10"
style="padding-right: 3.5rem;" [(ngModel)]="employee.select.position.tdesc"> readonly style="padding-right: 3.5rem;" [(ngModel)]="employee.select.position.tdesc">
<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)="employee.select.position.positionId='';employee.select.position.tdesc=''">
<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="#sub-employee-registration-position-table-modal"> data-hs-overlay="#sub-employee-registration-position-table-modal">
<i class="ri-search-line cursor-pointer text-gray"></i> <i class="ri-search-line cursor-pointer text-gray"></i>
...@@ -285,14 +297,18 @@ ...@@ -285,14 +297,18 @@
</div> </div>
</div> </div>
<div class="grid grid-cols-12 gap-x-6"> <div class="grid grid-cols-12 gap-x-6">
<label class="col-span-3 ti-form-label text-primary mt-2">ลักษณะงาน</label> <label class="col-span-3 ti-form-label text-primary mt-2">ลักษณะงาน*</label>
<div class="col-span-6 sm:col-span-6 "> <div class="col-span-6 sm:col-span-6 ">
<div class="flex"> <div class="flex">
<div class="relative flex rounded-md"> <div class="relative flex rounded-md">
<input type="text" class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10" <input type="text" class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10"
style="padding-right: 3.5rem;" [(ngModel)]="employee.select.jobCode.tdesc"> readonly style="padding-right: 3.5rem;" [(ngModel)]="employee.select.jobCode.tdesc">
<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)="employee.select.jobCode.jobcodeId='';employee.select.jobCode.tdesc=''">
<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="#sub-employee-registration-jobcode-table-modal"> data-hs-overlay="#sub-employee-registration-jobcode-table-modal">
<i class="ri-search-line cursor-pointer text-gray"></i> <i class="ri-search-line cursor-pointer text-gray"></i>
...@@ -303,14 +319,18 @@ ...@@ -303,14 +319,18 @@
</div> </div>
</div> </div>
<div class="grid grid-cols-12 gap-x-6"> <div class="grid grid-cols-12 gap-x-6">
<label class="col-span-3 ti-form-label text-primary mt-2">สาขา</label> <label class="col-span-3 ti-form-label text-primary mt-2">สาขา*</label>
<div class="col-span-6 sm:col-span-6 "> <div class="col-span-6 sm:col-span-6 ">
<div class="flex"> <div class="flex">
<div class="relative flex rounded-md"> <div class="relative flex rounded-md">
<input type="text" class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10" <input type="text" class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10"
style="padding-right: 3.5rem;" [(ngModel)]="employee.select.branch.tdesc"> readonly style="padding-right: 3.5rem;" [(ngModel)]="employee.select.branch.tdesc">
<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)="employee.select.branch.branchId='';employee.select.branch.tdesc=''">
<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="#sub-employee-registration-branch-table-modal"> data-hs-overlay="#sub-employee-registration-branch-table-modal">
<i class="ri-search-line cursor-pointer text-gray"></i> <i class="ri-search-line cursor-pointer text-gray"></i>
...@@ -321,14 +341,18 @@ ...@@ -321,14 +341,18 @@
</div> </div>
</div> </div>
<div class="grid grid-cols-12 gap-x-6"> <div class="grid grid-cols-12 gap-x-6">
<label class="col-span-3 ti-form-label text-primary mt-2">ประเภทพนักงาน</label> <label class="col-span-3 ti-form-label text-primary mt-2">ประเภทพนักงาน*</label>
<div class="col-span-6 sm:col-span-6 "> <div class="col-span-6 sm:col-span-6 ">
<div class="flex"> <div class="flex">
<div class="relative flex rounded-md"> <div class="relative flex rounded-md">
<input type="text" class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10" <input type="text" class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10"
style="padding-right: 3.5rem;" [(ngModel)]="employee.select.empType.tdesc"> readonly style="padding-right: 3.5rem;" [(ngModel)]="employee.select.empType.tdesc">
<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)="employee.select.empType.codeId='';employee.select.empType.tdesc=''">
<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="#sub-employee-registration-emptype-table-modal"> data-hs-overlay="#sub-employee-registration-emptype-table-modal">
<i class="ri-search-line cursor-pointer text-gray"></i> <i class="ri-search-line cursor-pointer text-gray"></i>
...@@ -339,14 +363,18 @@ ...@@ -339,14 +363,18 @@
</div> </div>
</div> </div>
<div class="grid grid-cols-12 gap-x-6"> <div class="grid grid-cols-12 gap-x-6">
<label class="col-span-3 ti-form-label text-primary mt-2">ระดับพนักงาน (PL)</label> <label class="col-span-3 ti-form-label text-primary mt-2">ระดับพนักงาน (PL)*</label>
<div class="col-span-6 sm:col-span-6 "> <div class="col-span-6 sm:col-span-6 ">
<div class="flex"> <div class="flex">
<div class="relative flex rounded-md"> <div class="relative flex rounded-md">
<input type="text" class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10" <input type="text" class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10"
style="padding-right: 3.5rem;" [(ngModel)]="employee.select.personalLevel.tdesc"> readonly style="padding-right: 3.5rem;" [(ngModel)]="employee.select.personalLevel.tdesc">
<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)="employee.select.personalLevel.plId='';employee.select.personalLevel.tdesc=''">
<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="#sub-employee-registration-pl-table-modal"> data-hs-overlay="#sub-employee-registration-pl-table-modal">
<i class="ri-search-line cursor-pointer text-gray"></i> <i class="ri-search-line cursor-pointer text-gray"></i>
...@@ -363,10 +391,11 @@ ...@@ -363,10 +391,11 @@
data-hs-overlay="#sub-employee-registration-modal"> data-hs-overlay="#sub-employee-registration-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="#sub-employee-registration-alert-add-modal"> data-hs-overlay="#sub-employee-registration-alert-add-modal" [class.ti-btn-disabled]="checkEmployeeModel()"
[disabled]="checkEmployeeModel()">
บันทึกข้อมูล บันทึกข้อมูล
</a> </button>
</div> </div>
</div> </div>
</div> </div>
...@@ -467,7 +496,7 @@ ...@@ -467,7 +496,7 @@
ย้อนกลับ ย้อนกลับ
</button> </button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);" <a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#sub-employee-registration-alert-delete-modal" (click)="updateEmployeeList('delete')"> data-hs-overlay="#sub-employee-registration-alert-delete-modal" (click)="updateEmployeeList(modalType)">
ลบข้อมูล ลบข้อมูล
</a> </a>
</div> </div>
...@@ -495,9 +524,9 @@ ...@@ -495,9 +524,9 @@
<div class="flex justify-end pb-1rem"> <div class="flex justify-end pb-1rem">
<div class="px-1"> <div class="px-1">
<div class="relative shadow-md"> <div class="relative shadow-md">
<input type="text" id="hs-leading-icon" name="hs-leading-icon" <input type="text" 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)]="modal.search"
[(ngModel)]="modal.search" (ngModelChange)="searchModalChange(empGroupListFilter())"> (ngModelChange)="searchModalChange(empGroupListFilter())">
<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>
...@@ -623,9 +652,9 @@ ...@@ -623,9 +652,9 @@
<div class="flex justify-end pb-1rem"> <div class="flex justify-end pb-1rem">
<div class="px-1"> <div class="px-1">
<div class="relative shadow-md"> <div class="relative shadow-md">
<input type="text" id="hs-leading-icon" name="hs-leading-icon" <input type="text" 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)]="modal.search"
[(ngModel)]="modal.search" (ngModelChange)="searchModalChange(bu1ListFilter())"> (ngModelChange)="searchModalChange(bu1ListFilter())">
<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>
...@@ -750,9 +779,9 @@ ...@@ -750,9 +779,9 @@
<div class="flex justify-end pb-1rem"> <div class="flex justify-end pb-1rem">
<div class="px-1"> <div class="px-1">
<div class="relative shadow-md"> <div class="relative shadow-md">
<input type="text" id="hs-leading-icon" name="hs-leading-icon" <input type="text" 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)]="modal.search"
[(ngModel)]="modal.search" (ngModelChange)="searchModalChange(positionListFilter())"> (ngModelChange)="searchModalChange(positionListFilter())">
<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>
...@@ -878,9 +907,9 @@ ...@@ -878,9 +907,9 @@
<div class="flex justify-end pb-1rem"> <div class="flex justify-end pb-1rem">
<div class="px-1"> <div class="px-1">
<div class="relative shadow-md"> <div class="relative shadow-md">
<input type="text" id="hs-leading-icon" name="hs-leading-icon" <input type="text" 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)]="modal.search"
[(ngModel)]="modal.search" (ngModelChange)="searchModalChange(jobcodeListFilter())"> (ngModelChange)="searchModalChange(jobcodeListFilter())">
<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>
...@@ -1006,9 +1035,9 @@ ...@@ -1006,9 +1035,9 @@
<div class="flex justify-end pb-1rem"> <div class="flex justify-end pb-1rem">
<div class="px-1"> <div class="px-1">
<div class="relative shadow-md"> <div class="relative shadow-md">
<input type="text" id="hs-leading-icon" name="hs-leading-icon" <input type="text" 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)]="modal.search"
[(ngModel)]="modal.search" (ngModelChange)="searchModalChange(branchListFilter())"> (ngModelChange)="searchModalChange(branchListFilter())">
<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>
...@@ -1134,9 +1163,9 @@ ...@@ -1134,9 +1163,9 @@
<div class="flex justify-end pb-1rem"> <div class="flex justify-end pb-1rem">
<div class="px-1"> <div class="px-1">
<div class="relative shadow-md"> <div class="relative shadow-md">
<input type="text" id="hs-leading-icon" name="hs-leading-icon" <input type="text" 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)]="modal.search"
[(ngModel)]="modal.search" (ngModelChange)="searchModalChange(empTypeListFilter())"> (ngModelChange)="searchModalChange(empTypeListFilter())">
<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>
...@@ -1262,9 +1291,9 @@ ...@@ -1262,9 +1291,9 @@
<div class="flex justify-end pb-1rem"> <div class="flex justify-end pb-1rem">
<div class="px-1"> <div class="px-1">
<div class="relative shadow-md"> <div class="relative shadow-md">
<input type="text" id="hs-leading-icon" name="hs-leading-icon" <input type="text" 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)]="modal.search"
[(ngModel)]="modal.search" (ngModelChange)="searchModalChange(plListFilter())"> (ngModelChange)="searchModalChange(plListFilter())">
<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>
......
...@@ -116,7 +116,7 @@ export class SubEmployeeRegistrationComponent { ...@@ -116,7 +116,7 @@ export class SubEmployeeRegistrationComponent {
}) })
} }
downloadFile() { downloadFile() {
const fileName = 'IMPORT_MPOSITION.xlsx' const fileName = '.xlsx'
this.fileService.downloadTemplate(fileName).subscribe({ this.fileService.downloadTemplate(fileName).subscribe({
next: response => { next: response => {
const url = window.URL.createObjectURL(response); const url = window.URL.createObjectURL(response);
...@@ -304,6 +304,7 @@ export class SubEmployeeRegistrationComponent { ...@@ -304,6 +304,7 @@ export class SubEmployeeRegistrationComponent {
break; break;
} }
} }
this.employee.loading = true
this.employeeService[type](body).subscribe({ this.employeeService[type](body).subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
...@@ -311,9 +312,13 @@ export class SubEmployeeRegistrationComponent { ...@@ -311,9 +312,13 @@ export class SubEmployeeRegistrationComponent {
this.getEmployeeList() this.getEmployeeList()
} else { } else {
this.showAlert(response.message, 'error') this.showAlert(response.message, 'error')
this.employee.loading = false
this.cdr.detectChanges()
} }
}, error: error => { }, error: error => {
this.showAlert(error.message, 'error') this.showAlert(error.message, 'error')
this.employee.loading = false
this.cdr.detectChanges()
} }
}) })
} }
...@@ -385,4 +390,23 @@ export class SubEmployeeRegistrationComponent { ...@@ -385,4 +390,23 @@ export class SubEmployeeRegistrationComponent {
this.isDataListChecked = Boolean(this.numDataListChecked) this.isDataListChecked = Boolean(this.numDataListChecked)
} }
checkEmployeeModel() {
let disable = false
if (!this.employee.select.employeeId ||
!this.employee.select.fname ||
!this.employee.select.lname ||
!this.employee.select.empGroup.groupId ||
!this.employee.select.firstHireDate ||
!this.employee.select.bu1.bu1id ||
!this.employee.select.position.positionId ||
!this.employee.select.jobCode.jobcodeId ||
!this.employee.select.branch.branchId ||
!this.employee.select.empType.codeId ||
!this.employee.select.personalLevel.plId
) {
disable = true
}
return disable
}
} }
...@@ -10,15 +10,15 @@ ...@@ -10,15 +10,15 @@
<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)="pathTitle = ['การประเมินสมรรถนะ','ทะเบียนหลักสูตร','หลักสูตรการพัฒนา']"> aria-controls="underline-1"
(click)="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 id="underline-1" role="tabpanel" aria-labelledby="underline-item-1">
<app-development-course [pathTitle]="pathTitle" <app-development-course></app-development-course>
(sendPathTitle)="pathTitle=$event"></app-development-course>
</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">{{mockDataSelect.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,28 +32,26 @@ ...@@ -35,28 +32,26 @@
<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="#development-course-modal-add"> data-hs-overlay="#development-course-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>
</div> </div>
<div class="px-1"> <div class="px-1">
<button type="button" class="ti-btn ti-btn-soft-secondary h-10 m-0 shadow-md" <button type="button" class="ti-btn ti-btn-soft-secondary h-10 m-0 shadow-md"
data-hs-overlay="#development-course-modal-add" (click)="selectCompetencycourse()"> data-hs-overlay="#development-course-modal" (click)="currentModal='add';selectCompetencycourse()">
<i class="ri-add-line"></i> <i class="ri-add-line"></i>
Add Add
</button> </button>
</div> </div>
<div class="px-1"> <div class="px-1">
<button href="javascript:void(0);" class="ti-btn ti-btn-soft-danger h-10 m-0 shadow-md"> <button href="javascript:void(0);" class="ti-btn ti-btn-soft-danger h-10 m-0 shadow-md"
data-hs-overlay="#development-course-alert-modal"
(click)="currentModal='deleteGroup';selectCompetencycourse()">
<i class="ri-delete-bin-6-line"></i> <i class="ri-delete-bin-6-line"></i>
Delete Delete
</button> </button>
<!-- <button href="javascript:void(0);" class="ti-btn ti-btn-soft-danger h-10 m-0 shadow-md"
data-hs-overlay="#development-course-alert-delete-modal">
<i class="ri-delete-bin-6-line"></i>
Delete
</button> -->
</div> </div>
<div class="px-1"> <div class="px-1">
<button href="javascript:void(0);" class="ti-btn ti-btn-soft-warning h-10 m-0 shadow-md"> <button href="javascript:void(0);" class="ti-btn ti-btn-soft-warning h-10 m-0 shadow-md">
...@@ -85,7 +80,7 @@ ...@@ -85,7 +80,7 @@
</ng-container> </ng-container>
</tr> </tr>
</thead> </thead>
<tbody *ngIf="dataLoading"> <tbody *ngIf="competencyCourse.loading">
<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"
...@@ -95,27 +90,31 @@ ...@@ -95,27 +90,31 @@
</td> </td>
</tr> </tr>
</tbody> </tbody>
<tbody *ngIf="!dataLoading&&!dataListFilter().length"> <tbody *ngIf="!competencyCourse.loading&&!dataListFilter().length">
<tr> <tr>
<td class="text-center" colspan="100%"> <td class="text-center" colspan="100%">
ไม่พบข้อมูล ไม่พบข้อมูล
</td> </td>
</tr> </tr>
</tbody> </tbody>
<tbody *ngIf="!dataLoading&&dataListFilter().length"> <tbody *ngIf="!competencyCourse.loading&&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="text-center"> <td class="text-center">
<input type="checkbox" class="ti-form-checkbox cursor-pointer" id="checkbox-{{item.id}}" <input type="checkbox" class="ti-form-checkbox cursor-pointer"
[(ngModel)]="item.checked" (change)="checkSelect()"> id="checkbox-{{item.data.competencyCourseId}}" [(ngModel)]="item.check"
<label for="checkbox-{{item.id}}">&nbsp;{{item.id}}</label> (change)="dataListCheck()">
<label
for="checkbox-{{item.data.competencyCourseId}}">&nbsp;{{item.data.competencyCourseId}}</label>
</td> </td>
<td>{{item.name}}</td> <td>{{item.data.tdesc}}</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)="selectCompetencycourse(item)" <i class="ti ti-edit cursor-pointer i-gray fs-l px-1"
data-hs-overlay="#development-course-modal-edit"></i> (click)="currentModal='edit' ;selectCompetencycourse(item.data)"
<i class="ti ti-trash cursor-pointer i-gray fs-l px-1" (click)="selectCompetencycourse(item)" data-hs-overlay="#development-course-modal"></i>
data-hs-overlay="#development-course-alert-delete-modal"></i> <i class="ti ti-trash cursor-pointer i-gray fs-l px-1"
(click)="currentModal='delete' ;selectCompetencycourse(item.data)"
data-hs-overlay="#development-course-alert-modal"></i>
</td> </td>
</tr> </tr>
</tbody> </tbody>
...@@ -160,91 +159,77 @@ ...@@ -160,91 +159,77 @@
</nav> </nav>
</div> </div>
<div id="development-course-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 id="development-course-modal-add" class="hs-overlay hidden ti-modal"> <div class="ti-modal-header bg-primary !rounded-none !rounded-t-sm">
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)]"> <h5 class="text-xxl font-bold text-white">
<div class="max-h-full overflow-hidden ti-modal-content"> นำเข้าหลักสูตรการพัฒนา
<div class="ti-modal-header"> </h5>
<h3 class="text-xxl font-bold text-primary"> </div>
เพิ่มหลักสูตรการพัฒนา <div class="ti-modal-body max-h-full overflow-hidden ti-modal-content !rounded-t-none !rounded-b-sm">
</h3> <h1 class="mt-2" style="text-align: center;">ไฟล์</h1>
<div class="flex justify-end"> <div class="mt-2 p-2">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger" <div class="flex rounded-md">
data-hs-overlay="#development-course-modal-add"> <input #fileInput id="fileInput" type="file" (change)="onFileSelected($event)" hidden>
<span class="sr-only">Close</span> <input type="text" [value]="selectedFileName" readonly (click)="fileInput.click()"
<i class="ti ti-circle-x fs-xxl"></i> class="ti-form-input rounded-none ltr:rounded-l-md rtl:rounded-r-md focus:z-10 cursor-pointer">
<button type="button" (click)="fileInput.click()"
class="inline-flex flex-shrink-0 justify-center items-center h-[2.875rem] w-[2.875rem] ltr:rounded-r-md rtl:rounded-l-md border border-transparent font-semibold bg-secondary text-white hover:bg-secondary focus:z-10 focus:outline-none focus:ring-0 focus:ring-secondary transition-all text-sm">
<i class="ti ti-upload"></i>
</button> </button>
</div> </div>
</div> <div class="flex justify-center mt-2rem ">
<div class="ti-modal-center"> <h1 class="cursor-pointer justify-center -mb-px inline-flex items-center gap-2 font-weight-500 font-size-12px
<div class="flex justify-end" style="padding-right: 1rem;"> text-center text-secondary border-secondary border-b-2 align-items-end" (click)="downloadFile()">
<div class="px-1"> ดาวน์โหลดตัวอย่างไฟล์</h1>
<button type="button" class="ti-btn ti-btn-soft-indigo h-45px m-0 shadow-md">
<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> <div class="flex justify-center mt-2rem mb-1rem space-x-4">
<div class="ti-modal-body mt-1"> <button type="submit" class="ti-btn ti-btn-secondary"
<label for="input-label" class="ti-form-label">รหัสหลักสูตร*</label> data-hs-overlay="#type-registration-component-upload-modal"
<input type="text" id="input-label" class="ti-form-input w-1/2" [(ngModel)]="dataSelect.id"> [class.ti-btn-disabled]="!selectedFile" (click)="uploadFile()" [disabled]="!selectedFile"
<label for="detail_th" class="ti-form-label mt-2rem">ชื่อหลักสูตร (ไทย)*</label> [disabled]="!selectedFile">
<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>
<input type="text" id="detail_eng" class="ti-form-input h-10" [(ngModel)]="dataSelect.edesc">
<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"
[(ngModel)]="dataSelect.detail"> </textarea>
<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"
[(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">
<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="#development-course-modal-add">
ย้อนกลับ
</button> </button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#development-course-alert-add-modal">
บันทึกข้อมูล
</a>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div id="development-course-modal-edit" class="hs-overlay hidden ti-modal">
<div id="development-course-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" *ngIf="currentModal=='add'">
เพิ่มหลักสูตรการพัฒนา
</h3>
<h3 class="text-xxl font-bold text-primary" *ngIf="currentModal=='edit'">
แก้ไขหัวข้อสมรรถนะ แก้ไขหัวข้อสมรรถนะ
</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="#development-course-modal-edit"> data-hs-overlay="#development-course-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>
...@@ -253,7 +238,8 @@ ...@@ -253,7 +238,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(currentModal)">
<svg class="svg-indigo" width="16" height="16" viewBox="0 0 64.00 64.00" <svg class="svg-indigo" width="16" height="16" viewBox="0 0 64.00 64.00"
xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#595BEA" stroke-width="3.84" xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#595BEA" stroke-width="3.84"
transform="rotate(45)matrix(-1, 0, 0, 1, 0, 0)"> transform="rotate(45)matrix(-1, 0, 0, 1, 0, 0)">
...@@ -279,30 +265,35 @@ ...@@ -279,30 +265,35 @@
</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 <input type="text" id="input-label" class="ti-form-input w-1/2"
[(ngModel)]="dataSelect.id"> [ngClass]="{'bg-input-readonly':currentModal=='edit'}" [readonly]="currentModal=='edit'"
[(ngModel)]="competencyCourse.select.competencyCourseId">
<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)]="competencyCourse.select.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-10" [(ngModel)]="dataSelect.edesc"> <input type="text" id="detail_eng" class="ti-form-input h-10"
[(ngModel)]="competencyCourse.select.edesc">
<label for="detail_eng" class="ti-form-label mt-2rem">วัตถุประสงค์</label> <label for="detail_eng" class="ti-form-label mt-2rem">วัตถุประสงค์</label>
<textarea type="text" id="detail_eng" class="ti-form-input" rows="4" cols="50" <textarea type="text" id="detail_eng" class="ti-form-input" rows="4" cols="50"
[(ngModel)]="dataSelect.detail"> </textarea> [(ngModel)]="competencyCourse.select.courseDetail"> </textarea>
<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)]="competencyCourse.select.courseTopic"> </textarea>
<label for="input-label" class="ti-form-label">Link myLearn</label> <label class="ti-form-label mt-2rem">Link myLearn</label>
<input type="text" id="input-label" class="ti-form-input h-10" [(ngModel)]="dataSelect.courseLinkMylearn"> <input type="text" class="ti-form-input h-10" [(ngModel)]="competencyCourse.select.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"
data-hs-overlay="#development-course-modal-edit"> data-hs-overlay="#development-course-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="#development-course-alert-edit-modal"> data-hs-overlay="#development-course-alert-modal"
[class.ti-btn-disabled]="!competencyCourse.select.competencyCourseId||!competencyCourse.select.tdesc"
[disabled]="!competencyCourse.select.competencyCourseId||!competencyCourse.select.tdesc">
บันทึกข้อมูล บันทึกข้อมูล
</a> </button>
</div> </div>
</div> </div>
</div> </div>
...@@ -310,7 +301,7 @@ ...@@ -310,7 +301,7 @@
</div> </div>
<div id="development-course-alert-add-modal" class="hs-overlay hidden ti-modal"> <div id="development-course-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">
...@@ -319,96 +310,48 @@ ...@@ -319,96 +310,48 @@
</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="#development-course-alert-add-modal"> *ngIf="currentModal=='add'||currentModal=='edit'"
data-hs-overlay="#development-course-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 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="#development-course-modal-add">
ย้อนกลับ
</button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#development-course-alert-add-modal" (click)="addUser()">
บันทึกข้อมูล
</a>
</div>
</div>
</div>
</div>
</div>
<div id="development-course-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" <button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#development-course-alert-edit-modal"> *ngIf="currentModal=='delete'||currentModal=='deleteGroup'"
data-hs-overlay="#development-course-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" *ngIf="currentModal=='add'||currentModal=='edit'">
ยืนยันการเเก้ไขข้อมูลหรือไม่ ยืนยันการบันทึกข้อมูลหรือไม่
</p>
<p class="mt-1 text-gray-800 dark:text-white/70"
*ngIf="currentModal=='delete'||currentModal=='deleteGroup'">
ยืนยันการลบข้อมูลหรือไม่
</p> </p>
<div class="flex justify-end mt-2rem mb-1rem"> <div class="flex justify-end mt-2rem mb-1rem" *ngIf="currentModal=='add'||currentModal=='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="#development-course-modal-edit"> data-hs-overlay="#development-course-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="#development-course-alert-edit-modal" (click)="addUser()"> data-hs-overlay="#development-course-alert-modal" (click)="updateCompetencyCourse('post')">
บันทึกข้อมูล บันทึกข้อมูล
</a> </a>
</div> </div>
</div> <div class="flex justify-end mt-2rem mb-1rem"
</div> *ngIf="currentModal=='delete'||currentModal=='deleteGroup'">
</div>
</div>
<div id="development-course-alert-delete-modal" class="hs-overlay hidden ti-modal">
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)] flex items-center">
<div class="max-h-full overflow-hidden ti-modal-content 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="#development-course-alert-delete-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" <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="#development-course-alert-delete-modal"> data-hs-overlay="#development-course-alert-modal">
ย้อนกลับ ย้อนกลับ
</button> </button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);" <a class="ti-btn ti-btn-danger" href="javascript:void(0);"
data-hs-overlay="#development-course-alert-delete-modal" (click)="deleteUser()"> data-hs-overlay="#development-course-alert-modal" (click)="updateCompetencyCourse('delete')">
ลบข้อมูล ลบข้อมูล
</a> </a>
</div> </div>
......
import { ChangeDetectorRef, Component, EventEmitter, Input, Output } from '@angular/core'; import { ChangeDetectorRef, Component, EventEmitter, Input, Output } from '@angular/core';
import { ToastrService } from 'ngx-toastr'; import { ToastrService } from 'ngx-toastr';
import { CompetencyCourseModel, MyCompetencyCourseModel } from 'src/app/shared/model/competency-course.model';
import { MyCompetencycourseModel } from 'src/app/shared/model/competencycourse.model'; import { MyCompetencycourseModel } from 'src/app/shared/model/competencycourse.model';
import { CompetencycourseService } from 'src/app/shared/services/competencycourse.service'; import { CompetencycourseService } from 'src/app/shared/services/competencycourse.service';
export interface DataModel { import { FileService } from 'src/app/shared/services/file.service';
id: string
name: string
edesc: string
detail: string
topic: string
courseLinkMylearn: string
checked: boolean
}
@Component({ @Component({
selector: 'app-development-course', selector: 'app-development-course',
templateUrl: './development-course.component.html', templateUrl: './development-course.component.html',
styleUrls: ['./development-course.component.scss'] styleUrls: ['./development-course.component.scss']
}) })
export class DevelopmentCourseComponent { export class DevelopmentCourseComponent {
@Input() pathTitle = ['การประเมินสมรรถนะ', 'ทะเบียนหลักสูตร', 'หลักสูตรการพัฒนา'];
@Output() sendPathTitle: EventEmitter<string[]> = new EventEmitter<string[]>();
activeTab: string = 'tab1'; // กำหนด tab เริ่มต้น
currentPage = 1 currentPage = 1
page = Array.from({ length: 1 }, (_, i) => i + 1); page = Array.from({ length: 1 }, (_, i) => i + 1);
search = "" search = ""
// ฟังก์ชันในการเปลี่ยนแท็บ currentModal: 'add' | 'edit' | 'delete' | 'deleteGroup' = "add";
changeTab(tab: { id: string, text: string }) { competencyCourse: { loading: boolean, select: CompetencyCourseModel, dataList: { check: boolean, data: CompetencyCourseModel }[] } = { loading: false, select: new MyCompetencyCourseModel(), dataList: [] }
this.sendPathTitle.emit(['การประเมินสมรรถนะ', 'ตั้งค่าผู้ใช้งาน', tab.text]); numDataListChecked = 0
this.activeTab = tab.id; isDataListChecked = false
} isDataListCheckedAll = false
// การจัดการการเปิดปิด modal
modalOptions: {
[nameModal: string]: {
isModalOpen: boolean;
modalSize: string;
backdropClose: boolean;
};
} = {
"add": {
isModalOpen: false,
modalSize: 'm',
backdropClose: true,
},
"edit": {
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';
}
closeModal(name: string) {
this.modalOptions[name].isModalOpen = false;
if (!this.isAnyModalOpen()) {
document.body.style.overflow = ''; // คืนค่าการ Scroll เฉพาะเมื่อ Modal ทั้งหมดปิดแล้ว
}
}
isAnyModalOpen(): boolean { selectedFile: File | null = null;
return Object.values(this.modalOptions).some(modal => modal.isModalOpen); // ตรวจสอบว่า modal อื่นยังเปิดอยู่หรือไม่ selectedFileName: string = 'กรุณาเลือกไฟล์';
constructor(private toastr: ToastrService,
private cdr: ChangeDetectorRef,
private competencycourseService: CompetencycourseService,
private fileService: FileService
) { }
ngOnInit(): void {
this.getCompetencycourseList()
} }
onFileSelected(event: any) {
// ฟังก์ชัน toggle checkbox this.selectedFile = event.target.files.length > 0 ? event.target.files[0] : null;
isChecked: boolean = false; // ใช้สำหรับตรวจสอบสถานะของ checkbox this.selectedFileName = this.selectedFile?.name || "กรุณาเลือกไฟล์"
toggleCheckbox() {
this.isChecked = !this.isChecked;
this.mockData.forEach((item) => {
item.checked = this.isChecked;
});
this.checkSelect();
} }
uploadFile() {
// ฟังก์ชันสำหรับการเพิ่ม ลบ หรือแก้ไข ข้อมูล if (!this.selectedFile) {
addUser() { alert('กรุณาเลือกไฟล์ก่อนอัปโหลด')
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 }) return
this.competencycourseService.post(body).subscribe((response: any) => { }
if (response.success) { const formData = new FormData();
this.showSuccess() formData.append('file', this.selectedFile);
this.getCompetencycourseList() this.competencyCourse.loading = true
this.fileService.uploadExcel(formData, '').subscribe({
next: response => {
if (response.success) {
this.showAlert(response.message, 'success')
this.getCompetencycourseList()
} else {
this.showAlert(response.message, 'error')
this.competencyCourse.loading = false
this.cdr.detectChanges()
}
}, error: error => {
this.showAlert(error.message, 'error')
this.competencyCourse.loading = false
this.cdr.detectChanges()
} }
}) })
} }
deleteUser() { downloadFile() {
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 }) const fileName = '.xlsx'
this.competencycourseService.delete(body).subscribe((response: any) => { this.fileService.downloadTemplate(fileName).subscribe({
if (response.success) { next: response => {
this.showSuccessDelete() const url = window.URL.createObjectURL(response);
this.getCompetencycourseList() 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')
} }
}) })
}
currentModal = "";
mockData: DataModel[] = []
dataLoading = false
dataSelect: DataModel = { id: "", name: "", edesc: "", topic: "", detail: "",courseLinkMylearn:"", checked: false }
mockDataSelect: any = []
constructor(private toastr: ToastrService,
private cdr: ChangeDetectorRef,
private competencycourseService: CompetencycourseService
) { }
ngOnInit(): void {
this.getCompetencycourseList()
} }
getCompetencycourseList() { getCompetencycourseList() {
this.dataLoading = true this.competencyCourse.loading = 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,courseLinkMylearn:x.courseLinkMylearn, checked: false })) this.competencyCourse.dataList = response.map(x => ({ check: false, data: new MyCompetencyCourseModel(x) }))
this.dataLoading = false this.competencyCourse.loading = false
this.isDataListCheckedAll = false
this.dataListCheckAll()
this.searchChange() this.searchChange()
this.cdr.detectChanges() this.cdr.detectChanges()
}, error: error => { }, error: error => {
this.dataLoading = false this.competencyCourse.loading = false
this.cdr.detectChanges() this.cdr.detectChanges()
} }
}) })
...@@ -133,39 +97,78 @@ export class DevelopmentCourseComponent { ...@@ -133,39 +97,78 @@ export class DevelopmentCourseComponent {
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.mockData.filter(x => { return this.competencyCourse.dataList.filter(x => {
const data = x const data = x.data
const match = data.id.includes(this.search) || data.name.includes(this.search) const match = data.competencyCourseId.toLowerCase().includes(this.search.toLowerCase()) || data.tdesc.toLowerCase().includes(this.search.toLowerCase())
return match; return match;
}); });
} }
selectCompetencycourse(data?: DataModel) { selectCompetencycourse(data?: CompetencyCourseModel) {
this.dataSelect = JSON.parse(JSON.stringify(data || { id: "", name: "", edesc: "", topic: "", detail: "", checked: false })); this.competencyCourse.select = new MyCompetencyCourseModel(data)
} }
checkSelect() { updateCompetencyCourse(typeApi: 'post' | 'delete') {
this.mockDataSelect = this.mockData.filter(item => item.checked); this.competencyCourse.loading = true
let body: CompetencyCourseModel | CompetencyCourseModel[]
switch (this.currentModal) {
case ('deleteGroup'): {
body = this.competencyCourse.dataList.filter(x => x.check).map(x => new MyCompetencyCourseModel(x.data))
break;
}
default: {
body = new MyCompetencyCourseModel(this.competencyCourse.select)
}
}
this.competencycourseService[typeApi]((body as any)).subscribe({
next: response => {
if (response.success) {
this.showAlert(response.message, 'success')
this.getCompetencycourseList()
this.searchChange()
} else {
this.showAlert(response.message, 'error')
this.competencyCourse.loading = false
}
this.cdr.detectChanges()
}, error: error => {
this.showAlert(error.message, 'error')
this.competencyCourse.loading = false
this.cdr.detectChanges()
}
})
} }
showSuccess() { 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',
}); })
} }
showSuccessEdit() { dataListCheckAll() {
this.toastr.success('เเก้ไขข้อมูลสำเร็จ', 'เเจ้งเตือน', { const selectAll = this.isDataListCheckedAll;
timeOut: 3000, this.competencyCourse.dataList.filter(x => {
positionClass: 'toast-top-right', const data = x.data
}); const match = data.competencyCourseId.toLowerCase().includes(this.search.toLowerCase()) || data.tdesc.toLowerCase().includes(this.search.toLowerCase())
return match;
}).forEach(x => x.check = selectAll);
this.dataListCheck();
} }
showSuccessDelete() { dataListCheck() {
this.toastr.success('ลบข้อมูลสำเร็จ', 'เเจ้งเตือน', { const dataCheck = this.dataListFilter();
timeOut: 3000, this.isDataListCheckedAll = dataCheck.length ? dataCheck.every(x => x.check) : false;
positionClass: 'toast-top-right', this.numDataListChecked = this.competencyCourse.dataList.filter(x => x.check).length;
}); this.isDataListChecked = Boolean(this.numDataListChecked)
}
clearData(modalStatus: string) {
if (modalStatus == 'add') {
this.selectCompetencycourse()
} else if (modalStatus == 'edit') {
this.selectCompetencycourse(new MyCompetencyCourseModel({ competencyCourseId: this.competencyCourse.select.competencyCourseId }))
}
} }
} }
...@@ -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 {
competencyCourseId: string competencyCourseId: string
...@@ -13,13 +14,15 @@ export class MyCompetencyCourseModel implements CompetencyCourseModel { ...@@ -13,13 +14,15 @@ export class MyCompetencyCourseModel implements CompetencyCourseModel {
tdesc: string tdesc: string
courseDetail: string courseDetail: string
courseTopic: string courseTopic: string
constructor(data: Partial<CompetencyCourseModel>) { courseLinkMylearn: string
this.competencyCourseId = data.competencyCourseId || "" constructor(data?: Partial<CompetencyCourseModel>) {
this.tdesc = data.tdesc || "" this.competencyCourseId = data?.competencyCourseId || ""
this.edesc = data.edesc || "" this.tdesc = data?.tdesc || ""
this.companyId = data.companyId || "" this.edesc = data?.edesc || ""
this.courseDetail = data.courseDetail || "" this.companyId = data?.companyId || ""
this.courseTopic = data.courseTopic || "" this.courseDetail = data?.courseDetail || ""
this.courseTopic = data?.courseTopic || ""
this.courseLinkMylearn = data?.courseLinkMylearn || ""
} }
} }
...@@ -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 { CompetencycourseModel } from '../model/competencycourse.model'; import { CompetencycourseModel } from '../model/competencycourse.model';
import { AlertModel } from '../model/alert.model';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
}) })
...@@ -17,16 +18,16 @@ export class CompetencycourseService { ...@@ -17,16 +18,16 @@ export class CompetencycourseService {
getList(): Observable<CompetencycourseModel[]> { getList(): Observable<CompetencycourseModel[]> {
return this.http.get<CompetencycourseModel[]>(this.urlApi + "/lists") return this.http.get<CompetencycourseModel[]>(this.urlApi + "/lists")
} }
post(body: CompetencycourseModel) { post(body: CompetencycourseModel): Observable<AlertModel> {
return this.http.post(this.urlApi, body) return this.http.post<AlertModel>(this.urlApi, body)
} }
delete(body: CompetencycourseModel) { delete(body: CompetencycourseModel): Observable<AlertModel> {
const options = { const options = {
headers: new HttpHeaders({ headers: new HttpHeaders({
"Content-Type": "application/json", "Content-Type": "application/json",
}), }),
body: body body: body
}; };
return this.http.delete(this.urlApi, options) return this.http.delete<AlertModel>(this.urlApi, options)
} }
} }
\ No newline at end of file
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