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>
......
......@@ -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