ส่วนย่อยที่1 เเละ ส่วนย่อยที่2 API

parent f98e2989
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { Bu3Model, MyBu3Model } from 'src/app/shared/model/bu3.model';
import { Bu4Model, MyBu4Model } from 'src/app/shared/model/bu4.model';
import { Bu3Service } from 'src/app/shared/services/bu3.service';
import { Bu4Service } from 'src/app/shared/services/bu4.service';
@Component({
selector: 'app-sub-department-one',
......@@ -6,43 +10,52 @@ import { Component, EventEmitter, Input, Output } from '@angular/core';
styleUrls: ['./sub-department-one.component.scss']
})
export class SubDepartmentOneComponent {
modalOptions: {
[nameModal: string]: { // ชื่อตรวจสอบการเปิดปิด
isModalOpen: boolean; // เปิด/ปิด
modalSize: string; // ขนาดของ Modal (s,m,l,vw10-vw100 )
backdropClose: boolean; // (คลิก Backdrop แล้ว true ปิด false ไม่ปิด )
}
} = {
"add": {
isModalOpen: false,
modalSize: 'm',
backdropClose: true,
},
"edit": {
isModalOpen: false,
modalSize: 'm',
backdropClose: true,
}
}
openModal(name: string, size: string, closeOnBackdrop?: boolean) {
this.modalOptions[name].modalSize = size;
this.modalOptions[name].backdropClose = closeOnBackdrop || false;
this.modalOptions[name].isModalOpen = true;
document.body.style.overflow = 'hidden'; // ล็อก Scroll
currentPage = 1
page = Array.from({ length: 1 }, (_, i) => i + 1);
bu4List: Bu4Model[] = []
bu4: Bu4Model = new MyBu4Model({})
bu3: Bu3Model = new MyBu3Model({})
search = ""
constructor(private bu4Service: Bu4Service,
private bu3Service: Bu3Service
) { }
ngOnInit(): void {
this.getBu4List()
}
closeModal(name: string) {
this.modalOptions[name].isModalOpen = false;
// ตรวจสอบว่ามี Modal อื่นเปิดอยู่หรือไม่
if (!this.isAnyModalOpen()) {
document.body.style.overflow = ''; // คืนค่าการ Scroll เฉพาะเมื่อ Modal ทั้งหมดปิดแล้ว
}
getBu4List() {
this.bu4Service.getList().subscribe(response => {
this.bu4List = response
this.searchChange()
})
}
isAnyModalOpen(): boolean {
// Logic ตรวจสอบว่า Modal อื่นยังเปิดอยู่หรือไม่
return Object.values(this.modalOptions).some(modal => modal.isModalOpen); // หากไม่มี Modal อื่นเปิด
searchChange() {
this.currentPage = 1
this.page = Array.from({ length: Math.ceil(this.bu4ListFilter().length / 10) }, (_, i) => i + 1);
}
bu4ListFilter() {
return this.bu4List.filter(x => x.bu4id.toLowerCase().includes(this.search) ||
x.tdesc.toLowerCase().includes(this.search) ||
x.edesc.toLowerCase().includes(this.search))
}
selectBu4(bu4: Bu4Model) {
this.bu3Service.getById(bu4.parent).subscribe(response => {
this.bu3 = response
})
this.bu4 = new MyBu4Model(bu4)
}
addBu4() {
// this.bu4Service.post(this.bu4).subscribe((response:any) => {
// if (response.success) {
// this.getBu4List()
// }
// })
}
deleteBu4(bu4: Bu4Model) {
// this.bu4Service.delete(new MyBu4Model(bu4)).subscribe((response:any) => {
// if (response.success) {
// this.getBu4List()
// }
// })
}
}
......
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { Component, EventEmitter, Input, OnInit } from '@angular/core';
import { Bu4Model, MyBu4Model } from 'src/app/shared/model/bu4.model';
import { Bu5Model, MyBu5Model } from 'src/app/shared/model/bu5.model';
import { Bu4Service } from 'src/app/shared/services/bu4.service';
import { Bu5Service } from 'src/app/shared/services/bu5.service';
@Component({
selector: 'app-sub-department-two',
templateUrl: './sub-department-two.component.html',
styleUrls: ['./sub-department-two.component.scss']
})
export class SubDepartmentTwoComponent {
modalOptions: {
[nameModal: string]: { // ชื่อตรวจสอบการเปิดปิด
isModalOpen: boolean; // เปิด/ปิด
modalSize: string; // ขนาดของ Modal (s,m,l,vw10-vw100 )
backdropClose: boolean; // (คลิก Backdrop แล้ว true ปิด false ไม่ปิด )
}
} = {
"add": {
isModalOpen: false,
modalSize: 'm',
backdropClose: true,
},
"edit": {
isModalOpen: false,
modalSize: 'm',
backdropClose: true,
}
}
openModal(name: string, size: string, closeOnBackdrop?: boolean) {
this.modalOptions[name].modalSize = size;
this.modalOptions[name].backdropClose = closeOnBackdrop || false;
this.modalOptions[name].isModalOpen = true;
document.body.style.overflow = 'hidden'; // ล็อก Scroll
export class SubDepartmentTwoComponent implements OnInit {
currentPage = 1
page = Array.from({ length: 1 }, (_, i) => i + 1);
bu5List: Bu5Model[] = []
bu5: Bu5Model = new MyBu5Model({})
bu4: Bu4Model = new MyBu4Model({})
search = ""
constructor(private bu5Service: Bu5Service,
private bu4Service: Bu4Service
) { }
ngOnInit(): void {
this.getBu5List()
}
closeModal(name: string) {
this.modalOptions[name].isModalOpen = false;
// ตรวจสอบว่ามี Modal อื่นเปิดอยู่หรือไม่
if (!this.isAnyModalOpen()) {
document.body.style.overflow = ''; // คืนค่าการ Scroll เฉพาะเมื่อ Modal ทั้งหมดปิดแล้ว
}
getBu5List() {
this.bu5Service.getList().subscribe(response => {
this.bu5List = response
this.searchChange()
})
}
isAnyModalOpen(): boolean {
// Logic ตรวจสอบว่า Modal อื่นยังเปิดอยู่หรือไม่
return Object.values(this.modalOptions).some(modal => modal.isModalOpen); // หากไม่มี Modal อื่นเปิด
searchChange() {
this.currentPage = 1
this.page = Array.from({ length: Math.ceil(this.bu5ListFilter().length / 10) }, (_, i) => i + 1);
}
bu5ListFilter() {
return this.bu5List.filter(x => x.bu5id.toLowerCase().includes(this.search) ||
x.tdesc.toLowerCase().includes(this.search) ||
x.edesc.toLowerCase().includes(this.search))
}
selectBu5(bu5: Bu5Model) {
this.bu4Service.getById(bu5.parent).subscribe(response => {
this.bu4 = response
})
this.bu5 = new MyBu5Model(bu5)
}
addBu5() {
// this.bu5Service.post(this.bu5).subscribe((response:any) => {
// if (response.success) {
// this.getBu5List()
// }
// })
}
deleteBu5(bu5: Bu5Model) {
// this.bu5Service.delete(new MyBu5Model(bu5)).subscribe((response:any) => {
// if (response.success) {
// this.getBu5List()
// }
// })
}
}
......@@ -44,7 +44,7 @@ import { FormsModule } from '@angular/forms';
import { Bu2Service } from 'src/app/shared/services/bu2.service';
import { Bu3Service } from 'src/app/shared/services/bu3.service';
import { Bu4Service } from 'src/app/shared/services/bu4.service';
import { Bu5Service } from 'src/app/shared/services/bu5service';
import { Bu5Service } from 'src/app/shared/services/bu5.service';
import { Bu6Service } from 'src/app/shared/services/bu6.service';
import { Bu7Service } from 'src/app/shared/services/bu7.service';
......
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