Commit 9fc248ab by Nakarin Luankla

UPDATE ทะเบียนบริษัท > หน่วยธุรกิจ เปลี่ยน modal

parent f267a8cc
...@@ -23,14 +23,14 @@ ...@@ -23,14 +23,14 @@
</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"
(click)="currentModal='add';selectBu6();selectBu7()" data-hs-overlay="#sub-department-four-modal"> (click)="currentModal='add';selectBu6();selectBu7();openDialog()" >
<i class="ri-add-line"></i> <i class="ri-add-line"></i>
Add Add
</button> </button>
</div> </div>
<div class="px-1"> <div class="px-1">
<button href="javascript:void(0);" class="ti-btn ti-btn-soft-danger h-45px m-0 shadow-md" <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"> (click)="currentModal='delete';deleteBu7();">
<i class="ri-delete-bin-6-line"></i> <i class="ri-delete-bin-6-line"></i>
Delete Delete
</button> </button>
...@@ -40,272 +40,148 @@ ...@@ -40,272 +40,148 @@
<div class="page px-rem"> <div class="page px-rem">
<app-datagrid-syncfution [searchSettings]="searchSettings" [searchText]="search" [dataSource]="bu7.dataList" <app-datagrid-syncfution [searchSettings]="searchSettings" [searchText]="search" [dataSource]="bu7.dataList"
[columns]="columns" [selectedItems]="selectedItems" modalName="#sub-department-four-modal" [columns]="columns" [selectedItems]="selectedItems"
(sendSelectData)="currentModal='edit';selectBu7($event)" (sendSelectedItems)="onSelectItemChange($event)"> (sendSelectData)="currentModal='edit';selectBu7($event);openDialog()" (sendSelectedItems)="onSelectItemChange($event)">
</app-datagrid-syncfution> </app-datagrid-syncfution>
</div> </div>
<ng-template #subDepartmentFourModal let-modal>
<h3 mat-dialog-title>
<div id="sub-department-four-modal" class="hs-overlay hidden ti-modal"> {{currentModal=='add'?'เพิ่มข้อมูลทะเบียนส่วนย่อย 4':'แก้ไขข้อมูลทะเบียนส่วนย่อย 4'}}
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)]"> </h3>
<div class="max-h-full overflow-hidden ti-modal-content"> <div class="w-full flex justify-end mb-1rem">
<div class="ti-modal-header"> <div class="absolute flex">
<h3 class="text-xxl font-bold text-primary"> <div class="px-1">
<ng-container *ngIf="currentModal=='add'"> <button type="button" class="ti-btn ti-btn-soft-indigo h-45px m-0 shadow-md" (click)="selectBu6();selectBu7()">
เพิ่มข้อมูลทะเบียนส่วนย่อย 4 <i class="ti ti-eraser text-base"></i>
</ng-container> Clear
<ng-container *ngIf="currentModal=='edit'"> </button>
แก้ไขข้อมูลทะเบียนส่วนย่อย 4
</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-four-modal">
<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();selectBu7()">
<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>
</div>
<div class="ti-modal-body">
<label 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 class="ti-form-label mt-2rem">ส่วนย่อย4
<span class="text-danger">*
<ng-container *ngIf="currentModal=='add'&&checkPrimary()">
ส่วนย่อย4ซ้ำ
</ng-container>
</span>
</label>
<div class="relative flex rounded-md w-1/2">
<input type="text" class="ti-form-input"
[class.!border-red]="currentModal=='add'&&checkPrimary()"
[class.!bg-input-readonly]="currentModal=='edit'" [readonly]="currentModal=='edit'"
[(ngModel)]="bu7.select.bu7id">
</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.select.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.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-four-modal">
ย้อนกลับ
</button>
<button type="button" class="ti-btn ti-btn-success" data-hs-overlay="#sub-department-four-alert"
[class.ti-btn-disabled]="!bu6.bu6id||!bu7.select.bu7id||!bu7.select.tdesc||(currentModal=='add'&&checkPrimary())"
[disabled]=" !bu6.bu6id||!bu7.select.bu7id||!bu7.select.tdesc||(currentModal=='add' &&checkPrimary())">
บันทึกข้อมูล
</button>
</div>
</div> </div>
</div> </div>
</div> </div>
</div> <mat-dialog-content>
<label class="ti-form-label ">อยู่ภายใต้หน่วยงาน<span class="text-danger">*</span></label>
<div id="sub-department-four-bu6-table-modal" class="hs-overlay hidden ti-modal"> <div class="flex">
<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"> <div class="relative flex rounded-md">
<div class="max-h-full overflow-hidden ti-modal-content"> <input type="text" id="hs-leading-button-add-on-with-icon-and-button"
<div class="ti-modal-header"> name="hs-leading-button-add-on-with-icon-and-button"
<h3 class="text-xxl font-bold text-primary"> class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10" readonly
ข้อมูลทะเบียนส่วนย่อย 3 style="padding-right: 3.5rem;" [(ngModel)]="bu6.bu6id" (ngModelChange)="bu6idChange()">
</h3> <div
<div class="flex justify-end"> 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="hs-dropdown-toggle ti-modal-clode-btn text-danger" <button type="button" class="flex items-center text-red-500" (click)="selectBu6()">
data-hs-overlay="#sub-department-four-modal"> <i class="ti ti-circle-x cursor-pointer"></i>
<span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i>
</button>
</div>
</div>
<div class="ti-modal-body">
<div class="flex justify-end pb-1rem">
<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)]="bu6Modal.search"
(ngModelChange)="onBu6ModalSearchChange()">
<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>
</div>
</div>
</div>
</div>
<div class="overflow-auto border">
<table class="ti-custom-table ti-custom-table-head ti-custom-table-hover">
<thead>
<tr>
<ng-container
*ngFor="let item of ['ลำดับ','รหัสส่วนย่อย3','รายละเอียดส่วนย่อย3 (ไทย)','รายละเอียดส่วนย่อย3 (อังกฤษ)']; let f = first; let l = last">
<th scope="col" class="relative px-10px py-10px bg-soft-secondary text-primary"
[class.!text-center]="f">
<span class="text-sm">{{ item }}</span>
<div class="absolute top-1/2 transform -translate-y-1/2 right-0" *ngIf="!l">
<i class="ti ti-dots-vertical fs-l"></i>
</div>
</th>
</ng-container>
</tr>
</thead>
<tbody *ngIf="!filterBu6Modal().length">
<tr>
<td class="text-center" colspan="100%">
ไม่พบข้อมูล
</td>
</tr>
</tbody>
<tbody *ngIf="filterBu6Modal().length">
<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">
<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>
</tbody>
</table>
</div>
<app-pagination [totalItems]="filterBu6Modal().length" [pageSize]="bu6Modal.pageSize"
(pageChange)="bu6Modal.currentPage = $event"
(pageSizeChange)="bu6Modal.pageSize = $event;bu6Modal.currentPage = 1"></app-pagination>
<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">
ย้อนกลับ
</button> </button>
</div> <button type="button" class="flex items-center text-gray-500 dark:text-white/70" (click)="openDialogBu6()">
</div> <i class="ri-search-line cursor-pointer text-gray"></i>
</div>
</div>
</div>
<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="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">
<span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i>
</button> </button>
</div> </div>
</div> </div>
<div class="ti-modal-body "> <div class="flex rounded-md w-1/2 pl-1rem">
<p class="mt-1 text-gray-800 dark:text-white/70"> <input type="text" id="input-label" class="ti-form-input w-full pr-10 bg-input-readonly"
ยืนยันการบันทึกข้อมูลหรือไม่ readonly [value]="bu6.tdesc">
</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-four-modal">
ย้อนกลับ
</button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#sub-department-four-alert" (click)="addBu7();">
บันทึกข้อมูล
</a>
</div>
</div> </div>
</div> </div>
</div> <label class="ti-form-label mt-2rem">ส่วนย่อย4
</div> <span class="text-danger">*
<ng-container *ngIf="currentModal=='add'&&checkPrimary()">
ส่วนย่อย4ซ้ำ
</ng-container>
</span>
</label>
<div class="relative flex rounded-md w-1/2">
<input type="text" class="ti-form-input"
[class.!border-red]="currentModal=='add'&&checkPrimary()"
[class.!bg-input-readonly]="currentModal=='edit'" [readonly]="currentModal=='edit'"
[(ngModel)]="bu7.select.bu7id">
</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.select.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.select.edesc">
</mat-dialog-content>
<mat-dialog-actions align="end">
<button type="button" mat-button [mat-dialog-close]
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">
ย้อนกลับ
</button>
<button type="button" class="ti-btn ti-btn-success" mat-button (click)="addBu7();"
[class.ti-btn-disabled]="!bu6.bu6id||!bu7.select.bu7id||!bu7.select.tdesc||(currentModal=='add'&&checkPrimary())"
[disabled]=" !bu6.bu6id||!bu7.select.bu7id||!bu7.select.tdesc||(currentModal=='add' &&checkPrimary())">
บันทึกข้อมูล
</button>
</mat-dialog-actions>
</ng-template>
<div id="sub-department-four-alert-delete-modal" class="hs-overlay hidden ti-modal">
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)] flex items-center">
<div class="max-h-full overflow-hidden ti-modal-content w-full">
<div class="ti-modal-header">
<h3 class="text-xxl font-bold text-primary">
แจ้งเตือน
</h3>
<div class="flex justify-end">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#sub-department-four-alert-delete-modal">
<span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i>
</button>
</div>
</div>
<div class="ti-modal-body ">
<p class="mt-1 text-gray-800 dark:text-white/70">
<ng-container *ngIf="numSelectItem()">
ยืนยันการลบข้อมูลหรือไม่
</ng-container>
<ng-container *ngIf="!numSelectItem()">
เลือกข้อมูลที่ต้องการลบ
</ng-container>
</p>
<div class="flex justify-end mt-2rem mb-1rem">
<button type="button" <ng-template #subDepartmentFourModalBu6 let-modal>
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" <h3 mat-dialog-title>
data-hs-overlay="#sub-department-four-alert-delete-modal"> ข้อมูลทะเบียนส่วนย่อย 3
ย้อนกลับ </h3>
</button> <mat-dialog-content>
<a class="ti-btn ti-btn-danger" href="javascript:void(0);" <div class="flex justify-end pb-1rem">
data-hs-overlay="#sub-department-four-alert-delete-modal" (click)="deleteBu7();" <div class="px-1">
*ngIf="numSelectItem()"> <div class="relative shadow-md">
ลบข้อมูล <input type="text" id="hs-leading-icon" name="hs-leading-icon"
</a> class="ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 "
placeholder="Search by No. or Name" [(ngModel)]="bu6Modal.search"
(ngModelChange)="onBu6ModalSearchChange()">
<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>
</div>
</div> </div>
</div> </div>
</div> </div>
</div> <div class="overflow-auto border">
</div> <table class="ti-custom-table ti-custom-table-head ti-custom-table-hover">
<thead>
<tr>
<ng-container
*ngFor="let item of ['ลำดับ','รหัสส่วนย่อย3','รายละเอียดส่วนย่อย3 (ไทย)','รายละเอียดส่วนย่อย3 (อังกฤษ)']; let f = first; let l = last">
<th scope="col" class="relative px-10px py-10px bg-soft-secondary text-primary"
[class.!text-center]="f">
<span class="text-sm">{{ item }}</span>
<div class="absolute top-1/2 transform -translate-y-1/2 right-0" *ngIf="!l">
<i class="ti ti-dots-vertical fs-l"></i>
</div>
</th>
</ng-container>
</tr>
</thead>
<tbody *ngIf="!filterBu6Modal().length">
<tr>
<td class="text-center" colspan="100%">
ไม่พบข้อมูล
</td>
</tr>
</tbody>
<tbody *ngIf="filterBu6Modal().length">
<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);closeDialogBu6()">
<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>
</tbody>
</table>
</div>
<app-pagination [totalItems]="filterBu6Modal().length" [pageSize]="bu6Modal.pageSize"
(pageChange)="bu6Modal.currentPage = $event"
(pageSizeChange)="bu6Modal.pageSize = $event;bu6Modal.currentPage = 1"></app-pagination>
</mat-dialog-content>
<mat-dialog-actions align="end">
<button type="button" mat-button [mat-dialog-close]
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">
ย้อนกลับ
</button>
</mat-dialog-actions>
</ng-template>
<div id="sub-department-four-upload-modal" class="hs-overlay hidden ti-modal"> <div id="sub-department-four-upload-modal" class="hs-overlay hidden ti-modal">
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out rounded-md"> <div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out rounded-md">
......
import { ChangeDetectorRef, Component, EventEmitter, Input, OnInit } from '@angular/core'; import { ChangeDetectorRef, Component, EventEmitter, Input, OnInit, ViewChild } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { ColumnModel } from '@syncfusion/ej2-grids'; 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';
...@@ -6,6 +7,7 @@ import { Bu7Model, MyBu7Model } from 'src/app/shared/model/bu7.model'; ...@@ -6,6 +7,7 @@ import { Bu7Model, MyBu7Model } from 'src/app/shared/model/bu7.model';
import { Bu6Service } from 'src/app/shared/services/bu6.service'; import { Bu6Service } from 'src/app/shared/services/bu6.service';
import { Bu7Service } from 'src/app/shared/services/bu7.service'; import { Bu7Service } from 'src/app/shared/services/bu7.service';
import { FileService } from 'src/app/shared/services/file.service'; import { FileService } from 'src/app/shared/services/file.service';
import Swal from 'sweetalert2';
interface table { interface table {
currentPage: number, currentPage: number,
...@@ -57,17 +59,41 @@ export class SubDepartmentFourComponent implements OnInit { ...@@ -57,17 +59,41 @@ export class SubDepartmentFourComponent implements OnInit {
}; };
search = '' search = ''
selectedItems: { key: string, count: number, data: Map<string, boolean> } = { key: '', count: 0, data: new Map<string, boolean>() }; selectedItems: { key: string, count: number, data: Map<string, boolean> } = { key: '', count: 0, data: new Map<string, boolean>() };
@ViewChild("subDepartmentFourModal") subDepartmentFourModal: any;
@ViewChild("subDepartmentFourModalBu6") subDepartmentFourModalBu6: any;
dialogRef: any
dialogRefBu6: any
constructor(private bu7Service: Bu7Service, constructor(private bu7Service: Bu7Service,
private bu6Service: Bu6Service, private bu6Service: Bu6Service,
private toastr: ToastrService, private toastr: ToastrService,
private cdr: ChangeDetectorRef, private cdr: ChangeDetectorRef,
private fileService: FileService private fileService: FileService,
private dialog: MatDialog
) { } ) { }
ngOnInit(): void { ngOnInit(): void {
this.getBu7List() this.getBu7List()
this.getBu6List() this.getBu6List()
} }
openDialog() {
this.dialogRef = this.dialog.open(this.subDepartmentFourModal, {
width: '500px',
})
}
openDialogBu6() {
this.dialogRefBu6 = this.dialog.open(this.subDepartmentFourModalBu6, {
width: '500px',
})
}
closeDialog() {
this.dialogRef.close()
}
closeDialogBu6() {
this.dialogRefBu6.close()
}
onFileSelected(event: any) { onFileSelected(event: any) {
this.selectedFile = event.target.files.length > 0 ? event.target.files[0] : null; this.selectedFile = event.target.files.length > 0 ? event.target.files[0] : null;
this.selectedFileName = this.selectedFile?.name || "กรุณาเลือกไฟล์" this.selectedFileName = this.selectedFile?.name || "กรุณาเลือกไฟล์"
...@@ -153,38 +179,68 @@ export class SubDepartmentFourComponent implements OnInit { ...@@ -153,38 +179,68 @@ export class SubDepartmentFourComponent implements OnInit {
} }
addBu7() { addBu7() {
this.bu7.loading = true Swal.fire({
this.bu7Service.post({ ...this.bu7.select, parent: this.bu6.bu6id }).subscribe({ icon: 'question',
next: response => { title: 'แจ้งเตือน',
if (response.success) { text: 'ยืนยันการบันทึกข้อมูลหรือไม่',
this.showAlert(response.message, 'success') showCancelButton: true,
this.getBu7List() confirmButtonText: 'ยืนยัน',
} else { }).then((result) => {
this.showAlert(response.message, 'error') if (result.isConfirmed) {
this.bu7.loading = false this.bu7.loading = true
} this.bu7Service.post({ ...this.bu7.select, parent: this.bu6.bu6id }).subscribe({
}, error: error => { next: response => {
this.showAlert(error.message, 'error') if (response.success) {
this.bu7.loading = false this.showAlert(response.message, 'success')
this.getBu7List()
this.closeDialog()
} else {
this.showAlert(response.message, 'error')
this.bu7.loading = false
this.closeDialog()
}
}, error: error => {
this.showAlert(error.message, 'error')
this.bu7.loading = false
this.closeDialog()
}
})
} }
}) })
} }
deleteBu7() { deleteBu7() {
this.bu7.loading = true if (this.numSelectItem() == 0) {
const selectedKeys = Array.from(this.selectedItems.data.keys()); this.showAlert('กรุณาเลือกข้อมูลที่จะลบ', 'error')
const body = this.bu7.dataList.filter(x => selectedKeys.includes(x.bu7id) && this.selectedItems.data.get(x.bu7id)).map(x => new MyBu7Model(x)) return
this.bu7Service.delete(body).subscribe({ }
next: response => { Swal.fire({
if (response.success) { icon: 'question',
this.showAlert(response.message, 'success') title: 'แจ้งเตือน',
this.getBu7List() text: 'ยืนยันการลบข้อมูลหรือไม่',
} else { showCancelButton: true,
this.showAlert(response.message, 'error') confirmButtonText: 'ลบข้อมูล',
this.bu7.loading = false }).then((result) => {
} if (result.isConfirmed) {
}, error: error => { this.bu7.loading = true
this.showAlert(error.message, 'error') const selectedKeys = Array.from(this.selectedItems.data.keys());
this.bu7.loading = false 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({
next: response => {
if (response.success) {
this.showAlert(response.message, 'success')
this.getBu7List()
this.closeDialog()
} else {
this.showAlert(response.message, 'error')
this.bu7.loading = false
this.closeDialog()
}
}, error: error => {
this.showAlert(error.message, 'error')
this.bu7.loading = false
this.closeDialog()
}
})
} }
}) })
} }
...@@ -213,9 +269,12 @@ export class SubDepartmentFourComponent implements OnInit { ...@@ -213,9 +269,12 @@ export class SubDepartmentFourComponent implements OnInit {
} }
showAlert(text: string, type: 'success' | 'error') { showAlert(text: string, type: 'success' | 'error') {
this.toastr[type](text, 'แจ้งเตือน', { Swal.fire({
timeOut: 3000, icon: type,
positionClass: 'toast-top-right', title: 'แจ้งเตือน',
text: text,
showCancelButton: false,
confirmButtonText: 'ยืนยัน',
}) })
} }
......
...@@ -23,14 +23,14 @@ ...@@ -23,14 +23,14 @@
</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"
(click)="currentModal='add';selectBu5();selectBu6()" data-hs-overlay="#sub-department-three-modal"> (click)="currentModal='add';selectBu5();selectBu6();openDialog()" >
<i class="ri-add-line"></i> <i class="ri-add-line"></i>
Add Add
</button> </button>
</div> </div>
<div class="px-1"> <div class="px-1">
<button href="javascript:void(0);" class="ti-btn ti-btn-soft-danger h-45px m-0 shadow-md" <button href="javascript:void(0);" class="ti-btn ti-btn-soft-danger h-45px m-0 shadow-md"
data-hs-overlay="#sub-department-three-alert-delete-modal"> (click)="deleteBu6()">
<i class="ri-delete-bin-6-line"></i> <i class="ri-delete-bin-6-line"></i>
Delete Delete
</button> </button>
...@@ -40,273 +40,149 @@ ...@@ -40,273 +40,149 @@
<div class="page px-rem"> <div class="page px-rem">
<app-datagrid-syncfution [searchSettings]="searchSettings" [searchText]="search" [dataSource]="bu6.dataList" <app-datagrid-syncfution [searchSettings]="searchSettings" [searchText]="search" [dataSource]="bu6.dataList"
[columns]="columns" [selectedItems]="selectedItems" modalName="#sub-department-three-modal" [columns]="columns" [selectedItems]="selectedItems"
(sendSelectData)="currentModal='edit';selectBu6($event)" (sendSelectedItems)="onSelectItemChange($event)"> (sendSelectData)="currentModal='edit';selectBu6($event);openDialog()" (sendSelectedItems)="onSelectItemChange($event)">
</app-datagrid-syncfution> </app-datagrid-syncfution>
</div> </div>
<ng-template #subDepartmentThreeModal let-modal>
<div id="sub-department-three-modal" class="hs-overlay hidden ti-modal"> <h3 mat-dialog-title>
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)]"> {{currentModal=='add'?'เพิ่มข้อมูลทะเบียนส่วนย่อย 3':'แก้ไขข้อมูลทะเบียนส่วนย่อย 3'}}
<div class="max-h-full overflow-hidden ti-modal-content"> </h3>
<div class="ti-modal-header"> <div class="w-full flex justify-end mb-1rem">
<h3 class="text-xxl font-bold text-primary"> <div class="absolute flex">
<ng-container *ngIf="currentModal=='add'"> <div class="px-1">
เพิ่มข้อมูลทะเบียนส่วนย่อย 3 <button type="button" class="ti-btn ti-btn-soft-indigo h-45px m-0 shadow-md" (click)="selectBu5();selectBu6()">
</ng-container> <i class="ti ti-eraser text-base"></i>
<ng-container *ngIf="currentModal=='edit'"> Clear
แก้ไขข้อมูลทะเบียนส่วนย่อย 3 </button>
</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-three-modal">
<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)="selectBu5();selectBu6()">
<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>
</div>
<div class="ti-modal-body">
<label 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)]="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-three-bu5-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]="bu5.tdesc">
</div>
</div>
<label class="ti-form-label mt-2rem">ส่วนย่อย3
<span class="text-danger">*
<ng-container *ngIf="currentModal=='add'&&checkPrimary()">
ส่วนย่อย3ซ้ำ
</ng-container>
</span>
</label>
<div class="relative flex rounded-md w-1/2">
<input type="text" class="ti-form-input" [class.!border-red]="currentModal=='add'&&checkPrimary()"
[class.!bg-input-readonly]="currentModal=='edit'" [readonly]="currentModal=='edit'"
[(ngModel)]="bu6.select.bu6id">
</div>
<label for="detail_th" class="ti-form-label mt-2rem">รายละเอียดส่วนย่อย3 (ไทย)<span
class="text-danger">*</span></label>
<input type="text" id="detail_th" class="ti-form-input h-16" [(ngModel)]="bu6.select.tdesc">
<label for="detail_eng" class="ti-form-label mt-2rem">รายละเอียดส่วนย่อย3 (อังกฤษ)</label>
<input type="text" id="detail_eng" class="ti-form-input h-16" [(ngModel)]="bu6.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-three-modal">
ย้อนกลับ
</button>
<button type="button" class="ti-btn ti-btn-success"
data-hs-overlay="#sub-department-three-alert-modal"
[class.ti-btn-disabled]="!bu5.bu5id||!bu6.select.bu6id||!bu6.select.tdesc||(currentModal=='add'&&checkPrimary())"
[disabled]="!bu5.bu5id||!bu6.select.bu6id||!bu6.select.tdesc||(currentModal=='add'&&checkPrimary())">
บันทึกข้อมูล
</button>
</div>
</div> </div>
</div> </div>
</div> </div>
</div> <mat-dialog-content>
<label class="ti-form-label ">อยู่ภายใต้หน่วยงาน<span class="text-danger">*</span></label>
<div class="flex">
<div id="sub-department-three-alert-modal" class="hs-overlay hidden ti-modal"> <div class="relative flex rounded-md">
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)] flex items-center"> <input type="text" id="hs-leading-button-add-on-with-icon-and-button"
<div class="max-h-full overflow-hidden ti-modal-content w-full"> name="hs-leading-button-add-on-with-icon-and-button"
<div class="ti-modal-header"> class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10" readonly
<h3 class="text-xxl font-bold text-primary"> style="padding-right: 3.5rem;" [(ngModel)]="bu5.bu5id" (ngModelChange)="bu5idChange()">
แจ้งเตือน <div
</h3> 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">
<div class="flex justify-end"> <button type="button" class="flex items-center text-red-500" (click)="selectBu5()">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger" <i class="ti ti-circle-x cursor-pointer"></i>
data-hs-overlay="#sub-department-three-modal">
<span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i>
</button> </button>
</div> <button type="button" class="flex items-center text-gray-500 dark:text-white/70" (click)="openDialogBu5()">
</div> <i class="ri-search-line cursor-pointer text-gray"></i>
<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-three-modal">
ย้อนกลับ
</button> </button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#sub-department-three-alert-modal" (click)="addBu6();">
บันทึกข้อมูล
</a>
</div> </div>
</div> </div>
</div> <div class="flex rounded-md w-1/2 pl-1rem">
</div> <input type="text" id="input-label" class="ti-form-input w-full pr-10 bg-input-readonly"
</div> readonly [value]="bu5.tdesc">
<div id="sub-department-three-alert-delete-modal" class="hs-overlay hidden ti-modal">
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)] flex items-center">
<div class="max-h-full overflow-hidden ti-modal-content w-full">
<div class="ti-modal-header">
<h3 class="text-xxl font-bold text-primary">
แจ้งเตือน
</h3>
<div class="flex justify-end">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#sub-department-three-alert-delete-modal">
<span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i>
</button>
</div>
</div>
<div class="ti-modal-body ">
<p class="mt-1 text-gray-800 dark:text-white/70">
<ng-container *ngIf="numSelectItem()">
ยืนยันการลบข้อมูลหรือไม่
</ng-container>
<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"
data-hs-overlay="#sub-department-three-alert-delete-modal">
ย้อนกลับ
</button>
<a class="ti-btn ti-btn-danger" href="javascript:void(0);"
data-hs-overlay="#sub-department-three-alert-delete-modal" (click)="deleteBu6()"
*ngIf="numSelectItem()">
ลบข้อมูล
</a>
</div>
</div> </div>
</div> </div>
</div> <label class="ti-form-label mt-2rem">ส่วนย่อย3
</div> <span class="text-danger">*
<ng-container *ngIf="currentModal=='add'&&checkPrimary()">
ส่วนย่อย3ซ้ำ
</ng-container>
</span>
</label>
<div class="relative flex rounded-md w-1/2">
<input type="text" class="ti-form-input" [class.!border-red]="currentModal=='add'&&checkPrimary()"
[class.!bg-input-readonly]="currentModal=='edit'" [readonly]="currentModal=='edit'"
[(ngModel)]="bu6.select.bu6id">
</div>
<label for="detail_th" class="ti-form-label mt-2rem">รายละเอียดส่วนย่อย3 (ไทย)<span
class="text-danger">*</span></label>
<input type="text" id="detail_th" class="ti-form-input h-16" [(ngModel)]="bu6.select.tdesc">
<label for="detail_eng" class="ti-form-label mt-2rem">รายละเอียดส่วนย่อย3 (อังกฤษ)</label>
<input type="text" id="detail_eng" class="ti-form-input h-16" [(ngModel)]="bu6.select.edesc">
</mat-dialog-content>
<mat-dialog-actions align="end">
<button type="button" mat-button [mat-dialog-close]
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">
ย้อนกลับ
</button>
<button type="button" class="ti-btn ti-btn-success" mat-button (click)="addBu6();"
[class.ti-btn-disabled]="!bu5.bu5id||!bu6.select.bu6id||!bu6.select.tdesc||(currentModal=='add'&&checkPrimary())"
[disabled]="!bu5.bu5id||!bu6.select.bu6id||!bu6.select.tdesc||(currentModal=='add'&&checkPrimary())">
บันทึกข้อมูล
</button>
</mat-dialog-actions>
</ng-template>
<div id="sub-department-three-bu5-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"> <ng-template #subDepartmentThreeModalBu5 let-modal>
<div class="max-h-full overflow-hidden ti-modal-content"> <h3 mat-dialog-title>
<div class="ti-modal-header"> ข้อมูลทะเบียนส่วนย่อย 2
<h3 class="text-xxl font-bold text-primary"> </h3>
ข้อมูลทะเบียนส่วนย่อย 2 <mat-dialog-content>
</h3> <div class="flex justify-end pb-1rem">
<div class="flex justify-end"> <div class="px-1">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger" <div class="relative shadow-md">
data-hs-overlay="#sub-department-three-modal"> <input type="text" id="hs-leading-icon" name="hs-leading-icon"
<span class="sr-only">Close</span> class="ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 "
<i class="ti ti-circle-x fs-xxl"></i> placeholder="Search by No. or Name" [(ngModel)]="bu5Modal.search"
</button> (ngModelChange)="onBu5ModalSearchChange()">
</div> <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">
<div class="ti-modal-body"> <i class="ri-search-line text-gray"></i>
<div class="flex justify-end pb-1rem">
<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)]="bu5Modal.search"
(ngModelChange)="onBu5ModalSearchChange()">
<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>
</div>
</div>
</div> </div>
</div> </div>
<div class="overflow-auto border">
<table class="ti-custom-table ti-custom-table-head ti-custom-table-hover">
<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"
[class.!text-center]="f">
<span class="text-sm">{{ item }}</span>
<div class="absolute top-1/2 transform -translate-y-1/2 right-0" *ngIf="!l">
<i class="ti ti-dots-vertical fs-l"></i>
</div>
</th>
</ng-container>
</tr>
</thead>
<tbody *ngIf="!filterBu5Modal().length">
<tr>
<td class="text-center" colspan="100%">
ไม่พบข้อมูล
</td>
</tr>
</tbody>
<tbody *ngIf="filterBu5Modal().length">
<tr *ngFor="let item of filterBu5Modal() | slice:((bu5Modal.currentPage-1) * bu5Modal.pageSize) : (((bu5Modal.currentPage-1) * bu5Modal.pageSize) + bu5Modal.pageSize);let i = index"
class="cursor-pointer" (click)="selectBu5(item)"
data-hs-overlay="#sub-department-three-modal">
<td class="flex justify-center">
{{((bu5Modal.currentPage-1) * bu5Modal.pageSize)+(i+1)}}
</td>
<td>{{item.bu5id}}</td>
<td>{{item.tdesc}}</td>
<td>{{item.edesc}}</td>
</tr>
</tbody>
</table>
</div>
<app-pagination [totalItems]="filterBu5Modal().length" [pageSize]="bu5Modal.pageSize"
(pageChange)="bu5Modal.currentPage = $event"
(pageSizeChange)="bu5Modal.pageSize = $event;bu5Modal.currentPage = 1"></app-pagination>
<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-three-modal">
ย้อนกลับ
</button>
</div>
</div> </div>
</div> </div>
</div> <div class="overflow-auto border">
</div> <table class="ti-custom-table ti-custom-table-head ti-custom-table-hover">
<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"
[class.!text-center]="f">
<span class="text-sm">{{ item }}</span>
<div class="absolute top-1/2 transform -translate-y-1/2 right-0" *ngIf="!l">
<i class="ti ti-dots-vertical fs-l"></i>
</div>
</th>
</ng-container>
</tr>
</thead>
<tbody *ngIf="!filterBu5Modal().length">
<tr>
<td class="text-center" colspan="100%">
ไม่พบข้อมูล
</td>
</tr>
</tbody>
<tbody *ngIf="filterBu5Modal().length">
<tr *ngFor="let item of filterBu5Modal() | slice:((bu5Modal.currentPage-1) * bu5Modal.pageSize) : (((bu5Modal.currentPage-1) * bu5Modal.pageSize) + bu5Modal.pageSize);let i = index"
class="cursor-pointer" (click)="selectBu5(item);closeDialogBu5()">
<td class="flex justify-center">
{{((bu5Modal.currentPage-1) * bu5Modal.pageSize)+(i+1)}}
</td>
<td>{{item.bu5id}}</td>
<td>{{item.tdesc}}</td>
<td>{{item.edesc}}</td>
</tr>
</tbody>
</table>
</div>
<app-pagination [totalItems]="filterBu5Modal().length" [pageSize]="bu5Modal.pageSize"
(pageChange)="bu5Modal.currentPage = $event"
(pageSizeChange)="bu5Modal.pageSize = $event;bu5Modal.currentPage = 1"></app-pagination>
</mat-dialog-content>
<mat-dialog-actions align="end">
<button type="button" mat-button [mat-dialog-close]
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">
ย้อนกลับ
</button>
</mat-dialog-actions>
</ng-template>
<div id="sub-department-three-upload-modal" class="hs-overlay hidden ti-modal"> <div id="sub-department-three-upload-modal" class="hs-overlay hidden ti-modal">
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out rounded-md"> <div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out rounded-md">
......
import { ChangeDetectorRef, Component, EventEmitter, Input, OnInit } from '@angular/core'; import { ChangeDetectorRef, Component, EventEmitter, Input, OnInit, ViewChild } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { ColumnModel } from '@syncfusion/ej2-grids'; import { ColumnModel } from '@syncfusion/ej2-grids';
import { ToastrService } from 'ngx-toastr'; import { ToastrService } from 'ngx-toastr';
import { Bu5Model, MyBu5Model } from 'src/app/shared/model/bu5.model'; import { Bu5Model, MyBu5Model } from 'src/app/shared/model/bu5.model';
...@@ -6,6 +7,7 @@ import { Bu6Model, MyBu6Model } from 'src/app/shared/model/bu6.model'; ...@@ -6,6 +7,7 @@ import { Bu6Model, MyBu6Model } from 'src/app/shared/model/bu6.model';
import { Bu5Service } from 'src/app/shared/services/bu5.service'; import { Bu5Service } from 'src/app/shared/services/bu5.service';
import { Bu6Service } from 'src/app/shared/services/bu6.service'; import { Bu6Service } from 'src/app/shared/services/bu6.service';
import { FileService } from 'src/app/shared/services/file.service'; import { FileService } from 'src/app/shared/services/file.service';
import Swal from 'sweetalert2';
interface table { interface table {
currentPage: number, currentPage: number,
...@@ -58,17 +60,38 @@ export class SubDepartmentThreeComponent implements OnInit { ...@@ -58,17 +60,38 @@ export class SubDepartmentThreeComponent implements OnInit {
}; };
search = '' search = ''
selectedItems: { key: string, count: number, data: Map<string, boolean> } = { key: '', count: 0, data: new Map<string, boolean>() }; selectedItems: { key: string, count: number, data: Map<string, boolean> } = { key: '', count: 0, data: new Map<string, boolean>() };
@ViewChild("subDepartmentThreeModal") subDepartmentThreeModal: any;
@ViewChild("subDepartmentThreeModalBu5") subDepartmentThreeModalBu5: any;
dialogRef: any
dialogRefBu5: any
constructor(private bu6Service: Bu6Service, constructor(private bu6Service: Bu6Service,
private bu5Service: Bu5Service, private bu5Service: Bu5Service,
private toastr: ToastrService, private toastr: ToastrService,
private cdr: ChangeDetectorRef, private cdr: ChangeDetectorRef,
private fileService: FileService private fileService: FileService,
private dialog: MatDialog
) { } ) { }
ngOnInit(): void { ngOnInit(): void {
this.getBu6List() this.getBu6List()
this.getBu5List() this.getBu5List()
} }
openDialog() {
this.dialogRef = this.dialog.open(this.subDepartmentThreeModal, {
width: '500px',
})
}
openDialogBu5() {
this.dialogRefBu5 = this.dialog.open(this.subDepartmentThreeModalBu5, {
width: '800px',
})
}
closeDialog() {
this.dialogRef.close()
}
closeDialogBu5() {
this.dialogRefBu5.close()
}
onFileSelected(event: any) { onFileSelected(event: any) {
this.selectedFile = event.target.files.length > 0 ? event.target.files[0] : null; this.selectedFile = event.target.files.length > 0 ? event.target.files[0] : null;
this.selectedFileName = this.selectedFile?.name || "กรุณาเลือกไฟล์" this.selectedFileName = this.selectedFile?.name || "กรุณาเลือกไฟล์"
...@@ -155,23 +178,50 @@ export class SubDepartmentThreeComponent implements OnInit { ...@@ -155,23 +178,50 @@ export class SubDepartmentThreeComponent implements OnInit {
} }
addBu6() { addBu6() {
this.bu6.loading = true Swal.fire({
this.bu6Service.post({ ...this.bu6.select, parent: this.bu5.bu5id }).subscribe({ icon: 'question',
next: response => { title: 'แจ้งเตือน',
if (response.success) { text: 'ยืนยันการบันทึกข้อมูลหรือไม่',
this.showAlert(response.message, 'success') showCancelButton: true,
this.getBu6List() confirmButtonText: 'ยืนยัน',
} else { }).then((result) => {
this.showAlert(response.message, 'error') if (result.isConfirmed) {
this.bu6.loading = false this.bu6.loading = true
} this.bu6Service.post({ ...this.bu6.select, parent: this.bu5.bu5id }).subscribe({
}, error: error => { next: response => {
this.showAlert(error.message, 'error') if (response.success) {
this.bu6.loading = false this.showAlert(response.message, 'success')
this.getBu6List()
this.closeDialog()
} else {
this.showAlert(response.message, 'error')
this.bu6.loading = false
this.closeDialog()
}
}, error: error => {
this.showAlert(error.message, 'error')
this.bu6.loading = false
this.closeDialog()
}
})
} }
}) })
} }
deleteBu6() { deleteBu6() {
if (this.numSelectItem() == 0) {
this.showAlert('กรุณาเลือกข้อมูลที่จะลบ', 'error')
return
}
Swal.fire({
icon: 'question',
title: 'แจ้งเตือน',
text: 'ยืนยันการลบข้อมูลหรือไม่',
showCancelButton: true,
confirmButtonText: 'ลบข้อมูล',
}).then((result) => {
if (result.isConfirmed) {
this.bu6.loading = true this.bu6.loading = true
const selectedKeys = Array.from(this.selectedItems.data.keys()); const selectedKeys = Array.from(this.selectedItems.data.keys());
const body = this.bu6.dataList.filter(x => selectedKeys.includes(x.bu6id) && this.selectedItems.data.get(x.bu6id)).map(x => new MyBu6Model(x)) const body = this.bu6.dataList.filter(x => selectedKeys.includes(x.bu6id) && this.selectedItems.data.get(x.bu6id)).map(x => new MyBu6Model(x))
...@@ -189,6 +239,8 @@ export class SubDepartmentThreeComponent implements OnInit { ...@@ -189,6 +239,8 @@ export class SubDepartmentThreeComponent implements OnInit {
this.bu6.loading = false this.bu6.loading = false
} }
}) })
}
})
} }
getBu5List() { getBu5List() {
...@@ -215,9 +267,12 @@ export class SubDepartmentThreeComponent implements OnInit { ...@@ -215,9 +267,12 @@ export class SubDepartmentThreeComponent implements OnInit {
} }
showAlert(text: string, type: 'success' | 'error') { showAlert(text: string, type: 'success' | 'error') {
this.toastr[type](text, 'แจ้งเตือน', { Swal.fire({
timeOut: 3000, icon: type,
positionClass: 'toast-top-right', title: 'แจ้งเตือน',
text: text,
showCancelButton: false,
confirmButtonText: 'ยืนยัน',
}) })
} }
......
...@@ -23,14 +23,13 @@ ...@@ -23,14 +23,13 @@
</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"
(click)="currentModal='add';selectBu4();selectBu5()" data-hs-overlay="#sub-department-two-modal"> (click)="currentModal='add';selectBu4();selectBu5();openDialog()">
<i class="ri-add-line"></i> <i class="ri-add-line"></i>
Add Add
</button> </button>
</div> </div>
<div class="px-1"> <div class="px-1">
<button href="javascript:void(0);" class="ti-btn ti-btn-soft-danger h-45px m-0 shadow-md" <button href="javascript:void(0);" class="ti-btn ti-btn-soft-danger h-45px m-0 shadow-md" (click)="deleteBu5()">
data-hs-overlay="#sub-department-two-alert-delete-modal">
<i class="ri-delete-bin-6-line"></i> <i class="ri-delete-bin-6-line"></i>
Delete Delete
</button> </button>
...@@ -39,271 +38,148 @@ ...@@ -39,271 +38,148 @@
</div> </div>
<div class="page px-rem"> <div class="page px-rem">
<app-datagrid-syncfution [searchSettings]="searchSettings" [searchText]="search" [dataSource]="bu5.dataList" <app-datagrid-syncfution [searchSettings]="searchSettings" [searchText]="search" [dataSource]="bu5.dataList"
[columns]="columns" [selectedItems]="selectedItems" modalName="#sub-department-two-modal" [columns]="columns" [selectedItems]="selectedItems"
(sendSelectData)="currentModal='edit';selectBu5($event)" (sendSelectedItems)="onSelectItemChange($event)"> (sendSelectData)="currentModal='edit';selectBu5($event);openDialog()" (sendSelectedItems)="onSelectItemChange($event)">
</app-datagrid-syncfution> </app-datagrid-syncfution>
</div> </div>
<div id="sub-department-two-modal" class="hs-overlay hidden ti-modal"> <ng-template #subDepartmentTwoModal let-modal>
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)]"> <h3 mat-dialog-title>
<div class="max-h-full overflow-hidden ti-modal-content"> {{currentModal=='add'?'เพิ่มข้อมูลทะเบียนส่วนย่อย 2':'แก้ไขข้อมูลทะเบียนส่วนย่อย 2'}}
<div class="ti-modal-header"> </h3>
<h3 class="text-xxl font-bold text-primary"> <div class="w-full flex justify-end mb-1rem">
<ng-container *ngIf="currentModal=='add'"> <div class="absolute flex">
เพิ่มข้อมูลทะเบียนส่วนย่อย 2 <div class="px-1">
</ng-container> <button type="button" class="ti-btn ti-btn-soft-indigo h-45px m-0 shadow-md" (click)="selectBu4();selectBu5()">
<ng-container *ngIf="currentModal=='edit'"> <i class="ti ti-eraser text-base"></i>
แก้ไขข้อมูลทะเบียนส่วนย่อย 2 Clear
</ng-container> </button>
</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">
<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();selectBu5()">
<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>
</div>
<div class="ti-modal-body">
<label 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 class="ti-form-label mt-2rem">ส่วนย่อย2
<span class="text-danger">*
<ng-container *ngIf="currentModal=='add'&&checkPrimary()">
ส่วนย่อย2ซ้ำ
</ng-container>
</span>
</label>
<div class="relative flex rounded-md w-1/2">
<input type="text" class="ti-form-input" [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.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.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">
ย้อนกลับ
</button>
<button class="ti-btn ti-btn-success" type="button"
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>
</div> </div>
</div> </div>
</div> </div>
</div> <mat-dialog-content>
<label class="ti-form-label">อยู่ภายใต้หน่วยงาน<span class="text-danger">*</span></label>
<div class="flex">
<div id="sub-department-two-bu4-table-modal" class="hs-overlay hidden ti-modal"> <div class="relative flex rounded-md">
<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"> <input type="text" id="hs-leading-button-add-on-with-icon-and-button"
<div class="max-h-full overflow-hidden ti-modal-content"> name="hs-leading-button-add-on-with-icon-and-button"
<div class="ti-modal-header"> class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10" readonly
<h3 class="text-xxl font-bold text-primary"> style="padding-right: 3.5rem;" [(ngModel)]="bu4.bu4id" (ngModelChange)="bu4idChange()">
ข้อมูลทะเบียนส่วนย่อย 1 <div
</h3> 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">
<div class="flex justify-end"> <button type="button" class="flex items-center text-red-500" (click)="selectBu4()">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger" <i class="ti ti-circle-x cursor-pointer"></i>
data-hs-overlay="#sub-department-two-modal">
<span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i>
</button> </button>
</div> <button type="button" class="flex items-center text-gray-500 dark:text-white/70" (click)="openDialogBu4()">
</div> <i class="ri-search-line cursor-pointer text-gray"></i>
<div class="ti-modal-body">
<div class="flex justify-end pb-1rem">
<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)]="bu4Modal.search"
(ngModelChange)="onBu4ModalSearchChange()">
<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>
</div>
</div>
</div>
</div>
<div class="overflow-auto border">
<table class="ti-custom-table ti-custom-table-head ti-custom-table-hover">
<thead>
<tr>
<ng-container
*ngFor="let item of ['ลำดับ','รหัสส่วนย่อย1','รายละเอียดส่วนย่อย1 (ไทย)','รายละเอียดส่วนย่อย1 (อังกฤษ)']; let f = first; let l = last">
<th scope="col" class="relative px-10px py-10px bg-soft-secondary text-primary"
[class.!text-center]="f">
<span class="text-sm">{{ item }}</span>
<div class="absolute top-1/2 transform -translate-y-1/2 right-0" *ngIf="!l">
<i class="ti ti-dots-vertical fs-l"></i>
</div>
</th>
</ng-container>
</tr>
</thead>
<tbody *ngIf="!filterBu4Modal().length">
<tr>
<td class="text-center" colspan="100%">
ไม่พบข้อมูล
</td>
</tr>
</tbody>
<tbody *ngIf="filterBu4Modal().length">
<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">
<td class="flex justify-center">
{{((bu4Modal.currentPage-1) * bu4Modal.pageSize)+(i+1)}}
</td>
<td>{{item.bu4id}}</td>
<td>{{item.tdesc}}</td>
<td>{{item.edesc}}</td>
</tr>
</tbody>
</table>
</div>
<app-pagination [totalItems]="filterBu4Modal().length" [pageSize]="bu4Modal.pageSize"
(pageChange)="bu4Modal.currentPage = $event"
(pageSizeChange)="bu4Modal.pageSize = $event;bu4Modal.currentPage = 1"></app-pagination>
<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">
ย้อนกลับ
</button> </button>
</div> </div>
</div> </div>
</div> <div class="flex rounded-md w-1/2 pl-1rem">
</div> <input type="text" id="input-label" class="ti-form-input w-full pr-10 bg-input-readonly"
</div> readonly [value]="bu4.tdesc">
<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">
<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">
<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">
ย้อนกลับ
</button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#sub-department-two-alert-modal" (click)="addBu5()">
บันทึกข้อมูล
</a>
</div>
</div> </div>
</div> </div>
</div> <label class="ti-form-label mt-2rem">ส่วนย่อย2
</div> <span class="text-danger">*
<ng-container *ngIf="currentModal=='add'&&checkPrimary()">
ส่วนย่อย2ซ้ำ
</ng-container>
</span>
</label>
<div class="relative flex rounded-md w-1/2">
<input type="text" class="ti-form-input" [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.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.select.edesc">
</mat-dialog-content>
<mat-dialog-actions align="end">
<button type="button" mat-button [mat-dialog-close]
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">
ย้อนกลับ
</button>
<button type="button" class="ti-btn ti-btn-success" mat-button (click)="addBu5();"
[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>
</mat-dialog-actions>
</ng-template>
<div id="sub-department-two-alert-delete-modal" class="hs-overlay hidden ti-modal"> <ng-template #subDepartmentTwoModalBu4 let-modal>
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out h-[calc(100%-3.5rem)] flex items-center"> <h3 mat-dialog-title>
<div class="max-h-full overflow-hidden ti-modal-content w-full"> ข้อมูลทะเบียนส่วนย่อย 1
<div class="ti-modal-header"> </h3>
<h3 class="text-xxl font-bold text-primary"> <mat-dialog-content>
แจ้งเตือน <div class="flex justify-end pb-1rem">
</h3> <div class="px-1">
<div class="flex justify-end"> <div class="relative shadow-md">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger" <input type="text" id="hs-leading-icon" name="hs-leading-icon"
data-hs-overlay="#sub-department-two-alert-delete-modal"> class="ti-form-input ltr:pl-11 rtl:pr-11 focus:z-10 "
<span class="sr-only">Close</span> placeholder="Search by No. or Name" [(ngModel)]="bu4Modal.search"
<i class="ti ti-circle-x fs-xxl"></i> (ngModelChange)="onBu4ModalSearchChange()">
</button> <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">
</div> <i class="ri-search-line text-gray"></i>
<div class="ti-modal-body "> </div>
<p class="mt-1 text-gray-800 dark:text-white/70">
<ng-container *ngIf="numSelectItem()">
ยืนยันการลบข้อมูลหรือไม่
</ng-container>
<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"
data-hs-overlay="#sub-department-two-alert-delete-modal">
ย้อนกลับ
</button>
<a class="ti-btn ti-btn-danger" href="javascript:void(0);"
data-hs-overlay="#sub-department-two-alert-delete-modal" (click)="deleteBu5()"
*ngIf="numSelectItem()">
ลบข้อมูล
</a>
</div> </div>
</div> </div>
</div> </div>
</div> <div class="overflow-auto border">
</div> <table class="ti-custom-table ti-custom-table-head ti-custom-table-hover">
<thead>
<tr>
<ng-container
*ngFor="let item of ['ลำดับ','รหัสส่วนย่อย1','รายละเอียดส่วนย่อย1 (ไทย)','รายละเอียดส่วนย่อย1 (อังกฤษ)']; let f = first; let l = last">
<th scope="col" class="relative px-10px py-10px bg-soft-secondary text-primary"
[class.!text-center]="f">
<span class="text-sm">{{ item }}</span>
<div class="absolute top-1/2 transform -translate-y-1/2 right-0" *ngIf="!l">
<i class="ti ti-dots-vertical fs-l"></i>
</div>
</th>
</ng-container>
</tr>
</thead>
<tbody *ngIf="!filterBu4Modal().length">
<tr>
<td class="text-center" colspan="100%">
ไม่พบข้อมูล
</td>
</tr>
</tbody>
<tbody *ngIf="filterBu4Modal().length">
<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);closeDialogBu4()">
<td class="flex justify-center">
{{((bu4Modal.currentPage-1) * bu4Modal.pageSize)+(i+1)}}
</td>
<td>{{item.bu4id}}</td>
<td>{{item.tdesc}}</td>
<td>{{item.edesc}}</td>
</tr>
</tbody>
</table>
</div>
<app-pagination [totalItems]="filterBu4Modal().length" [pageSize]="bu4Modal.pageSize"
(pageChange)="bu4Modal.currentPage = $event"
(pageSizeChange)="bu4Modal.pageSize = $event;bu4Modal.currentPage = 1"></app-pagination>
</mat-dialog-content>
<mat-dialog-actions align="end">
<button type="button" mat-button [mat-dialog-close]
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">
ย้อนกลับ
</button>
</mat-dialog-actions>
</ng-template>
<div id="sub-department-two-upload-modal" class="hs-overlay hidden ti-modal"> <div id="sub-department-two-upload-modal" class="hs-overlay hidden ti-modal">
<div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out rounded-md"> <div class="hs-overlay-open:mt-7 ti-modal-box mt-0 ease-out rounded-md">
...@@ -339,4 +215,4 @@ ...@@ -339,4 +215,4 @@
</div> </div>
</div> </div>
</div> </div>
</div> </div>
\ No newline at end of file
import { ChangeDetectorRef, Component, EventEmitter, Input, OnInit, } from '@angular/core'; import { ChangeDetectorRef, Component, EventEmitter, Input, OnInit, ViewChild, } from '@angular/core';
import { MatDialog } from '@angular/material/dialog';
import { ColumnModel } from '@syncfusion/ej2-grids'; import { ColumnModel } from '@syncfusion/ej2-grids';
import { ToastrService } from 'ngx-toastr'; import { ToastrService } from 'ngx-toastr';
import { Bu4Model, MyBu4Model } from 'src/app/shared/model/bu4.model'; import { Bu4Model, MyBu4Model } from 'src/app/shared/model/bu4.model';
...@@ -6,6 +7,7 @@ import { Bu5Model, MyBu5Model } from 'src/app/shared/model/bu5.model'; ...@@ -6,6 +7,7 @@ import { Bu5Model, MyBu5Model } from 'src/app/shared/model/bu5.model';
import { Bu4Service } from 'src/app/shared/services/bu4.service'; import { Bu4Service } from 'src/app/shared/services/bu4.service';
import { Bu5Service } from 'src/app/shared/services/bu5.service'; import { Bu5Service } from 'src/app/shared/services/bu5.service';
import { FileService } from 'src/app/shared/services/file.service'; import { FileService } from 'src/app/shared/services/file.service';
import Swal from 'sweetalert2';
interface table { interface table {
currentPage: number, currentPage: number,
page: number[], page: number[],
...@@ -56,17 +58,39 @@ export class SubDepartmentTwoComponent implements OnInit { ...@@ -56,17 +58,39 @@ export class SubDepartmentTwoComponent implements OnInit {
}; };
search = '' search = ''
selectedItems: { key: string, count: number, data: Map<string, boolean> } = { key: '', count: 0, data: new Map<string, boolean>() }; selectedItems: { key: string, count: number, data: Map<string, boolean> } = { key: '', count: 0, data: new Map<string, boolean>() };
@ViewChild("subDepartmentTwoModal") subDepartmentTwoModal: any;
@ViewChild("subDepartmentTwoModalBu4") subDepartmentTwoModalBu4: any;
dialogRef: any
dialogRefBu4: any
constructor(private bu5Service: Bu5Service, constructor(private bu5Service: Bu5Service,
private bu4Service: Bu4Service, private bu4Service: Bu4Service,
private toastr: ToastrService, private toastr: ToastrService,
private cdr: ChangeDetectorRef, private cdr: ChangeDetectorRef,
private fileService: FileService private fileService: FileService,
private dialog: MatDialog
) { } ) { }
ngOnInit(): void { ngOnInit(): void {
this.getBu5List() this.getBu5List()
this.getBu4List() this.getBu4List()
} }
openDialog() {
this.dialogRef = this.dialog.open(this.subDepartmentTwoModal, {
width: '500px',
})
}
openDialogBu4() {
this.dialogRefBu4 = this.dialog.open(this.subDepartmentTwoModalBu4, {
width: '800px',
})
}
closeDialog() {
this.dialogRef.close()
}
closeDialogBu4() {
this.dialogRefBu4.close()
}
onFileSelected(event: any) { onFileSelected(event: any) {
this.selectedFile = event.target.files.length > 0 ? event.target.files[0] : null; this.selectedFile = event.target.files.length > 0 ? event.target.files[0] : null;
this.selectedFileName = this.selectedFile?.name || "กรุณาเลือกไฟล์" this.selectedFileName = this.selectedFile?.name || "กรุณาเลือกไฟล์"
...@@ -153,39 +177,64 @@ export class SubDepartmentTwoComponent implements OnInit { ...@@ -153,39 +177,64 @@ export class SubDepartmentTwoComponent implements OnInit {
} }
addBu5() { addBu5() {
this.bu5.loading = true Swal.fire({
this.bu5Service.post({ ...this.bu5.select, parent: this.bu4.bu4id }).subscribe({ icon: 'question',
next: response => { title: 'แจ้งเตือน',
if (response.success) { text: 'ยืนยันการบันทึกข้อมูลหรือไม่',
this.showAlert(response.message, 'success') showCancelButton: true,
this.getBu5List() confirmButtonText: 'ยืนยัน',
} else { }).then((result) => {
this.showAlert(response.message, 'error') if (result.isConfirmed) {
this.bu5.loading = false this.bu5.loading = true
} this.bu5Service.post({ ...this.bu5.select, parent: this.bu4.bu4id }).subscribe({
}, error: error => { next: response => {
this.showAlert(error.message, 'error') if (response.success) {
this.bu5.loading = false this.showAlert(response.message, 'success')
this.getBu5List()
this.closeDialog()
} else {
this.showAlert(response.message, 'error')
this.bu5.loading = false
this.closeDialog()
}
}, error: error => {
this.showAlert(error.message, 'error')
this.bu5.loading = false
this.closeDialog()
}
})
} }
}) })
} }
deleteBu5() { deleteBu5() {
this.bu5.loading = true if (this.numSelectItem() == 0) {
const selectedKeys = Array.from(this.selectedItems.data.keys()); this.showAlert('กรุณาเลือกข้อมูลที่จะลบ', 'error')
const body = this.bu5.dataList.filter(x => selectedKeys.includes(x.bu5id) && this.selectedItems.data.get(x.bu5id)).map(x => new MyBu5Model(x)) return
this.bu5Service.delete(body).subscribe({ }
next: response => { Swal.fire({
if (response.success) { icon: 'question',
this.showAlert(response.message, 'success') title: 'แจ้งเตือน',
this.getBu5List() text: 'ยืนยันการลบข้อมูลหรือไม่',
showCancelButton: true,
confirmButtonText: 'ลบข้อมูล',
}).then((result) => {
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) {
this.showAlert(response.message, 'success')
this.getBu5List()
} else { } else {
this.showAlert(response.message, 'error') this.showAlert(response.message, 'error')
this.bu5.loading = false this.bu5.loading = false
} }
}, error: error => { }, error: error => {
this.showAlert(error.message, 'error') this.showAlert(error.message, 'error')
this.bu5.loading = false this.bu5.loading = false
} }
})
}) })
} }
...@@ -213,9 +262,12 @@ export class SubDepartmentTwoComponent implements OnInit { ...@@ -213,9 +262,12 @@ export class SubDepartmentTwoComponent implements OnInit {
} }
showAlert(text: string, type: 'success' | 'error') { showAlert(text: string, type: 'success' | 'error') {
this.toastr[type](text, 'แจ้งเตือน', { Swal.fire({
timeOut: 3000, icon: type,
positionClass: 'toast-top-right', title: 'แจ้งเตือน',
text: text,
showCancelButton: false,
confirmButtonText: 'ยืนยัน',
}) })
} }
......
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