Commit 466ca458 by Nattana Chaiyamat

ส่วนย่อย4

parent 348909e5
<div class="w-full min-height-50px mb-10px justify-between items-center"> <div class="w-full min-height-50px mb-10px justify-between items-center">
<div class="flex justify-between"> <div class="flex justify-end">
<div class="flex"> <div class="px-1">
<div class="flex items-center"> <div class="relative shadow-md">
<input type="checkbox" class="ti-form-checkbox pointer-events-none" id="hs-default-checkbox" <input type="text" id="hs-leading-icon" name="hs-leading-icon"
[(ngModel)]="isDataListChecked"> class="ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 " placeholder="Search by No. or Name"
<label for="hs-default-checkbox" class="text-sm text-gray-500 mx-2 pointer-events-none"> [(ngModel)]="search">
{{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)]="bu7Table.search" (ngModelChange)="onBu7TableSearchChange()">
<div <div
class="absolute inset-y-0 ltr:left-0 rtl:right-0 flex items-center pointer-events-none z-20 ltr:pl-4 rtl:pr-4"> class="absolute inset-y-0 ltr:left-0 rtl:right-0 flex items-center pointer-events-none z-20 ltr:pl-4 rtl:pr-4">
<i class="ri-search-line text-gray"></i> <i class="ri-search-line text-gray"></i>
</div>
</div> </div>
</div> </div>
<div class="px-1"> </div>
<button type="button" <div class="px-1">
class=" h-45px 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" <button type="button"
data-hs-overlay="#sub-department-four-upload-modal" class=" h-45px 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"
(click)="fileInput.value = '';selectedFile=null;selectedFileName = 'กรุณาเลือกไฟล์'"> data-hs-overlay="#sub-department-four-upload-modal"
<i class="ti ti-file-plus"></i> (click)="fileInput.value = '';selectedFile=null;selectedFileName = 'กรุณาเลือกไฟล์'">
import <i class="ti ti-file-plus"></i>
</button> import
</div> </button>
<div class="px-1"> </div>
<button type="button" class="ti-btn ti-btn-soft-secondary h-45px m-0 shadow-md" <div class="px-1">
(click)="currentModal='add';selectBu6();selectBu7()" <button type="button" class="ti-btn ti-btn-soft-secondary h-45px m-0 shadow-md"
data-hs-overlay="#sub-department-four-modal-add"> (click)="currentModal='add';selectBu6();selectBu7()" data-hs-overlay="#sub-department-four-modal">
<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-info h-45px m-0 shadow-md"> <button href="javascript:void(0);" class="ti-btn ti-btn-soft-danger h-45px m-0 shadow-md"
<i class="ri-printer-line"></i> (click)="currentModal='delete'" data-hs-overlay="#sub-department-four-alert-delete-modal">
Print <i class="ri-delete-bin-6-line"></i>
</button> Delete
</div> --> </button>
<div class="px-1">
<button href="javascript:void(0);" class="ti-btn ti-btn-soft-danger h-45px m-0 shadow-md"
(click)="currentModal='delete'" data-hs-overlay="#sub-department-four-alert-delete-modal">
<i class="ri-delete-bin-6-line"></i>
Delete
</button>
</div>
<!-- <div class="px-1">
<button href="javascript:void(0);" class="ti-btn ti-btn-soft-warning h-45px m-0 shadow-md">
<i class="ti ti-book fs-l"></i>
Help
</button>
</div> -->
</div> </div>
</div> </div>
</div> </div>
<div class="page px-rem"> <div class="page px-rem">
<div class="overflow-auto shadow-md rounded-t-md"> <app-datagrid-syncfution [searchSettings]="searchSettings" [searchText]="search" [dataSource]="bu7.dataList"
<table class="ti-custom-table ti-custom-table-head ti-custom-table-hover table-bordered"> [columns]="columns" [selectedItems]="selectedItems" modalName="#sub-department-four-modal"
<thead> (sendSelectData)="currentModal='edit';selectBu7($event)" (sendSelectedItems)="onSelectItemChange($event)">
<tr> </app-datagrid-syncfution>
<ng-container
*ngFor="let item of ['','รหัสส่วนย่อย4','รายละเอียดส่วนย่อย4 (ไทย)','รายละเอียดส่วนย่อย4 (อังกฤษ)','การจัดการ']; let f = first; let l = last">
<th scope="col" class="relative px-10px py-10px bg-soft-secondary text-primary !text-center">
<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="bu7ListLoading">
<tr>
<td class="text-center" colspan="100%">
<div *ngFor="let item of [1,2,3]" class="ti-spinner w-8 h-8 text-secondary mx-1" role="status"
aria-label="loading">
<span class="sr-only">Loading...</span>
</div>
</td>
</tr>
</tbody>
<tbody *ngIf="!bu7ListLoading&&!filterBu7Table().length">
<tr>
<td class="text-center" colspan="100%">
ไม่พบข้อมูล
</td>
</tr>
</tbody>
<tbody *ngIf="!bu7ListLoading&&filterBu7Table().length">
<tr
*ngFor="let item of filterBu7Table() | slice:((bu7Table.currentPage-1) * bu7Table.pageSize) : (((bu7Table.currentPage-1) * bu7Table.pageSize) + bu7Table.pageSize);let i = index">
<td class="text-center">
<input type="checkbox" class="ti-form-checkbox cursor-pointer" id="checkbox-{{item.data.bu7id}}"
[(ngModel)]="item.check" (ngModelChange)="dataListCheck()">
</td>
<td class="text-center">{{item.data.bu7id}}</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)="selectBu7(item.data);currentModal='edit'"
data-hs-overlay="#sub-department-four-modal-edit"></i>
<!-- <i class="ti ti-trash cursor-pointer i-gray fs-l px-1" (click)="selectBu7(item)"
data-hs-overlay="#sub-department-four-alert-delete-modal"></i> -->
</td>
</tr>
</tbody>
</table>
</div>
<app-pagination [totalItems]="filterBu7Table().length" [pageSize]="bu7Table.pageSize"
(pageChange)="bu7Table.currentPage = $event"
(pageSizeChange)="bu7Table.pageSize = $event;bu7Table.currentPage = 1"></app-pagination>
</div> </div>
<div id="sub-department-four-modal-add" class="hs-overlay hidden ti-modal"> <div id="sub-department-four-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">
เพิ่มข้อมูลทะเบียนส่วนย่อย 4 <ng-container *ngIf="currentModal=='add'">
เพิ่มข้อมูลทะเบียนส่วนย่อย 4
</ng-container>
<ng-container *ngIf="currentModal=='edit'">
แก้ไขข้อมูลทะเบียนส่วนย่อย 4
</ng-container>
</h3> </h3>
<div class="flex justify-end"> <div class="flex justify-end">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger" <button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#sub-department-four-modal-add"> data-hs-overlay="#sub-department-four-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>
...@@ -164,12 +86,6 @@ ...@@ -164,12 +86,6 @@
Clear Clear
</button> </button>
</div> </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>
<div class="ti-modal-body"> <div class="ti-modal-body">
...@@ -197,7 +113,7 @@ ...@@ -197,7 +113,7 @@
</div> </div>
</div> </div>
<label class="ti-form-label mt-2rem">ส่วนย่อย4 <label class="ti-form-label mt-2rem">ส่วนย่อย4
<span class="text-danger">* <span class="text-danger">*
<ng-container *ngIf="currentModal=='add'&&checkPrimary()"> <ng-container *ngIf="currentModal=='add'&&checkPrimary()">
ส่วนย่อย4ซ้ำ ส่วนย่อย4ซ้ำ
</ng-container> </ng-container>
...@@ -205,136 +121,24 @@ ...@@ -205,136 +121,24 @@
</label> </label>
<div class="relative flex rounded-md w-1/2"> <div class="relative flex rounded-md w-1/2">
<input type="text" class="ti-form-input h-16" <input type="text" class="ti-form-input h-16"
[class.!border-red]="currentModal=='add'&&checkPrimary()" [(ngModel)]="bu7.bu7id"> [class.!border-red]="currentModal=='add'&&checkPrimary()"
<!-- <input type="text" id="hs-leading-button-add-on-with-icon-and-button" [class.!bg-input-readonly]="currentModal=='edit'" [readonly]="currentModal=='edit'"
name="hs-leading-button-add-on-with-icon-and-button" [(ngModel)]="bu7.select.bu7id">
class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10"
style="padding-right: 3.5rem;" [(ngModel)]="bu7.bu7id" (ngModelChange)="bu7idChange()">
<div
class="absolute inset-y-0 ltr:right-0 rtl:left-0 flex items-center z-20 ltr:pr-4 rtl:pl-4 space-x-2">
<button type="button" class="flex items-center text-red-500" (click)="selectBu7()">
<i class="ti ti-circle-x cursor-pointer"></i>
</button>
<button type="button" class="flex items-center text-gray-500 dark:text-white/70"
data-hs-overlay="#sub-department-four-bu7-table-modal">
<i class="ri-search-line cursor-pointer text-gray"></i>
</button>
</div> -->
</div> </div>
<label for="detail_th" class="ti-form-label mt-2rem">รายละเอียด (ไทย)<span <label for="detail_th" class="ti-form-label mt-2rem">รายละเอียด (ไทย)<span
class="text-danger">*</span></label> class="text-danger">*</span></label>
<input type="text" id="detail_th" class="ti-form-input h-16" [(ngModel)]="bu7.tdesc"> <input type="text" id="detail_th" class="ti-form-input h-16" [(ngModel)]="bu7.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-16" [(ngModel)]="bu7.edesc"> <input type="text" id="detail_eng" class="ti-form-input h-16" [(ngModel)]="bu7.select.edesc">
<div class="flex justify-end mt-2rem mb-1rem space-x-4"> <div class="flex justify-end mt-2rem mb-1rem space-x-4">
<button type="button" <button type="button"
class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10" class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
data-hs-overlay="#sub-department-four-modal-add"> data-hs-overlay="#sub-department-four-modal">
ย้อนกลับ
</button>
<button type="button" class="ti-btn ti-btn-success"
data-hs-overlay="#sub-department-four-alert-add-modal"
[class.ti-btn-disabled]="!bu6.bu6id||!bu7.bu7id||!bu7.tdesc||(currentModal=='add'&&checkPrimary())"
[disabled]=" !bu6.bu6id||!bu7.bu7id||!bu7.tdesc||(currentModal=='add' &&checkPrimary())">
บันทึกข้อมูล
</button>
</div>
</div>
</div>
</div>
</div>
<div id="sub-department-four-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">
แก้ไขข้อมูลทะเบียนส่วนย่อย 4
</h3>
<div class="flex justify-end">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#sub-department-four-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)="selectBu6();bu7.tdesc='';bu7.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)]="bu6.bu6id" (ngModelChange)="bu6idChange()">
<div
class="absolute inset-y-0 ltr:right-0 rtl:left-0 flex items-center z-20 ltr:pr-4 rtl:pl-4 space-x-2">
<button type="button" class="flex items-center text-red-500" (click)="selectBu6()">
<i class="ti ti-circle-x cursor-pointer"></i>
</button>
<button type="button" class="flex items-center text-gray-500 dark:text-white/70"
data-hs-overlay="#sub-department-four-bu6-table-modal">
<i class="ri-search-line cursor-pointer text-gray"></i>
</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]="bu6.tdesc">
</div>
</div>
<label for="input-label" class="ti-form-label mt-2rem">ส่วนย่อย4<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]="bu7.bu7id">
</div>
</div>
<label for="detail_th" class="ti-form-label mt-2rem">รายละเอียด (ไทย)<span
class="text-danger">*</span></label>
<input type="text" id="detail_th" class="ti-form-input h-16" [(ngModel)]="bu7.tdesc">
<label for="detail_eng" class="ti-form-label mt-2rem">รายละเอียด (อังกฤษ)</label>
<input type="text" id="detail_eng" class="ti-form-input h-16" [(ngModel)]="bu7.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-four-modal-edit">
ย้อนกลับ ย้อนกลับ
</button> </button>
<button type="button" class="ti-btn ti-btn-success" <button type="button" class="ti-btn ti-btn-success" data-hs-overlay="#sub-department-four-alert"
data-hs-overlay="#sub-department-four-alert-edit-modal" [class.ti-btn-disabled]="!bu6.bu6id||!bu7.select.bu7id||!bu7.select.tdesc||(currentModal=='add'&&checkPrimary())"
[class.ti-btn-disabled]="!bu6.bu6id||!bu7.bu7id||!bu7.tdesc" [disabled]=" !bu6.bu6id||!bu7.select.bu7id||!bu7.select.tdesc||(currentModal=='add' &&checkPrimary())">
[disabled]="!bu6.bu6id||!bu7.bu7id||!bu7.tdesc">
บันทึกข้อมูล บันทึกข้อมูล
</button> </button>
</div> </div>
...@@ -351,15 +155,8 @@ ...@@ -351,15 +155,8 @@
ข้อมูลทะเบียนส่วนย่อย 3 ข้อมูลทะเบียนส่วนย่อย 3
</h3> </h3>
<div class="flex justify-end"> <div class="flex justify-end">
<button *ngIf="currentModal=='add'" type="button" <button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
class="hs-dropdown-toggle ti-modal-clode-btn text-danger" data-hs-overlay="#sub-department-four-modal">
data-hs-overlay="#sub-department-four-modal-add">
<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-four-modal-edit">
<span class="sr-only">Close</span> <span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i> <i class="ti ti-circle-x fs-xxl"></i>
</button> </button>
...@@ -404,30 +201,16 @@ ...@@ -404,30 +201,16 @@
</tr> </tr>
</tbody> </tbody>
<tbody *ngIf="filterBu6Modal().length"> <tbody *ngIf="filterBu6Modal().length">
<ng-container *ngIf="currentModal=='add'"> <tr *ngFor="let item of filterBu6Modal() | slice:((bu6Modal.currentPage-1) * bu6Modal.pageSize) : (((bu6Modal.currentPage-1) * bu6Modal.pageSize) + bu6Modal.pageSize);let i = index"
<tr *ngFor="let item of filterBu6Modal() | slice:((bu6Modal.currentPage-1) * bu6Modal.pageSize) : (((bu6Modal.currentPage-1) * bu6Modal.pageSize) + bu6Modal.pageSize);let i = index" class="cursor-pointer" (click)="selectBu6(item)"
class="cursor-pointer" (click)="selectBu6(item)" data-hs-overlay="#sub-department-four-modal">
data-hs-overlay="#sub-department-four-modal-add"> <td class="flex justify-center">
<td class="flex justify-center"> {{((bu6Modal.currentPage-1) * bu6Modal.pageSize)+(i+1)}}
{{((bu6Modal.currentPage-1) * bu6Modal.pageSize)+(i+1)}} </td>
</td> <td>{{item.bu6id}}</td>
<td>{{item.bu6id}}</td> <td>{{item.tdesc}}</td>
<td>{{item.tdesc}}</td> <td>{{item.edesc}}</td>
<td>{{item.edesc}}</td> </tr>
</tr>
</ng-container>
<ng-container *ngIf="currentModal=='edit'">
<tr *ngFor="let item of filterBu6Modal() | slice:((bu6Modal.currentPage-1) * bu6Modal.pageSize) : (((bu6Modal.currentPage-1) * bu6Modal.pageSize) + bu6Modal.pageSize);let i = index"
class="cursor-pointer" (click)="selectBu6(item)"
data-hs-overlay="#sub-department-four-modal-edit">
<td class="flex justify-center">
{{((bu6Modal.currentPage-1) * bu6Modal.pageSize)+(i+1)}}
</td>
<td>{{item.bu6id}}</td>
<td>{{item.tdesc}}</td>
<td>{{item.edesc}}</td>
</tr>
</ng-container>
</tbody> </tbody>
</table> </table>
</div> </div>
...@@ -435,59 +218,18 @@ ...@@ -435,59 +218,18 @@
(pageChange)="bu6Modal.currentPage = $event" (pageChange)="bu6Modal.currentPage = $event"
(pageSizeChange)="bu6Modal.pageSize = $event;bu6Modal.currentPage = 1"></app-pagination> (pageSizeChange)="bu6Modal.pageSize = $event;bu6Modal.currentPage = 1"></app-pagination>
<div class="flex justify-end mt-2rem mb-1rem space-x-4"> <div class="flex justify-end mt-2rem mb-1rem space-x-4">
<button type="button" *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-four-modal-add">
ย้อนกลับ
</button>
<button type="button" *ngIf="currentModal=='edit'"
class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
data-hs-overlay="#sub-department-four-modal-edit">
ย้อนกลับ
</button>
</div>
</div>
</div>
</div>
</div>
<div id="sub-department-four-alert-add-modal" class="hs-overlay hidden ti-modal">
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)] flex items-center">
<div class="max-h-full overflow-hidden ti-modal-content w-full">
<div class="ti-modal-header">
<h3 class="text-xxl font-bold text-primary">
แจ้งเตือน
</h3>
<div class="flex justify-end">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#sub-department-four-modal-add">
<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="#sub-department-four-modal-add"> data-hs-overlay="#sub-department-four-modal">
ย้อนกลับ ย้อนกลับ
</button> </button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#sub-department-four-alert-add-modal" (click)="addBu7();">
บันทึกข้อมูล
</a>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div id="sub-department-four-alert-edit-modal" class="hs-overlay hidden ti-modal"> <div id="sub-department-four-alert" 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">
...@@ -496,7 +238,7 @@ ...@@ -496,7 +238,7 @@
</h3> </h3>
<div class="flex justify-end"> <div class="flex justify-end">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger" <button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#sub-department-four-modal-edit"> data-hs-overlay="#sub-department-four-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>
...@@ -510,11 +252,11 @@ ...@@ -510,11 +252,11 @@
<div class="flex justify-end mt-2rem mb-1rem"> <div class="flex justify-end mt-2rem mb-1rem">
<button type="button" <button type="button"
class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10" class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
data-hs-overlay="#sub-department-four-modal-edit"> data-hs-overlay="#sub-department-four-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="#sub-department-four-alert-edit-modal" (click)="addBu7();"> data-hs-overlay="#sub-department-four-alert" (click)="addBu7();">
บันทึกข้อมูล บันทึกข้อมูล
</a> </a>
</div> </div>
...@@ -540,10 +282,10 @@ ...@@ -540,10 +282,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()">
ยืนยันการลบข้อมูลหรือไม่ ยืนยันการลบข้อมูลหรือไม่
</ng-container> </ng-container>
<ng-container *ngIf="!numDataListChecked"> <ng-container *ngIf="!numSelectItem()">
เลือกข้อมูลที่ต้องการลบ เลือกข้อมูลที่ต้องการลบ
</ng-container> </ng-container>
</p> </p>
...@@ -556,7 +298,7 @@ ...@@ -556,7 +298,7 @@
</button> </button>
<a class="ti-btn ti-btn-danger" href="javascript:void(0);" <a class="ti-btn ti-btn-danger" href="javascript:void(0);"
data-hs-overlay="#sub-department-four-alert-delete-modal" (click)="deleteBu7();" data-hs-overlay="#sub-department-four-alert-delete-modal" (click)="deleteBu7();"
*ngIf="numDataListChecked"> *ngIf="numSelectItem()">
ลบข้อมูล ลบข้อมูล
</a> </a>
</div> </div>
......
import { ChangeDetectorRef, Component, EventEmitter, Input, OnInit } from '@angular/core'; import { ChangeDetectorRef, Component, EventEmitter, Input, OnInit } from '@angular/core';
import { ColumnModel } from '@syncfusion/ej2-grids';
import { ToastrService } from 'ngx-toastr'; import { ToastrService } from 'ngx-toastr';
import { Bu6Model, MyBu6Model } from 'src/app/shared/model/bu6.model'; import { Bu6Model, MyBu6Model } from 'src/app/shared/model/bu6.model';
import { Bu7Model, MyBu7Model } from 'src/app/shared/model/bu7.model'; import { Bu7Model, MyBu7Model } from 'src/app/shared/model/bu7.model';
...@@ -18,25 +19,11 @@ interface table { ...@@ -18,25 +19,11 @@ interface table {
styleUrls: ['./sub-department-four.component.scss'] styleUrls: ['./sub-department-four.component.scss']
}) })
export class SubDepartmentFourComponent implements OnInit { export class SubDepartmentFourComponent implements OnInit {
bu7List: { check: boolean, data: Bu7Model }[] = [] bu7: { loading: boolean, select: Bu7Model, dataList: Bu7Model[] } = { loading: false, select: new MyBu7Model(), dataList: [] }
bu7ListLoading = false
bu7: Bu7Model = new MyBu7Model()
bu7Table: table = {
currentPage: 1,
page: Array.from({ length: 1 }, (_, i) => i + 1),
search: "",
pageSize: 10
}
selectedFile: File | null = null; selectedFile: File | null = null;
selectedFileName: string = 'กรุณาเลือกไฟล์'; selectedFileName: string = 'กรุณาเลือกไฟล์';
bu7Modal: table = {
currentPage: 1,
page: Array.from({ length: 1 }, (_, i) => i + 1),
search: "",
pageSize: 10
}
bu6List: Bu6Model[] = [] bu6List: Bu6Model[] = []
bu6: Bu6Model = new MyBu6Model() bu6: Bu6Model = new MyBu6Model()
bu6Modal: table = { bu6Modal: table = {
...@@ -47,9 +34,29 @@ export class SubDepartmentFourComponent implements OnInit { ...@@ -47,9 +34,29 @@ export class SubDepartmentFourComponent implements OnInit {
} }
currentModal: 'add' | 'edit' | 'delete' = "add" currentModal: 'add' | 'edit' | 'delete' = "add"
numDataListChecked = 0 columns: ColumnModel[] = [{
isDataListChecked = false field: "bu7id",
isDataListCheckedAll = false headerText: "รหัสฝ่าย",
type: "string",
isPrimaryKey: true,
},
{
field: "tdesc",
headerText: "รายละเอียดฝ่าย(ไทย)",
type: "string"
},
{
field: "edesc",
headerText: "รายละเอียดฝ่าย(อังกฤษ)",
type: "string"
}]
searchSettings = {
fields: ['bu7id', '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 bu7Service: Bu7Service, constructor(private bu7Service: Bu7Service,
private bu6Service: Bu6Service, private bu6Service: Bu6Service,
private toastr: ToastrService, private toastr: ToastrService,
...@@ -73,7 +80,7 @@ export class SubDepartmentFourComponent implements OnInit { ...@@ -73,7 +80,7 @@ export class SubDepartmentFourComponent implements OnInit {
} }
const formData = new FormData(); const formData = new FormData();
formData.append('file', this.selectedFile); formData.append('file', this.selectedFile);
this.bu7ListLoading = true this.bu7.loading = true
this.fileService.uploadExcel(formData, 'mbu7').subscribe({ this.fileService.uploadExcel(formData, 'mbu7').subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
...@@ -81,11 +88,11 @@ export class SubDepartmentFourComponent implements OnInit { ...@@ -81,11 +88,11 @@ export class SubDepartmentFourComponent implements OnInit {
this.getBu7List() this.getBu7List()
} else { } else {
this.showAlert(response.message, 'error') this.showAlert(response.message, 'error')
this.bu7ListLoading = false this.bu7.loading = false
} }
}, error: error => { }, error: error => {
this.showAlert(error.message, 'error') this.showAlert(error.message, 'error')
this.bu7ListLoading = false this.bu7.loading = false
} }
}) })
} }
...@@ -110,76 +117,62 @@ export class SubDepartmentFourComponent implements OnInit { ...@@ -110,76 +117,62 @@ export class SubDepartmentFourComponent implements OnInit {
} }
getBu7List() { getBu7List() {
this.bu7ListLoading = true this.bu7.loading = true
this.bu7Service.getList().subscribe({ this.bu7Service.getList().subscribe({
next: response => { next: response => {
this.bu7List = response.map(x => ({ check: false, data: new MyBu7Model(x) })) this.bu7.dataList = response.map(x => {
this.bu7ListLoading = false this.selectedItems.data.set(x.bu7id, false)
this.onBu7TableSearchChange() return new MyBu7Model(x)
this.isDataListCheckedAll = false })
this.dataListCheckAll() this.selectedItems.key = 'bu7id'
this.selectedItems.count = 0
this.bu7.loading = false
this.cdr.detectChanges() this.cdr.detectChanges()
}, error: error => { }, error: error => {
this.bu7ListLoading = false this.bu7.loading = false
this.cdr.detectChanges() this.cdr.detectChanges()
} }
}) })
} }
onBu7TableSearchChange() {
this.bu7Table.currentPage = 1
this.bu7Table.page = Array.from({ length: Math.ceil(this.filterBu7Table().length / 10) }, (_, i) => i + 1);
this.dataListCheck()
}
filterBu7Table() {
return this.bu7List.filter(x => {
const data = x.data
return data.bu7id.toLowerCase().includes(this.bu7Table.search.toLowerCase()) ||
data.tdesc.toLowerCase().includes(this.bu7Table.search.toLowerCase()) ||
data.edesc.toLowerCase().includes(this.bu7Table.search.toLowerCase())
})
}
selectBu7(bu7?: Bu7Model) { selectBu7(bu7?: Bu7Model) {
this.bu7 = new MyBu7Model(bu7 || {}) if (bu7) {
this.bu7.select = new MyBu7Model(bu7)
} else if (this.currentModal == 'add') {
this.bu7.select = new MyBu7Model()
} else if (this.currentModal == 'edit') {
this.bu7.select = new MyBu7Model({ bu7id: this.bu7.select.bu7id })
}
this.selectBu6() this.selectBu6()
if (this.bu7.parent) { if (this.bu7.select.parent) {
this.bu6Service.getById(this.bu7.parent).subscribe(response => { this.bu6Service.getById(this.bu7.select.parent).subscribe(response => {
this.bu6 = new MyBu6Model(response) this.bu6 = new MyBu6Model(response)
this.cdr.detectChanges() this.cdr.detectChanges()
}) })
} }
} }
onBu7ModalSearchChange() {
this.bu7Modal.currentPage = 1
this.bu7Modal.page = Array.from({ length: Math.ceil(this.filterBu7Modal().length / 10) }, (_, i) => i + 1);
}
filterBu7Modal() {
return this.bu7List.filter(x => {
const data = x.data
return data.bu7id.toLowerCase().includes(this.bu7Table.search.toLowerCase()) ||
data.tdesc.toLowerCase().includes(this.bu7Table.search.toLowerCase()) ||
data.edesc.toLowerCase().includes(this.bu7Table.search.toLowerCase())
})
}
addBu7() { addBu7() {
this.bu7ListLoading = true this.bu7.loading = true
this.bu7Service.post({ ...this.bu7, parent: this.bu6.bu6id }).subscribe({ this.bu7Service.post({ ...this.bu7.select, parent: this.bu6.bu6id }).subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
this.showAlert(response.message, 'success') this.showAlert(response.message, 'success')
this.getBu7List() this.getBu7List()
} else { } else {
this.showAlert(response.message, 'error') this.showAlert(response.message, 'error')
this.bu7ListLoading = false this.bu7.loading = false
} }
}, error: error => { }, error: error => {
this.showAlert(error.message, 'error') this.showAlert(error.message, 'error')
this.bu7ListLoading = false this.bu7.loading = false
} }
}) })
} }
deleteBu7() { deleteBu7() {
this.bu7ListLoading = true this.bu7.loading = true
const body = this.bu7List.filter(x => x.check).map(x => new MyBu7Model(x.data)) const selectedKeys = Array.from(this.selectedItems.data.keys());
const body = this.bu7.dataList.filter(x => selectedKeys.includes(x.bu7id) && this.selectedItems.data.get(x.bu7id)).map(x => new MyBu7Model(x))
this.bu7Service.delete(body).subscribe({ this.bu7Service.delete(body).subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
...@@ -187,11 +180,11 @@ export class SubDepartmentFourComponent implements OnInit { ...@@ -187,11 +180,11 @@ export class SubDepartmentFourComponent implements OnInit {
this.getBu7List() this.getBu7List()
} else { } else {
this.showAlert(response.message, 'error') this.showAlert(response.message, 'error')
this.bu7ListLoading = false this.bu7.loading = false
} }
}, error: error => { }, error: error => {
this.showAlert(error.message, 'error') this.showAlert(error.message, 'error')
this.bu7ListLoading = false this.bu7.loading = false
} }
}) })
} }
...@@ -226,21 +219,20 @@ export class SubDepartmentFourComponent implements OnInit { ...@@ -226,21 +219,20 @@ export class SubDepartmentFourComponent implements OnInit {
}) })
} }
dataListCheckAll() {
const selectAll = this.isDataListCheckedAll;
this.filterBu7Table().forEach(x => x.check = selectAll); checkPrimary() {
this.dataListCheck(); return this.bu7.dataList.find(x => x.bu7id == this.bu7.select.bu7id)
} }
dataListCheck() { numSelectItem() {
const dataCheck = this.filterBu7Table(); const selectedKeys = Array.from(this.selectedItems.data.keys());
this.isDataListCheckedAll = dataCheck.length ? dataCheck.every(x => x.check) : false; const num = this.bu7.dataList.filter(x => selectedKeys.includes(x.bu7id) && this.selectedItems.data.get(x.bu7id)).length
this.numDataListChecked = this.bu7List.filter(x => x.check).length return num
this.isDataListChecked = Boolean(this.numDataListChecked)
} }
checkPrimary() { onSelectItemChange(arg: any) {
return this.bu7List.find(x => x.data.bu7id == this.bu7.bu7id) this.selectedItems = arg
} }
} }
......
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