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()
})
}
......
......@@ -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()
......@@ -118,8 +121,8 @@ export class SubDepartmentFourComponent implements OnInit {
}
filterBu7Table() {
return this.bu7List.filter(x => x.bu7id.toLowerCase().includes(this.bu7Table.search.toLowerCase()) ||
x.tdesc.toLowerCase().includes(this.bu7Table.search.toLowerCase()) ||
x.edesc.toLowerCase().includes(this.bu7Table.search.toLowerCase()))
x.tdesc.toLowerCase().includes(this.bu7Table.search.toLowerCase()) ||
x.edesc.toLowerCase().includes(this.bu7Table.search.toLowerCase()))
}
selectBu7(bu7?: Bu7Model) {
this.bu7 = new MyBu7Model(bu7 || {})
......@@ -141,10 +144,11 @@ export class SubDepartmentFourComponent implements OnInit {
}
filterBu7Modal() {
return this.bu7List.filter(x => x.bu7id.toLowerCase().includes(this.bu7Modal.search.toLowerCase()) ||
x.tdesc.toLowerCase().includes(this.bu7Modal.search.toLowerCase()) ||
x.edesc.toLowerCase().includes(this.bu7Modal.search.toLowerCase()))
x.tdesc.toLowerCase().includes(this.bu7Modal.search.toLowerCase()) ||
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()
})
}
......@@ -189,8 +198,8 @@ export class SubDepartmentFourComponent implements OnInit {
}
filterBu6Modal() {
return this.bu6List.filter(x => x.bu6id.toLowerCase().includes(this.bu6Modal.search.toLowerCase()) ||
x.tdesc.toLowerCase().includes(this.bu6Modal.search.toLowerCase()) ||
x.edesc.toLowerCase().includes(this.bu6Modal.search.toLowerCase()))
x.tdesc.toLowerCase().includes(this.bu6Modal.search.toLowerCase()) ||
x.edesc.toLowerCase().includes(this.bu6Modal.search.toLowerCase()))
}
selectBu6(bu6?: Bu6Model) {
this.bu6 = new MyBu6Model(bu6 || {})
......
......@@ -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()
......@@ -148,43 +148,43 @@ export class SubDepartmentThreeComponent implements OnInit {
x.edesc.toLowerCase().includes(this.bu6Modal.search.toLowerCase()))
}
addBu6() {
this.bu6ListLoading = true
this.bu6Service.post({ ...this.bu6, parent: this.bu5.bu5id }).subscribe({
next: response => {
if (response.success) {
this.showAlert(response.message, 'success')
this.getBu6List()
} else {
this.showAlert(response.message, 'error')
this.bu6ListLoading = false
}
}, error: error => {
this.showAlert(error.message, 'error')
this.bu6ListLoading = true
this.bu6Service.post({ ...this.bu6, parent: this.bu5.bu5id }).subscribe({
next: response => {
if (response.success) {
this.showAlert(response.message, 'success')
this.getBu6List()
} else {
this.showAlert(response.message, 'error')
this.bu6ListLoading = false
}
}, error: error => {
this.showAlert(error.message, 'error')
this.bu6ListLoading = false
}
})
}
deleteBu6() {
this.bu6ListLoading = true
this.bu6Service.delete(this.bu6).subscribe({
next: response => {
if (response.success) {
this.showAlert(response.message, 'success')
this.getBu6List()
} else {
this.showAlert(response.message, 'error')
this.bu6ListLoading = false
}
}, error: error => {
this.showAlert(error.message, 'error')
this.bu6ListLoading = true
this.bu6Service.delete(this.bu6).subscribe({
next: response => {
if (response.success) {
this.showAlert(response.message, 'success')
this.getBu6List()
} else {
this.showAlert(response.message, 'error')
this.bu6ListLoading = false
}
}, error: error => {
this.showAlert(error.message, 'error')
this.bu6ListLoading = false
}
})
}
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