Commit a50525e9 by Nattana Chaiyamat

ทะเบียนส่วนย่อย1

parent fde0c870
......@@ -4,7 +4,8 @@
<!-- Content ของ div แรก -->
<div class="px-1">
<button type="button" class="ti-btn ti-btn-soft-secondary h-20px m-0 shadow-md"
data-hs-overlay="#department-list-upload-modal" (click)="selectedFile=null;selectedFileName = 'กรุณาเลือกไฟล์'">
data-hs-overlay="#department-list-upload-modal"
(click)="fileInput.value = '';selectedFile=null;selectedFileName = 'กรุณาเลือกไฟล์'">
<i class="ri-add-line"></i>
นำเข้าข้อมูล
</button>
......
......@@ -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="#department-register-upload-modal" (click)="selectedFile=null;selectedFileName = 'กรุณาเลือกไฟล์'">
data-hs-overlay="#department-register-upload-modal"
(click)="fileInput.value = '';selectedFile=null;selectedFileName = 'กรุณาเลือกไฟล์'">
<i class="ri-add-line"></i>
นำเข้าข้อมูล
</button>
......
......@@ -3,7 +3,7 @@
<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="#section-registration-upload-modal" (click)="selectedFile=null;selectedFileName = 'กรุณาเลือกไฟล์'">
data-hs-overlay="#section-registration-upload-modal" (click)="fileInput.value = '';selectedFile=null;selectedFileName = 'กรุณาเลือกไฟล์'">
<i class="ri-add-line"></i>
นำเข้าข้อมูล
</button>
......
......@@ -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-one-upload-modal">
data-hs-overlay="#sub-department-one-upload-modal"
(click)="fileInput.value = '';selectedFile=null;selectedFileName = 'กรุณาเลือกไฟล์'">
<i class="ri-add-line"></i>
นำเข้าข้อมูล
</button>
......@@ -96,7 +97,8 @@
<i class="ti ti-edit cursor-pointer i-gray fs-l px-1"
(click)="selectBu4(item);currentModal='edit'"
data-hs-overlay="#sub-department-one-modal-edit"></i>
<i class="ti ti-trash cursor-pointer i-gray fs-l px-1" (click)="selectBu4(item)"
<i class="ti ti-trash cursor-pointer i-gray fs-l px-1"
(click)="currentModal='delete';selectBu4(item)"
data-hs-overlay="#sub-department-one-alert-delete-modal"></i>
</td>
</tr>
......@@ -185,7 +187,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"
......@@ -208,9 +210,10 @@
readonly [value]="bu3.tdesc">
</div>
</div>
<label class="ti-form-label mt-2rem">ส่วนย่อย1</label>
<label class="ti-form-label mt-2rem">ส่วนย่อย1*</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)]="bu4.bu4id">
<!-- <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)]="bu4.bu4id" (ngModelChange)="bu4idChange()">
......@@ -223,9 +226,9 @@
data-hs-overlay="#sub-department-one-bu4-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)]="bu4.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)]="bu4.edesc">
......@@ -235,10 +238,12 @@
data-hs-overlay="#sub-department-one-modal-add">
ย้อนกลับ
</button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#sub-department-one-alert-modal">
<button class="ti-btn ti-btn-success" type="button"
data-hs-overlay="#sub-department-one-alert-modal"
[class.ti-btn-disabled]="!bu3.bu3id||!bu4.bu4id||!bu4.tdesc"
[disabled]="!bu3.bu3id||!bu4.bu4id||!bu4.tdesc">
บันทึกข้อมูล
</a>
</button>
</div>
</div>
</div>
......@@ -289,7 +294,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"
......@@ -312,14 +317,14 @@
readonly [value]="bu3.tdesc">
</div>
</div>
<label for="input-label" class="ti-form-label mt-2rem">ส่วนย่อย1</label>
<label for="input-label" class="ti-form-label mt-2rem">ส่วนย่อย1*</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]="bu4.bu4id">
</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)]="bu4.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)]="bu4.edesc">
......@@ -329,10 +334,12 @@
data-hs-overlay="#sub-department-one-modal-edit">
ย้อนกลับ
</button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#sub-department-one-alert-edit-modal">
<button class="ti-btn ti-btn-success" type="button"
data-hs-overlay="#sub-department-one-alert-edit-modal"
[class.ti-btn-disabled]="!bu3.bu3id||!bu4.bu4id||!bu4.tdesc"
[disabled]="!bu3.bu3id||!bu4.bu4id||!bu4.tdesc">
บันทึกข้อมูล
</a>
</button>
</div>
</div>
</div>
......@@ -578,7 +585,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-one-alert-modal">
data-hs-overlay="#sub-department-one-modal-add">
<span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i>
</button>
......@@ -590,16 +597,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-one-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-one-modal-edit">
ย้อนกลับ
</button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);"
data-hs-overlay="#sub-department-one-alert-modal" (click)="addBu4()">
บันทึกข้อมูล
......@@ -619,7 +621,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-one-alert-edit-modal">
data-hs-overlay="#sub-department-one-modal-edit">
<span class="sr-only">Close</span>
<i class="ti ti-circle-x fs-xxl"></i>
</button>
......@@ -672,14 +674,9 @@
</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-one-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-one-modal-edit">
data-hs-overlay="#sub-department-one-alert-delete-modal">
ย้อนกลับ
</button>
<a class="ti-btn ti-btn-success" href="javascript:void(0);"
......@@ -713,6 +710,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-one-upload-modal" [class.ti-btn-disabled]="!selectedFile"
[disabled]="!selectedFile">
อัปโหลด
</button>
......
......@@ -18,7 +18,7 @@ interface table {
export class SubDepartmentOneComponent implements OnInit {
bu4List: Bu4Model[] = []
bu4ListLoading = false
bu4: Bu4Model = new MyBu4Model({})
bu4: Bu4Model = new MyBu4Model()
bu4Table: table = {
currentPage: 1,
page: Array.from({ length: 1 }, (_, i) => i + 1),
......@@ -40,7 +40,7 @@ export class SubDepartmentOneComponent implements OnInit {
page: Array.from({ length: 1 }, (_, i) => i + 1),
search: ""
}
currentModal = ""
currentModal: 'add' | 'edit' | 'delete' = "add"
constructor(private bu4Service: Bu4Service,
private bu3Service: Bu3Service,
private toastr: ToastrService,
......@@ -65,6 +65,7 @@ export class SubDepartmentOneComponent implements OnInit {
}
const formData = new FormData();
formData.append('file', this.selectedFile);
this.bu4ListLoading = true
this.fileService.upload(formData, 'mbu4').subscribe({
next: response => {
if (response.success) {
......@@ -72,9 +73,11 @@ export class SubDepartmentOneComponent implements OnInit {
this.getBu4List()
} else {
this.showAlert(response.message, 'error')
this.bu4ListLoading = false
}
}, error: error => {
this.showAlert(error.message, 'error')
this.bu4ListLoading = false
}
})
}
......@@ -117,8 +120,8 @@ export class SubDepartmentOneComponent implements OnInit {
}
filterBu4Table() {
return this.bu4List.filter(x => x.bu4id.toLowerCase().includes(this.bu4Table.search.toLowerCase()) ||
x.tdesc.toLowerCase().includes(this.bu4Table.search.toLowerCase()) ||
x.edesc.toLowerCase().includes(this.bu4Table.search.toLowerCase()))
x.tdesc.toLowerCase().includes(this.bu4Table.search.toLowerCase()) ||
x.edesc.toLowerCase().includes(this.bu4Table.search.toLowerCase()))
}
selectBu4(bu4?: Bu4Model) {
this.bu4 = new MyBu4Model(bu4 || {})
......@@ -140,10 +143,11 @@ export class SubDepartmentOneComponent 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()))
}
addBu4() {
this.bu4ListLoading = true
this.bu4Service.post({ ...this.bu4, parent: this.bu3.bu3id }).subscribe({
next: response => {
if (response.success) {
......@@ -151,13 +155,16 @@ export class SubDepartmentOneComponent implements OnInit {
this.getBu4List()
} else {
this.showAlert(response.message, 'error')
this.bu4ListLoading = false
}
}, error: error => {
this.showAlert(error.message, 'error')
this.bu4ListLoading = false
}
})
}
deleteBu4() {
this.bu4ListLoading = true
this.bu4Service.delete(this.bu4).subscribe({
next: response => {
if (response.success) {
......@@ -165,9 +172,11 @@ export class SubDepartmentOneComponent implements OnInit {
this.getBu4List()
} else {
this.showAlert(response.message, 'error')
this.bu4ListLoading = false
}
}, error: error => {
this.showAlert(error.message, 'error')
this.bu4ListLoading = false
}
})
}
......@@ -188,8 +197,8 @@ export class SubDepartmentOneComponent implements OnInit {
}
filterBu3Modal() {
return this.bu3List.filter(x => x.bu3id.toLowerCase().includes(this.bu3Modal.search.toLowerCase()) ||
x.tdesc.toLowerCase().includes(this.bu3Modal.search.toLowerCase()) ||
x.edesc.toLowerCase().includes(this.bu3Modal.search.toLowerCase()))
x.tdesc.toLowerCase().includes(this.bu3Modal.search.toLowerCase()) ||
x.edesc.toLowerCase().includes(this.bu3Modal.search.toLowerCase()))
}
selectBu3(bu3?: Bu3Model) {
this.bu3 = new MyBu3Model(bu3 || {})
......
......@@ -34,7 +34,7 @@ export class SubDepartmentTwoComponent implements OnInit {
search: ""
}
bu4List: Bu4Model[] = []
bu4: Bu4Model = new MyBu4Model({})
bu4: Bu4Model = new MyBu4Model()
bu4Modal: table = {
currentPage: 1,
page: Array.from({ length: 1 }, (_, i) => i + 1),
......
......@@ -13,12 +13,12 @@ export class MyBu4Model implements Bu4Model {
edesc: string;
parent: string;
companyId: string;
constructor(data: Partial<Bu4Model>) {
this.bu4id = data.bu4id || ""
this.tdesc = data.tdesc || ""
this.edesc = data.edesc || ""
this.parent = data.parent || ""
this.companyId = data.companyId || ""
constructor(data?: Partial<Bu4Model>) {
this.bu4id = data?.bu4id || ""
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