Commit aa4afe9f by Nattana Chaiyamat

ทะเบียนส่วน

parent 789d0100
......@@ -210,10 +210,8 @@
</div>
<label class="ti-form-label mt-2rem">เเผนก*</label>
<div class="relative flex rounded-md w-1/2">
<input type="text" id="detail_th" class="ti-form-input h-16" [(ngModel)]="bu2.bu2id">
</div>
<!-- <div class="relative flex rounded-md w-1/2">
<input type="text" id="hs-leading-button-add-on-with-icon-and-button" name="hs-leading-button-add-on-with-icon-and-button" class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10" style="padding-right: 3.5rem;"
<input type="text" class="ti-form-input h-16" [(ngModel)]="bu2.bu2id">
<!-- <input type="text" id="hs-leading-button-add-on-with-icon-and-button" name="hs-leading-button-add-on-with-icon-and-button" class="ti-form-input rounded-sm ltr:rounded-r-sm rtl:rounded-l-sm focus:z-10" style="padding-right: 3.5rem;"
[(ngModel)]="bu2.bu2id" (ngModelChange)="bu2idChange()">
<div class="absolute inset-y-0 ltr:right-0 rtl:left-0 flex items-center z-20 ltr:pr-4 rtl:pl-4 space-x-2">
<button type="button" class="flex items-center text-red-500" (click)="selectBu2()">
......@@ -222,8 +220,8 @@
<button type="button" class="flex items-center text-gray-500 dark:text-white/70" data-hs-overlay="#department-list-bu2-table-modal">
<i class="ri-search-line cursor-pointer text-gray"></i>
</button>
</div>
</div> -->
</div> -->
</div>
<label for="detail_th" class="ti-form-label mt-2rem">รายละเอียดแผนก (ไทย)*</label>
<input type="text" id="detail_th" class="ti-form-input h-16" [(ngModel)]="bu2.tdesc">
<label for="detail_eng" class="ti-form-label mt-2rem">รายละเอียดแผนก (อังกฤษ)</label>
......
......@@ -18,7 +18,7 @@ interface table {
export class DepartmentListComponent implements OnInit {
bu2List: Bu2Model[] = []
bu2ListLoading = false
bu2: Bu2Model = new MyBu2Model({})
bu2: Bu2Model = new MyBu2Model()
bu2Table: table = {
currentPage: 1,
page: Array.from({ length: 1 }, (_, i) => i + 1),
......@@ -64,6 +64,7 @@ export class DepartmentListComponent implements OnInit {
}
const formData = new FormData();
formData.append('file', this.selectedFile);
this.bu2ListLoading = true
this.fileService.upload(formData, 'mbu2').subscribe({
next: response => {
if (response.success) {
......@@ -71,9 +72,11 @@ export class DepartmentListComponent implements OnInit {
this.getBu2List()
} else {
this.showAlert(response.message, 'error')
this.bu2ListLoading = false
}
}, error: error => {
this.showAlert(error.message, 'error')
this.bu2ListLoading = false
}
})
}
......@@ -121,7 +124,7 @@ export class DepartmentListComponent implements OnInit {
x.edesc.toLowerCase().includes(this.bu2Table.search.toLowerCase()))
}
selectBu2(bu2?: Bu2Model) {
this.bu2 = new MyBu2Model(bu2 || {})
this.bu2 = new MyBu2Model(bu2)
this.selectBu1()
if (this.bu2.parent) {
this.bu1Service.getById(this.bu2.parent).subscribe(response => {
......@@ -165,7 +168,7 @@ export class DepartmentListComponent implements OnInit {
x.edesc.toLowerCase().includes(this.bu1Modal.search.toLowerCase()))
}
selectBu1(bu1?: Bu1Model) {
this.bu1 = new MyBu1Model(bu1 || {})
this.bu1 = new MyBu1Model(bu1)
}
showAlert(text: string, type: 'success' | 'error') {
......@@ -175,6 +178,7 @@ export class DepartmentListComponent implements OnInit {
})
}
addBu2() {
this.bu2ListLoading = true
this.bu2Service.post({ ...this.bu2, parent: this.bu1.bu1id }).subscribe({
next: response => {
if (response.success) {
......@@ -182,13 +186,16 @@ export class DepartmentListComponent implements OnInit {
this.getBu2List()
} else {
this.showAlert(response.message, 'error')
this.bu2ListLoading = false
}
}, error: error => {
this.showAlert(error.message, 'error')
this.bu2ListLoading = false
}
})
}
deleteBu2() {
this.bu2ListLoading = true
this.bu2Service.delete(this.bu2).subscribe({
next: response => {
if (response.success) {
......@@ -196,9 +203,11 @@ export class DepartmentListComponent implements OnInit {
this.getBu2List()
} else {
this.showAlert(response.message, 'error')
this.bu2ListLoading = false
}
}, error: error => {
this.showAlert(error.message, 'error')
this.bu2ListLoading = false
}
})
}
......
......@@ -41,6 +41,7 @@ export class DepartmentRegisterComponent implements OnInit {
}
const formData = new FormData();
formData.append('file', this.selectedFile);
this.bu1ListLoading = true
this.fileService.upload(formData, 'mbu1').subscribe({
next: response => {
if (response.success) {
......@@ -48,9 +49,11 @@ export class DepartmentRegisterComponent implements OnInit {
this.getBu1List()
} else {
this.showAlert(response.message, 'error')
this.bu1ListLoading = false
}
}, error: error => {
this.showAlert(error.message, 'error')
this.bu1ListLoading = false
}
})
}
......@@ -99,7 +102,7 @@ export class DepartmentRegisterComponent implements OnInit {
x.edesc.toLowerCase().includes(this.search.toLowerCase()))
}
selectBu1(bu1?: Bu1Model) {
this.bu1 = new MyBu1Model(bu1 || {})
this.bu1 = new MyBu1Model(bu1)
}
showAlert(text: string, type: 'success' | 'error') {
......@@ -117,10 +120,11 @@ export class DepartmentRegisterComponent implements OnInit {
this.getBu1List()
} else {
this.showAlert(response.message, 'error')
this.bu1ListLoading = false
}
}, error: error => {
this.bu1ListLoading = false
this.showAlert(error.message, 'error')
this.bu1ListLoading = false
}
})
}
......@@ -133,10 +137,11 @@ export class DepartmentRegisterComponent implements OnInit {
this.getBu1List()
} else {
this.showAlert(response.message, 'error')
this.bu1ListLoading = false
}
}, error: error => {
this.bu1ListLoading = false
this.showAlert(error.message, 'error')
this.bu1ListLoading = false
}
})
}
......
......@@ -18,7 +18,7 @@ interface table {
export class SectionRegistrationComponent implements OnInit {
bu3List: Bu3Model[] = []
bu3ListLoading = false
bu3: Bu3Model = new MyBu3Model({})
bu3: Bu3Model = new MyBu3Model()
bu3Table: table = {
currentPage: 1,
page: Array.from({ length: 1 }, (_, i) => i + 1),
......@@ -34,13 +34,13 @@ export class SectionRegistrationComponent implements OnInit {
search: ""
}
bu2List: Bu2Model[] = []
bu2: Bu2Model = new MyBu2Model({})
bu2: Bu2Model = new MyBu2Model()
bu2Modal: table = {
currentPage: 1,
page: Array.from({ length: 1 }, (_, i) => i + 1),
search: ""
}
currentModal = ""
currentModal: 'add' | 'edit' | 'delete' = "add"
constructor(private bu3Service: Bu3Service,
private bu2Service: Bu2Service,
private toastr: ToastrService,
......@@ -65,6 +65,7 @@ export class SectionRegistrationComponent implements OnInit {
}
const formData = new FormData();
formData.append('file', this.selectedFile);
this.bu3ListLoading = true
this.fileService.upload(formData, 'mbu3').subscribe({
next: response => {
if (response.success) {
......@@ -72,9 +73,11 @@ export class SectionRegistrationComponent implements OnInit {
this.getBu3List()
} else {
this.showAlert(response.message, 'error')
this.bu3ListLoading = false
}
}, error: error => {
this.showAlert(error.message, 'error')
this.bu3ListLoading = false
}
})
}
......@@ -102,14 +105,14 @@ export class SectionRegistrationComponent implements OnInit {
this.bu3ListLoading = true
this.bu3Service.getList().subscribe({
next: response => {
this.bu3List = response
this.bu3ListLoading = false
this.onBu3TableSearchChange()
this.cdr.detectChanges()
}, error: error => {
this.bu3ListLoading = false
this.cdr.detectChanges()
}
this.bu3List = response
this.bu3ListLoading = false
this.onBu3TableSearchChange()
this.cdr.detectChanges()
}, error: error => {
this.bu3ListLoading = false
this.cdr.detectChanges()
}
})
}
onBu3TableSearchChange() {
......@@ -118,11 +121,11 @@ export class SectionRegistrationComponent implements OnInit {
}
filterBu3Table() {
return this.bu3List.filter(x => x.bu3id.toLowerCase().includes(this.bu3Table.search.toLowerCase()) ||
x.tdesc.toLowerCase().includes(this.bu3Table.search.toLowerCase()) ||
x.edesc.toLowerCase().includes(this.bu3Table.search.toLowerCase()))
x.tdesc.toLowerCase().includes(this.bu3Table.search.toLowerCase()) ||
x.edesc.toLowerCase().includes(this.bu3Table.search.toLowerCase()))
}
selectBu3(bu3?: Bu3Model) {
this.bu3 = new MyBu3Model(bu3 || {})
this.bu3 = new MyBu3Model(bu3)
this.selectBu2()
if (this.bu3.parent) {
this.bu2Service.getById(this.bu3.parent).subscribe(response => {
......@@ -141,10 +144,11 @@ export class SectionRegistrationComponent 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()))
}
addBu3() {
this.bu3ListLoading = true
this.bu3Service.post({ ...this.bu3, parent: this.bu2.bu2id }).subscribe({
next: response => {
if (response.success) {
......@@ -152,13 +156,16 @@ export class SectionRegistrationComponent implements OnInit {
this.getBu3List()
} else {
this.showAlert(response.message, 'error')
this.bu3ListLoading = false
}
}, error: error => {
this.showAlert(error.message, 'error')
this.bu3ListLoading = false
}
})
}
deleteBu3() {
this.bu3ListLoading = true
this.bu3Service.delete(this.bu3).subscribe({
next: response => {
if (response.success) {
......@@ -166,9 +173,11 @@ export class SectionRegistrationComponent implements OnInit {
this.getBu3List()
} else {
this.showAlert(response.message, 'error')
this.bu3ListLoading = false
}
}, error: error => {
this.showAlert(error.message, 'error')
this.bu3ListLoading = false
}
})
}
......@@ -189,11 +198,11 @@ export class SectionRegistrationComponent implements OnInit {
}
filterBu2Modal() {
return this.bu2List.filter(x => x.bu2id.toLowerCase().includes(this.bu2Modal.search.toLowerCase()) ||
x.tdesc.toLowerCase().includes(this.bu2Modal.search.toLowerCase()) ||
x.edesc.toLowerCase().includes(this.bu2Modal.search.toLowerCase()))
x.tdesc.toLowerCase().includes(this.bu2Modal.search.toLowerCase()) ||
x.edesc.toLowerCase().includes(this.bu2Modal.search.toLowerCase()))
}
selectBu2(bu2?: Bu2Model) {
this.bu2 = new MyBu2Model(bu2 || {})
this.bu2 = new MyBu2Model(bu2)
}
showAlert(text: string, type: 'success' | 'error') {
......
......@@ -34,7 +34,7 @@ export class SubDepartmentOneComponent implements OnInit {
search: ""
}
bu3List: Bu3Model[] = []
bu3: Bu3Model = new MyBu3Model({})
bu3: Bu3Model = new MyBu3Model()
bu3Modal: table = {
currentPage: 1,
page: Array.from({ length: 1 }, (_, i) => i + 1),
......
......@@ -742,7 +742,7 @@
<i class="ti ti-wallet text-lg"></i>
Bal: $7,12,950
</a>
<a routerLink="/signin/basic" class="ti-dropdown-item">
<a (click)="logOut()" routerLink="/auth/login" class="ti-dropdown-item">
<i class="ti ti-logout text-lg"></i>
Log Out
</a>
......
......@@ -13,6 +13,10 @@ export class HeaderComponent {
private elementRef: ElementRef) {
}
logOut() {
sessionStorage.clear()
}
themeChange(type: string, type1: string) {
this.elementRef.nativeElement.ownerDocument.documentElement?.setAttribute('class', type);
this.elementRef.nativeElement.ownerDocument.documentElement?.setAttribute('style', "");
......@@ -37,11 +41,11 @@ export class HeaderComponent {
toggleSidebar() {
let html = this.elementRef.nativeElement.ownerDocument.documentElement;
if(window.innerWidth <= 992){
if (window.innerWidth <= 992) {
html?.setAttribute('toggled', html?.getAttribute('toggled') == 'open' ? 'close' : 'open');
if(html?.getAttribute('toggled') == 'open'){
if (html?.getAttribute('toggled') == 'open') {
document.querySelector('#responsive-overlay')?.classList.add('active');
}else{
} else {
document.querySelector('#responsive-overlay')?.classList.remove('active');
}
}
......
......@@ -13,12 +13,12 @@ export class MyBu2Model implements Bu2Model {
edesc: string;
parent: string;
companyId: string;
constructor(data: Partial<Bu2Model>) {
this.bu2id = data.bu2id || ""
this.tdesc = data.tdesc || ""
this.edesc = data.edesc || ""
this.parent = data.parent || ""
this.companyId = data.companyId || ""
constructor(data?: Partial<Bu2Model>) {
this.bu2id = data?.bu2id || ""
this.tdesc = data?.tdesc || ""
this.edesc = data?.edesc || ""
this.parent = data?.parent || ""
this.companyId = data?.companyId || ""
}
}
......@@ -13,12 +13,12 @@ export class MyBu3Model implements Bu3Model {
edesc: string;
parent: string;
companyId: string;
constructor(data: Partial<Bu3Model>) {
this.bu3id = data.bu3id || ""
this.tdesc = data.tdesc || ""
this.edesc = data.edesc || ""
this.parent = data.parent || ""
this.companyId = data.companyId || ""
constructor(data?: Partial<Bu3Model>) {
this.bu3id = data?.bu3id || ""
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