Commit 55e84dd8 by Nakarin Luankla

แก้ modal

parent aff91f9f
...@@ -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>
...@@ -45,265 +44,142 @@ ...@@ -45,265 +44,142 @@
</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>
</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)]="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> <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>
</div>
</div>
<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> </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]="bu4.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-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">
......
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