Commit d64e63f4 by Nattana Chaiyamat

ส่วนย่อย2

parent 6e853dbf
......@@ -132,6 +132,7 @@ export class DepartmentListComponent implements OnInit {
getBu2List() {
this.bu2ListLoading = true
this.selectedItems.data.clear()
this.bu2Service.getList().subscribe({
next: response => {
this.bu2List = response.map(x => {
......
......@@ -102,6 +102,7 @@ export class DepartmentRegisterComponent implements OnInit {
getBu1List() {
this.bu1.loading = true
this.selectedItems.data.clear()
this.bu1Service.getList().subscribe({
next: response => {
this.bu1.dataList = response.map(x => {
......
......@@ -118,6 +118,7 @@ export class SectionRegistrationComponent implements OnInit {
getBu3List() {
this.bu3.loading = true
this.selectedItems.data.clear()
this.bu3Service.getList().subscribe({
next: response => {
this.bu3.dataList = response.map(x => {
......
......@@ -124,6 +124,7 @@ export class SubDepartmentOneComponent implements OnInit {
}
getBu4List() {
this.bu4.loading = true
this.selectedItems.data.clear()
this.bu4Service.getList().subscribe({
next: response => {
this.bu4.dataList = response.map(x => {
......
<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="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"
[(ngModel)]="bu5Table.search" (ngModelChange)="onBu5TableSearchChange()">
[(ngModel)]="search">
<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">
......@@ -40,18 +23,11 @@
</div>
<div class="px-1">
<button type="button" class="ti-btn ti-btn-soft-secondary h-45px m-0 shadow-md"
(click)="currentModal='add';selectBu4();selectBu5()"
data-hs-overlay="#sub-department-two-modal-add">
(click)="currentModal='add';selectBu4();selectBu5()" data-hs-overlay="#sub-department-two-modal">
<i class="ri-add-line"></i>
Add
</button>
</div>
<!-- <div class="px-1">
<button href="javascript:void(0);" 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 href="javascript:void(0);" class="ti-btn ti-btn-soft-danger h-45px m-0 shadow-md"
data-hs-overlay="#sub-department-two-alert-delete-modal">
......@@ -59,86 +35,31 @@
Delete
</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="page px-rem">
<div class="overflow-auto shadow-md rounded-t-md">
<table class="ti-custom-table ti-custom-table-head ti-custom-table-hover table-bordered">
<thead>
<tr>
<ng-container
*ngFor="let item of ['','รหัสส่วนย่อย2','รายละเอียดส่วนย่อย2 (ไทย)','รายละเอียดส่วนย่อย2 (อังกฤษ)','การจัดการ']; let f = first; let l = last">
<th scope="col" class="relative px-10px py-10px bg-soft-secondary text-primary !text-center">
<span class="font-size-12px font-weight-700">{{ item }}</span>
<div class="absolute top-1/2 transform -translate-y-1/2 right-0" *ngIf="!f&&!l">
<i class="ti ti-dots-vertical fs-l"></i>
</div>
</th>
</ng-container>
</tr>
</thead>
<tbody *ngIf="bu5ListLoading">
<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="!bu5ListLoading&&!filterBu5Table().length">
<tr>
<td class="text-center" colspan="100%">
ไม่พบข้อมูล
</td>
</tr>
</tbody>
<tbody *ngIf="!bu5ListLoading&&filterBu5Table().length">
<tr
*ngFor="let item of filterBu5Table() | slice:((bu5Table.currentPage-1) * bu5Table.pageSize) : (((bu5Table.currentPage-1) * bu5Table.pageSize) + bu5Table.pageSize);let i = index">
<td td class="text-center">
<input type="checkbox" class="ti-form-checkbox cursor-pointer" id="checkbox-{{item.data.bu5id}}"
[(ngModel)]="item.check" (ngModelChange)="dataListCheck()">
</td>
<td class="text-center">{{item.data.bu5id}}</td>
<td>{{item.data.tdesc}}</td>
<td>{{item.data.edesc}}</td>
<td class="flex justify-center">
<i class="ti ti-edit cursor-pointer i-gray fs-l px-1"
(click)="selectBu5(item.data);currentModal='edit'"
data-hs-overlay="#sub-department-two-modal-edit"></i>
<!-- <i class="ti ti-trash cursor-pointer i-gray fs-l px-1"
(click)="currentModal='delete';selectBu5(item)"
data-hs-overlay="#sub-department-two-alert-delete-modal"></i> -->
</td>
</tr>
</tbody>
</table>
</div>
<app-pagination [totalItems]="filterBu5Table().length" [pageSize]="bu5Table.pageSize"
(pageChange)="bu5Table.currentPage = $event"
(pageSizeChange)="bu5Table.pageSize = $event;bu5Table.currentPage = 1"></app-pagination>
<app-datagrid-syncfution [searchSettings]="searchSettings" [searchText]="search" [dataSource]="bu5.dataList"
[columns]="columns" [selectedItems]="selectedItems" modalName="#sub-department-two-modal"
(sendSelectData)="currentModal='edit';selectBu5($event)" (sendSelectedItems)="onSelectItemChange($event)">
</app-datagrid-syncfution>
</div>
<div id="sub-department-two-modal-add" class="hs-overlay hidden ti-modal">
<div id="sub-department-two-modal" class="hs-overlay hidden ti-modal">
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)]">
<div class="max-h-full overflow-hidden ti-modal-content">
<div class="ti-modal-header">
<h3 class="text-xxl font-bold text-primary">
<ng-container *ngIf="currentModal=='add'">
เพิ่มข้อมูลทะเบียนส่วนย่อย 2
</ng-container>
<ng-container *ngIf="currentModal=='edit'">
แก้ไขข้อมูลทะเบียนส่วนย่อย 2
</ng-container>
</h3>
<div class="flex justify-end">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#sub-department-two-modal-add">
data-hs-overlay="#sub-department-two-modal">
<span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i>
</button>
......@@ -204,38 +125,25 @@
</span>
</label>
<div class="relative flex rounded-md w-1/2">
<input type="text" class="ti-form-input h-16"
[class.!border-red]="currentModal=='add'&&checkPrimary()" [(ngModel)]="bu5.bu5id">
<!-- <input type="text" id="hs-leading-button-add-on-with-icon-and-button"
name="hs-leading-button-add-on-with-icon-and-button"
class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10"
style="padding-right: 3.5rem;" [(ngModel)]="bu5.bu5id" (ngModelChange)="bu5idChange()">
<div
class="absolute inset-y-0 ltr:right-0 rtl:left-0 flex items-center z-20 ltr:pr-4 rtl:pl-4 space-x-2">
<button type="button" class="flex items-center text-red-500" (click)="selectBu5()">
<i class="ti ti-circle-x cursor-pointer"></i>
</button>
<button type="button" class="flex items-center text-gray-500 dark:text-white/70"
data-hs-overlay="#sub-department-two-bu5-table-modal">
<i class="ri-search-line cursor-pointer text-gray"></i>
</button>
</div> -->
<input type="text" class="ti-form-input h-16" [class.!bg-input-readonly]="currentModal=='edit'"
[readonly]="currentModal=='edit'" [class.!border-red]="currentModal=='add'&&checkPrimary()"
[(ngModel)]="bu5.select.bu5id">
</div>
<label for="detail_th" class="ti-form-label mt-2rem">รายละเอียดส่วนย่อย2 (ไทย)<span
class="text-danger">*</span></label>
<input type="text" id="detail_th" class="ti-form-input h-16" [(ngModel)]="bu5.tdesc">
<input type="text" id="detail_th" class="ti-form-input h-16" [(ngModel)]="bu5.select.tdesc">
<label for="detail_eng" class="ti-form-label mt-2rem">รายละเอียดส่วนย่อย2 (อังกฤษ)</label>
<input type="text" id="detail_eng" class="ti-form-input h-16" [(ngModel)]="bu5.edesc">
<input type="text" id="detail_eng" class="ti-form-input h-16" [(ngModel)]="bu5.select.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="#sub-department-two-modal-add">
data-hs-overlay="#sub-department-two-modal">
ย้อนกลับ
</button>
<button class="ti-btn ti-btn-success" type="button"
data-hs-overlay="#sub-department-two-alert-add-modal"
[class.ti-btn-disabled]="!bu4.bu4id||!bu5.bu5id||!bu5.tdesc||(currentModal=='add'&&checkPrimary())"
[disabled]="!bu4.bu4id||!bu5.bu5id||!bu5.tdesc||(currentModal=='add'&&checkPrimary())">
data-hs-overlay="#sub-department-two-alert-modal"
[class.ti-btn-disabled]="!bu4.bu4id||!bu5.select.bu5id||!bu5.select.tdesc||(currentModal=='add'&&checkPrimary())"
[disabled]="!bu4.bu4id||!bu5.select.bu5id||!bu5.select.tdesc||(currentModal=='add'&&checkPrimary())">
บันทึกข้อมูล
</button>
</div>
......@@ -244,104 +152,6 @@
</div>
</div>
<div id="sub-department-two-modal-edit" class="hs-overlay hidden ti-modal">
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)]">
<div class="max-h-full overflow-hidden ti-modal-content">
<div class="ti-modal-header">
<h3 class="text-xxl font-bold text-primary">
แก้ไขข้อมูลทะเบียนส่วนย่อย 2
</h3>
<div class="flex justify-end">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#sub-department-two-modal-edit">
<span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i>
</button>
</div>
</div>
<div class="ti-modal-center">
<div class="flex justify-end" style="padding-right: 1rem;">
<div class="px-1">
<button type="button" class="ti-btn ti-btn-soft-indigo h-45px m-0 shadow-md"
(click)="selectBu4();bu5.tdesc='';bu5.edesc=''">
<svg class="svg-indigo" width="16" height="16" viewBox="0 0 64.00 64.00"
xmlns="http://www.w3.org/2000/svg" fill="none" stroke="#595BEA" stroke-width="3.84"
transform="rotate(45)matrix(-1, 0, 0, 1, 0, 0)">
<g id="SVGRepo_bgCarrier" stroke-width="0"></g>
<g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g>
<g id="SVGRepo_iconCarrier">
<path d="M15 49A24 24 0 0 1 32 8"></path>
<path d="M49 15a24 24 0 0 1-17 41"></path>
<polyline points="15.03 40 15.03 48.97 8 48.97"></polyline>
<polyline points="48.97 24 48.97 15.03 56 15.03"></polyline>
</g>
</svg>
Clear
</button>
</div>
<!-- <div class="px-1">
<button href="javascript:void(0);" class="ti-btn ti-btn-soft-warning h-45px m-0 shadow-md">
<i class="ti ti-book fs-l"></i>
Help
</button>
</div> -->
</div>
</div>
<div class="ti-modal-body">
<label for="hs-trailing-button-add-on-with-icon" class="ti-form-label">อยู่ภายใต้หน่วยงาน<span
class="text-danger">*</span></label>
<div class="flex">
<div class="relative flex rounded-md">
<input type="text" id="hs-leading-button-add-on-with-icon-and-button"
name="hs-leading-button-add-on-with-icon-and-button"
class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10" readonly
style="padding-right: 3.5rem;" [(ngModel)]="bu4.bu4id" (ngModelChange)="bu4idChange()">
<div
class="absolute inset-y-0 ltr:right-0 rtl:left-0 flex items-center z-20 ltr:pr-4 rtl:pl-4 space-x-2">
<button type="button" class="flex items-center text-red-500" (click)="selectBu4()">
<i class="ti ti-circle-x cursor-pointer"></i>
</button>
<button type="button" class="flex items-center text-gray-500 dark:text-white/70"
data-hs-overlay="#sub-department-two-bu4-table-modal">
<i class="ri-search-line cursor-pointer text-gray"></i>
</button>
</div>
</div>
<div class="flex rounded-md w-1/2 pl-1rem">
<input type="text" id="input-label" class="ti-form-input w-full pr-10 bg-input-readonly"
readonly [value]="bu4.tdesc">
</div>
</div>
<label for="input-label" class="ti-form-label mt-2rem">ส่วนย่อย2<span
class="text-danger">*</span></label>
<div class="sm:grid grid-cols-2 gap-1">
<div class="relative w-full">
<input type="text" id="input-label" class="ti-form-input w-full pr-10 bg-input-readonly"
readonly [value]="bu5.bu5id">
</div>
</div>
<label for="detail_th" class="ti-form-label mt-2rem">รายละเอียดส่วนย่อย2 (ไทย)<span
class="text-danger">*</span></label>
<input type="text" id="detail_th" class="ti-form-input h-16" [(ngModel)]="bu5.tdesc">
<label for="detail_eng" class="ti-form-label mt-2rem">รายละเอียดส่วนย่อย2 (อังกฤษ)</label>
<input type="text" id="detail_eng" class="ti-form-input h-16" [(ngModel)]="bu5.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="#sub-department-two-modal-edit">
ย้อนกลับ
</button>
<button class="ti-btn ti-btn-success" type="button"
data-hs-overlay="#sub-department-two-alert-edit-modal"
[class.ti-btn-disabled]="!bu4.bu4id||!bu5.bu5id||!bu5.tdesc"
[disabled]="!bu4.bu4id||!bu5.bu5id||!bu5.tdesc">
บันทึกข้อมูล
</button>
</div>
</div>
</div>
</div>
</div>
<div id="sub-department-two-bu4-table-modal" class="hs-overlay hidden ti-modal">
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out lg:!max-w-4xl lg:w-full m-3 lg:!mx-auto">
......@@ -353,13 +163,13 @@
<div class="flex justify-end">
<button *ngIf="currentModal=='add'" type="button"
class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#sub-department-two-modal-add">
data-hs-overlay="#sub-department-two-modal">
<span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i>
</button>
<button *ngIf="currentModal=='edit'" type="button"
class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#sub-department-two-modal-edit">
data-hs-overlay="#sub-department-two-modal">
<span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i>
</button>
......@@ -407,7 +217,7 @@
<ng-container *ngIf="currentModal=='add'">
<tr *ngFor="let item of filterBu4Modal() | slice:((bu4Modal.currentPage-1) * bu4Modal.pageSize) : (((bu4Modal.currentPage-1) * bu4Modal.pageSize) + bu4Modal.pageSize);let i = index"
class="cursor-pointer" (click)="selectBu4(item)"
data-hs-overlay="#sub-department-two-modal-add">
data-hs-overlay="#sub-department-two-modal">
<td class="flex justify-center">
{{((bu4Modal.currentPage-1) * bu4Modal.pageSize)+(i+1)}}
</td>
......@@ -419,7 +229,7 @@
<ng-container *ngIf="currentModal=='edit'">
<tr *ngFor="let item of filterBu4Modal() | slice:((bu4Modal.currentPage-1) * bu4Modal.pageSize) : (((bu4Modal.currentPage-1) * bu4Modal.pageSize) + bu4Modal.pageSize);let i = index"
class="cursor-pointer" (click)="selectBu4(item)"
data-hs-overlay="#sub-department-two-modal-edit">
data-hs-overlay="#sub-department-two-modal">
<td class="flex justify-center">
{{((bu4Modal.currentPage-1) * bu4Modal.pageSize)+(i+1)}}
</td>
......@@ -460,12 +270,12 @@
<div class="flex justify-end mt-2rem mb-1rem space-x-4">
<button type="button" *ngIf="currentModal=='add'"
class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
data-hs-overlay="#sub-department-two-modal-add">
data-hs-overlay="#sub-department-two-modal">
ย้อนกลับ
</button>
<button type="button" *ngIf="currentModal=='edit'"
class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
data-hs-overlay="#sub-department-two-modal-edit">
data-hs-overlay="#sub-department-two-modal">
ย้อนกลับ
</button>
</div>
......@@ -474,7 +284,7 @@
</div>
</div>
<div id="sub-department-two-alert-add-modal" class="hs-overlay hidden ti-modal">
<div id="sub-department-two-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">
......@@ -483,7 +293,7 @@
</h3>
<div class="flex justify-end">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#sub-department-two-modal-add">
data-hs-overlay="#sub-department-two-modal">
<span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i>
</button>
......@@ -493,50 +303,14 @@
<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="#sub-department-two-modal-add">
ย้อนกลับ
</button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#sub-department-two-alert-add-modal" (click)="addBu5()">
บันทึกข้อมูล
</a>
</div>
</div>
</div>
</div>
</div>
<div id="sub-department-two-alert-edit-modal" class="hs-overlay hidden ti-modal">
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)] flex items-center">
<div class="max-h-full overflow-hidden ti-modal-content w-full">
<div class="ti-modal-header">
<h3 class="text-xxl font-bold text-primary">
แจ้งเตือน
</h3>
<div class="flex justify-end">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#sub-department-two-modal-edit">
<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="#sub-department-two-modal-edit">
data-hs-overlay="#sub-department-two-modal">
ย้อนกลับ
</button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#sub-department-two-alert-edit-modal" (click)="addBu5()">
data-hs-overlay="#sub-department-two-alert-modal" (click)="addBu5()">
บันทึกข้อมูล
</a>
</div>
......@@ -562,14 +336,13 @@
</div>
<div class="ti-modal-body ">
<p class="mt-1 text-gray-800 dark:text-white/70">
<ng-container *ngIf="numDataListChecked">
<ng-container *ngIf="numSelectItem()">
ยืนยันการลบข้อมูลหรือไม่
</ng-container>
<ng-container *ngIf="!numDataListChecked">
<ng-container *ngIf="!numSelectItem()">
เลือกข้อมูลที่ต้องการลบ
</ng-container>
</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"
......@@ -578,7 +351,7 @@
</button>
<a class="ti-btn ti-btn-danger" href="javascript:void(0);"
data-hs-overlay="#sub-department-two-alert-delete-modal" (click)="deleteBu5()"
*ngIf="numDataListChecked">
*ngIf="numSelectItem()">
ลบข้อมูล
</a>
</div>
......
import { ChangeDetectorRef, Component, EventEmitter, Input, OnInit, } from '@angular/core';
import { ColumnModel } from '@syncfusion/ej2-grids';
import { ToastrService } from 'ngx-toastr';
import { Bu4Model, MyBu4Model } from 'src/app/shared/model/bu4.model';
import { Bu5Model, MyBu5Model } from 'src/app/shared/model/bu5.model';
......@@ -17,25 +18,11 @@ interface table {
styleUrls: ['./sub-department-two.component.scss']
})
export class SubDepartmentTwoComponent implements OnInit {
bu5List: { check: boolean, data: Bu5Model }[] = []
bu5ListLoading = false
bu5: Bu5Model = new MyBu5Model()
bu5Table: table = {
currentPage: 1,
page: Array.from({ length: 1 }, (_, i) => i + 1),
search: "",
pageSize: 10
}
bu5: { loading: boolean, select: Bu5Model, dataList: Bu5Model[] } = { loading: false, select: new MyBu5Model(), dataList: [] }
selectedFile: File | null = null;
selectedFileName: string = 'กรุณาเลือกไฟล์';
bu5Modal: table = {
currentPage: 1,
page: Array.from({ length: 1 }, (_, i) => i + 1),
search: "",
pageSize: 10
}
bu4List: Bu4Model[] = []
bu4: Bu4Model = new MyBu4Model()
bu4Modal: table = {
......@@ -46,10 +33,29 @@ export class SubDepartmentTwoComponent implements OnInit {
}
currentModal: 'add' | 'edit' | 'delete' = "add"
numDataListChecked = 0
isDataListChecked = false
isDataListCheckedAll = false
columns: ColumnModel[] = [{
field: "bu5id",
headerText: "รหัสฝ่าย",
type: "string",
isPrimaryKey: true,
},
{
field: "tdesc",
headerText: "รายละเอียดฝ่าย(ไทย)",
type: "string"
},
{
field: "edesc",
headerText: "รายละเอียดฝ่าย(อังกฤษ)",
type: "string"
}]
searchSettings = {
fields: ['bu5id', 'tdesc', 'edesc'],
operator: 'contains',
ignoreCase: false
};
search = ''
selectedItems: { key: string, count: number, data: Map<string, boolean> } = { key: '', count: 0, data: new Map<string, boolean>() };
constructor(private bu5Service: Bu5Service,
private bu4Service: Bu4Service,
private toastr: ToastrService,
......@@ -73,7 +79,7 @@ export class SubDepartmentTwoComponent implements OnInit {
}
const formData = new FormData();
formData.append('file', this.selectedFile);
this.bu5ListLoading = true
this.bu5.loading = true
this.fileService.uploadExcel(formData, 'mbu5').subscribe({
next: response => {
if (response.success) {
......@@ -81,11 +87,11 @@ export class SubDepartmentTwoComponent implements OnInit {
this.getBu5List()
} else {
this.showAlert(response.message, 'error')
this.bu5ListLoading = false
this.bu5.loading = false
}
}, error: error => {
this.showAlert(error.message, 'error')
this.bu5ListLoading = false
this.bu5.loading = false
}
})
}
......@@ -110,76 +116,63 @@ export class SubDepartmentTwoComponent implements OnInit {
}
getBu5List() {
this.bu5ListLoading = true
this.bu5.loading = true
this.selectedItems.data.clear()
this.bu5Service.getList().subscribe({
next: response => {
this.bu5List = response.map(x => ({ check: false, data: new MyBu5Model(x) }))
this.bu5ListLoading = false
this.onBu5TableSearchChange()
this.isDataListCheckedAll = false
this.dataListCheckAll()
this.bu5.dataList = response.map(x => {
this.selectedItems.data.set(x.bu5id, false)
return new MyBu5Model(x)
})
this.selectedItems.key = 'bu5id'
this.selectedItems.count = 0
this.bu5.loading = false
this.cdr.detectChanges()
}, error: error => {
this.bu5ListLoading = false
this.bu5.loading = false
this.cdr.detectChanges()
}
})
}
onBu5TableSearchChange() {
this.bu5Table.currentPage = 1
this.bu5Table.page = Array.from({ length: Math.ceil(this.filterBu5Table().length / 10) }, (_, i) => i + 1);
this.dataListCheck()
}
filterBu5Table() {
return this.bu5List.filter(x => {
const data = x.data
return data.bu5id.toLowerCase().includes(this.bu5Table.search.toLowerCase()) ||
data.tdesc.toLowerCase().includes(this.bu5Table.search.toLowerCase()) ||
data.edesc.toLowerCase().includes(this.bu5Table.search.toLowerCase())
})
}
selectBu5(bu5?: Bu5Model) {
this.bu5 = new MyBu5Model(bu5 || {})
if (bu5) {
this.bu5.select = new MyBu5Model(bu5)
} else if (this.currentModal == 'add') {
this.bu5.select = new MyBu5Model()
} else if (this.currentModal == 'edit') {
this.bu5.select = new MyBu5Model({ bu5id: this.bu5.select.bu5id })
}
this.selectBu4()
if (this.bu5.parent) {
this.bu4Service.getById(this.bu5.parent).subscribe(response => {
if (this.bu5.select.parent) {
this.bu4Service.getById(this.bu5.select.parent).subscribe(response => {
this.bu4 = new MyBu4Model(response)
this.cdr.detectChanges()
})
}
}
onBu5ModalSearchChange() {
this.bu5Modal.currentPage = 1
this.bu5Modal.page = Array.from({ length: Math.ceil(this.filterBu5Modal().length / 10) }, (_, i) => i + 1);
}
filterBu5Modal() {
return this.bu5List.filter(x => {
const data = x.data
return data.bu5id.toLowerCase().includes(this.bu5Table.search.toLowerCase()) ||
data.tdesc.toLowerCase().includes(this.bu5Table.search.toLowerCase()) ||
data.edesc.toLowerCase().includes(this.bu5Table.search.toLowerCase())
})
}
addBu5() {
this.bu5ListLoading = true
this.bu5Service.post({ ...this.bu5, parent: this.bu4.bu4id }).subscribe({
this.bu5.loading = true
this.bu5Service.post({ ...this.bu5.select, parent: this.bu4.bu4id }).subscribe({
next: response => {
if (response.success) {
this.showAlert(response.message, 'success')
this.getBu5List()
} else {
this.showAlert(response.message, 'error')
this.bu5ListLoading = false
this.bu5.loading = false
}
}, error: error => {
this.showAlert(error.message, 'error')
this.bu5ListLoading = false
this.bu5.loading = false
}
})
}
deleteBu5() {
this.bu5ListLoading = true
const body = this.bu5List.filter(x => x.check).map(x => new MyBu5Model(x.data))
this.bu5.loading = true
const selectedKeys = Array.from(this.selectedItems.data.keys());
const body = this.bu5.dataList.filter(x => selectedKeys.includes(x.bu5id) && this.selectedItems.data.get(x.bu5id)).map(x => new MyBu5Model(x))
this.bu5Service.delete(body).subscribe({
next: response => {
if (response.success) {
......@@ -187,11 +180,11 @@ export class SubDepartmentTwoComponent implements OnInit {
this.getBu5List()
} else {
this.showAlert(response.message, 'error')
this.bu5ListLoading = false
this.bu5.loading = false
}
}, error: error => {
this.showAlert(error.message, 'error')
this.bu5ListLoading = false
this.bu5.loading = false
}
})
}
......@@ -226,21 +219,18 @@ export class SubDepartmentTwoComponent implements OnInit {
})
}
dataListCheckAll() {
const selectAll = this.isDataListCheckedAll;
this.filterBu5Table().forEach(x => x.check = selectAll);
this.dataListCheck();
checkPrimary() {
return this.bu5.dataList.find(x => x.bu5id == this.bu5.select.bu5id)
}
dataListCheck() {
const dataCheck = this.filterBu5Table();
this.isDataListCheckedAll = dataCheck.length ? dataCheck.every(x => x.check) : false;
this.numDataListChecked = this.bu5List.filter(x => x.check).length
this.isDataListChecked = Boolean(this.numDataListChecked)
numSelectItem() {
const selectedKeys = Array.from(this.selectedItems.data.keys());
const num = this.bu5.dataList.filter(x => selectedKeys.includes(x.bu5id) && this.selectedItems.data.get(x.bu5id)).length
return num
}
checkPrimary() {
return this.bu5List.find(x => x.data.bu5id == this.bu5.bu5id)
onSelectItemChange(arg: any) {
this.selectedItems = arg
}
}
......@@ -64,6 +64,7 @@ export class CompanyRegistrationPageComponent {
getCompanyList() {
this.dataLoading = true
this.selectedItems.data.clear()
this.companyService.getList().subscribe({
next: response => {
this.dataList = response.map(x => {
......
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