Commit 6198a78e by Nattana Chaiyamat

กำหนดกลุ่มการอนุมัติ

parent 9e34f55b
import { ChangeDetectorRef, Component, EventEmitter, Input, OnInit, } from '@angular/core'; import { ChangeDetectorRef, Component, EventEmitter, Input, OnInit, } from '@angular/core';
import { ColumnModel } from '@syncfusion/ej2-grids';
import { ToastrService } from 'ngx-toastr'; import { ToastrService } from 'ngx-toastr';
import { Bu1Model, MyBu1Model } from 'src/app/shared/model/bu1.model'; import { Bu1Model, MyBu1Model } from 'src/app/shared/model/bu1.model';
import { Bu2Model, MyBu2Model } from 'src/app/shared/model/bu2.model'; import { Bu2Model, MyBu2Model } from 'src/app/shared/model/bu2.model';
...@@ -17,8 +18,31 @@ interface table { ...@@ -17,8 +18,31 @@ interface table {
styleUrls: ['./department-list.component.scss'] styleUrls: ['./department-list.component.scss']
}) })
export class DepartmentListComponent implements OnInit { export class DepartmentListComponent implements OnInit {
columns: ColumnModel[] = [{
bu2List: { check: boolean, data: Bu2Model }[] = [] field: "bu2id",
headerText: "ทะเบียนแผนก",
type: "string",
isPrimaryKey: true,
},
{
field: "tdesc",
headerText: "ทะเบียนแผนก(ไทย)",
type: "string"
},
{
field: "edesc",
headerText: "ทะเบียนแผนก(อังกฤษ)",
type: "string"
}]
searchSettings = {
fields: ['bu2id', 'tdesc', 'edesc'],
operator: 'contains',
ignoreCase: false
};
search = ""
selectedItems: { key: string, count: number, data: Map<string, boolean> } = { key: '', count: 0, data: new Map<string, boolean>() };
bu2List: Bu2Model[] = []
bu2ListLoading = false bu2ListLoading = false
bu2: Bu2Model = new MyBu2Model() bu2: Bu2Model = new MyBu2Model()
bu2Table: table = { bu2Table: table = {
...@@ -47,10 +71,6 @@ export class DepartmentListComponent implements OnInit { ...@@ -47,10 +71,6 @@ export class DepartmentListComponent implements OnInit {
} }
currentModal: 'add' | 'edit' | 'delete' = "add" currentModal: 'add' | 'edit' | 'delete' = "add"
numDataListChecked = 0
isDataListChecked = false
isDataListCheckedAll = false
constructor(private bu2Service: Bu2Service, constructor(private bu2Service: Bu2Service,
private bu1Service: Bu1Service, private bu1Service: Bu1Service,
private toastr: ToastrService, private toastr: ToastrService,
...@@ -114,11 +134,13 @@ export class DepartmentListComponent implements OnInit { ...@@ -114,11 +134,13 @@ export class DepartmentListComponent implements OnInit {
this.bu2ListLoading = true this.bu2ListLoading = true
this.bu2Service.getList().subscribe({ this.bu2Service.getList().subscribe({
next: response => { next: response => {
this.bu2List = response.map(x => ({ check: false, data: new MyBu2Model(x) })) this.bu2List = response.map(x => {
this.selectedItems.data.set(x.bu2id, false)
return new MyBu2Model(x)
})
this.selectedItems.key = 'bu2id'
this.selectedItems.count = 0
this.bu2ListLoading = false this.bu2ListLoading = false
this.onBu2TableSearchChange()
this.isDataListCheckedAll = false
this.dataListCheckAll()
this.cdr.detectChanges() this.cdr.detectChanges()
}, error: error => { }, error: error => {
this.bu2ListLoading = false this.bu2ListLoading = false
...@@ -126,18 +148,7 @@ export class DepartmentListComponent implements OnInit { ...@@ -126,18 +148,7 @@ export class DepartmentListComponent implements OnInit {
} }
}) })
} }
onBu2TableSearchChange() {
this.bu2Table.currentPage = 1
this.bu2Table.page = Array.from({ length: Math.ceil(this.filterBu2Table().length / 10) }, (_, i) => i + 1);
}
filterBu2Table() {
return this.bu2List.filter(x => {
const data = x.data
return data.bu2id.toLowerCase().includes(this.bu2Table.search.toLowerCase()) ||
data.tdesc.toLowerCase().includes(this.bu2Table.search.toLowerCase()) ||
data.edesc.toLowerCase().includes(this.bu2Table.search.toLowerCase())
})
}
selectBu2(bu2?: Bu2Model) { selectBu2(bu2?: Bu2Model) {
this.bu2 = new MyBu2Model(bu2) this.bu2 = new MyBu2Model(bu2)
this.selectBu1() this.selectBu1()
...@@ -148,24 +159,6 @@ export class DepartmentListComponent implements OnInit { ...@@ -148,24 +159,6 @@ export class DepartmentListComponent implements OnInit {
}) })
} }
} }
// bu2idChange() {
// const bu2 = this.bu2List.find(x => x.bu2id == this.bu2.bu2id)
// this.selectBu2(bu2 || new MyBu2Model({ bu2id: this.bu2.bu2id }))
// }
onBu2ModalSearchChange() {
this.bu2Modal.currentPage = 1
this.bu2Modal.page = Array.from({ length: Math.ceil(this.filterBu2Modal().length / 10) }, (_, i) => i + 1);
this.dataListCheck()
}
filterBu2Modal() {
return this.bu2List.filter(x => {
const data = x.data
return data.bu2id.toLowerCase().includes(this.bu2Table.search.toLowerCase()) ||
data.tdesc.toLowerCase().includes(this.bu2Table.search.toLowerCase()) ||
data.edesc.toLowerCase().includes(this.bu2Table.search.toLowerCase())
})
}
getBu1List() { getBu1List() {
this.bu1Service.getList().subscribe(response => { this.bu1Service.getList().subscribe(response => {
...@@ -215,38 +208,36 @@ export class DepartmentListComponent implements OnInit { ...@@ -215,38 +208,36 @@ export class DepartmentListComponent implements OnInit {
} }
deleteBu2() { deleteBu2() {
this.bu2ListLoading = true this.bu2ListLoading = true
const body = this.bu2List.filter(x => x.check).map(x => new MyBu2Model(x.data)) // const body = this.bu2List.filter(x => x.check).map(x => new MyBu2Model(x.data))
this.bu2Service.delete(body).subscribe({ // this.bu2Service.delete(body).subscribe({
next: response => { // next: response => {
if (response.success) { // if (response.success) {
this.showAlert(response.message, 'success') // this.showAlert(response.message, 'success')
this.getBu2List() // this.getBu2List()
} else { // } else {
this.showAlert(response.message, 'error') // this.showAlert(response.message, 'error')
this.bu2ListLoading = false // this.bu2ListLoading = false
} // }
}, error: error => { // }, error: error => {
this.showAlert(error.message, 'error') // this.showAlert(error.message, 'error')
this.bu2ListLoading = false // this.bu2ListLoading = false
} // }
}) // })
} }
dataListCheckAll() {
const selectAll = this.isDataListCheckedAll; checkPrimary() {
this.filterBu2Table().forEach(x => x.check = selectAll); return this.bu2List.find(x => x.bu2id == this.bu2.bu2id)
this.dataListCheck();
} }
dataListCheck() { onSelectItemChange(arg: any) {
const dataCheck = this.filterBu2Table(); this.selectedItems = arg
this.isDataListCheckedAll = dataCheck.length ? dataCheck.every(x => x.check) : false;
this.numDataListChecked = this.bu2List.filter(x => x.check).length
this.isDataListChecked = Boolean(this.numDataListChecked)
} }
checkPrimary() { numSelectItem() {
return this.bu2List.find(x => x.data.bu2id == this.bu2.bu2id) const selectedKeys = Array.from(this.selectedItems.data.keys());
const num = this.bu2List.filter(x => selectedKeys.includes(x.bu2id) && this.selectedItems.data.get(x.bu2id)).length
return num
} }
} }
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 { ar } from 'date-fns/locale';
import { ToastrService } from 'ngx-toastr'; import { ToastrService } from 'ngx-toastr';
import { Bu1Model, MyBu1Model } from 'src/app/shared/model/bu1.model'; import { Bu1Model, MyBu1Model } from 'src/app/shared/model/bu1.model';
import { Bu1Service } from 'src/app/shared/services/bu1.service'; import { Bu1Service } from 'src/app/shared/services/bu1.service';
import { FileService } from 'src/app/shared/services/file.service'; import { FileService } from 'src/app/shared/services/file.service';
import Swal from 'sweetalert2';
@Component({ @Component({
selector: 'app-department-register', selector: 'app-department-register',
...@@ -19,11 +20,11 @@ export class DepartmentRegisterComponent implements OnInit { ...@@ -19,11 +20,11 @@ export class DepartmentRegisterComponent implements OnInit {
selectedFile: File | null = null; selectedFile: File | null = null;
selectedFileName: string = 'กรุณาเลือกไฟล์'; selectedFileName: string = 'กรุณาเลือกไฟล์';
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>() };
currentModel: 'add' | 'edit' | 'delete' = "add" currentModal: 'add' | 'edit' | 'delete' = "add"
bu1: { loading: boolean, select: Bu1Model, dataList: Bu1Model[] } = { loading: false, select: new MyBu1Model(), dataList: [] } bu1: { loading: boolean, select: Bu1Model, dataList: Bu1Model[] } = { loading: false, select: new MyBu1Model(), dataList: [] }
columns: ColumnModel[] = [{ columns: ColumnModel[] = [{
field: "bu1id", field: "bu1id",
headerText: "รหัสกลุ่มการอนุมัติ", headerText: "รหัสฝ่าย",
type: "string", type: "string",
isPrimaryKey: true, isPrimaryKey: true,
}, },
...@@ -42,8 +43,10 @@ export class DepartmentRegisterComponent implements OnInit { ...@@ -42,8 +43,10 @@ export class DepartmentRegisterComponent implements OnInit {
operator: 'contains', operator: 'contains',
ignoreCase: false ignoreCase: false
}; };
@ViewChild("departmentRegisterModal") departmentRegisterModal: any;
dialogRef: any
constructor(private bu1Service: Bu1Service, constructor(private bu1Service: Bu1Service,
private toastr: ToastrService, private dialog: MatDialog,
private cdr: ChangeDetectorRef, private cdr: ChangeDetectorRef,
private fileService: FileService private fileService: FileService
) { } ) { }
...@@ -119,54 +122,87 @@ export class DepartmentRegisterComponent implements OnInit { ...@@ -119,54 +122,87 @@ export class DepartmentRegisterComponent implements OnInit {
selectBu1(bu1?: Bu1Model) { selectBu1(bu1?: Bu1Model) {
if (bu1) { if (bu1) {
this.bu1.select = new MyBu1Model(bu1) this.bu1.select = new MyBu1Model(bu1)
} else if (this.currentModel == 'add') { } else if (this.currentModal == 'add') {
this.bu1.select = new MyBu1Model() this.bu1.select = new MyBu1Model()
} else if (this.currentModel == 'edit') { } else if (this.currentModal == 'edit') {
this.bu1.select = new MyBu1Model({ bu1id: this.bu1.select.bu1id }) this.bu1.select = new MyBu1Model({ bu1id: this.bu1.select.bu1id })
} }
} }
showAlert(text: string, type: 'success' | 'error') { showAlert(text: string, type: 'success' | 'error') {
this.toastr[type](text, 'แจ้งเตือน', { Swal.fire({
timeOut: 3000, title: 'แจ้งเตือน',
positionClass: 'toast-top-right', text: text,
}) icon: type,
confirmButtonText: 'ตกลง',
});
} }
addBu1() { addBu1() {
this.bu1.loading = true Swal.fire({
this.bu1Service.post(this.bu1.select).subscribe({ icon: 'question',
next: response => { title: 'แจ้งเตือน',
if (response.success) { text: 'ยืนยันการบันทึกข้อมูลหรือไม่',
this.showAlert(response.message, 'success') showCancelButton: true,
this.getBu1List() confirmButtonText: 'บันทึกข้อมูล',
} else { cancelButtonText: 'ย้อนกลับ',
this.showAlert(response.message, 'error') reverseButtons: true,
this.bu1.loading = false }).then((result) => {
} if (result.isConfirmed) {
}, error: error => { console.log(" 🐒 result:", result)
this.showAlert(error.message, 'error') // this.bu1.loading = true
this.bu1.loading = false // this.bu1Service.post(this.bu1.select).subscribe({
// next: response => {
// if (response.success) {
// this.showAlert(response.message, 'success')
// this.getBu1List()
// } else {
// this.showAlert(response.message, 'error')
// this.bu1.loading = false
// }
// }, error: error => {
// this.showAlert(error.message, 'error')
// this.bu1.loading = false
// }
// })
} }
}) })
} }
deleteBu1() { deleteBu1() {
this.bu1.loading = true if (!this.numSelectItem()) {
const selectedKeys = Array.from(this.selectedItems.data.keys()); this.showAlert('กรุณาเลือกข้อมูลที่ต้องการลบ', 'error')
const body = this.bu1.dataList.filter(x => selectedKeys.includes(x.bu1id) && this.selectedItems.data.get(x.bu1id)).map(x => new MyBu1Model(x)) return
this.bu1Service.delete(body).subscribe({ }
next: response => { Swal.fire({
if (response.success) { icon: 'question',
this.showAlert(response.message, 'success') title: 'แจ้งเตือน',
this.getBu1List() text: 'ยืนยันการลบข้อมูลหรือไม่',
} else { showCancelButton: true,
this.showAlert(response.message, 'error') confirmButtonText: 'ลบข้อมูล',
this.bu1.loading = false cancelButtonText: 'ย้อนกลับ',
} reverseButtons: true,
}, error: error => { }).then((result) => {
this.showAlert(error.message, 'error') if (result.isConfirmed) {
this.bu1.loading = false console.log(" 🐒 result:", result)
// this.bu1.loading = true
// const selectedKeys = Array.from(this.selectedItems.data.keys());
// const body = this.bu1.dataList.filter(x => selectedKeys.includes(x.bu1id) && this.selectedItems.data.get(x.bu1id)).map(x => new MyBu1Model(x))
// this.bu1Service.delete(body).subscribe({
// next: response => {
// if (response.success) {
// this.showAlert(response.message, 'success')
// this.getBu1List()
// } else {
// this.showAlert(response.message, 'error')
// this.bu1.loading = false
// }
// }, error: error => {
// this.showAlert(error.message, 'error')
// this.bu1.loading = false
// }
// })
} }
}) });
} }
checkPrimary() { checkPrimary() {
...@@ -176,4 +212,20 @@ export class DepartmentRegisterComponent implements OnInit { ...@@ -176,4 +212,20 @@ export class DepartmentRegisterComponent implements OnInit {
onSelectItemChange(arg: any) { onSelectItemChange(arg: any) {
this.selectedItems = arg this.selectedItems = arg
} }
openDialog() {
this.dialogRef = this.dialog.open(this.departmentRegisterModal, {
width: '500px',
disableClose: false,
});
}
closeDialog() {
this.dialogRef.close()
}
numSelectItem() {
const selectedKeys = Array.from(this.selectedItems.data.keys());
const num = this.bu1.dataList.filter(x => selectedKeys.includes(x.bu1id) && this.selectedItems.data.get(x.bu1id)).length
return num
}
} }
\ No newline at end of file
...@@ -21,14 +21,14 @@ ...@@ -21,14 +21,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)="modalStatus='add';setData()" (click)="openDialog()"> (click)="currentModal='add';setData()" (click)="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)="modalStatus='deleteGroup';setData();deleteCompany()"> (click)="currentModal='delete';setData();deleteCompany()">
<i class="ri-delete-bin-6-line"></i> <i class="ri-delete-bin-6-line"></i>
Delete Delete
</button> </button>
...@@ -39,14 +39,14 @@ ...@@ -39,14 +39,14 @@
<div class="page px-rem"> <div class="page px-rem">
<app-datagrid-syncfution [searchSettings]="searchSettings" [searchText]="search" [dataSource]="dataList" <app-datagrid-syncfution [searchSettings]="searchSettings" [searchText]="search" [dataSource]="dataList"
[columns]="columns" [selectedItems]="selectedItems" [columns]="columns" [selectedItems]="selectedItems"
(sendSelectData)="modalStatus='edit';setData($event);openDialog()" (sendSelectData)="currentModal='edit';setData($event);openDialog()"
(sendSelectedItems)="onSelectItemChange($event)" (sendOpenDialog)="openDialog()"> (sendSelectedItems)="onSelectItemChange($event)">
</app-datagrid-syncfution> </app-datagrid-syncfution>
</div> </div>
<ng-template #registrationModal let-modal> <ng-template #registrationModal let-modal>
<h3 mat-dialog-title> <h3 mat-dialog-title>
{{modalStatus=='add'?'เพิ่มข้อมูลบริษัท':'แก้ไขข้อมูลบริษัท'}} {{currentModal=='add'?'เพิ่มข้อมูลบริษัท':'แก้ไขข้อมูลบริษัท'}}
</h3> </h3>
<div class="w-full flex justify-end"> <div class="w-full flex justify-end">
<div class="absolute flex"> <div class="absolute flex">
...@@ -61,13 +61,13 @@ ...@@ -61,13 +61,13 @@
<mat-dialog-content> <mat-dialog-content>
<label for="input-label" class="ti-form-label mt-2rem">รหัสบริษัท<span class="text-danger"> <label for="input-label" class="ti-form-label mt-2rem">รหัสบริษัท<span class="text-danger">
* *
<ng-container *ngIf="modalStatus=='add'&&checkPrimary()"> <ng-container *ngIf="currentModal=='add'&&checkPrimary()">
รหัสบริษัทซ้ำ รหัสบริษัทซ้ำ
</ng-container> </ng-container>
</span></label> </span></label>
<input type="text" id="input-label" class="ti-form-input w-1/2" <input type="text" id="input-label" class="ti-form-input w-1/2"
[class.!border-red]="modalStatus=='add'&&checkPrimary()" [class.!border-red]="currentModal=='add'&&checkPrimary()"
[ngClass]="{'!bg-input-readonly':modalStatus=='edit'}" [readonly]="modalStatus=='edit'" [ngClass]="{'!bg-input-readonly':currentModal=='edit'}" [readonly]="currentModal=='edit'"
[(ngModel)]="dataSelect.code" [maxLength]="5"> [(ngModel)]="dataSelect.code" [maxLength]="5">
<label for="detail_th" class="ti-form-label mt-2rem">รายละเอียด (ไทย)<span class="text-danger">*</span></label> <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)]="dataSelect.tdesc"> <input type="text" id="detail_th" class="ti-form-input h-16" [(ngModel)]="dataSelect.tdesc">
...@@ -84,8 +84,8 @@ ...@@ -84,8 +84,8 @@
ย้อนกลับ ย้อนกลับ
</button> </button>
<button type="button" class="ti-btn ti-btn-success" mat-button (click)="addCompany()" <button type="button" class="ti-btn ti-btn-success" mat-button (click)="addCompany()"
[class.ti-btn-disabled]="!dataSelect.code||!dataSelect.tdesc||(modalStatus=='add'&&checkPrimary())" [class.ti-btn-disabled]="!dataSelect.code||!dataSelect.tdesc||(currentModal=='add'&&checkPrimary())"
[disabled]="!dataSelect.code||!dataSelect.tdesc||(modalStatus=='add'&&checkPrimary())"> [disabled]="!dataSelect.code||!dataSelect.tdesc||(currentModal=='add'&&checkPrimary())">
บันทึกข้อมูล บันทึกข้อมูล
</button> </button>
...@@ -97,7 +97,7 @@ ...@@ -97,7 +97,7 @@
<div class="max-h-full overflow-hidden ti-modal-content"> <div class="max-h-full overflow-hidden ti-modal-content">
<div class="ti-modal-header"> <div class="ti-modal-header">
<h3 class="text-xxl font-bold text-primary"> <h3 class="text-xxl font-bold text-primary">
{{modalStatus=='add'?'เพิ่มข้อมูลบริษัท':'แก้ไขข้อมูลบริษัท'}} {{currentModal=='add'?'เพิ่มข้อมูลบริษัท':'แก้ไขข้อมูลบริษัท'}}
</h3> </h3>
<div class="flex justify-end"> <div class="flex justify-end">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger" <button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
...@@ -132,13 +132,13 @@ ...@@ -132,13 +132,13 @@
<div class="ti-modal-body padding-16px pt-0 overflow-y-0"> <div class="ti-modal-body padding-16px pt-0 overflow-y-0">
<label for="input-label" class="ti-form-label mt-2rem">รหัสบริษัท<span class="text-danger"> <label for="input-label" class="ti-form-label mt-2rem">รหัสบริษัท<span class="text-danger">
* *
<ng-container *ngIf="modalStatus=='add'&&checkPrimary()"> <ng-container *ngIf="currentModal=='add'&&checkPrimary()">
รหัสบริษัทซ้ำ รหัสบริษัทซ้ำ
</ng-container> </ng-container>
</span></label> </span></label>
<input type="text" id="input-label" class="ti-form-input w-1/2" <input type="text" id="input-label" class="ti-form-input w-1/2"
[class.!border-red]="modalStatus=='add'&&checkPrimary()" [class.!border-red]="currentModal=='add'&&checkPrimary()"
[ngClass]="{'bg-input-readonly':modalStatus=='edit'}" [readonly]="modalStatus=='edit'" [ngClass]="{'bg-input-readonly':currentModal=='edit'}" [readonly]="currentModal=='edit'"
[(ngModel)]="dataSelect.code" [maxLength]="5"> [(ngModel)]="dataSelect.code" [maxLength]="5">
<label for="detail_th" class="ti-form-label mt-2rem">รายละเอียด (ไทย)<span <label for="detail_th" class="ti-form-label mt-2rem">รายละเอียด (ไทย)<span
class="text-danger">*</span></label> class="text-danger">*</span></label>
...@@ -157,8 +157,8 @@ ...@@ -157,8 +157,8 @@
</button> </button>
<button type="button" class="ti-btn ti-btn-success" <button type="button" class="ti-btn ti-btn-success"
data-hs-overlay="#company-registration-page-alert-modal" data-hs-overlay="#company-registration-page-alert-modal"
[class.ti-btn-disabled]="!dataSelect.code||!dataSelect.tdesc||(modalStatus=='add'&&checkPrimary())" [class.ti-btn-disabled]="!dataSelect.code||!dataSelect.tdesc||(currentModal=='add'&&checkPrimary())"
[disabled]="!dataSelect.code||!dataSelect.tdesc||(modalStatus=='add'&&checkPrimary())"> [disabled]="!dataSelect.code||!dataSelect.tdesc||(currentModal=='add'&&checkPrimary())">
บันทึกข้อมูล บันทึกข้อมูล
</button> </button>
</div> </div>
...@@ -175,14 +175,14 @@ ...@@ -175,14 +175,14 @@
แจ้งเตือน แจ้งเตือน
</h3> </h3>
<div class="flex justify-end"> <div class="flex justify-end">
<ng-container *ngIf="modalStatus=='add'||modalStatus=='edit'"> <ng-container *ngIf="currentModal=='add'||currentModal=='edit'">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger" <button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#company-registration-page-modal"> data-hs-overlay="#company-registration-page-modal">
<span class="sr-only">Close</span> <span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i> <i class="ti ti-circle-x fs-xxl"></i>
</button> </button>
</ng-container> </ng-container>
<ng-container *ngIf="modalStatus=='delete'||modalStatus=='deleteGroup'"> <ng-container *ngIf="currentModal=='delete'||currentModal=='deleteGroup'">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger" <button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#company-registration-page-alert-modal"> data-hs-overlay="#company-registration-page-alert-modal">
<span class="sr-only">Close</span> <span class="sr-only">Close</span>
...@@ -193,10 +193,10 @@ ...@@ -193,10 +193,10 @@
</div> </div>
<div class="ti-modal-body "> <div class="ti-modal-body ">
<p class="mt-1 text-gray-800 dark:text-white/70"> <p class="mt-1 text-gray-800 dark:text-white/70">
<ng-container *ngIf="modalStatus=='add'||modalStatus=='edit'"> <ng-container *ngIf="currentModal=='add'||currentModal=='edit'">
ยืนยันการบันทึกข้อมูลหรือไม่ ยืนยันการบันทึกข้อมูลหรือไม่
</ng-container> </ng-container>
<ng-container *ngIf="modalStatus=='delete'||modalStatus=='deleteGroup'"> <ng-container *ngIf="currentModal=='delete'||currentModal=='deleteGroup'">
<ng-container *ngIf="numSelectItem()"> <ng-container *ngIf="numSelectItem()">
ยืนยันการลบข้อมูลหรือไม่ ยืนยันการลบข้อมูลหรือไม่
</ng-container> </ng-container>
...@@ -207,7 +207,7 @@ ...@@ -207,7 +207,7 @@
</p> </p>
<div class="flex justify-end mt-2rem mb-1rem"> <div class="flex justify-end mt-2rem mb-1rem">
<ng-container *ngIf="modalStatus=='add'||modalStatus=='edit'"> <ng-container *ngIf="currentModal=='add'||currentModal=='edit'">
<button type="button" <button type="button"
class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10" class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
data-hs-overlay="#company-registration-page-modal"> data-hs-overlay="#company-registration-page-modal">
...@@ -218,7 +218,7 @@ ...@@ -218,7 +218,7 @@
บันทึกข้อมูล บันทึกข้อมูล
</a> </a>
</ng-container> </ng-container>
<ng-container *ngIf="modalStatus=='delete'||modalStatus=='deleteGroup'"> <ng-container *ngIf="currentModal=='delete'||currentModal=='deleteGroup'">
<button type="button" <button type="button"
class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10" class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
data-hs-overlay="#company-registration-page-alert-modal"> data-hs-overlay="#company-registration-page-alert-modal">
......
...@@ -24,7 +24,7 @@ export class CompanyRegistrationPageComponent { ...@@ -24,7 +24,7 @@ export class CompanyRegistrationPageComponent {
currentPage = 1 currentPage = 1
page = Array.from({ length: 1 }, (_, i) => i + 1); page = Array.from({ length: 1 }, (_, i) => i + 1);
search = "" search = ""
modalStatus = 'add' currentModal: 'add' | 'edit' | 'delete' = 'add'
dataList: DataModel[] = [] dataList: DataModel[] = []
dataLoading = false dataLoading = false
dataSelect: DataModel = { code: "", tdesc: "", edesc: "", address: "", contact: "" } dataSelect: DataModel = { code: "", tdesc: "", edesc: "", address: "", contact: "" }
...@@ -54,8 +54,7 @@ export class CompanyRegistrationPageComponent { ...@@ -54,8 +54,7 @@ export class CompanyRegistrationPageComponent {
selectedFile: File | null = null; selectedFile: File | null = null;
selectedFileName: string = 'กรุณาเลือกไฟล์'; selectedFileName: string = 'กรุณาเลือกไฟล์';
dialogRef: any dialogRef: any
constructor(private toastr: ToastrService, constructor(private companyService: CompanyService,
private companyService: CompanyService,
private cdr: ChangeDetectorRef, private cdr: ChangeDetectorRef,
private dialog: MatDialog, private dialog: MatDialog,
private fileService: FileService) { } private fileService: FileService) { }
...@@ -217,7 +216,7 @@ export class CompanyRegistrationPageComponent { ...@@ -217,7 +216,7 @@ export class CompanyRegistrationPageComponent {
}) })
} }
clearData() { clearData() {
if (this.modalStatus == 'add') { if (this.currentModal == 'add') {
this.setData() this.setData()
} else { } else {
this.setData({ code: this.dataSelect.code, tdesc: "", edesc: "", address: "", contact: "" }) this.setData({ code: this.dataSelect.code, tdesc: "", edesc: "", address: "", contact: "" })
......
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