Commit 9d97a7d6 by Nattana Chaiyamat

ส่วนย่อย2

parent 8dc83645
......@@ -35,7 +35,7 @@ export class SubDepartmentThreeComponent implements OnInit {
search: ""
}
bu5List: Bu5Model[] = []
bu5: Bu5Model = new MyBu5Model({})
bu5: Bu5Model = new MyBu5Model()
bu5Modal: table = {
currentPage: 1,
page: Array.from({ length: 1 }, (_, i) => i + 1),
......
......@@ -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-two-upload-modal">
data-hs-overlay="#sub-department-two-upload-modal"
(click)="fileInput.value = '';selectedFile=null;selectedFileName = 'กรุณาเลือกไฟล์'">
<i class="ri-add-line"></i>
นำเข้าข้อมูล
</button>
......@@ -95,7 +96,8 @@
<i class="ti ti-edit cursor-pointer i-gray fs-l px-1"
(click)="selectBu5(item);currentModal='edit'"
data-hs-overlay="#sub-department-two-modal-edit"></i>
<i class="ti ti-trash cursor-pointer i-gray fs-l px-1" (click)="selectBu5(item)"
<i class="ti ti-trash cursor-pointer i-gray fs-l px-1"
(click)="currentModal='delete';selectBu5(item)"
data-hs-overlay="#sub-department-two-alert-delete-modal"></i>
</td>
</tr>
......@@ -183,7 +185,7 @@
</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"
......@@ -206,9 +208,10 @@
readonly [value]="bu4.tdesc">
</div>
</div>
<label class="ti-form-label mt-2rem">ส่วนย่อย2</label>
<label class="ti-form-label mt-2rem">ส่วนย่อย2*</label>
<div class="relative flex rounded-md w-1/2">
<input type="text" id="hs-leading-button-add-on-with-icon-and-button"
<input type="text" class="ti-form-input h-16" [(ngModel)]="bu5.bu5id">
<!-- <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)]="bu5.bu5id" (ngModelChange)="bu5idChange()">
......@@ -221,9 +224,9 @@
data-hs-overlay="#sub-department-two-bu5-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)]="bu5.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)]="bu5.edesc">
......@@ -233,10 +236,12 @@
data-hs-overlay="#sub-department-two-modal-add">
ย้อนกลับ
</button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#sub-department-two-alert-add-modal">
<button class="ti-btn ti-btn-success" type="button"
data-hs-overlay="#sub-department-two-alert-add-modal"
[class.ti-btn-disabled]="!bu4.bu4id||!bu5.bu5id||!bu5.tdesc"
[disabled]="!bu4.bu4id||!bu5.bu5id||!bu5.tdesc">
บันทึกข้อมูล
</a>
</button>
</div>
</div>
</div>
......@@ -287,7 +292,7 @@
</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"
......@@ -310,14 +315,14 @@
readonly [value]="bu4.tdesc">
</div>
</div>
<label for="input-label" class="ti-form-label mt-2rem">ส่วนย่อย2</label>
<label for="input-label" class="ti-form-label mt-2rem">ส่วนย่อย2*</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]="bu5.bu5id">
</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)]="bu5.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)]="bu5.edesc">
......@@ -327,10 +332,12 @@
data-hs-overlay="#sub-department-two-modal-edit">
ย้อนกลับ
</button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#sub-department-two-alert-edit-modal">
<button class="ti-btn ti-btn-success" type="button"
data-hs-overlay="#sub-department-two-alert-edit-modal"
[class.ti-btn-disabled]="!bu4.bu4id||!bu5.bu5id||!bu5.tdesc"
[disabled]="!bu4.bu4id||!bu5.bu5id||!bu5.tdesc">
บันทึกข้อมูล
</a>
</button>
</div>
</div>
</div>
......@@ -574,7 +581,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-two-alert-add-modal">
data-hs-overlay="#sub-department-two-modal-add">
<span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i>
</button>
......@@ -586,16 +593,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-two-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-two-modal-edit">
ย้อนกลับ
</button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#sub-department-two-alert-add-modal" (click)="addBu5()">
บันทึกข้อมูล
......@@ -615,7 +617,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-two-alert-edit-modal">
data-hs-overlay="#sub-department-two-modal-edit">
<span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i>
</button>
......@@ -625,14 +627,8 @@
<p class="mt-1 text-gray-800 dark:text-white/70">
ยืนยันการแก้ไขข้อมูลหรือไม่
</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-two-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-two-modal-edit">
ย้อนกลับ
......@@ -694,7 +690,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()"
......@@ -704,6 +700,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-two-upload-modal" [class.ti-btn-disabled]="!selectedFile"
[disabled]="!selectedFile">
อัปโหลด
</button>
......
......@@ -18,7 +18,7 @@ interface table {
export class SubDepartmentTwoComponent implements OnInit {
bu5List: Bu5Model[] = []
bu5ListLoading = false
bu5: Bu5Model = new MyBu5Model({})
bu5: Bu5Model = new MyBu5Model()
bu5Table: table = {
currentPage: 1,
page: Array.from({ length: 1 }, (_, i) => i + 1),
......@@ -40,7 +40,7 @@ export class SubDepartmentTwoComponent implements OnInit {
page: Array.from({ length: 1 }, (_, i) => i + 1),
search: ""
}
currentModal = ""
currentModal: 'add' | 'edit' | 'delete' = "add"
constructor(private bu5Service: Bu5Service,
private bu4Service: Bu4Service,
private toastr: ToastrService,
......@@ -64,6 +64,7 @@ export class SubDepartmentTwoComponent implements OnInit {
}
const formData = new FormData();
formData.append('file', this.selectedFile);
this.bu5ListLoading = true
this.fileService.upload(formData, 'mbu5').subscribe({
next: response => {
if (response.success) {
......@@ -71,9 +72,11 @@ export class SubDepartmentTwoComponent implements OnInit {
this.getBu5List()
} else {
this.showAlert(response.message, 'error')
this.bu5ListLoading = false
}
}, error: error => {
this.showAlert(error.message, 'error')
this.bu5ListLoading = false
}
})
}
......@@ -117,8 +120,8 @@ export class SubDepartmentTwoComponent implements OnInit {
}
filterBu5Table() {
return this.bu5List.filter(x => x.bu5id.toLowerCase().includes(this.bu5Table.search.toLowerCase()) ||
x.tdesc.toLowerCase().includes(this.bu5Table.search.toLowerCase()) ||
x.edesc.toLowerCase().includes(this.bu5Table.search.toLowerCase()))
x.tdesc.toLowerCase().includes(this.bu5Table.search.toLowerCase()) ||
x.edesc.toLowerCase().includes(this.bu5Table.search.toLowerCase()))
}
selectBu5(bu5?: Bu5Model) {
this.bu5 = new MyBu5Model(bu5 || {})
......@@ -140,10 +143,11 @@ export class SubDepartmentTwoComponent implements OnInit {
}
filterBu5Modal() {
return this.bu5List.filter(x => x.bu5id.toLowerCase().includes(this.bu5Modal.search.toLowerCase()) ||
x.tdesc.toLowerCase().includes(this.bu5Modal.search.toLowerCase()) ||
x.edesc.toLowerCase().includes(this.bu5Modal.search.toLowerCase()))
x.tdesc.toLowerCase().includes(this.bu5Modal.search.toLowerCase()) ||
x.edesc.toLowerCase().includes(this.bu5Modal.search.toLowerCase()))
}
addBu5() {
this.bu5ListLoading = true
this.bu5Service.post({ ...this.bu5, parent: this.bu4.bu4id }).subscribe({
next: response => {
if (response.success) {
......@@ -151,13 +155,16 @@ export class SubDepartmentTwoComponent implements OnInit {
this.getBu5List()
} else {
this.showAlert(response.message, 'error')
this.bu5ListLoading = false
}
}, error: error => {
this.showAlert(error.message, 'error')
this.bu5ListLoading = false
}
})
}
deleteBu5() {
this.bu5ListLoading = true
this.bu5Service.delete(this.bu5).subscribe({
next: response => {
if (response.success) {
......@@ -165,9 +172,11 @@ export class SubDepartmentTwoComponent implements OnInit {
this.getBu5List()
} else {
this.showAlert(response.message, 'error')
this.bu5ListLoading = false
}
}, error: error => {
this.showAlert(error.message, 'error')
this.bu5ListLoading = false
}
})
}
......@@ -188,8 +197,8 @@ export class SubDepartmentTwoComponent implements OnInit {
}
filterBu4Modal() {
return this.bu4List.filter(x => x.bu4id.toLowerCase().includes(this.bu4Modal.search.toLowerCase()) ||
x.tdesc.toLowerCase().includes(this.bu4Modal.search.toLowerCase()) ||
x.edesc.toLowerCase().includes(this.bu4Modal.search.toLowerCase()))
x.tdesc.toLowerCase().includes(this.bu4Modal.search.toLowerCase()) ||
x.edesc.toLowerCase().includes(this.bu4Modal.search.toLowerCase()))
}
selectBu4(bu4?: Bu4Model) {
this.bu4 = new MyBu4Model(bu4 || {})
......
......@@ -13,12 +13,12 @@ export class MyBu5Model implements Bu5Model {
edesc: string;
parent: string;
companyId: string;
constructor(data: Partial<Bu5Model>) {
this.bu5id = data.bu5id || ""
this.tdesc = data.tdesc || ""
this.edesc = data.edesc || ""
this.parent = data.parent || ""
this.companyId = data.companyId || ""
constructor(data?: Partial<Bu5Model>) {
this.bu5id = data?.bu5id || ""
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