Commit aa4afe9f by Nattana Chaiyamat

ทะเบียนส่วน

parent 789d0100
...@@ -210,10 +210,8 @@ ...@@ -210,10 +210,8 @@
</div> </div>
<label class="ti-form-label mt-2rem">เเผนก*</label> <label class="ti-form-label mt-2rem">เเผนก*</label>
<div class="relative flex rounded-md w-1/2"> <div class="relative flex rounded-md w-1/2">
<input type="text" id="detail_th" class="ti-form-input h-16" [(ngModel)]="bu2.bu2id"> <input type="text" class="ti-form-input h-16" [(ngModel)]="bu2.bu2id">
</div> <!-- <input type="text" id="hs-leading-button-add-on-with-icon-and-button" name="hs-leading-button-add-on-with-icon-and-button" class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10" style="padding-right: 3.5rem;"
<!-- <div class="relative flex rounded-md w-1/2">
<input type="text" id="hs-leading-button-add-on-with-icon-and-button" name="hs-leading-button-add-on-with-icon-and-button" class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10" style="padding-right: 3.5rem;"
[(ngModel)]="bu2.bu2id" (ngModelChange)="bu2idChange()"> [(ngModel)]="bu2.bu2id" (ngModelChange)="bu2idChange()">
<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"> <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)="selectBu2()"> <button type="button" class="flex items-center text-red-500" (click)="selectBu2()">
...@@ -222,8 +220,8 @@ ...@@ -222,8 +220,8 @@
<button type="button" class="flex items-center text-gray-500 dark:text-white/70" data-hs-overlay="#department-list-bu2-table-modal"> <button type="button" class="flex items-center text-gray-500 dark:text-white/70" data-hs-overlay="#department-list-bu2-table-modal">
<i class="ri-search-line cursor-pointer text-gray"></i> <i class="ri-search-line cursor-pointer text-gray"></i>
</button> </button>
</div>
</div> --> </div> -->
</div>
<label for="detail_th" class="ti-form-label mt-2rem">รายละเอียดแผนก (ไทย)*</label> <label for="detail_th" class="ti-form-label mt-2rem">รายละเอียดแผนก (ไทย)*</label>
<input type="text" id="detail_th" class="ti-form-input h-16" [(ngModel)]="bu2.tdesc"> <input type="text" id="detail_th" class="ti-form-input h-16" [(ngModel)]="bu2.tdesc">
<label for="detail_eng" class="ti-form-label mt-2rem">รายละเอียดแผนก (อังกฤษ)</label> <label for="detail_eng" class="ti-form-label mt-2rem">รายละเอียดแผนก (อังกฤษ)</label>
......
...@@ -18,7 +18,7 @@ interface table { ...@@ -18,7 +18,7 @@ interface table {
export class DepartmentListComponent implements OnInit { export class DepartmentListComponent implements OnInit {
bu2List: Bu2Model[] = [] bu2List: Bu2Model[] = []
bu2ListLoading = false bu2ListLoading = false
bu2: Bu2Model = new MyBu2Model({}) bu2: Bu2Model = new MyBu2Model()
bu2Table: table = { bu2Table: table = {
currentPage: 1, currentPage: 1,
page: Array.from({ length: 1 }, (_, i) => i + 1), page: Array.from({ length: 1 }, (_, i) => i + 1),
...@@ -64,6 +64,7 @@ export class DepartmentListComponent implements OnInit { ...@@ -64,6 +64,7 @@ export class DepartmentListComponent implements OnInit {
} }
const formData = new FormData(); const formData = new FormData();
formData.append('file', this.selectedFile); formData.append('file', this.selectedFile);
this.bu2ListLoading = true
this.fileService.upload(formData, 'mbu2').subscribe({ this.fileService.upload(formData, 'mbu2').subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
...@@ -71,9 +72,11 @@ export class DepartmentListComponent implements OnInit { ...@@ -71,9 +72,11 @@ export class DepartmentListComponent implements OnInit {
this.getBu2List() this.getBu2List()
} else { } else {
this.showAlert(response.message, 'error') this.showAlert(response.message, 'error')
this.bu2ListLoading = false
} }
}, error: error => { }, error: error => {
this.showAlert(error.message, 'error') this.showAlert(error.message, 'error')
this.bu2ListLoading = false
} }
}) })
} }
...@@ -121,7 +124,7 @@ export class DepartmentListComponent implements OnInit { ...@@ -121,7 +124,7 @@ export class DepartmentListComponent implements OnInit {
x.edesc.toLowerCase().includes(this.bu2Table.search.toLowerCase())) x.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()
if (this.bu2.parent) { if (this.bu2.parent) {
this.bu1Service.getById(this.bu2.parent).subscribe(response => { this.bu1Service.getById(this.bu2.parent).subscribe(response => {
...@@ -165,7 +168,7 @@ export class DepartmentListComponent implements OnInit { ...@@ -165,7 +168,7 @@ export class DepartmentListComponent implements OnInit {
x.edesc.toLowerCase().includes(this.bu1Modal.search.toLowerCase())) x.edesc.toLowerCase().includes(this.bu1Modal.search.toLowerCase()))
} }
selectBu1(bu1?: Bu1Model) { selectBu1(bu1?: Bu1Model) {
this.bu1 = new MyBu1Model(bu1 || {}) this.bu1 = new MyBu1Model(bu1)
} }
showAlert(text: string, type: 'success' | 'error') { showAlert(text: string, type: 'success' | 'error') {
...@@ -175,6 +178,7 @@ export class DepartmentListComponent implements OnInit { ...@@ -175,6 +178,7 @@ export class DepartmentListComponent implements OnInit {
}) })
} }
addBu2() { addBu2() {
this.bu2ListLoading = true
this.bu2Service.post({ ...this.bu2, parent: this.bu1.bu1id }).subscribe({ this.bu2Service.post({ ...this.bu2, parent: this.bu1.bu1id }).subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
...@@ -182,13 +186,16 @@ export class DepartmentListComponent implements OnInit { ...@@ -182,13 +186,16 @@ export class DepartmentListComponent implements OnInit {
this.getBu2List() this.getBu2List()
} else { } else {
this.showAlert(response.message, 'error') this.showAlert(response.message, 'error')
this.bu2ListLoading = false
} }
}, error: error => { }, error: error => {
this.showAlert(error.message, 'error') this.showAlert(error.message, 'error')
this.bu2ListLoading = false
} }
}) })
} }
deleteBu2() { deleteBu2() {
this.bu2ListLoading = true
this.bu2Service.delete(this.bu2).subscribe({ this.bu2Service.delete(this.bu2).subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
...@@ -196,9 +203,11 @@ export class DepartmentListComponent implements OnInit { ...@@ -196,9 +203,11 @@ export class DepartmentListComponent implements OnInit {
this.getBu2List() this.getBu2List()
} else { } else {
this.showAlert(response.message, 'error') this.showAlert(response.message, 'error')
this.bu2ListLoading = false
} }
}, error: error => { }, error: error => {
this.showAlert(error.message, 'error') this.showAlert(error.message, 'error')
this.bu2ListLoading = false
} }
}) })
} }
......
...@@ -41,6 +41,7 @@ export class DepartmentRegisterComponent implements OnInit { ...@@ -41,6 +41,7 @@ export class DepartmentRegisterComponent implements OnInit {
} }
const formData = new FormData(); const formData = new FormData();
formData.append('file', this.selectedFile); formData.append('file', this.selectedFile);
this.bu1ListLoading = true
this.fileService.upload(formData, 'mbu1').subscribe({ this.fileService.upload(formData, 'mbu1').subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
...@@ -48,9 +49,11 @@ export class DepartmentRegisterComponent implements OnInit { ...@@ -48,9 +49,11 @@ export class DepartmentRegisterComponent implements OnInit {
this.getBu1List() this.getBu1List()
} else { } else {
this.showAlert(response.message, 'error') this.showAlert(response.message, 'error')
this.bu1ListLoading = false
} }
}, error: error => { }, error: error => {
this.showAlert(error.message, 'error') this.showAlert(error.message, 'error')
this.bu1ListLoading = false
} }
}) })
} }
...@@ -99,7 +102,7 @@ export class DepartmentRegisterComponent implements OnInit { ...@@ -99,7 +102,7 @@ export class DepartmentRegisterComponent implements OnInit {
x.edesc.toLowerCase().includes(this.search.toLowerCase())) x.edesc.toLowerCase().includes(this.search.toLowerCase()))
} }
selectBu1(bu1?: Bu1Model) { selectBu1(bu1?: Bu1Model) {
this.bu1 = new MyBu1Model(bu1 || {}) this.bu1 = new MyBu1Model(bu1)
} }
showAlert(text: string, type: 'success' | 'error') { showAlert(text: string, type: 'success' | 'error') {
...@@ -117,10 +120,11 @@ export class DepartmentRegisterComponent implements OnInit { ...@@ -117,10 +120,11 @@ export class DepartmentRegisterComponent implements OnInit {
this.getBu1List() this.getBu1List()
} else { } else {
this.showAlert(response.message, 'error') this.showAlert(response.message, 'error')
this.bu1ListLoading = false
} }
}, error: error => { }, error: error => {
this.bu1ListLoading = false
this.showAlert(error.message, 'error') this.showAlert(error.message, 'error')
this.bu1ListLoading = false
} }
}) })
} }
...@@ -133,10 +137,11 @@ export class DepartmentRegisterComponent implements OnInit { ...@@ -133,10 +137,11 @@ export class DepartmentRegisterComponent implements OnInit {
this.getBu1List() this.getBu1List()
} else { } else {
this.showAlert(response.message, 'error') this.showAlert(response.message, 'error')
this.bu1ListLoading = false
} }
}, error: error => { }, error: error => {
this.bu1ListLoading = false
this.showAlert(error.message, 'error') this.showAlert(error.message, 'error')
this.bu1ListLoading = false
} }
}) })
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<div class="flex pr-2"> <div class="flex pr-2">
<div class="px-1"> <div class="px-1">
<button type="button" class="ti-btn ti-btn-soft-secondary h-20px m-0 shadow-md" <button type="button" class="ti-btn ti-btn-soft-secondary h-20px m-0 shadow-md"
data-hs-overlay="#section-registration-upload-modal"> data-hs-overlay="#section-registration-upload-modal" (click)="selectedFileName = 'กรุณาเลือกไฟล์'">
<i class="ri-add-line"></i> <i class="ri-add-line"></i>
นำเข้าข้อมูล นำเข้าข้อมูล
</button> </button>
...@@ -28,7 +28,8 @@ ...@@ -28,7 +28,8 @@
</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';selectBu2();selectBu3()" data-hs-overlay="#section-registration-modal-add"> (click)="currentModal='add';selectBu2();selectBu3()"
data-hs-overlay="#section-registration-modal-add">
<i class="ri-add-line"></i> <i class="ri-add-line"></i>
Add Add
</button> </button>
...@@ -47,10 +48,10 @@ ...@@ -47,10 +48,10 @@
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="page px-rem"> <div class="page px-rem">
<div class="overflow-auto shadow-md rounded-t-md"> <div class="overflow-auto shadow-md rounded-t-md">
<table class="ti-custom-table ti-custom-table-head ti-custom-table-hover table-bordered"> <table class="ti-custom-table ti-custom-table-head ti-custom-table-hover table-bordered">
<thead> <thead>
...@@ -96,7 +97,8 @@ ...@@ -96,7 +97,8 @@
<i class="ti ti-edit cursor-pointer i-gray fs-l px-1" <i class="ti ti-edit cursor-pointer i-gray fs-l px-1"
(click)="selectBu3(item);currentModal='edit'" (click)="selectBu3(item);currentModal='edit'"
data-hs-overlay="#section-registration-modal-edit"></i> data-hs-overlay="#section-registration-modal-edit"></i>
<i class="ti ti-trash cursor-pointer i-gray fs-l px-1" (click)="selectBu3(item)" data-hs-overlay="#section-registration-alert-delete-modal"></i> <i class="ti ti-trash cursor-pointer i-gray fs-l px-1" currentModal='delete'
(click)="selectBu3(item)" data-hs-overlay="#section-registration-alert-delete-modal"></i>
</td> </td>
</tr> </tr>
</tbody> </tbody>
...@@ -111,11 +113,13 @@ ...@@ -111,11 +113,13 @@
</a> </a>
</li> </li>
<li *ngFor="let item of bu3Table.page;let f = first;let l = last"> <li *ngFor="let item of bu3Table.page;let f = first;let l = last">
<ng-container *ngIf="item==3&&bu3Table.currentPage!=1&&bu3Table.currentPage!=2&&bu3Table.currentPage!=3"> <ng-container
*ngIf="item==3&&bu3Table.currentPage!=1&&bu3Table.currentPage!=2&&bu3Table.currentPage!=3">
<a aria-label="anchor" class="page-link" href="javascript:void(0);"><i class="ri-more-line"></i> <a aria-label="anchor" class="page-link" href="javascript:void(0);"><i class="ri-more-line"></i>
</a> </a>
</ng-container> </ng-container>
<ng-container *ngIf="(f||l)||(item==bu3Table.currentPage-1||item==bu3Table.currentPage||item==bu3Table.currentPage+1)"> <ng-container
*ngIf="(f||l)||(item==bu3Table.currentPage-1||item==bu3Table.currentPage||item==bu3Table.currentPage+1)">
<a class="page-link" href="javascript:void(0);" [class.active]="item==bu3Table.currentPage" <a class="page-link" href="javascript:void(0);" [class.active]="item==bu3Table.currentPage"
(click)="bu3Table.currentPage=item">{{item}} (click)="bu3Table.currentPage=item">{{item}}
</a> </a>
...@@ -134,7 +138,7 @@ ...@@ -134,7 +138,7 @@
</li> </li>
</ul> </ul>
</nav> </nav>
</div> </div>
<div id="section-registration-modal-add" class="hs-overlay hidden ti-modal"> <div id="section-registration-modal-add" class="hs-overlay hidden ti-modal">
...@@ -181,16 +185,20 @@ ...@@ -181,16 +185,20 @@
</div> </div>
</div> </div>
<div class="ti-modal-body"> <div class="ti-modal-body">
<label class="ti-form-label">อยู่ภายใต้หน่วยงาน</label> <label class="ti-form-label">อยู่ภายใต้หน่วยงาน*</label>
<div class="flex"> <div class="flex">
<div class="relative flex rounded-md"> <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" style="padding-right: 3.5rem;" <input type="text" id="hs-leading-button-add-on-with-icon-and-button"
[(ngModel)]="bu2.bu2id" (ngModelChange)="bu2idChange()"> name="hs-leading-button-add-on-with-icon-and-button"
<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"> class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10"
style="padding-right: 3.5rem;" [(ngModel)]="bu2.bu2id" (ngModelChange)="bu2idChange()">
<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)="selectBu2()"> <button type="button" class="flex items-center text-red-500" (click)="selectBu2()">
<i class="ti ti-circle-x cursor-pointer"></i> <i class="ti ti-circle-x cursor-pointer"></i>
</button> </button>
<button type="button" class="flex items-center text-gray-500 dark:text-white/70" data-hs-overlay="#section-registration-bu2-table-modal"> <button type="button" class="flex items-center text-gray-500 dark:text-white/70"
data-hs-overlay="#section-registration-bu2-table-modal">
<i class="ri-search-line cursor-pointer text-gray"></i> <i class="ri-search-line cursor-pointer text-gray"></i>
</button> </button>
</div> </div>
...@@ -200,18 +208,23 @@ ...@@ -200,18 +208,23 @@
readonly [value]="bu2.tdesc"> readonly [value]="bu2.tdesc">
</div> </div>
</div> </div>
<label class="ti-form-label mt-2rem">ส่วน</label> <label class="ti-form-label mt-2rem">ส่วน*</label>
<div class="relative flex rounded-md w-1/2"> <div class="relative flex rounded-md w-1/2">
<input type="text" id="hs-leading-button-add-on-with-icon-and-button" name="hs-leading-button-add-on-with-icon-and-button" class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10" style="padding-right: 3.5rem;" <input type="text" class="ti-form-input h-16" [(ngModel)]="bu3.bu3id">
[(ngModel)]="bu3.bu3id" (ngModelChange)="bu3idChange()"> <!-- <input type="text" id="hs-leading-button-add-on-with-icon-and-button"
<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"> name="hs-leading-button-add-on-with-icon-and-button"
class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10"
style="padding-right: 3.5rem;" [(ngModel)]="bu3.bu3id" (ngModelChange)="bu3idChange()">
<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)="selectBu3()"> <button type="button" class="flex items-center text-red-500" (click)="selectBu3()">
<i class="ti ti-circle-x cursor-pointer"></i> <i class="ti ti-circle-x cursor-pointer"></i>
</button> </button>
<button type="button" class="flex items-center text-gray-500 dark:text-white/70" data-hs-overlay="#section-registration-bu3-table-modal"> <button type="button" class="flex items-center text-gray-500 dark:text-white/70"
data-hs-overlay="#section-registration-bu3-table-modal">
<i class="ri-search-line cursor-pointer text-gray"></i> <i class="ri-search-line cursor-pointer text-gray"></i>
</button> </button>
</div> </div> -->
</div> </div>
<label for="detail_th" class="ti-form-label mt-2rem">รายละเอียด (ไทย)</label> <label for="detail_th" class="ti-form-label mt-2rem">รายละเอียด (ไทย)</label>
<input type="text" id="detail_th" class="ti-form-input h-16" [(ngModel)]="bu3.tdesc"> <input type="text" id="detail_th" class="ti-form-input h-16" [(ngModel)]="bu3.tdesc">
...@@ -223,10 +236,12 @@ ...@@ -223,10 +236,12 @@
data-hs-overlay="#section-registration-modal-add"> data-hs-overlay="#section-registration-modal-add">
ย้อนกลับ ย้อนกลับ
</button> </button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);" <button type="button" class="ti-btn ti-btn-success"
data-hs-overlay="#section-registration-alert-modal"> data-hs-overlay="#section-registration-alert-modal"
[class.ti-btn-disabled]="!bu2.bu2id||!bu3.bu3id||!bu3.tdesc"
[disabled]="!bu2.bu2id||!bu3.bu3id||!bu3.tdesc">
บันทึกข้อมูล บันทึกข้อมูล
</a> </button>
</div> </div>
</div> </div>
</div> </div>
...@@ -277,17 +292,20 @@ ...@@ -277,17 +292,20 @@
</div> </div>
</div> </div>
<div class="ti-modal-body"> <div class="ti-modal-body">
<label for="hs-trailing-button-add-on-with-icon" <label for="hs-trailing-button-add-on-with-icon" class="ti-form-label">อยู่ภายใต้หน่วยงาน</label>
class="ti-form-label">อยู่ภายใต้หน่วยงาน</label>
<div class="flex"> <div class="flex">
<div class="relative flex rounded-md"> <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" style="padding-right: 3.5rem;" <input type="text" id="hs-leading-button-add-on-with-icon-and-button"
[(ngModel)]="bu2.bu2id" (ngModelChange)="bu2idChange()"> name="hs-leading-button-add-on-with-icon-and-button"
<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"> class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10"
style="padding-right: 3.5rem;" [(ngModel)]="bu2.bu2id" (ngModelChange)="bu2idChange()">
<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)="selectBu2()"> <button type="button" class="flex items-center text-red-500" (click)="selectBu2()">
<i class="ti ti-circle-x cursor-pointer"></i> <i class="ti ti-circle-x cursor-pointer"></i>
</button> </button>
<button type="button" class="flex items-center text-gray-500 dark:text-white/70" data-hs-overlay="#section-registration-bu2-table-modal"> <button type="button" class="flex items-center text-gray-500 dark:text-white/70"
data-hs-overlay="#section-registration-bu2-table-modal">
<i class="ri-search-line cursor-pointer text-gray"></i> <i class="ri-search-line cursor-pointer text-gray"></i>
</button> </button>
</div> </div>
...@@ -314,10 +332,12 @@ ...@@ -314,10 +332,12 @@
data-hs-overlay="#section-registration-modal-edit"> data-hs-overlay="#section-registration-modal-edit">
ย้อนกลับ ย้อนกลับ
</button> </button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);" <button type="button" class="ti-btn ti-btn-success"
data-hs-overlay="#section-registration-alert-edit-modal"> data-hs-overlay="#section-registration-alert-edit-modal"
[class.ti-btn-disabled]="!bu2.bu2id||!bu3.bu3id||!bu3.tdesc"
[disabled]="!bu2.bu2id||!bu3.bu3id||!bu3.tdesc">
บันทึกข้อมูล บันทึกข้อมูล
</a> </button>
</div> </div>
</div> </div>
</div> </div>
...@@ -563,7 +583,7 @@ ...@@ -563,7 +583,7 @@
</h3> </h3>
<div class="flex justify-end"> <div class="flex justify-end">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger" <button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#section-registration-alert-modal"> data-hs-overlay="#section-registration-modal-add">
<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>
...@@ -575,16 +595,11 @@ ...@@ -575,16 +595,11 @@
</p> </p>
<div class="flex justify-end mt-2rem mb-1rem"> <div class="flex justify-end mt-2rem mb-1rem">
<button type="button" *ngIf="currentModal=='add'" <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="#section-registration-modal-add"> data-hs-overlay="#section-registration-modal-add">
ย้อนกลับ ย้อนกลับ
</button> </button>
<button type="button" *ngIf="currentModal=='edit'"
class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
data-hs-overlay="#section-registration-modal-edit">
ย้อนกลับ
</button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);" <a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#section-registration-alert-modal" (click)="addBu3()"> data-hs-overlay="#section-registration-alert-modal" (click)="addBu3()">
บันทึกข้อมูล บันทึกข้อมูล
...@@ -604,7 +619,7 @@ ...@@ -604,7 +619,7 @@
</h3> </h3>
<div class="flex justify-end"> <div class="flex justify-end">
<button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger" <button type="button" class="hs-dropdown-toggle ti-modal-clode-btn text-danger"
data-hs-overlay="#section-registration-alert-modal"> data-hs-overlay="#section-registration-modal-edit">
<span class="sr-only">Close</span> <span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i> <i class="ti ti-circle-x fs-xxl"></i>
</button> </button>
...@@ -616,11 +631,6 @@ ...@@ -616,11 +631,6 @@
</p> </p>
<div class="flex justify-end mt-2rem mb-1rem"> <div class="flex justify-end mt-2rem mb-1rem">
<button type="button" *ngIf="currentModal=='add'"
class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
data-hs-overlay="#section-registration-modal-add">
ย้อนกลับ
</button>
<button type="button" *ngIf="currentModal=='edit'" <button type="button" *ngIf="currentModal=='edit'"
class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10" 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="#section-registration-modal-edit"> data-hs-overlay="#section-registration-modal-edit">
...@@ -657,14 +667,9 @@ ...@@ -657,14 +667,9 @@
</p> </p>
<div class="flex justify-end mt-2rem mb-1rem"> <div class="flex justify-end mt-2rem mb-1rem">
<button type="button" *ngIf="currentModal=='add'" <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="#section-registration-modal-add">
ย้อนกลับ
</button>
<button type="button" *ngIf="currentModal=='edit'"
class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10" 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="#section-registration-modal-edit"> data-hs-overlay="#section-registration-alert-delete-modal">
ย้อนกลับ ย้อนกลับ
</button> </button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);" <a class="ti-btn ti-btn-success" href="javascript:void(0);"
...@@ -697,7 +702,8 @@ ...@@ -697,7 +702,8 @@
</button> </button>
</div> </div>
<div class="flex justify-center mt-2rem mb-1rem space-x-4"> <div class="flex justify-center mt-2rem mb-1rem space-x-4">
<button type="submit" class="ti-btn ti-btn-secondary" (click)="uploadFile()" <button type="submit" class="ti-btn ti-btn-secondary"
data-hs-overlay="#section-registration-upload-modal" (click)="uploadFile()"
[disabled]="!selectedFile"> [disabled]="!selectedFile">
อัปโหลด อัปโหลด
</button> </button>
......
...@@ -18,7 +18,7 @@ interface table { ...@@ -18,7 +18,7 @@ interface table {
export class SectionRegistrationComponent implements OnInit { export class SectionRegistrationComponent implements OnInit {
bu3List: Bu3Model[] = [] bu3List: Bu3Model[] = []
bu3ListLoading = false bu3ListLoading = false
bu3: Bu3Model = new MyBu3Model({}) bu3: Bu3Model = new MyBu3Model()
bu3Table: table = { bu3Table: table = {
currentPage: 1, currentPage: 1,
page: Array.from({ length: 1 }, (_, i) => i + 1), page: Array.from({ length: 1 }, (_, i) => i + 1),
...@@ -34,13 +34,13 @@ export class SectionRegistrationComponent implements OnInit { ...@@ -34,13 +34,13 @@ export class SectionRegistrationComponent implements OnInit {
search: "" search: ""
} }
bu2List: Bu2Model[] = [] bu2List: Bu2Model[] = []
bu2: Bu2Model = new MyBu2Model({}) bu2: Bu2Model = new MyBu2Model()
bu2Modal: table = { bu2Modal: table = {
currentPage: 1, currentPage: 1,
page: Array.from({ length: 1 }, (_, i) => i + 1), page: Array.from({ length: 1 }, (_, i) => i + 1),
search: "" search: ""
} }
currentModal = "" currentModal: 'add' | 'edit' | 'delete' = "add"
constructor(private bu3Service: Bu3Service, constructor(private bu3Service: Bu3Service,
private bu2Service: Bu2Service, private bu2Service: Bu2Service,
private toastr: ToastrService, private toastr: ToastrService,
...@@ -65,6 +65,7 @@ export class SectionRegistrationComponent implements OnInit { ...@@ -65,6 +65,7 @@ export class SectionRegistrationComponent implements OnInit {
} }
const formData = new FormData(); const formData = new FormData();
formData.append('file', this.selectedFile); formData.append('file', this.selectedFile);
this.bu3ListLoading = true
this.fileService.upload(formData, 'mbu3').subscribe({ this.fileService.upload(formData, 'mbu3').subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
...@@ -72,9 +73,11 @@ export class SectionRegistrationComponent implements OnInit { ...@@ -72,9 +73,11 @@ export class SectionRegistrationComponent implements OnInit {
this.getBu3List() this.getBu3List()
} else { } else {
this.showAlert(response.message, 'error') this.showAlert(response.message, 'error')
this.bu3ListLoading = false
} }
}, error: error => { }, error: error => {
this.showAlert(error.message, 'error') this.showAlert(error.message, 'error')
this.bu3ListLoading = false
} }
}) })
} }
...@@ -122,7 +125,7 @@ export class SectionRegistrationComponent implements OnInit { ...@@ -122,7 +125,7 @@ export class SectionRegistrationComponent implements OnInit {
x.edesc.toLowerCase().includes(this.bu3Table.search.toLowerCase())) x.edesc.toLowerCase().includes(this.bu3Table.search.toLowerCase()))
} }
selectBu3(bu3?: Bu3Model) { selectBu3(bu3?: Bu3Model) {
this.bu3 = new MyBu3Model(bu3 || {}) this.bu3 = new MyBu3Model(bu3)
this.selectBu2() this.selectBu2()
if (this.bu3.parent) { if (this.bu3.parent) {
this.bu2Service.getById(this.bu3.parent).subscribe(response => { this.bu2Service.getById(this.bu3.parent).subscribe(response => {
...@@ -145,6 +148,7 @@ export class SectionRegistrationComponent implements OnInit { ...@@ -145,6 +148,7 @@ export class SectionRegistrationComponent implements OnInit {
x.edesc.toLowerCase().includes(this.bu3Modal.search.toLowerCase())) x.edesc.toLowerCase().includes(this.bu3Modal.search.toLowerCase()))
} }
addBu3() { addBu3() {
this.bu3ListLoading = true
this.bu3Service.post({ ...this.bu3, parent: this.bu2.bu2id }).subscribe({ this.bu3Service.post({ ...this.bu3, parent: this.bu2.bu2id }).subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
...@@ -152,13 +156,16 @@ export class SectionRegistrationComponent implements OnInit { ...@@ -152,13 +156,16 @@ export class SectionRegistrationComponent implements OnInit {
this.getBu3List() this.getBu3List()
} else { } else {
this.showAlert(response.message, 'error') this.showAlert(response.message, 'error')
this.bu3ListLoading = false
} }
}, error: error => { }, error: error => {
this.showAlert(error.message, 'error') this.showAlert(error.message, 'error')
this.bu3ListLoading = false
} }
}) })
} }
deleteBu3() { deleteBu3() {
this.bu3ListLoading = true
this.bu3Service.delete(this.bu3).subscribe({ this.bu3Service.delete(this.bu3).subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
...@@ -166,9 +173,11 @@ export class SectionRegistrationComponent implements OnInit { ...@@ -166,9 +173,11 @@ export class SectionRegistrationComponent implements OnInit {
this.getBu3List() this.getBu3List()
} else { } else {
this.showAlert(response.message, 'error') this.showAlert(response.message, 'error')
this.bu3ListLoading = false
} }
}, error: error => { }, error: error => {
this.showAlert(error.message, 'error') this.showAlert(error.message, 'error')
this.bu3ListLoading = false
} }
}) })
} }
...@@ -193,7 +202,7 @@ export class SectionRegistrationComponent implements OnInit { ...@@ -193,7 +202,7 @@ export class SectionRegistrationComponent implements OnInit {
x.edesc.toLowerCase().includes(this.bu2Modal.search.toLowerCase())) x.edesc.toLowerCase().includes(this.bu2Modal.search.toLowerCase()))
} }
selectBu2(bu2?: Bu2Model) { selectBu2(bu2?: Bu2Model) {
this.bu2 = new MyBu2Model(bu2 || {}) this.bu2 = new MyBu2Model(bu2)
} }
showAlert(text: string, type: 'success' | 'error') { showAlert(text: string, type: 'success' | 'error') {
......
...@@ -34,7 +34,7 @@ export class SubDepartmentOneComponent implements OnInit { ...@@ -34,7 +34,7 @@ export class SubDepartmentOneComponent implements OnInit {
search: "" search: ""
} }
bu3List: Bu3Model[] = [] bu3List: Bu3Model[] = []
bu3: Bu3Model = new MyBu3Model({}) bu3: Bu3Model = new MyBu3Model()
bu3Modal: table = { bu3Modal: table = {
currentPage: 1, currentPage: 1,
page: Array.from({ length: 1 }, (_, i) => i + 1), page: Array.from({ length: 1 }, (_, i) => i + 1),
......
...@@ -742,7 +742,7 @@ ...@@ -742,7 +742,7 @@
<i class="ti ti-wallet text-lg"></i> <i class="ti ti-wallet text-lg"></i>
Bal: $7,12,950 Bal: $7,12,950
</a> </a>
<a routerLink="/signin/basic" class="ti-dropdown-item"> <a (click)="logOut()" routerLink="/auth/login" class="ti-dropdown-item">
<i class="ti ti-logout text-lg"></i> <i class="ti ti-logout text-lg"></i>
Log Out Log Out
</a> </a>
......
...@@ -13,6 +13,10 @@ export class HeaderComponent { ...@@ -13,6 +13,10 @@ export class HeaderComponent {
private elementRef: ElementRef) { private elementRef: ElementRef) {
} }
logOut() {
sessionStorage.clear()
}
themeChange(type: string, type1: string) { themeChange(type: string, type1: string) {
this.elementRef.nativeElement.ownerDocument.documentElement?.setAttribute('class', type); this.elementRef.nativeElement.ownerDocument.documentElement?.setAttribute('class', type);
this.elementRef.nativeElement.ownerDocument.documentElement?.setAttribute('style', ""); this.elementRef.nativeElement.ownerDocument.documentElement?.setAttribute('style', "");
...@@ -37,11 +41,11 @@ export class HeaderComponent { ...@@ -37,11 +41,11 @@ export class HeaderComponent {
toggleSidebar() { toggleSidebar() {
let html = this.elementRef.nativeElement.ownerDocument.documentElement; let html = this.elementRef.nativeElement.ownerDocument.documentElement;
if(window.innerWidth <= 992){ if (window.innerWidth <= 992) {
html?.setAttribute('toggled', html?.getAttribute('toggled') == 'open' ? 'close' : 'open'); html?.setAttribute('toggled', html?.getAttribute('toggled') == 'open' ? 'close' : 'open');
if(html?.getAttribute('toggled') == 'open'){ if (html?.getAttribute('toggled') == 'open') {
document.querySelector('#responsive-overlay')?.classList.add('active'); document.querySelector('#responsive-overlay')?.classList.add('active');
}else{ } else {
document.querySelector('#responsive-overlay')?.classList.remove('active'); document.querySelector('#responsive-overlay')?.classList.remove('active');
} }
} }
......
...@@ -13,12 +13,12 @@ export class MyBu2Model implements Bu2Model { ...@@ -13,12 +13,12 @@ export class MyBu2Model implements Bu2Model {
edesc: string; edesc: string;
parent: string; parent: string;
companyId: string; companyId: string;
constructor(data: Partial<Bu2Model>) { constructor(data?: Partial<Bu2Model>) {
this.bu2id = data.bu2id || "" this.bu2id = data?.bu2id || ""
this.tdesc = data.tdesc || "" this.tdesc = data?.tdesc || ""
this.edesc = data.edesc || "" this.edesc = data?.edesc || ""
this.parent = data.parent || "" this.parent = data?.parent || ""
this.companyId = data.companyId || "" this.companyId = data?.companyId || ""
} }
} }
...@@ -13,12 +13,12 @@ export class MyBu3Model implements Bu3Model { ...@@ -13,12 +13,12 @@ export class MyBu3Model implements Bu3Model {
edesc: string; edesc: string;
parent: string; parent: string;
companyId: string; companyId: string;
constructor(data: Partial<Bu3Model>) { constructor(data?: Partial<Bu3Model>) {
this.bu3id = data.bu3id || "" this.bu3id = data?.bu3id || ""
this.tdesc = data.tdesc || "" this.tdesc = data?.tdesc || ""
this.edesc = data.edesc || "" this.edesc = data?.edesc || ""
this.parent = data.parent || "" this.parent = data?.parent || ""
this.companyId = data.companyId || "" this.companyId = data?.companyId || ""
} }
} }
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