Commit 670180e4 by Nattana Chaiyamat

ทะเบียนพนักงาน

parent 75c45679
<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">
<div class="flex items-center">
<input type="checkbox" class="ti-form-checkbox pointer-events-none" id="hs-default-checkbox"
[(ngModel)]="isDataListChecked">
<label for="hs-default-checkbox" class="text-sm text-gray-500 mx-2 pointer-events-none">
{{numDataListChecked}} Selected</label>
</div>
<div class="mx-1 flex items-center">
<button (click)="isDataListCheckedAll = !isDataListCheckedAll;dataListCheckAll()" id='check-boxall'
class="focus:ring-2 focus:ring-primary rounded-sm flex item-center">
<i class="fs-l transition-all duration-200"
[ngClass]="{'ri-checkbox-multiple-line text-gray-500': !isDataListCheckedAll, 'ri-checkbox-multiple-fill text-primary': isDataListCheckedAll}"></i>
</button>
<label class="text-sm text-gray-500 ml-2" for="check-boxall">Select All</label>
</div>
</div>
<div class="flex justify-end"> <div class="flex justify-end">
<div class="px-1"> <div class="px-1">
<div class="relative shadow-md"> <div class="relative shadow-md">
<input type="text" class="ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 " placeholder="Search by No. or Name" <input type="text" 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">
<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>
...@@ -38,7 +21,7 @@ ...@@ -38,7 +21,7 @@
</div> </div>
<div class="px-1"> <div class="px-1">
<button type="button" class="ti-btn ti-btn-soft-secondary h-45px m-0 shadow-md" <button type="button" class="ti-btn ti-btn-soft-secondary h-45px m-0 shadow-md"
data-hs-overlay="#sub-employee-registration-modal" (click)="modalType='add';selectEmployee()"> data-hs-overlay="#sub-employee-registration-modal" (click)="currentModal='add';selectEmployee()">
<i class="ri-add-line"></i> <i class="ri-add-line"></i>
Add Add
</button> </button>
...@@ -46,90 +29,21 @@ ...@@ -46,90 +29,21 @@
<div class="px-1"> <div class="px-1">
<button class="ti-btn ti-btn-soft-danger h-45px m-0 shadow-md" <button class="ti-btn ti-btn-soft-danger h-45px m-0 shadow-md"
data-hs-overlay="#sub-employee-registration-alert-delete-modal" data-hs-overlay="#sub-employee-registration-alert-delete-modal"
(click)="modalType='deleteGroup';selectEmployee()"> (click)="currentModal='delete';selectEmployee()">
<i class="ri-delete-bin-6-line"></i> <i class="ri-delete-bin-6-line"></i>
Delete Delete
</button> </button>
</div> </div>
<!-- <div class="px-1">
<button class="ti-btn ti-btn-soft-info h-45px m-0 shadow-md">
<i class="ri-printer-line"></i>
Print
</button>
</div> -->
<!-- <div class="px-1">
<button 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> </div>
<div class="page px-rem"> <div class="page px-rem">
<div class="overflow-auto table-bordered rounded-t-md"> <app-datagrid-syncfution [searchSettings]="searchSettings" [searchText]="search" [dataSource]="employee.dataList"
<div class="overflow-auto shadow-md rounded-t-md"> [columns]="columns" [selectedItems]="selectedItems" modalName="#sub-employee-registration-modal"
<table class="ti-custom-table ti-custom-table-head ti-custom-table-hover"> (sendSelectData)="currentModal='update';selectEmployee($event)" (sendSelectedItems)="onSelectItemChange($event)">
<thead> </app-datagrid-syncfution>
<tr>
<ng-container
*ngFor="let item of ['','รหัสพนักงาน','ชื่อ','นามสกุล','ตำแหน่ง','การจัดการ']; let f = first; let l = last; let i = index">
<th scope="col" class=" px-10px py-10px bg-soft-secondary text-primary !text-center">
<span class="font-size-12px font-weight-700">{{ item }}</span>
<!-- <div class="absolute top-1/2 transform -translate-y-1/2 right-0" *ngIf="!l&&!f">
<i class="ti ti-dots-vertical fs-l"></i>
</div> -->
</th>
</ng-container>
</tr>
</thead>
<tbody *ngIf="employee.loading">
<tr>
<td class="text-center" colspan="100%">
<div *ngFor="let item of [1,2,3]" class="ti-spinner w-8 h-8 text-secondary mx-1" role="status"
aria-label="loading">
<span class="sr-only">Loading...</span>
</div>
</td>
</tr>
</tbody>
<tbody *ngIf="!employee.loading&&!employeeFilter().length">
<tr>
<td class="text-center" colspan="100%">
ไม่พบข้อมูล
</td>
</tr>
</tbody>
<tbody *ngIf="!employee.loading&&employeeFilter().length">
<tr
*ngFor="let item of employeeFilter() | slice:((currentPage-1) * pageSize) : (((currentPage-1) * pageSize) + pageSize);let i = index">
<td class="text-center">
<input type="checkbox" class="ti-form-checkbox cursor-pointer" id="checkbox-{{item.data.employeeId}}"
[(ngModel)]="item.check" (ngModelChange)="dataListCheck()">
</td>
<td class="text-center">
<label for="checkbox-{{item.data.employeeId}}">&nbsp;{{item.data.employeeId}}</label>
</td>
<td>{{item.data.fname}}</td>
<td>{{item.data.lname}}</td>
<td>{{item.data.position.tdesc}}</td>
<td class="flex justify-center">
<i class="ti ti-edit cursor-pointer i-gray fs-l px-1" data-hs-overlay="#sub-employee-registration-modal"
(click)="modalType='update';selectEmployee(item.data)"></i>
<!-- <i class="ti ti-trash cursor-pointer i-gray fs-l px-1"
data-hs-overlay="#sub-employee-registration-alert-delete-modal"
(click)="modalType='delete';selectEmployee(item.data)"></i> -->
</td>
</tr>
</tbody>
</table>
</div>
</div>
<app-pagination [totalItems]="employeeFilter().length" [pageSize]="pageSize" (pageChange)="currentPage = $event"
(pageSizeChange)="pageSize = $event;currentPage = 1"></app-pagination>
</div>
</div>
<div id="sub-employee-registration-modal" class="hs-overlay hidden ti-modal"> <div id="sub-employee-registration-modal" class="hs-overlay hidden ti-modal">
...@@ -151,10 +65,6 @@ ...@@ -151,10 +65,6 @@
<div class="w-full flex justify-end"> <div class="w-full flex justify-end">
<div class="absolute flex"> <div class="absolute flex">
<div class="px-1"> <div class="px-1">
<!-- <button 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> -->
<button type="button" class="ti-btn ti-btn-soft-indigo h-45px m-0 shadow-md" (click)="selectEmployee()"> <button type="button" class="ti-btn ti-btn-soft-indigo h-45px m-0 shadow-md" (click)="selectEmployee()">
<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"
...@@ -178,13 +88,13 @@ ...@@ -178,13 +88,13 @@
<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">รหัสพนักงาน<span <label class="col-span-3 ti-form-label text-primary mt-2 align-center">รหัสพนักงาน<span
class="text-danger">* class="text-danger">*
<ng-container *ngIf="(modalType=='add')&&checkPrimary()"> <ng-container *ngIf="(currentModal=='add')&&checkPrimary()">
<br>รหัสพนักงานซ้ำ <br>รหัสพนักงานซ้ำ
</ng-container> </ng-container>
</span></label> </span></label>
<input type="text" class="col-span-6 ti-form-input" [ngClass]="{'bg-input-readonly':modalType=='update'}" <input type="text" class="col-span-6 ti-form-input" [ngClass]="{'bg-input-readonly':currentModal=='update'}"
oninput="this.value = this.value.replace(/[^a-zA-Z0-9\u0E00-\uFFFF]/g, '')" maxlength="15" oninput="this.value = this.value.replace(/[^a-zA-Z0-9\u0E00-\uFFFF]/g, '')" maxlength="15"
[readonly]="modalType=='update'" [(ngModel)]="employee.select.employeeId"> [readonly]="currentModal=='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-2 align-center">ชื่อ-นามสกุล<span <label class="col-span-3 ti-form-label text-primary mt-2 align-center">ชื่อ-นามสกุล<span
...@@ -592,8 +502,8 @@ ...@@ -592,8 +502,8 @@
</button> </button>
<button type="button" class="ti-btn ti-btn-success" <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()||(modalType=='add'&&checkPrimary())" [class.ti-btn-disabled]="checkEmployeeModel()||(currentModal=='add'&&checkPrimary())"
[disabled]="checkEmployeeModel()||(modalType=='add'&&checkPrimary())"> [disabled]="checkEmployeeModel()||(currentModal=='add'&&checkPrimary())">
บันทึกข้อมูล บันทึกข้อมูล
</button> </button>
</div> </div>
...@@ -665,7 +575,7 @@ ...@@ -665,7 +575,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-add-modal" (click)="updateEmployeeList(modalType)"> data-hs-overlay="#sub-employee-registration-alert-add-modal" (click)="updateEmployeeList(currentModal)">
บันทึกข้อมูล บันทึกข้อมูล
</a> </a>
</div> </div>
...@@ -691,10 +601,10 @@ ...@@ -691,10 +601,10 @@
</div> </div>
<div class="ti-modal-body "> <div class="ti-modal-body ">
<p class="mt-1 text-gray-800 dark:text-white/70"> <p class="mt-1 text-gray-800 dark:text-white/70">
<ng-container *ngIf="numDataListChecked"> <ng-container *ngIf="numSelectItem()y">
ยืนยันการลบข้อมูลหรือไม่ ยืนยันการลบข้อมูลหรือไม่
</ng-container> </ng-container>
<ng-container *ngIf="!numDataListChecked"> <ng-container *ngIf="!numSelectItem()y">
เลือกข้อมูลที่ต้องการลบ เลือกข้อมูลที่ต้องการลบ
</ng-container>! </ng-container>!
</p> </p>
...@@ -706,8 +616,8 @@ ...@@ -706,8 +616,8 @@
ย้อนกลับ ย้อนกลับ
</button> </button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);" <a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#sub-employee-registration-alert-delete-modal" (click)="updateEmployeeList(modalType)" data-hs-overlay="#sub-employee-registration-alert-delete-modal" (click)="updateEmployeeList(currentModal)"
*ngIf="numDataListChecked"> *ngIf="numSelectItem()y">
ลบข้อมูล ลบข้อมูล
</a> </a>
</div> </div>
......
...@@ -32,14 +32,7 @@ import { Bu7Model, MyBu7Model } from 'src/app/shared/model/bu7.model'; ...@@ -32,14 +32,7 @@ import { Bu7Model, MyBu7Model } from 'src/app/shared/model/bu7.model';
import { EmpStatusService } from 'src/app/shared/services/emp-status.service'; import { EmpStatusService } from 'src/app/shared/services/emp-status.service';
import { StatusModel, MyStatusModel } from 'src/app/shared/model/status.model'; import { StatusModel, MyStatusModel } from 'src/app/shared/model/status.model';
import { MyBossModel } from 'src/app/shared/model/boss.model'; import { MyBossModel } from 'src/app/shared/model/boss.model';
export interface DataEmployee { import { ColumnModel } from '@syncfusion/ej2-grids';
loading: boolean
select: EmployeeModel | any
dataList: {
check: boolean
data: EmployeeModel
}[]
}
export interface DataModal { export interface DataModal {
search: string, search: string,
currentPage: number, currentPage: number,
...@@ -53,13 +46,36 @@ export interface DataModal { ...@@ -53,13 +46,36 @@ export interface DataModal {
}) })
export class SubEmployeeRegistrationComponent { export class SubEmployeeRegistrationComponent {
employee: DataEmployee = { loading: false, select: new MyEmployeeModel({}), dataList: [] } employee: { loading: boolean, select: EmployeeModel | any, dataList: EmployeeModel[] } = { loading: false, select: new MyEmployeeModel(), dataList: [] }
currentPage = 1
pageSize = 10
page = Array.from({ length: 1 }, (_, i) => i + 1);
search = "" search = ""
modalType: 'add' | 'update' | 'delete' | 'deleteGroup' = 'add' currentModal: 'add' | 'update' | 'delete' = 'add'
columns: ColumnModel[] = [{
field: "employeeId",
headerText: "รหัสพนักงาน",
type: "string",
isPrimaryKey: true,
},
{
field: "fname",
headerText: "ชื่อ",
type: "string"
},
{
field: "lname",
headerText: "นามสกุล",
type: "string"
},
{
field: "position.tdesc",
headerText: "ตำแหน่ง",
type: "string"
}]
searchSettings = {
fields: ['employeeId', 'fname', 'lname', 'position.tdesc'],
operator: 'contains',
ignoreCase: false
}
selectedItems: { key: string, count: number, data: Map<string, boolean> } = { key: '', count: 0, data: new Map<string, boolean>() };
modal: DataModal = { modal: DataModal = {
search: "", search: "",
...@@ -68,10 +84,6 @@ export class SubEmployeeRegistrationComponent { ...@@ -68,10 +84,6 @@ export class SubEmployeeRegistrationComponent {
pageSize: 10 pageSize: 10
} }
numDataListChecked = 0
isDataListChecked = false
isDataListCheckedAll = false
selectedFile: File | null = null; selectedFile: File | null = null;
selectedFileName: string = 'กรุณาเลือกไฟล์'; selectedFileName: string = 'กรุณาเลือกไฟล์';
...@@ -186,7 +198,6 @@ export class SubEmployeeRegistrationComponent { ...@@ -186,7 +198,6 @@ export class SubEmployeeRegistrationComponent {
next: response => { next: response => {
this.pl.dataList = response.map((x: any) => new MyPLModel(x)) this.pl.dataList = response.map((x: any) => new MyPLModel(x))
this.pl.loading = false this.pl.loading = false
this.searchChange()
this.cdr.detectChanges() this.cdr.detectChanges()
}, error: error => { }, error: error => {
this.pl.loading = false this.pl.loading = false
...@@ -206,7 +217,6 @@ export class SubEmployeeRegistrationComponent { ...@@ -206,7 +217,6 @@ export class SubEmployeeRegistrationComponent {
next: response => { next: response => {
this.empType.dataList = response.map((x: any) => new MyEmpTypeModel(x)) this.empType.dataList = response.map((x: any) => new MyEmpTypeModel(x))
this.empType.loading = false this.empType.loading = false
this.searchChange()
this.cdr.detectChanges() this.cdr.detectChanges()
}, error: error => { }, error: error => {
this.empType.loading = false this.empType.loading = false
...@@ -226,7 +236,6 @@ export class SubEmployeeRegistrationComponent { ...@@ -226,7 +236,6 @@ export class SubEmployeeRegistrationComponent {
next: response => { next: response => {
this.branch.dataList = response.map((x: any) => new MyBranchModel(x)) this.branch.dataList = response.map((x: any) => new MyBranchModel(x))
this.branch.loading = false this.branch.loading = false
this.searchChange()
this.cdr.detectChanges() this.cdr.detectChanges()
}, error: error => { }, error: error => {
this.branch.loading = false this.branch.loading = false
...@@ -246,7 +255,6 @@ export class SubEmployeeRegistrationComponent { ...@@ -246,7 +255,6 @@ export class SubEmployeeRegistrationComponent {
next: response => { next: response => {
this.jobcode.dataList = response.map((x: any) => new MyJobCodeModel(x)) this.jobcode.dataList = response.map((x: any) => new MyJobCodeModel(x))
this.jobcode.loading = false this.jobcode.loading = false
this.searchChange()
this.cdr.detectChanges() this.cdr.detectChanges()
}, error: error => { }, error: error => {
this.jobcode.loading = false this.jobcode.loading = false
...@@ -266,7 +274,6 @@ export class SubEmployeeRegistrationComponent { ...@@ -266,7 +274,6 @@ export class SubEmployeeRegistrationComponent {
next: response => { next: response => {
this.position.dataList = response.map((x: any) => new MyPositionModel(x)) this.position.dataList = response.map((x: any) => new MyPositionModel(x))
this.position.loading = false this.position.loading = false
this.searchChange()
this.cdr.detectChanges() this.cdr.detectChanges()
}, error: error => { }, error: error => {
this.position.loading = false this.position.loading = false
...@@ -286,7 +293,6 @@ export class SubEmployeeRegistrationComponent { ...@@ -286,7 +293,6 @@ export class SubEmployeeRegistrationComponent {
next: response => { next: response => {
this.bu1.dataList = response?.map((x: any) => new MyBu1Model(x)) || [] this.bu1.dataList = response?.map((x: any) => new MyBu1Model(x)) || []
this.bu1.loading = false this.bu1.loading = false
this.searchChange()
this.cdr.detectChanges() this.cdr.detectChanges()
}, error: error => { }, error: error => {
this.bu1.loading = false this.bu1.loading = false
...@@ -320,7 +326,6 @@ export class SubEmployeeRegistrationComponent { ...@@ -320,7 +326,6 @@ export class SubEmployeeRegistrationComponent {
next: response => { next: response => {
this.bu2.dataList = response?.map((x: any) => new MyBu2Model(x)) || [] this.bu2.dataList = response?.map((x: any) => new MyBu2Model(x)) || []
this.bu2.loading = false this.bu2.loading = false
this.searchChange()
this.cdr.detectChanges() this.cdr.detectChanges()
}, error: error => { }, error: error => {
this.bu2.loading = false this.bu2.loading = false
...@@ -353,7 +358,6 @@ export class SubEmployeeRegistrationComponent { ...@@ -353,7 +358,6 @@ export class SubEmployeeRegistrationComponent {
next: response => { next: response => {
this.bu3.dataList = response?.map((x: any) => new MyBu3Model(x)) || [] this.bu3.dataList = response?.map((x: any) => new MyBu3Model(x)) || []
this.bu3.loading = false this.bu3.loading = false
this.searchChange()
this.cdr.detectChanges() this.cdr.detectChanges()
}, error: error => { }, error: error => {
this.bu3.loading = false this.bu3.loading = false
...@@ -385,7 +389,6 @@ export class SubEmployeeRegistrationComponent { ...@@ -385,7 +389,6 @@ export class SubEmployeeRegistrationComponent {
next: response => { next: response => {
this.bu4.dataList = response?.map((x: any) => new MyBu4Model(x)) || [] this.bu4.dataList = response?.map((x: any) => new MyBu4Model(x)) || []
this.bu4.loading = false this.bu4.loading = false
this.searchChange()
this.cdr.detectChanges() this.cdr.detectChanges()
}, error: error => { }, error: error => {
this.bu4.loading = false this.bu4.loading = false
...@@ -416,7 +419,6 @@ export class SubEmployeeRegistrationComponent { ...@@ -416,7 +419,6 @@ export class SubEmployeeRegistrationComponent {
next: response => { next: response => {
this.bu5.dataList = response?.map((x: any) => new MyBu5Model(x)) || [] this.bu5.dataList = response?.map((x: any) => new MyBu5Model(x)) || []
this.bu5.loading = false this.bu5.loading = false
this.searchChange()
this.cdr.detectChanges() this.cdr.detectChanges()
}, error: error => { }, error: error => {
this.bu5.loading = false this.bu5.loading = false
...@@ -446,7 +448,6 @@ export class SubEmployeeRegistrationComponent { ...@@ -446,7 +448,6 @@ export class SubEmployeeRegistrationComponent {
next: response => { next: response => {
this.bu6.dataList = response?.map((x: any) => new MyBu6Model(x)) || [] this.bu6.dataList = response?.map((x: any) => new MyBu6Model(x)) || []
this.bu6.loading = false this.bu6.loading = false
this.searchChange()
this.cdr.detectChanges() this.cdr.detectChanges()
}, error: error => { }, error: error => {
this.bu6.loading = false this.bu6.loading = false
...@@ -475,7 +476,6 @@ export class SubEmployeeRegistrationComponent { ...@@ -475,7 +476,6 @@ export class SubEmployeeRegistrationComponent {
next: response => { next: response => {
this.bu7.dataList = response?.map((x: any) => new MyBu7Model(x)) || [] this.bu7.dataList = response?.map((x: any) => new MyBu7Model(x)) || []
this.bu7.loading = false this.bu7.loading = false
this.searchChange()
this.cdr.detectChanges() this.cdr.detectChanges()
}, error: error => { }, error: error => {
this.bu7.loading = false this.bu7.loading = false
...@@ -498,7 +498,6 @@ export class SubEmployeeRegistrationComponent { ...@@ -498,7 +498,6 @@ export class SubEmployeeRegistrationComponent {
next: response => { next: response => {
this.empGroup.dataList = response.map((x: any) => new MyEmpGroupModel(x)) this.empGroup.dataList = response.map((x: any) => new MyEmpGroupModel(x))
this.empGroup.loading = false this.empGroup.loading = false
this.searchChange()
this.cdr.detectChanges() this.cdr.detectChanges()
}, error: error => { }, error: error => {
this.empGroup.loading = false this.empGroup.loading = false
...@@ -517,12 +516,14 @@ export class SubEmployeeRegistrationComponent { ...@@ -517,12 +516,14 @@ export class SubEmployeeRegistrationComponent {
this.employee.loading = true this.employee.loading = true
this.employeeService.getList().subscribe({ this.employeeService.getList().subscribe({
next: response => { next: response => {
this.employee.dataList = response.map((x: any) => ({ check: false, data: new MyEmployeeModel(x) })) this.employee.dataList = response.map(x => {
this.selectedItems.data.set(x.employeeId, false)
return new MyEmployeeModel(x)
})
this.employeeModal.dataList = response.filter(x => x.employeeId != this.decodeJWT(sessionStorage.getItem("accessToken") || '').employeeid).map((x: any) => new MyEmployeeModel(x)) this.employeeModal.dataList = response.filter(x => x.employeeId != this.decodeJWT(sessionStorage.getItem("accessToken") || '').employeeid).map((x: any) => new MyEmployeeModel(x))
this.selectedItems.key = 'employeeId'
this.selectedItems.count = 0
this.employee.loading = false this.employee.loading = false
this.isDataListCheckedAll = false
this.dataListCheckAll()
this.searchChange()
this.cdr.detectChanges() this.cdr.detectChanges()
}, error: error => { }, error: error => {
this.employee.loading = false this.employee.loading = false
...@@ -538,26 +539,21 @@ export class SubEmployeeRegistrationComponent { ...@@ -538,26 +539,21 @@ export class SubEmployeeRegistrationComponent {
} }
updateEmployeeList(type: 'add' | 'update' | 'delete' | 'deleteGroup') { updateEmployeeList(type: 'add' | 'update' | 'delete') {
let body = this.employee.select this.employee.loading = true
let body: any = this.employee.select
switch (type) { switch (type) {
case 'delete': { case 'delete': {
body = [this.employee.select] const selectedKeys = Array.from(this.selectedItems.data.keys());
break; body = this.employee.dataList.filter(x => selectedKeys.includes(x.employeeId) && this.selectedItems.data.get(x.employeeId)).map(x => new MyEmployeeModel(x))
}
case 'deleteGroup': {
body = this.employee.dataList.filter(x => x.check).map(x => new MyEmployeeModel(x.data))
type = 'delete'
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) {
this.showAlert(response.message, 'success') this.showAlert(response.message, 'success')
this.search = "" this.search = ""
this.searchChange()
this.getEmployeeList() this.getEmployeeList()
} else { } else {
this.showAlert(response.message, 'error') this.showAlert(response.message, 'error')
...@@ -571,20 +567,8 @@ export class SubEmployeeRegistrationComponent { ...@@ -571,20 +567,8 @@ export class SubEmployeeRegistrationComponent {
} }
}) })
} }
searchChange() {
this.currentPage = 1
this.page = Array.from({ length: Math.ceil(this.employeeFilter().length / 10) }, (_, i) => i + 1);
this.dataListCheck()
}
employeeFilter() {
return this.employee.dataList.filter(x =>
x.data.employeeId.toLowerCase().includes(this.search.toLowerCase()) ||
x.data.fname.toLowerCase().includes(this.search.toLowerCase()) ||
x.data.lname.toLowerCase().includes(this.search.toLowerCase()) ||
x.data.position.tdesc.toLowerCase().includes(this.search.toLowerCase()))
}
selectEmployee(data?: EmployeeModel) { selectEmployee(data?: EmployeeModel) {
if (this.modalType == 'update' && !data) { if (this.currentModal == 'update' && !data) {
this.employee.select = { ...new MyEmployeeModel({ employeeId: this.employee.select.employeeId }), dateIso: '', dateEndIso: '2100-12-31' } this.employee.select = { ...new MyEmployeeModel({ employeeId: this.employee.select.employeeId }), dateIso: '', dateEndIso: '2100-12-31' }
this.employee.select.resignDate = '2100-12-31' this.employee.select.resignDate = '2100-12-31'
this.employee.select.status = new MyStatusModel(this.empStatus.dataList[0]) this.employee.select.status = new MyStatusModel(this.empStatus.dataList[0])
...@@ -660,22 +644,6 @@ export class SubEmployeeRegistrationComponent { ...@@ -660,22 +644,6 @@ export class SubEmployeeRegistrationComponent {
}) })
} }
dataListCheckAll() {
const selectAll = this.isDataListCheckedAll;
this.employee.dataList.filter(x =>
x.data.employeeId.toLowerCase().includes(this.search.toLowerCase()) ||
x.data.fname.toLowerCase().includes(this.search.toLowerCase()) ||
x.data.lname.toLowerCase().includes(this.search.toLowerCase()) ||
x.data.position.tdesc.toLowerCase().includes(this.search.toLowerCase()) ||
x.data.jobCode.tdesc.toLowerCase().includes(this.search.toLowerCase())).forEach(x => x.check = selectAll);
this.dataListCheck();
}
dataListCheck() {
const dataCheck = this.employeeFilter();
this.isDataListCheckedAll = dataCheck.length ? dataCheck.every(x => x.check) : false;
this.numDataListChecked = this.employee.dataList.filter(x => x.check).length;
this.isDataListChecked = Boolean(this.numDataListChecked)
}
checkEmployeeModel() { checkEmployeeModel() {
let disable = false let disable = false
...@@ -712,6 +680,16 @@ export class SubEmployeeRegistrationComponent { ...@@ -712,6 +680,16 @@ export class SubEmployeeRegistrationComponent {
} }
checkPrimary() { checkPrimary() {
return this.employee.dataList.find(x => x.data.employeeId == this.employee.select.employeeId) return this.employee.dataList.find(x => x.employeeId == this.employee.select.employeeId)
}
numSelectItem() {
const selectedKeys = Array.from(this.selectedItems.data.keys());
const num = this.employee.dataList.filter(x => selectedKeys.includes(x.employeeId) && this.selectedItems.data.get(x.employeeId)).length
return num
}
onSelectItemChange(arg: any) {
this.selectedItems = arg
} }
} }
...@@ -221,8 +221,10 @@ export class DatagridSyncfutionComponent implements OnInit { ...@@ -221,8 +221,10 @@ export class DatagridSyncfutionComponent implements OnInit {
} }
filterData(text: string, fields: string[]): any[] { filterData(text: string, fields: string[]): any[] {
return this.dataSource.filter(item => { return this.dataSource.filter(item => {
return fields.some(field => return fields.some(field => {
item[field]?.toString().toLowerCase().includes(text.toLowerCase()) const value = field.split('.').reduce((obj, key) => obj?.[key], item);
return value?.toString().toLowerCase().includes(text.toLowerCase());
}
); );
}); });
} }
......
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