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