Commit 8cbf148f by Nattana Chaiyamat

ส่วนย่อย4

parent 39c6ff1f
...@@ -104,7 +104,7 @@ export class DepartmentListComponent implements OnInit { ...@@ -104,7 +104,7 @@ export class DepartmentListComponent implements OnInit {
this.bu2ListLoading = true this.bu2ListLoading = true
this.bu2Service.getList().subscribe({ this.bu2Service.getList().subscribe({
next: response => { next: response => {
this.bu2List = response this.bu2List = response.map(x => new MyBu2Model(x))
this.bu2ListLoading = false this.bu2ListLoading = false
this.onBu2TableSearchChange() this.onBu2TableSearchChange()
this.cdr.detectChanges() this.cdr.detectChanges()
...@@ -150,7 +150,7 @@ export class DepartmentListComponent implements OnInit { ...@@ -150,7 +150,7 @@ export class DepartmentListComponent implements OnInit {
getBu1List() { getBu1List() {
this.bu1Service.getList().subscribe(response => { this.bu1Service.getList().subscribe(response => {
this.bu1List = response this.bu1List = response.map(x => new MyBu1Model(x))
this.onBu1ModalSearchChange() this.onBu1ModalSearchChange()
}) })
} }
......
...@@ -82,7 +82,7 @@ export class DepartmentRegisterComponent implements OnInit { ...@@ -82,7 +82,7 @@ export class DepartmentRegisterComponent implements OnInit {
this.bu1ListLoading = true this.bu1ListLoading = true
this.bu1Service.getList().subscribe({ this.bu1Service.getList().subscribe({
next: response => { next: response => {
this.bu1List = response this.bu1List = response.map(x => new MyBu1Model(x))
this.bu1ListLoading = false this.bu1ListLoading = false
this.searchChange() this.searchChange()
this.cdr.detectChanges() this.cdr.detectChanges()
......
...@@ -105,7 +105,7 @@ export class SectionRegistrationComponent implements OnInit { ...@@ -105,7 +105,7 @@ export class SectionRegistrationComponent implements OnInit {
this.bu3ListLoading = true this.bu3ListLoading = true
this.bu3Service.getList().subscribe({ this.bu3Service.getList().subscribe({
next: response => { next: response => {
this.bu3List = response this.bu3List = response.map(x => new MyBu3Model(x))
this.bu3ListLoading = false this.bu3ListLoading = false
this.onBu3TableSearchChange() this.onBu3TableSearchChange()
this.cdr.detectChanges() this.cdr.detectChanges()
...@@ -184,7 +184,7 @@ export class SectionRegistrationComponent implements OnInit { ...@@ -184,7 +184,7 @@ export class SectionRegistrationComponent implements OnInit {
getBu2List() { getBu2List() {
this.bu2Service.getList().subscribe(response => { this.bu2Service.getList().subscribe(response => {
this.bu2List = response this.bu2List = response.map(x => new MyBu2Model(x))
this.onBu2ModalSearchChange() this.onBu2ModalSearchChange()
}) })
} }
......
...@@ -19,7 +19,7 @@ interface table { ...@@ -19,7 +19,7 @@ interface table {
export class SubDepartmentFourComponent implements OnInit { export class SubDepartmentFourComponent implements OnInit {
bu7List: Bu7Model[] = [] bu7List: Bu7Model[] = []
bu7ListLoading = false bu7ListLoading = false
bu7: Bu7Model = new MyBu7Model({}) bu7: Bu7Model = new MyBu7Model()
bu7Table: table = { bu7Table: table = {
currentPage: 1, currentPage: 1,
page: Array.from({ length: 1 }, (_, i) => i + 1), page: Array.from({ length: 1 }, (_, i) => i + 1),
...@@ -35,13 +35,13 @@ export class SubDepartmentFourComponent implements OnInit { ...@@ -35,13 +35,13 @@ export class SubDepartmentFourComponent implements OnInit {
search: "" search: ""
} }
bu6List: Bu6Model[] = [] bu6List: Bu6Model[] = []
bu6: Bu6Model = new MyBu6Model({}) bu6: Bu6Model = new MyBu6Model()
bu6Modal: table = { bu6Modal: table = {
currentPage: 1, currentPage: 1,
page: Array.from({ length: 1 }, (_, i) => i + 1), page: Array.from({ length: 1 }, (_, i) => i + 1),
search: "" search: ""
} }
currentModal = "" currentModal: 'add' | 'edit' | 'delete' = "add"
constructor(private bu7Service: Bu7Service, constructor(private bu7Service: Bu7Service,
private bu6Service: Bu6Service, private bu6Service: Bu6Service,
private toastr: ToastrService, private toastr: ToastrService,
...@@ -65,6 +65,7 @@ export class SubDepartmentFourComponent implements OnInit { ...@@ -65,6 +65,7 @@ export class SubDepartmentFourComponent implements OnInit {
} }
const formData = new FormData(); const formData = new FormData();
formData.append('file', this.selectedFile); formData.append('file', this.selectedFile);
this.bu7ListLoading = true
this.fileService.upload(formData, 'mbu7').subscribe({ this.fileService.upload(formData, 'mbu7').subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
...@@ -72,9 +73,11 @@ export class SubDepartmentFourComponent implements OnInit { ...@@ -72,9 +73,11 @@ export class SubDepartmentFourComponent implements OnInit {
this.getBu7List() this.getBu7List()
} else { } else {
this.showAlert(response.message, 'error') this.showAlert(response.message, 'error')
this.bu7ListLoading = false
} }
}, error: error => { }, error: error => {
this.showAlert(error.message, 'error') this.showAlert(error.message, 'error')
this.bu7ListLoading = false
} }
}) })
} }
...@@ -102,7 +105,7 @@ export class SubDepartmentFourComponent implements OnInit { ...@@ -102,7 +105,7 @@ export class SubDepartmentFourComponent implements OnInit {
this.bu7ListLoading = true this.bu7ListLoading = true
this.bu7Service.getList().subscribe({ this.bu7Service.getList().subscribe({
next: response => { next: response => {
this.bu7List = response this.bu7List = response.map(x => new MyBu7Model(x))
this.bu7ListLoading = false this.bu7ListLoading = false
this.onBu7TableSearchChange() this.onBu7TableSearchChange()
this.cdr.detectChanges() this.cdr.detectChanges()
...@@ -118,8 +121,8 @@ export class SubDepartmentFourComponent implements OnInit { ...@@ -118,8 +121,8 @@ export class SubDepartmentFourComponent implements OnInit {
} }
filterBu7Table() { filterBu7Table() {
return this.bu7List.filter(x => x.bu7id.toLowerCase().includes(this.bu7Table.search.toLowerCase()) || return this.bu7List.filter(x => x.bu7id.toLowerCase().includes(this.bu7Table.search.toLowerCase()) ||
x.tdesc.toLowerCase().includes(this.bu7Table.search.toLowerCase()) || x.tdesc.toLowerCase().includes(this.bu7Table.search.toLowerCase()) ||
x.edesc.toLowerCase().includes(this.bu7Table.search.toLowerCase())) x.edesc.toLowerCase().includes(this.bu7Table.search.toLowerCase()))
} }
selectBu7(bu7?: Bu7Model) { selectBu7(bu7?: Bu7Model) {
this.bu7 = new MyBu7Model(bu7 || {}) this.bu7 = new MyBu7Model(bu7 || {})
...@@ -141,10 +144,11 @@ export class SubDepartmentFourComponent implements OnInit { ...@@ -141,10 +144,11 @@ export class SubDepartmentFourComponent implements OnInit {
} }
filterBu7Modal() { filterBu7Modal() {
return this.bu7List.filter(x => x.bu7id.toLowerCase().includes(this.bu7Modal.search.toLowerCase()) || return this.bu7List.filter(x => x.bu7id.toLowerCase().includes(this.bu7Modal.search.toLowerCase()) ||
x.tdesc.toLowerCase().includes(this.bu7Modal.search.toLowerCase()) || x.tdesc.toLowerCase().includes(this.bu7Modal.search.toLowerCase()) ||
x.edesc.toLowerCase().includes(this.bu7Modal.search.toLowerCase())) x.edesc.toLowerCase().includes(this.bu7Modal.search.toLowerCase()))
} }
addBu7() { addBu7() {
this.bu7ListLoading = true
this.bu7Service.post({ ...this.bu7, parent: this.bu6.bu6id }).subscribe({ this.bu7Service.post({ ...this.bu7, parent: this.bu6.bu6id }).subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
...@@ -152,13 +156,16 @@ export class SubDepartmentFourComponent implements OnInit { ...@@ -152,13 +156,16 @@ export class SubDepartmentFourComponent implements OnInit {
this.getBu7List() this.getBu7List()
} else { } else {
this.showAlert(response.message, 'error') this.showAlert(response.message, 'error')
this.bu7ListLoading = false
} }
}, error: error => { }, error: error => {
this.showAlert(error.message, 'error') this.showAlert(error.message, 'error')
this.bu7ListLoading = false
} }
}) })
} }
deleteBu7() { deleteBu7() {
this.bu7ListLoading = true
this.bu7Service.delete(this.bu7).subscribe({ this.bu7Service.delete(this.bu7).subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
...@@ -166,16 +173,18 @@ export class SubDepartmentFourComponent implements OnInit { ...@@ -166,16 +173,18 @@ export class SubDepartmentFourComponent implements OnInit {
this.getBu7List() this.getBu7List()
} else { } else {
this.showAlert(response.message, 'error') this.showAlert(response.message, 'error')
this.bu7ListLoading = false
} }
}, error: error => { }, error: error => {
this.showAlert(error.message, 'error') this.showAlert(error.message, 'error')
this.bu7ListLoading = false
} }
}) })
} }
getBu6List() { getBu6List() {
this.bu6Service.getList().subscribe(response => { this.bu6Service.getList().subscribe(response => {
this.bu6List = response this.bu6List = response.map(x => new MyBu6Model(x))
this.onBu6ModalSearchChange() this.onBu6ModalSearchChange()
}) })
} }
...@@ -189,8 +198,8 @@ export class SubDepartmentFourComponent implements OnInit { ...@@ -189,8 +198,8 @@ export class SubDepartmentFourComponent implements OnInit {
} }
filterBu6Modal() { filterBu6Modal() {
return this.bu6List.filter(x => x.bu6id.toLowerCase().includes(this.bu6Modal.search.toLowerCase()) || return this.bu6List.filter(x => x.bu6id.toLowerCase().includes(this.bu6Modal.search.toLowerCase()) ||
x.tdesc.toLowerCase().includes(this.bu6Modal.search.toLowerCase()) || x.tdesc.toLowerCase().includes(this.bu6Modal.search.toLowerCase()) ||
x.edesc.toLowerCase().includes(this.bu6Modal.search.toLowerCase())) x.edesc.toLowerCase().includes(this.bu6Modal.search.toLowerCase()))
} }
selectBu6(bu6?: Bu6Model) { selectBu6(bu6?: Bu6Model) {
this.bu6 = new MyBu6Model(bu6 || {}) this.bu6 = new MyBu6Model(bu6 || {})
......
...@@ -104,7 +104,7 @@ export class SubDepartmentOneComponent implements OnInit { ...@@ -104,7 +104,7 @@ export class SubDepartmentOneComponent implements OnInit {
this.bu4ListLoading = true this.bu4ListLoading = true
this.bu4Service.getList().subscribe({ this.bu4Service.getList().subscribe({
next: response => { next: response => {
this.bu4List = response this.bu4List = response.map(x => new MyBu4Model(x))
this.bu4ListLoading = false this.bu4ListLoading = false
this.onBu4TableSearchChange() this.onBu4TableSearchChange()
this.cdr.detectChanges() this.cdr.detectChanges()
...@@ -183,7 +183,7 @@ export class SubDepartmentOneComponent implements OnInit { ...@@ -183,7 +183,7 @@ export class SubDepartmentOneComponent implements OnInit {
getBu3List() { getBu3List() {
this.bu3Service.getList().subscribe(response => { this.bu3Service.getList().subscribe(response => {
this.bu3List = response this.bu3List = response.map(x => new MyBu3Model(x))
this.onBu3ModalSearchChange() this.onBu3ModalSearchChange()
}) })
} }
......
...@@ -105,7 +105,7 @@ export class SubDepartmentThreeComponent implements OnInit { ...@@ -105,7 +105,7 @@ export class SubDepartmentThreeComponent implements OnInit {
this.bu6ListLoading = true this.bu6ListLoading = true
this.bu6Service.getList().subscribe({ this.bu6Service.getList().subscribe({
next: response => { next: response => {
this.bu6List = response this.bu6List = response.map(x => new MyBu6Model(x))
this.bu6ListLoading = false this.bu6ListLoading = false
this.onBu6TableSearchChange() this.onBu6TableSearchChange()
this.cdr.detectChanges() this.cdr.detectChanges()
...@@ -148,43 +148,43 @@ export class SubDepartmentThreeComponent implements OnInit { ...@@ -148,43 +148,43 @@ export class SubDepartmentThreeComponent implements OnInit {
x.edesc.toLowerCase().includes(this.bu6Modal.search.toLowerCase())) x.edesc.toLowerCase().includes(this.bu6Modal.search.toLowerCase()))
} }
addBu6() { addBu6() {
this.bu6ListLoading = true this.bu6ListLoading = true
this.bu6Service.post({ ...this.bu6, parent: this.bu5.bu5id }).subscribe({ this.bu6Service.post({ ...this.bu6, parent: this.bu5.bu5id }).subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
this.showAlert(response.message, 'success') this.showAlert(response.message, 'success')
this.getBu6List() this.getBu6List()
} else { } else {
this.showAlert(response.message, 'error') this.showAlert(response.message, 'error')
this.bu6ListLoading = false
}
}, error: error => {
this.showAlert(error.message, 'error')
this.bu6ListLoading = false this.bu6ListLoading = false
}
}, error: error => {
this.showAlert(error.message, 'error')
this.bu6ListLoading = false
} }
}) })
} }
deleteBu6() { deleteBu6() {
this.bu6ListLoading = true this.bu6ListLoading = true
this.bu6Service.delete(this.bu6).subscribe({ this.bu6Service.delete(this.bu6).subscribe({
next: response => { next: response => {
if (response.success) { if (response.success) {
this.showAlert(response.message, 'success') this.showAlert(response.message, 'success')
this.getBu6List() this.getBu6List()
} else { } else {
this.showAlert(response.message, 'error') this.showAlert(response.message, 'error')
this.bu6ListLoading = false
}
}, error: error => {
this.showAlert(error.message, 'error')
this.bu6ListLoading = false this.bu6ListLoading = false
}
}, error: error => {
this.showAlert(error.message, 'error')
this.bu6ListLoading = false
} }
}) })
} }
getBu5List() { getBu5List() {
this.bu5Service.getList().subscribe(response => { this.bu5Service.getList().subscribe(response => {
this.bu5List = response this.bu5List = response.map(x => new MyBu5Model(x))
this.onBu5ModalSearchChange() this.onBu5ModalSearchChange()
}) })
} }
......
...@@ -104,7 +104,7 @@ export class SubDepartmentTwoComponent implements OnInit { ...@@ -104,7 +104,7 @@ export class SubDepartmentTwoComponent implements OnInit {
this.bu5ListLoading = true this.bu5ListLoading = true
this.bu5Service.getList().subscribe({ this.bu5Service.getList().subscribe({
next: response => { next: response => {
this.bu5List = response this.bu5List = response.map(x => new MyBu5Model(x))
this.bu5ListLoading = false this.bu5ListLoading = false
this.onBu5TableSearchChange() this.onBu5TableSearchChange()
this.cdr.detectChanges() this.cdr.detectChanges()
...@@ -183,7 +183,7 @@ export class SubDepartmentTwoComponent implements OnInit { ...@@ -183,7 +183,7 @@ export class SubDepartmentTwoComponent implements OnInit {
getBu4List() { getBu4List() {
this.bu4Service.getList().subscribe(response => { this.bu4Service.getList().subscribe(response => {
this.bu4List = response this.bu4List = response.map(x => new MyBu4Model(x))
this.onBu4ModalSearchChange() this.onBu4ModalSearchChange()
}) })
} }
......
...@@ -13,12 +13,12 @@ export class MyBu7Model implements Bu7Model { ...@@ -13,12 +13,12 @@ export class MyBu7Model implements Bu7Model {
edesc: string; edesc: string;
parent: string; parent: string;
companyId: string; companyId: string;
constructor(data: Partial<Bu7Model>) { constructor(data?: Partial<Bu7Model>) {
this.bu7id = data.bu7id || "" this.bu7id = data?.bu7id || ""
this.tdesc = data.tdesc || "" this.tdesc = data?.tdesc || ""
this.edesc = data.edesc || "" this.edesc = data?.edesc || ""
this.parent = data.parent || "" this.parent = data?.parent || ""
this.companyId = data.companyId || "" 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