Commit 8cbf148f by Nattana Chaiyamat

ส่วนย่อย4

parent 39c6ff1f
......@@ -104,7 +104,7 @@ export class DepartmentListComponent implements OnInit {
this.bu2ListLoading = true
this.bu2Service.getList().subscribe({
next: response => {
this.bu2List = response
this.bu2List = response.map(x => new MyBu2Model(x))
this.bu2ListLoading = false
this.onBu2TableSearchChange()
this.cdr.detectChanges()
......@@ -150,7 +150,7 @@ export class DepartmentListComponent implements OnInit {
getBu1List() {
this.bu1Service.getList().subscribe(response => {
this.bu1List = response
this.bu1List = response.map(x => new MyBu1Model(x))
this.onBu1ModalSearchChange()
})
}
......
......@@ -82,7 +82,7 @@ export class DepartmentRegisterComponent implements OnInit {
this.bu1ListLoading = true
this.bu1Service.getList().subscribe({
next: response => {
this.bu1List = response
this.bu1List = response.map(x => new MyBu1Model(x))
this.bu1ListLoading = false
this.searchChange()
this.cdr.detectChanges()
......
......@@ -105,7 +105,7 @@ export class SectionRegistrationComponent implements OnInit {
this.bu3ListLoading = true
this.bu3Service.getList().subscribe({
next: response => {
this.bu3List = response
this.bu3List = response.map(x => new MyBu3Model(x))
this.bu3ListLoading = false
this.onBu3TableSearchChange()
this.cdr.detectChanges()
......@@ -184,7 +184,7 @@ export class SectionRegistrationComponent implements OnInit {
getBu2List() {
this.bu2Service.getList().subscribe(response => {
this.bu2List = response
this.bu2List = response.map(x => new MyBu2Model(x))
this.onBu2ModalSearchChange()
})
}
......
......@@ -3,7 +3,8 @@
<div class="flex pr-2">
<div class="px-1">
<button type="button" class="ti-btn ti-btn-soft-secondary h-20px m-0 shadow-md"
data-hs-overlay="#sub-department-four-upload-modal">
data-hs-overlay="#sub-department-four-upload-modal"
(click)="fileInput.value = '';selectedFile=null;selectedFileName = 'กรุณาเลือกไฟล์'">
<i class="ri-add-line"></i>
นำเข้าข้อมูล
</button>
......@@ -28,7 +29,8 @@
</div>
<div class="px-1">
<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-add">
(click)="currentModal='add';selectBu6();selectBu7()"
data-hs-overlay="#sub-department-four-modal-add">
<i class="ri-add-line"></i>
Add
</button>
......@@ -47,9 +49,9 @@
</div>
</div>
</div>
</div>
</div>
<div class="page px-rem">
<div class="page px-rem">
<div class="overflow-auto shadow-md rounded-t-md">
<table class="ti-custom-table ti-custom-table-head ti-custom-table-hover table-bordered">
<thead>
......@@ -111,11 +113,13 @@
</a>
</li>
<li *ngFor="let item of bu7Table.page;let f = first;let l = last">
<ng-container *ngIf="item==3&&bu7Table.currentPage!=1&&bu7Table.currentPage!=2&&bu7Table.currentPage!=3">
<ng-container
*ngIf="item==3&&bu7Table.currentPage!=1&&bu7Table.currentPage!=2&&bu7Table.currentPage!=3">
<a aria-label="anchor" class="page-link" href="javascript:void(0);"><i class="ri-more-line"></i>
</a>
</ng-container>
<ng-container *ngIf="(f||l)||(item==bu7Table.currentPage-1||item==bu7Table.currentPage||item==bu7Table.currentPage+1)">
<ng-container
*ngIf="(f||l)||(item==bu7Table.currentPage-1||item==bu7Table.currentPage||item==bu7Table.currentPage+1)">
<a class="page-link" href="javascript:void(0);" [class.active]="item==bu7Table.currentPage"
(click)="bu7Table.currentPage=item">{{item}}
</a>
......@@ -181,16 +185,20 @@
</div>
</div>
<div class="ti-modal-body">
<label class="ti-form-label ">อยู่ภายใต้หน่วยงาน</label>
<label class="ti-form-label ">อยู่ภายใต้หน่วยงาน*</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" 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">
<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)]="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">
<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>
......@@ -200,20 +208,25 @@
readonly [value]="bu6.tdesc">
</div>
</div>
<label class="ti-form-label mt-2rem">ส่วนย่อย4</label>
<label class="ti-form-label mt-2rem">ส่วนย่อย4*</label>
<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)]="bu7.bu7id" (ngModelChange)="bu7idChange()">
<div class="absolute inset-y-0 ltr:right-0 rtl:left-0 flex items-center z-20 ltr:pr-4 rtl:pl-4 space-x-2">
<input type="text" class="ti-form-input h-16" [(ngModel)]="bu7.bu7id">
<!-- <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)]="bu7.bu7id" (ngModelChange)="bu7idChange()">
<div
class="absolute inset-y-0 ltr:right-0 rtl:left-0 flex items-center z-20 ltr:pr-4 rtl:pl-4 space-x-2">
<button type="button" class="flex items-center text-red-500" (click)="selectBu7()">
<i class="ti ti-circle-x cursor-pointer"></i>
</button>
<button type="button" class="flex items-center text-gray-500 dark:text-white/70" data-hs-overlay="#sub-department-four-bu7-table-modal">
<button type="button" class="flex items-center text-gray-500 dark:text-white/70"
data-hs-overlay="#sub-department-four-bu7-table-modal">
<i class="ri-search-line cursor-pointer text-gray"></i>
</button>
</div> -->
</div>
</div>
<label for="detail_th" class="ti-form-label mt-2rem">รายละเอียด (ไทย)</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)]="bu7.tdesc">
<label for="detail_eng" class="ti-form-label mt-2rem">รายละเอียด (อังกฤษ)</label>
<input type="text" id="detail_eng" class="ti-form-input h-16" [(ngModel)]="bu7.edesc">
......@@ -223,10 +236,12 @@
data-hs-overlay="#sub-department-four-modal-add">
ย้อนกลับ
</button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#sub-department-four-alert-add-modal">
<button type="button" class="ti-btn ti-btn-success"
data-hs-overlay="#sub-department-four-alert-add-modal"
[class.ti-btn-disabled]="!bu6.bu6id||!bu7.bu7id||!bu7.tdesc"
[disabled]="!bu6.bu6id||!bu7.bu7id||!bu7.tdesc">
บันทึกข้อมูล
</a>
</button>
</div>
</div>
</div>
......@@ -277,17 +292,20 @@
</div>
</div>
<div class="ti-modal-body">
<label for="hs-trailing-button-add-on-with-icon"
class="ti-form-label">อยู่ภายใต้หน่วยงาน</label>
<label for="hs-trailing-button-add-on-with-icon" class="ti-form-label">อยู่ภายใต้หน่วยงาน*</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" 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">
<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)]="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">
<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>
......@@ -297,14 +315,14 @@
readonly [value]="bu6.tdesc">
</div>
</div>
<label for="input-label" class="ti-form-label mt-2rem">ส่วนย่อย4</label>
<label for="input-label" class="ti-form-label mt-2rem">ส่วนย่อย4*</label>
<div class="sm:grid grid-cols-2 gap-1">
<div class="relative w-full">
<input type="text" id="input-label" class="ti-form-input w-full pr-10 bg-input-readonly"
readonly [value]="bu7.bu7id">
</div>
</div>
<label for="detail_th" class="ti-form-label mt-2rem">รายละเอียด (ไทย)</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)]="bu7.tdesc">
<label for="detail_eng" class="ti-form-label mt-2rem">รายละเอียด (อังกฤษ)</label>
<input type="text" id="detail_eng" class="ti-form-input h-16" [(ngModel)]="bu7.edesc">
......@@ -314,10 +332,12 @@
data-hs-overlay="#sub-department-four-modal-edit">
ย้อนกลับ
</button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#sub-department-four-alert-edit-modal">
<button type="button" class="ti-btn ti-btn-success"
data-hs-overlay="#sub-department-four-alert-edit-modal"
[class.ti-btn-disabled]="!bu6.bu6id||!bu7.bu7id||!bu7.tdesc"
[disabled]="!bu6.bu6id||!bu7.bu7id||!bu7.tdesc">
บันทึกข้อมูล
</a>
</button>
</div>
</div>
</div>
......@@ -563,7 +583,7 @@
</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-add-modal">
data-hs-overlay="#sub-department-four-modal-add">
<span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i>
</button>
......@@ -575,16 +595,11 @@
</p>
<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="#sub-department-four-modal-add">
ย้อนกลับ
</button>
<button type="button" *ngIf="currentModal=='edit'"
class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
data-hs-overlay="#sub-department-four-modal-edit">
ย้อนกลับ
</button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#sub-department-four-alert-add-modal" (click)="addBu7();">
บันทึกข้อมูล
......@@ -604,7 +619,7 @@
</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-edit-modal">
data-hs-overlay="#sub-department-four-modal-edit">
<span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i>
</button>
......@@ -616,12 +631,7 @@
</p>
<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="#sub-department-four-modal-add">
ย้อนกลับ
</button>
<button type="button" *ngIf="currentModal=='edit'"
<button type="button"
class="hs-dropdown-toggle ti-btn ti-border font-medium bg-white text-gray-700 shadow-sm align-middle hover:bg-gray-50 focus:ring-offset-white focus:ring-primary dark:bg-bgdark dark:hover:bg-black/20 dark:border-white/10 dark:text-white/70 dark:hover:text-white dark:focus:ring-offset-white/10"
data-hs-overlay="#sub-department-four-modal-edit">
ย้อนกลับ
......@@ -683,7 +693,7 @@
<h1 class="mt-2" style="text-align: center;">ไฟล์</h1>
<div class="mt-2 p-2">
<div class="flex rounded-md">
<input #fileInput type="file" (change)="onFileSelected($event)" hidden>
<input #fileInput id="fileInput" type="file" (change)="onFileSelected($event)" hidden>
<input type="text" [value]="selectedFileName" readonly (click)="fileInput.click()"
class="ti-form-input rounded-none ltr:rounded-l-md rtl:rounded-r-md focus:z-10 cursor-pointer">
<button type="button" (click)="fileInput.click()"
......@@ -693,6 +703,7 @@
</div>
<div class="flex justify-center mt-2rem mb-1rem space-x-4">
<button type="submit" class="ti-btn ti-btn-secondary" (click)="uploadFile()"
data-hs-overlay="#sub-department-four-upload-modal" [class.ti-btn-disabled]="!selectedFile"
[disabled]="!selectedFile">
อัปโหลด
</button>
......
......@@ -19,7 +19,7 @@ interface table {
export class SubDepartmentFourComponent implements OnInit {
bu7List: Bu7Model[] = []
bu7ListLoading = false
bu7: Bu7Model = new MyBu7Model({})
bu7: Bu7Model = new MyBu7Model()
bu7Table: table = {
currentPage: 1,
page: Array.from({ length: 1 }, (_, i) => i + 1),
......@@ -35,13 +35,13 @@ export class SubDepartmentFourComponent implements OnInit {
search: ""
}
bu6List: Bu6Model[] = []
bu6: Bu6Model = new MyBu6Model({})
bu6: Bu6Model = new MyBu6Model()
bu6Modal: table = {
currentPage: 1,
page: Array.from({ length: 1 }, (_, i) => i + 1),
search: ""
}
currentModal = ""
currentModal: 'add' | 'edit' | 'delete' = "add"
constructor(private bu7Service: Bu7Service,
private bu6Service: Bu6Service,
private toastr: ToastrService,
......@@ -65,6 +65,7 @@ export class SubDepartmentFourComponent implements OnInit {
}
const formData = new FormData();
formData.append('file', this.selectedFile);
this.bu7ListLoading = true
this.fileService.upload(formData, 'mbu7').subscribe({
next: response => {
if (response.success) {
......@@ -72,9 +73,11 @@ export class SubDepartmentFourComponent implements OnInit {
this.getBu7List()
} else {
this.showAlert(response.message, 'error')
this.bu7ListLoading = false
}
}, error: error => {
this.showAlert(error.message, 'error')
this.bu7ListLoading = false
}
})
}
......@@ -102,7 +105,7 @@ export class SubDepartmentFourComponent implements OnInit {
this.bu7ListLoading = true
this.bu7Service.getList().subscribe({
next: response => {
this.bu7List = response
this.bu7List = response.map(x => new MyBu7Model(x))
this.bu7ListLoading = false
this.onBu7TableSearchChange()
this.cdr.detectChanges()
......@@ -145,6 +148,7 @@ export class SubDepartmentFourComponent implements OnInit {
x.edesc.toLowerCase().includes(this.bu7Modal.search.toLowerCase()))
}
addBu7() {
this.bu7ListLoading = true
this.bu7Service.post({ ...this.bu7, parent: this.bu6.bu6id }).subscribe({
next: response => {
if (response.success) {
......@@ -152,13 +156,16 @@ export class SubDepartmentFourComponent implements OnInit {
this.getBu7List()
} else {
this.showAlert(response.message, 'error')
this.bu7ListLoading = false
}
}, error: error => {
this.showAlert(error.message, 'error')
this.bu7ListLoading = false
}
})
}
deleteBu7() {
this.bu7ListLoading = true
this.bu7Service.delete(this.bu7).subscribe({
next: response => {
if (response.success) {
......@@ -166,16 +173,18 @@ export class SubDepartmentFourComponent implements OnInit {
this.getBu7List()
} else {
this.showAlert(response.message, 'error')
this.bu7ListLoading = false
}
}, error: error => {
this.showAlert(error.message, 'error')
this.bu7ListLoading = false
}
})
}
getBu6List() {
this.bu6Service.getList().subscribe(response => {
this.bu6List = response
this.bu6List = response.map(x => new MyBu6Model(x))
this.onBu6ModalSearchChange()
})
}
......
......@@ -104,7 +104,7 @@ export class SubDepartmentOneComponent implements OnInit {
this.bu4ListLoading = true
this.bu4Service.getList().subscribe({
next: response => {
this.bu4List = response
this.bu4List = response.map(x => new MyBu4Model(x))
this.bu4ListLoading = false
this.onBu4TableSearchChange()
this.cdr.detectChanges()
......@@ -183,7 +183,7 @@ export class SubDepartmentOneComponent implements OnInit {
getBu3List() {
this.bu3Service.getList().subscribe(response => {
this.bu3List = response
this.bu3List = response.map(x => new MyBu3Model(x))
this.onBu3ModalSearchChange()
})
}
......
......@@ -105,7 +105,7 @@ export class SubDepartmentThreeComponent implements OnInit {
this.bu6ListLoading = true
this.bu6Service.getList().subscribe({
next: response => {
this.bu6List = response
this.bu6List = response.map(x => new MyBu6Model(x))
this.bu6ListLoading = false
this.onBu6TableSearchChange()
this.cdr.detectChanges()
......@@ -184,7 +184,7 @@ export class SubDepartmentThreeComponent implements OnInit {
getBu5List() {
this.bu5Service.getList().subscribe(response => {
this.bu5List = response
this.bu5List = response.map(x => new MyBu5Model(x))
this.onBu5ModalSearchChange()
})
}
......
......@@ -104,7 +104,7 @@ export class SubDepartmentTwoComponent implements OnInit {
this.bu5ListLoading = true
this.bu5Service.getList().subscribe({
next: response => {
this.bu5List = response
this.bu5List = response.map(x => new MyBu5Model(x))
this.bu5ListLoading = false
this.onBu5TableSearchChange()
this.cdr.detectChanges()
......@@ -183,7 +183,7 @@ export class SubDepartmentTwoComponent implements OnInit {
getBu4List() {
this.bu4Service.getList().subscribe(response => {
this.bu4List = response
this.bu4List = response.map(x => new MyBu4Model(x))
this.onBu4ModalSearchChange()
})
}
......
......@@ -13,12 +13,12 @@ export class MyBu7Model implements Bu7Model {
edesc: string;
parent: string;
companyId: string;
constructor(data: Partial<Bu7Model>) {
this.bu7id = data.bu7id || ""
this.tdesc = data.tdesc || ""
this.edesc = data.edesc || ""
this.parent = data.parent || ""
this.companyId = data.companyId || ""
constructor(data?: Partial<Bu7Model>) {
this.bu7id = data?.bu7id || ""
this.tdesc = data?.tdesc || ""
this.edesc = data?.edesc || ""
this.parent = data?.parent || ""
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