Commit ba4be01e by kantavee

api data ตำเเหน่งงาน ระดับพนักงาน(PL)

parent b1c90c4b
......@@ -47,6 +47,8 @@ import { Bu4Service } from 'src/app/shared/services/bu4.service';
import { Bu5Service } from 'src/app/shared/services/bu5.service';
import { Bu6Service } from 'src/app/shared/services/bu6.service';
import { Bu7Service } from 'src/app/shared/services/bu7.service';
import { PositionService } from 'src/app/shared/services/position.service';
import { PLService } from 'src/app/shared/services/pl.service';
@NgModule({
declarations: [
......@@ -94,7 +96,7 @@ import { Bu7Service } from 'src/app/shared/services/bu7.service';
HttpClientModule,
FormsModule
],
providers: [Bu1Service,Bu2Service,Bu3Service,Bu4Service,Bu5Service,Bu6Service,Bu7Service,{
providers: [Bu1Service,Bu2Service,Bu3Service,Bu4Service,Bu5Service,Bu6Service,Bu7Service,PositionService,PLService,{
provide: HTTP_INTERCEPTORS,
useClass: HttpRequestInterceptor,
multi: true,
......
......@@ -2,7 +2,8 @@
<div class="px-1">
<div class="relative shadow-md">
<input type="text" id="hs-leading-icon" name="hs-leading-icon"
class="ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 " placeholder="Search by No. or Name">
class="ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 " placeholder="Search by No. or Name"
[(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>
......@@ -73,25 +74,54 @@
</ng-container>
</tr>
</thead>
<tbody>
<tr *ngFor="let item of[
['001', 'หัวหน้าทีม', 'Team Leander/Supervisor'],
['002', 'ผู้จัดการ', 'Manager'],
['001', 'ผู้บริการระดับสูง', 'Director/Top Management']];let i = index">
<td style="font-size: 12px; " class="flex justify-center">
<tbody *ngIf="!plListFilter().length">
<tr>
<td class="text-center" colspan="100%">
ไม่พบข้อมูล
</td>
</tr>
</tbody>
<tbody *ngIf="plListFilter().length">
<tr
*ngFor="let item of plListFilter() | slice:((currentPage-1) * 10) : (((currentPage-1) * 10) + 10);let i = index">
<td style="font-size: 12px;" class="flex justify-center">
<input type="checkbox" style="margin-right: 20px; transform:scale(0.7)">
{{item[0]}}
{{item.plId}}
</td>
<td style="text-align: center; font-size: 12px;padding-left: 9.7%; padding-right: 50%;">{{item[1]}}</td>
<td style="text-align: center; font-size: 12px;padding-left: 10.5%; padding-right: 50%;">{{item[2]}}</td>
<td class="text-center" >{{item.tdesc}}</td>
<td class="text-center" >{{item.edesc}}</td>
<td class="flex justify-center">
<i class="ti ti-edit cursor-pointer i-gray fs-l px-1" data-hs-overlay="#employee-level-modal-edit"></i>
<i class="ti ti-trash cursor-pointer i-gray fs-l px-1"></i>
<i class="ti ti-edit cursor-pointer i-gray fs-l px-1" (click)="selectPL(item)"
data-hs-overlay="#employee-level-modal-edit"></i>
<i class="ti ti-trash cursor-pointer i-gray fs-l px-1" (click)="deletePL(item)"></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">
<a class="page-link" href="javascript:void(0);" [class.active]="item==currentPage"
(click)="currentPage=item">{{item}}
</a>
<!-- <a aria-label="anchor" class="page-link" href="javascript:void(0);"><i class="ri-more-line"></i>
</a> -->
</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>
......@@ -137,18 +167,20 @@
</div>
<div class="ti-modal-body" style="margin-top: 40px;">
<label for="input-label" class="ti-form-label mt-2rem">รหัสระดับพนักงาน(PL)*</label>
<input type="text" id="input-label" class="ti-form-input w-1/2" placeholder="">
<input type="text" id="input-label" class="ti-form-input w-1/2">
<label for="detail_th" class="ti-form-label mt-2rem">รายละเอียด (ไทย)</label>
<input type="text" id="detail_th" class="ti-form-input h-16" placeholder="">
<input type="text" id="detail_th" class="ti-form-input h-16">
<label for="detail_eng" class="ti-form-label mt-2rem">รายละเอียด (อังกฤษ)</label>
<input type="text" id="detail_eng" class="ti-form-input h-16" placeholder="">
<input type="text" id="detail_eng" class="ti-form-input h-16">
<div class="flex justify-end mt-2rem mb-1rem space-x-4">
<button type="button"
class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
data-hs-overlay="#employee-level-modal-add">
ย้อนกลับ
</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-alert-modal">
บันทึกข้อมูล
</a>
</div>
......@@ -198,18 +230,19 @@
<div class="ti-modal-body" style="margin-top: 40px;">
<label for="input-label" class="ti-form-label mt-2rem">รหัสระดับพนักงาน(PL)</label>
<input type="text" id="input-label" class="ti-form-input w-1/2 bg-input-readonly"
style="background-color: #B3B3B3;" placeholder="" readonly>
style="background-color: #B3B3B3;" [(ngModel)]="pl.plId" readonly>
<label for="detail_th" class="ti-form-label mt-2rem">รายละเอียด (ไทย)</label>
<input type="text" id="detail_th" class="ti-form-input h-16" placeholder="">
<input type="text" id="detail_th" class="ti-form-input h-16" [(ngModel)]="pl.tdesc">
<label for="detail_eng" class="ti-form-label mt-2rem">รายละเอียด (อังกฤษ)</label>
<input type="text" id="detail_eng" class="ti-form-input h-16" placeholder="">
<input type="text" id="detail_eng" class="ti-form-input h-16" [(ngModel)]="pl.edesc">
<div class="flex justify-end mt-2rem mb-1rem space-x-4">
<button type="button"
class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
data-hs-overlay="#employee-level-modal-edit">
data-hs-overlay="#employee-level-modal-edit" data-hs-overlay-close>
ย้อนกลับ
</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-alert-modal" data-hs-overlay-close>
บันทึกข้อมูล
</a>
</div>
......@@ -245,3 +278,38 @@
</div>
</div>
</div>
<div id="employee-level-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="#employee-level-alert-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="#employee-level-alert-modal">
ย้อนกลับ
</button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#employee-level-alert-modal" (click)="addPL()">
บันทึกข้อมูล
</a>
</div>
</div>
</div>
</div>
</div>
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { ToastrService } from 'ngx-toastr';
import { MyPLModel, PLModel } from 'src/app/shared/model/pl.model';
import { PLService } from 'src/app/shared/services/pl.service';
@Component({
selector: 'app-employee-level',
templateUrl: './employee-level.component.html',
styleUrls: ['./employee-level.component.scss']
})
export class EmployeeLevel {
export class EmployeeLevel implements OnInit {
@Input() pathTitle = ['การจัดการข้อมูลองค์กร', 'ข้อมูลลักษณะงาน', 'กลุ่มพนักงาน']
@Output() sendPathTitle: EventEmitter<string[]> = new EventEmitter<string[]>();
activeTab: string = 'tab1'; // กำหนด tab เริ่มต้น
......@@ -15,48 +18,56 @@ export class EmployeeLevel {
this.sendPathTitle.emit(['การจัดการข้อมูลองค์กร', 'ข้อมูลลักษณะงาน', tab.text])
this.activeTab = tab.id;
}
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,
},
"upload": {
isModalOpen: false,
modalSize: 'm',
backdropClose: true,
currentPage = 1
page = Array.from({ length: 1 }, (_, i) => i + 1);
plList: PLModel[] = []
pl: PLModel = new MyPLModel({})
search = ""
constructor(private plService: PLService,
private toastr: ToastrService
) { }
ngOnInit(): void {
this.getPLList()
}
getPLList() {
this.plService.getList().subscribe(response => {
this.plList = response
this.searchChange()
})
}
openModal(name: string, size: string, closeOnBackdrop?: boolean) {
this.modalOptions[name].modalSize = size;
this.modalOptions[name].backdropClose = closeOnBackdrop || false;
this.modalOptions[name].isModalOpen = true;
document.body.style.overflow = 'hidden'; // ล็อก Scroll
searchChange() {
this.currentPage = 1
this.page = Array.from({ length: Math.ceil(this.plListFilter().length / 10) }, (_, i) => i + 1);
}
closeModal(name: string) {
this.modalOptions[name].isModalOpen = false;
// ตรวจสอบว่ามี Modal อื่นเปิดอยู่หรือไม่
if (!this.isAnyModalOpen()) {
document.body.style.overflow = ''; // คืนค่าการ Scroll เฉพาะเมื่อ Modal ทั้งหมดปิดแล้ว
plListFilter() {
return this.plList.filter(x => x.plId.toLowerCase().includes(this.search) ||
x.tdesc.toLowerCase().includes(this.search) ||
x.edesc.toLowerCase().includes(this.search))
}
selectPL(pl: PLModel) {
// this.showSuccess()
this.pl = new MyPLModel(pl)
}
isAnyModalOpen(): boolean {
// Logic ตรวจสอบว่า Modal อื่นยังเปิดอยู่หรือไม่
return Object.values(this.modalOptions).some(modal => modal.isModalOpen); // หากไม่มี Modal อื่นเปิด
// showSuccess() {
// this.toastr.success('This is an example of tip', 'TIP', {
// timeOut: 3000,
// plClass: 'toast-top-right',
// });
// }
addPL() {
// this.plService.post(this.pl).subscribe((response:any) => {
// if (response.success) {
// this.getPLList()
// }
// })
}
deletePL(pl: PLModel) {
// this.plService.delete(new MyPLModel(pl)).subscribe((response:any) => {
// if (response.success) {
// this.getPLList()
// }
// })
}
}
......@@ -46,6 +46,54 @@
</div>
</div> -->
<!-- <app-page-header [pathTitle]="pathTitle"></app-page-header>
<div class="bg-card-white">
</div>
<div class="block-main-content">
<div>
<p class="text-xxl font-bold py-2 px-4 text-primary ltr:ml-5" style="margin-bottom: 15px;">ข้อมูลลักษณะงาน</p>
</div>
<div class="body-content">
<ul class="nav-tabs">
<li class="nav-item" *ngFor="let item of [{id:'tab1',text:'กลุ่มพนักงาน'},
{id:'tab2',text:'ตำเเหน่ง'},
{id:'tab3',text:'ลักษณะงาน'},
{id:'tab4',text:'ประเภทพนักงาน'},
{id:'tab5',text:'ระดับพนักงาน (PL)'}]" (click)="changeTab(item)">
<a [class.active]="activeTab === item.id" class="nav-link">{{item.text}}</a>
</li>
</ul>
<div class="tab-content">
<div *ngIf="activeTab === 'tab1'" class="tab-pane">
<div class="mt-5">
<app-employee-group-unit [pathTitle]="pathTitle"
(sendPathTitle)="pathTitle=$event"></app-employee-group-unit>
</div>
</div>
<div *ngIf="activeTab === 'tab2'" class="tab-pane">
<div class="mt-5">
<app-position-unit [pathTitle]="pathTitle" (sendPathTitle)="pathTitle=$event"></app-position-unit>
</div>
</div>
<div *ngIf="activeTab === 'tab3'" class="tab-pane">
<div class="mt-5">
</div>
</div>
<div *ngIf="activeTab === 'tab4'" class="tab-pane">
<div class="mt-5">
<app-employee-categories [pathTitle]="pathTitle"
(sendPathTitle)="pathTitle=$event"></app-employee-categories>
</div>
</div>
<div *ngIf="activeTab === 'tab5'" class="tab-pane">
<div class="mt-5">
<app-employee-level [pathTitle]="pathTitle" (sendPathTitle)="pathTitle=$event"></app-employee-level>
</div>
</div>
</div>
</div>
</div> -->
<app-page-header [pathTitle]="pathTitle"></app-page-header>
<div class="bg-card-white">
</div>
......
......@@ -2,7 +2,8 @@
<div class="px-1">
<div class="relative shadow-md">
<input type="text" id="hs-leading-icon" name="hs-leading-icon"
class="ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 " placeholder="Search by No. or Name">
class="ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 " placeholder="Search by No. or Name"
[(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>
......@@ -65,29 +66,54 @@
</ng-container>
</tr>
</thead>
<tbody>
<tr *ngFor="let item of[
['000001', 'หัวหน้าแผนกสำนักงานอาวุโส', 'Senior Office Supervisor'],
['000002', 'รักษาการเลขานุการบริหารเบื้องต้น', 'Junior Secretary (Acting)'],
['000003', 'ผู้บริหารระดับคุณภาพ', 'BPD Quality Management Office'],
['000004', 'ช่างเทคนิค', 'Technician'],
['000005', 'หัวหน้าหน่วยบุคคล', 'Chief Human Resources Office'],
['000006', 'ผู้ช่วยหัวหน้าหน่วย', 'Assistant of Unit Chief'],
['000007', 'กรรมการบริษัท', 'Director'],];let i = index">
<tbody *ngIf="!positionListFilter().length">
<tr>
<td class="text-center" colspan="100%">
ไม่พบข้อมูล
</td>
</tr>
</tbody>
<tbody *ngIf="positionListFilter().length">
<tr
*ngFor="let item of positionListFilter() | slice:((currentPage-1) * 10) : (((currentPage-1) * 10) + 10);let i = index">
<td style="font-size: 12px;" class="flex justify-center">
<input type="checkbox" style="margin-right: 20px; transform:scale(0.7)">
{{item[0]}}
{{item.positionId}}
</td>
<td style="text-align: center; font-size: 12px;" >{{item[1]}}</td>
<td style="text-align: center; font-size: 12px;" >{{item[2]}}</td>
<td class="text-center" >{{item.tdesc}}</td>
<td class="text-center" >{{item.edesc}}</td>
<td class="flex justify-center">
<i class="ti ti-edit cursor-pointer i-gray fs-l px-1" data-hs-overlay="#position-unit-component-modal-edit"></i>
<i class="ti ti-trash cursor-pointer i-gray fs-l px-1"></i>
<i class="ti ti-edit cursor-pointer i-gray fs-l px-1" (click)="selectPosition(item)"
data-hs-overlay="#position-unit-component-modal-edit"></i>
<i class="ti ti-trash cursor-pointer i-gray fs-l px-1" (click)="deletePosition(item)"></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">
<a class="page-link" href="javascript:void(0);" [class.active]="item==currentPage"
(click)="currentPage=item">{{item}}
</a>
<!-- <a aria-label="anchor" class="page-link" href="javascript:void(0);"><i class="ri-more-line"></i>
</a> -->
</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>
......@@ -144,7 +170,8 @@
data-hs-overlay="#position-unit-component-modal-add">
ย้อนกลับ
</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="#position-unit-component-alert-modal">
บันทึกข้อมูล
</a>
</div>
......@@ -193,18 +220,19 @@
</div>
<div class="ti-modal-body " style="margin-top: 40px;">
<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" value="01" readonly style="background-color: #B3B3B3;">
<input type="text" id="input-label" class="ti-form-input w-1/2 bg-input-readonly" [(ngModel)]="position.positionId" readonly style="background-color: #B3B3B3;">
<label for="detail_th" class="ti-form-label mt-2rem">รายละเอียดฝ่าย (ไทย)</label>
<input type="text" id="detail_th" class="ti-form-input" value="การเงินการคลัง">
<input type="text" id="detail_th" class="ti-form-input" [(ngModel)]="position.tdesc">
<label for="detail_eng" class="ti-form-label mt-2rem">รายละเอียดฝ่าย (อังกฤษ)</label>
<input type="text" id="detail_eng" class="ti-form-input" placeholder="">
<input type="text" id="detail_eng" class="ti-form-input" [(ngModel)]="position.edesc">
<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="#position-unit-component-modal-edit">
data-hs-overlay="#position-unit-component-modal-edit" data-hs-overlay-close>
ย้อนกลับ
</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="#position-unit-component-alert-modal" data-hs-overlay-close>
บันทึกข้อมูล
</a>
</div>
......@@ -239,3 +267,38 @@
</div>
</div>
</div>
<div id="position-unit-component-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="#position-unit-component-alert-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="#position-unit-component-alert-modal">
ย้อนกลับ
</button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#position-unit-component-alert-modal" (click)="addPosition()">
บันทึกข้อมูล
</a>
</div>
</div>
</div>
</div>
</div>
\ No newline at end of file
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { ToastrService } from 'ngx-toastr';
import { MyPositionModel, PositionModel } from 'src/app/shared/model/position.model';
import { PositionService } from 'src/app/shared/services/position.service';
@Component({
selector: 'app-position-unit',
templateUrl: './position-unit.component.html',
styleUrls: ['./position-unit.component.scss']
})
export class PositionUnitComponent {
@Input() pathTitle = ['การจัดการข้อมูลองค์กร', 'ทะเบียนบริษัท', 'สาขาและหน่วยธุรกิจ']
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.sendPathTitle.emit(['การจัดการข้อมูลองค์กร', 'ข้อมูลลักษณะงาน', tab.text])
this.activeTab = tab.id;
}
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,
},
"upload":{
isModalOpen: false,
modalSize: 'm',
backdropClose: true,
currentPage = 1
page = Array.from({ length: 1 }, (_, i) => i + 1);
positionList: PositionModel[] = []
position: PositionModel = new MyPositionModel({})
search = ""
constructor(private positionService: PositionService,
private toastr: ToastrService
) { }
ngOnInit(): void {
this.getPositionList()
}
getPositionList() {
this.positionService.getList().subscribe(response => {
this.positionList = response
this.searchChange()
})
}
openModal(name: string, size: string, closeOnBackdrop?: boolean) {
this.modalOptions[name].modalSize = size;
this.modalOptions[name].backdropClose = closeOnBackdrop || false;
this.modalOptions[name].isModalOpen = true;
document.body.style.overflow = 'hidden'; // ล็อก Scroll
searchChange() {
this.currentPage = 1
this.page = Array.from({ length: Math.ceil(this.positionListFilter().length / 10) }, (_, i) => i + 1);
}
closeModal(name: string) {
this.modalOptions[name].isModalOpen = false;
// ตรวจสอบว่ามี Modal อื่นเปิดอยู่หรือไม่
if (!this.isAnyModalOpen()) {
document.body.style.overflow = ''; // คืนค่าการ Scroll เฉพาะเมื่อ Modal ทั้งหมดปิดแล้ว
positionListFilter() {
return this.positionList.filter(x => x.positionId.toLowerCase().includes(this.search) ||
x.tdesc.toLowerCase().includes(this.search) ||
x.edesc.toLowerCase().includes(this.search))
}
selectPosition(position: PositionModel) {
// this.showSuccess()
this.position = new MyPositionModel(position)
}
isAnyModalOpen(): boolean {
// Logic ตรวจสอบว่า Modal อื่นยังเปิดอยู่หรือไม่
return Object.values(this.modalOptions).some(modal => modal.isModalOpen); // หากไม่มี Modal อื่นเปิด
showSuccess() {
this.toastr.success('This is an example of tip', 'TIP', {
timeOut: 3000,
positionClass: 'toast-top-right',
});
}
addPosition() {
// this.positionService.post(this.position).subscribe((response:any) => {
// if (response.success) {
// this.getPositionList()
// }
// })
}
deletePosition(position: PositionModel) {
// this.positionService.delete(new MyPositionModel(position)).subscribe((response:any) => {
// if (response.success) {
// this.getPositionList()
// }
// })
}
}
export interface PLModel {
plId: string;
tdesc: string;
edesc: string;
}
export class MyPLModel implements PLModel {
plId: string;
tdesc: string;
edesc: string;
constructor(data: Partial<PLModel>) {
this.plId = data.plId || ""
this.tdesc = data.tdesc || ""
this.edesc = data.edesc || ""
}
}
export interface PositionModel {
positionId: string;
tdesc: string;
edesc: string;
}
export class MyPositionModel implements PositionModel {
positionId: string;
tdesc: string;
edesc: string;
constructor(data: Partial<PositionModel>) {
this.positionId = data.positionId || ""
this.tdesc = data.tdesc || ""
this.edesc = data.edesc || ""
}
}
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { environment } from 'src/environments/environment';
import { PLModel } from '../model/pl.model';
@Injectable({
providedIn: 'root'
})
export class PLService {
api = "/pl"
urlApi = environment.baseUrl + this.api
constructor(private http: HttpClient) {
}
getById(plId:string): Observable<PLModel> {
return this.http.get<PLModel>(this.urlApi + "/" + plId)
}
getList(): Observable<PLModel[]> {
return this.http.get<PLModel[]>(this.urlApi + "/lists")
}
// post(body: PLModel) {
// return this.http.post(this.urlApi, body)
// }
// delete(body: PLModel) {
// const options = {
// headers: new HttpHeaders({
// "Content-Type": "application/json",
// }),
// body: body
// };
// return this.http.delete(this.urlApi, options)
// }
}
\ No newline at end of file
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { environment } from 'src/environments/environment';
import { PositionModel } from '../model/position.model';
@Injectable({
providedIn: 'root'
})
export class PositionService {
api = "/position"
urlApi = environment.baseUrl + this.api
constructor(private http: HttpClient) {
}
getById(positionId:string): Observable<PositionModel> {
return this.http.get<PositionModel>(this.urlApi + "/" + positionId)
}
getList(): Observable<PositionModel[]> {
return this.http.get<PositionModel[]>(this.urlApi + "/lists")
}
// post(body: PositionModel) {
// return this.http.post(this.urlApi, body)
// }
// delete(body: PositionModel) {
// const options = {
// headers: new HttpHeaders({
// "Content-Type": "application/json",
// }),
// body: body
// };
// return this.http.delete(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