Commit 67e6377e by Nattana Chaiyamat

ทะเบียนบริษัท

parent 9d7c4558
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { Component, EventEmitter, Input, OnInit, } from '@angular/core';
import { Bu1Model, MyBu1Model } from 'src/app/shared/model/bu1.model';
import { Bu1Service } from 'src/app/shared/services/bu1.service';
@Component({
selector: 'app-department-register',
templateUrl: './department-register.component.html',
styleUrls: ['./department-register.component.scss']
})
export class DepartmentRegisterComponent {
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 DepartmentRegisterComponent implements OnInit {
currentPage = 1
page = Array.from({ length: 1 }, (_, i) => i + 1);
bu1List: Bu1Model[] = []
bu1: Bu1Model = new MyBu1Model({})
search = ""
constructor(private bu1Service: Bu1Service) { }
ngOnInit(): void {
this.getBu1List()
}
closeModal(name: string) {
this.modalOptions[name].isModalOpen = false;
// ตรวจสอบว่ามี Modal อื่นเปิดอยู่หรือไม่
if (!this.isAnyModalOpen()) {
document.body.style.overflow = ''; // คืนค่าการ Scroll เฉพาะเมื่อ Modal ทั้งหมดปิดแล้ว
}
getBu1List() {
this.bu1Service.getList().subscribe(response => {
this.bu1List = 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.bu1ListFilter().length / 10) }, (_, i) => i + 1);
}
bu1ListFilter() {
return this.bu1List.filter(x => x.bu1id.toLowerCase().includes(this.search) ||
x.tdesc.toLowerCase().includes(this.search) ||
x.edesc.toLowerCase().includes(this.search))
}
selectBu1(bu1: Bu1Model) {
this.bu1 = new MyBu1Model(bu1)
}
addBu1() {
// this.bu1Service.post(this.bu1).subscribe((response:any) => {
// if (response.success) {
// this.getBu1List()
// }
// })
}
deleteBu1(bu1: Bu1Model) {
// this.bu1Service.delete(new MyBu1Model(bu1)).subscribe((response:any) => {
// if (response.success) {
// this.getBu1List()
// }
// })
}
}
......@@ -24,8 +24,8 @@ import { CompanyRegistrationComponent } from '../company-registration/company-re
import { DepartmentRegisterComponent } from '../company-registration/branch-business-unit/department-register/department-register.component';
import { BranchBusinessUnitComponent } from '../company-registration/branch-business-unit/branch-business-unit.component';
import { DepartmentListComponent } from '../company-registration/branch-business-unit/department-list/department-list.component';
import { SubDepartmentOneComponent} from '../company-registration/branch-business-unit/sub-department-one/sub-department-one.component';
import { SubDepartmentThreeComponent} from '../company-registration/branch-business-unit/sub-department-three/sub-department-three.component';
import { SubDepartmentOneComponent } from '../company-registration/branch-business-unit/sub-department-one/sub-department-one.component';
import { SubDepartmentThreeComponent } from '../company-registration/branch-business-unit/sub-department-three/sub-department-three.component';
import { SubDepartmentTwoComponent } from '../company-registration/branch-business-unit/sub-department-two/sub-department-two.component';
import { SubDepartmentFourComponent } from '../company-registration/branch-business-unit/sub-department-four/sub-department-four.component';
import { SectionRegistrationComponent } from '../company-registration/branch-business-unit/section-registration/section-registration.component';
......@@ -37,6 +37,10 @@ import { AccountSettingsComponent } from '../account-settings/account-settings.c
import { UserSettingsComponent } from '../account-settings/user-settings/user-settings.component';
import { EmployeeLevel } from '../job-description/employee-level/employee-level.component';
import { SetAPasswordComponent } from '../account-settings/set-a-password/set-a-password.component';
import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
import { Bu1Service } from 'src/app/shared/services/bu1.service';
import { HttpRequestInterceptor } from 'src/app/shared/services/http-request.interceptor';
import { FormsModule } from '@angular/forms';
@NgModule({
declarations: [
......@@ -81,6 +85,13 @@ import { SetAPasswordComponent } from '../account-settings/set-a-password/set-a-
SharedModule,
NgxChartsModule,
NgSelectModule,
HttpClientModule,
FormsModule
],
providers: [Bu1Service, {
provide: HTTP_INTERCEPTORS,
useClass: HttpRequestInterceptor,
multi: true,
},]
})
export class DashboardModule { }
export interface Bu1Model {
bu1id: string;
tdesc: string;
edesc: string;
}
export class MyBu1Model implements Bu1Model {
bu1id: string;
tdesc: string;
edesc: string;
constructor(data: Partial<Bu1Model>) {
this.bu1id = data.bu1id || ""
this.tdesc = data.tdesc || ""
this.edesc = data.edesc || ""
}
}
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { environment } from 'src/environments/environment';
import { Bu1Model } from '../model/bu1.model';
@Injectable({
providedIn: 'root'
})
export class Bu1Service {
api = "/bu1"
urlApi = environment.baseUrl + this.api
constructor(private http: HttpClient) {
}
getList(): Observable<Bu1Model[]> {
return this.http.get<Bu1Model[]>(this.urlApi + "/lists")
}
// post(body: Bu1Model) {
// return this.http.post(this.urlApi, body)
// }
// delete(body: Bu1Model) {
// const options = {
// headers: new HttpHeaders({
// "Content-Type": "application/json",
// }),
// body: body
// };
// return this.http.delete(this.urlApi, options)
// }
}
import { Injectable } from '@angular/core';
import {
HttpRequest,
HttpHandler,
HttpEvent,
HttpInterceptor,
HttpErrorResponse
} from '@angular/common/http';
import { Observable, of, throwError } from 'rxjs';
import { catchError, tap } from 'rxjs/operators';
@Injectable()
export class HttpRequestInterceptor {
responseCache = new Map()
constructor() { }
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
if (req.url.startsWith("./")) {
return next.handle(req);
} else {
const authHeader = 'Bearer ' + "eyJhbGciOiJIUzI1NiJ9.eyJzY2hlbWEiOiJkYm8iLCJlbmNvZGUiOiIyIiwic3ViIjoiQXV0aCIsImNvbXBhbnlOYW1lIjoi4Lia4Lij4Li04Lip4Lix4LiXIOC4oeC4suC4ouC5gOC4reC4iuC4reC4suC4o-C5jCDguIjguLPguIHguLHguJQiLCJkYk5hbWUiOiJNWUhSUExVUyIsInJvbGVzIjpbIlVTRVIiXSwid29ya2FyZWEiOiJUS1ciLCJpc3MiOiJDb21wdXRlciBTY2llbmNlIENvcnBvcmF0aW9uIExpbWl0ZWQiLCJ6bWxvZ2luIjoiZmFsc2UiLCJyb2xlX2xldmVsIjoiNiIsImVtcGxveWVlaWQiOiIxMDAwMDA4MiIsImJyYW5jaCI6Im15aHIzIiwiZW1wX3Bvc2l0aW9uIjoiMDk3IiwidXNlcl9yb2xlIjoiQWxsIiwidWlkIjoiMTAwMDAwODIiLCJjb21wYW55aWQiOiIxMDAiLCJhY3RvcmlkIjoiMTAwMDAwODIiLCJsYW5nIjoidGgiLCJhZCI6ImZhbHNlIiwiZmlyc3Rsb2dpbiI6ImZhbHNlIiwidXJsX215aHIiOiJodHRwOi8vaHJwbHVzLXN0ZC5teWhyLmNvLnRoL2hyIiwiYXBwX25hbWUiOiJteWhyIiwicmVnaW9uYWxsdHkiOiJFTkciLCJ0b2tlbl96ZWVtZSI6IiIsInVzZXJfbGV2ZWwiOiJNWUhSIiwiZnVsbG5hbWUiOiLguJnguLLguKLguK3guJ7guLTguKPguLHguJXguJnguYwgIOC4l-C4lOC4quC4reC4miIsImNvbWlkIjoiIiwiam9iIjoiMDk3LTI0NjkiLCJ1c2VyIjoibXlociIsInptX3VzZXIiOiIiLCJ1c2VybmFtZSI6Im15aHIiLCJtZW1iZXJpZCI6IiJ9.5VUk7ZilGchdTTm-5YC0xIL53cEYX6AkfEW4d8Xd-1g";
const overideReq = {
headers: req.headers.set('Authorization', authHeader),
url: req.url,
};
const authReq = req.clone(overideReq);
return next.handle(authReq).pipe(tap(response => {
this.responseCache.set(req.urlWithParams, response)
}));
}
}
}
......@@ -3352,7 +3352,8 @@ select option:active,
}
}
.ti-pagination li .page-link.active{
background-color: rgb(var(--color-primary));
/* background-color: rgb(var(--color-primary)); */
background-color: rgb(var(--color-secondary));
--tw-text-opacity: 1;
color: rgb(255 255 255 / var(--tw-text-opacity));
}
......
......@@ -12,6 +12,7 @@ export const environment = {
appId: '********************************',
measurementId: '********************************',
},
baseUrl: 'https://hrplus-std.myhr.co.th/plus',
};
/*
......
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