Commit 559c22d0 by Nattana Chaiyamat

จัดการบริษัท จัดการพนักงาน

parent 5411f194
import { TranslateService } from "@ngx-translate/core";
import { BaseModel } from "../base.model";
import { environment } from "../../../../environments/environment";
export interface EmployeeSyncModel {
birthdate: string
branchEngName: string
branchId: string
branchName: string
bu1EngName: string
bu1Id: string
bu1Name: string
bu2EngName: string
bu2Id: string
bu2Name: string
bu3EngName: string
bu3Id: string
bu3Name: string
bu4EngName: string
bu4Id: string
bu4Name: string
bu5EngName: string
bu5Id: string
bu5Name: string
bu6EngName: string
bu6Id: string
bu6Name: string
bu7EngName: string
bu7Id: string
bu7Name: string
companyCode: string
companyId: string
companyName: string
email: string
empGroupEngName: string
empGroupId: string
empGroupName: string
employeeId: string
empStatusEngName: string
empStatusId: string
empStatusName: string
empTypeEngName: string
empTypeId: string
empTypeName: string
firstEngName: string
firstHireDate: string
firstname: string
jobEngName: string
jobId: string
jobName: string
lastEngName: string
lastname: string
marryEngName: string
marryId: string
marryName: string
memberId: string
mobile: string
nationalityEngName: string
nationalityId: string
nationalityName: string
picture: string
plEngName: string
plId: string
plName: string
positionEngName: string
positionId: string
positionName: string
prefixEngName: string
prefixId: string
prefixName: string
sex: string
sexEngName: string
sexName: string
startDate: string
workareaEngName: string
workareaId: string
workareaName: string
}
export class MyEmployeeSyncModel extends BaseModel implements EmployeeSyncModel {
birthdate: string
branchEngName: string
branchId: string
branchName: string
bu1EngName: string
bu1Id: string
bu1Name: string
bu2EngName: string
bu2Id: string
bu2Name: string
bu3EngName: string
bu3Id: string
bu3Name: string
bu4EngName: string
bu4Id: string
bu4Name: string
bu5EngName: string
bu5Id: string
bu5Name: string
bu6EngName: string
bu6Id: string
bu6Name: string
bu7EngName: string
bu7Id: string
bu7Name: string
companyCode: string
companyId: string
companyName: string
email: string
empGroupEngName: string
empGroupId: string
empGroupName: string
employeeId: string
empStatusEngName: string
empStatusId: string
empStatusName: string
empTypeEngName: string
empTypeId: string
empTypeName: string
firstEngName: string
firstHireDate: string
firstname: string
jobEngName: string
jobId: string
jobName: string
lastEngName: string
lastname: string
marryEngName: string
marryId: string
marryName: string
memberId: string
mobile: string
nationalityEngName: string
nationalityId: string
nationalityName: string
picture: string
plEngName: string
plId: string
plName: string
positionEngName: string
positionId: string
positionName: string
prefixEngName: string
prefixId: string
prefixName: string
sex: string
sexEngName: string
sexName: string
startDate: string
workareaEngName: string
workareaId: string
workareaName: string
constructor(data?: Partial<EmployeeSyncModel>, translateService?: TranslateService) {
super(data, translateService)
this.birthdate = data?.birthdate || ''
this.branchEngName = data?.branchEngName || ''
this.branchId = data?.branchId || ''
this.branchName = data?.branchName || ''
this.bu1EngName = data?.bu1EngName || ''
this.bu1Id = data?.bu1Id || ''
this.bu1Name = data?.bu1Name || ''
this.bu2EngName = data?.bu2EngName || ''
this.bu2Id = data?.bu2Id || ''
this.bu2Name = data?.bu2Name || ''
this.bu3EngName = data?.bu3EngName || ''
this.bu3Id = data?.bu3Id || ''
this.bu3Name = data?.bu3Name || ''
this.bu4EngName = data?.bu4EngName || ''
this.bu4Id = data?.bu4Id || ''
this.bu4Name = data?.bu4Name || ''
this.bu5EngName = data?.bu5EngName || ''
this.bu5Id = data?.bu5Id || ''
this.bu5Name = data?.bu5Name || ''
this.bu6EngName = data?.bu6EngName || ''
this.bu6Id = data?.bu6Id || ''
this.bu6Name = data?.bu6Name || ''
this.bu7EngName = data?.bu7EngName || ''
this.bu7Id = data?.bu7Id || ''
this.bu7Name = data?.bu7Name || ''
this.companyCode = data?.companyCode || ''
this.companyId = data?.companyId || ''
this.companyName = data?.companyName || ''
this.email = data?.email || ''
this.empGroupEngName = data?.empGroupEngName || ''
this.empGroupId = data?.empGroupId || ''
this.empGroupName = data?.empGroupName || ''
this.employeeId = data?.employeeId || ''
this.empStatusEngName = data?.empStatusEngName || ''
this.empStatusId = data?.empStatusId || ''
this.empStatusName = data?.empStatusName || ''
this.empTypeEngName = data?.empTypeEngName || ''
this.empTypeId = data?.empTypeId || ''
this.empTypeName = data?.empTypeName || ''
this.firstEngName = data?.firstEngName || ''
this.firstHireDate = data?.firstHireDate || ''
this.firstname = data?.firstname || ''
this.jobEngName = data?.jobEngName || ''
this.jobId = data?.jobId || ''
this.jobName = data?.jobName || ''
this.lastEngName = data?.lastEngName || ''
this.lastname = data?.lastname || ''
this.marryEngName = data?.marryEngName || ''
this.marryId = data?.marryId || ''
this.marryName = data?.marryName || ''
this.memberId = data?.memberId || ''
this.mobile = data?.mobile || ''
this.nationalityEngName = data?.nationalityEngName || ''
this.nationalityId = data?.nationalityId || ''
this.nationalityName = data?.nationalityName || ''
this.picture = data?.picture || ''
this.plEngName = data?.plEngName || ''
this.plId = data?.plId || ''
this.plName = data?.plName || ''
this.positionEngName = data?.positionEngName || ''
this.positionId = data?.positionId || ''
this.positionName = data?.positionName || ''
this.prefixEngName = data?.prefixEngName || ''
this.prefixId = data?.prefixId || ''
this.prefixName = data?.prefixName || ''
this.sex = data?.sex || ''
this.sexEngName = data?.sexEngName || ''
this.sexName = data?.sexName || ''
this.startDate = data?.startDate || ''
this.workareaEngName = data?.workareaEngName || ''
this.workareaId = data?.workareaId || ''
this.workareaName = data?.workareaName || ''
}
}
......@@ -55,30 +55,30 @@ export class MyHrcompanyModel extends BaseModel implements HrcompanyModel {
recommendType: number;
constructor(data?: Partial<HrcompanyModel>, translateService?: TranslateService) {
super(data, translateService)
this.companyId = data?.companyId!
this.companyCode = data?.companyCode!
this.companyName = data?.companyName!
this.companySource = data?.companySource!
this.companyEmail = data?.companyEmail!
this.branchId = data?.branchId!
this.branchName = data?.branchName!
this.pictureUrl = data?.pictureUrl!
this.role = data?.role!
this.database = data?.database!
this.myhrCode = data?.myhrCode!
this.myhrUrl = data?.myhrUrl!
this.companyAddr = data?.companyAddr!
this.companyTel = data?.companyTel!
this.companyTax = data?.companyTax!
this.prefix = data?.prefix!
this.lastNumber = data?.lastNumber!
this.number = data?.number!
this.receiptSignature1 = data?.receiptSignature1!
this.receiptSignature2 = data?.receiptSignature2!
this.logo = data?.logo!
this.displayType = data?.displayType!
this.bestsellerType = data?.bestsellerType!
this.recommendType = data?.recommendType!
this.companyId = data?.companyId || ''
this.companyCode = data?.companyCode || ''
this.companyName = data?.companyName || ''
this.companySource = data?.companySource || ''
this.companyEmail = data?.companyEmail || ''
this.branchId = data?.branchId || ''
this.branchName = data?.branchName || ''
this.pictureUrl = data?.pictureUrl || ''
this.role = data?.role || ''
this.database = data?.database || ''
this.myhrCode = data?.myhrCode || ''
this.myhrUrl = data?.myhrUrl || ''
this.companyAddr = data?.companyAddr || ''
this.companyTel = data?.companyTel || ''
this.companyTax = data?.companyTax || ''
this.prefix = data?.prefix || ''
this.lastNumber = data?.lastNumber || ''
this.number = data?.number || ''
this.receiptSignature1 = data?.receiptSignature1 || ''
this.receiptSignature2 = data?.receiptSignature2 || ''
this.logo = data?.logo || ''
this.displayType = data?.displayType ?? 0
this.bestsellerType = data?.bestsellerType ?? 0
this.recommendType = data?.recommendType ?? 0
}
// getPictureURL(): string {
......
import { TranslateService } from "@ngx-translate/core";
import { BaseModel } from "../base.model";
import { environment } from "../../../../environments/environment";
export interface ZeemeCompanyModel {
companyName: string
companyType: string
website: string
metaData: string
companyStatus: string
suggestion: string
radiusStampAllow: string
latitude: string
longitude: string
pictureCompany: string
ownerId: string
ownerName: string
mainbranchId: string
mainbranchName: string
partitionId: string
companyId: string
companyCode: string
qrCode: string
locationList: {
latitude: string
longitude: string
name: string
expiredDate: string
}[]
}
export class MyZeemeCompanyModel extends BaseModel implements ZeemeCompanyModel {
companyName: string
companyType: string
website: string
metaData: string
companyStatus: string
suggestion: string
radiusStampAllow: string
latitude: string
longitude: string
pictureCompany: string
ownerId: string
ownerName: string
mainbranchId: string
mainbranchName: string
partitionId: string
companyId: string
companyCode: string
qrCode: string
locationList: {
latitude: string
longitude: string
name: string
expiredDate: string
}[]
constructor(data?: Partial<ZeemeCompanyModel>, translateService?: TranslateService) {
super(data, translateService)
this.companyName = data?.companyName || ''
this.companyType = data?.companyType || ''
this.website = data?.website || ''
this.metaData = data?.metaData || ''
this.companyStatus = data?.companyStatus || ''
this.suggestion = data?.suggestion || ''
this.radiusStampAllow = data?.radiusStampAllow || ''
this.latitude = data?.latitude || ''
this.longitude = data?.longitude || ''
this.pictureCompany = data?.pictureCompany || ''
this.ownerId = data?.ownerId || ''
this.ownerName = data?.ownerName || ''
this.mainbranchId = data?.mainbranchId || ''
this.mainbranchName = data?.mainbranchName || ''
this.partitionId = data?.partitionId || ''
this.companyId = data?.companyId || ''
this.companyCode = data?.companyCode || ''
this.qrCode = data?.qrCode || ''
this.locationList = (data?.locationList || []).map(e => ({
latitude: e.latitude || '',
longitude: e.longitude || '',
name: e.name || '',
expiredDate: e.expiredDate || ''
}))
}
}
.bg-input-readonly {
background-color: #e5e7eb;
cursor: not-allowed;
}
.\!bg-input-readonly {
background-color: #e5e7eb !important;
cursor: not-allowed !important;
}
\ No newline at end of file
import { ChangeDetectorRef, Component, ElementRef, OnInit, TemplateRef, ViewChild } from '@angular/core';
import { SharedModule } from '../../../shared/shared.module';
import { CommonModule } from '@angular/common';
import { TranslateModule, TranslateService } from '@ngx-translate/core';
import { UserService } from '../../services/mylearn/user.service';
import {
HrcompanyModel,
MyHrcompanyModel,
} from '../../models/mylearn/myhrcompany.model';
import { MyhrcompanyService } from '../../services/mylearn/myhrcompany.service';
import swal from 'sweetalert';
import { FormsModule } from '@angular/forms';
import { Router } from '@angular/router';
import { ResponseModel } from '../../models/response.model.';
import { MyZeemeCompanyModel, ZeemeCompanyModel } from '../../models/mylearn/zeeme-company.model';
import { MatDialog, MatDialogRef } from '@angular/material/dialog';
import { FileItem, FileUploader, FileUploadModule, ParsedResponseHeaders } from 'ng2-file-upload';
import { environment } from '../../../../environments/environment';
import { TokenService } from '../../../shared/services/token.service';
import { forkJoin } from 'rxjs';
import { EmployeeSyncModel, MyEmployeeSyncModel } from '../../models/mylearn/employee-sync.model';
@Component({
selector: 'app-employee-manage',
templateUrl: './employee-manage.component.html',
styleUrls: ['./employee-manage.component.scss'],
standalone: true,
imports: [CommonModule, SharedModule, TranslateModule, FormsModule, FileUploadModule],
})
export class EmployeeManageComponent implements OnInit {
baseUrlMylearn = environment.baseUrlMylearn
search = ''
page = 0
pageIndex = 10
state = {
hrCompany: {
loading: false,
list: [] as HrcompanyModel[],
selectedIds: [] as string[]
},
employeeSync: {
loading: false,
list: [] as EmployeeSyncModel[],
selectedIds: [] as string[]
},
};
@ViewChild('employeeModal') employeeModal?: TemplateRef<any>;
employeeModalRef?: MatDialogRef<any>;
searchModal = ''
pageModal = 0
pageSizeModal = 10
constructor(
private myhrcompanyservice: MyhrcompanyService,
private userService: UserService,
public translate: TranslateService,
private router: Router,
private modal: MatDialog,
private tokenService: TokenService,
private cdr: ChangeDetectorRef
) { }
ngOnInit(): void {
this.getHrCompanyList()
}
getHrCompanyList() {
this.state.hrCompany.loading = true
this.myhrcompanyservice.getList().subscribe({
next: (result) => {
this.state.hrCompany.list = result.map(e => new MyHrcompanyModel(e)).filter(e => e.companySource == 'ZeeMe')
this.state.hrCompany.loading = false
this.cdr.markForCheck()
},
error: (err) => {
this.state.hrCompany.loading = false
swal('ข้อผิดพลาด', 'ไม่สามารถดึงข้อมูลบริษัทได้', 'error');
this.cdr.markForCheck()
}
});
}
hrCompanyListFilter() {
return this.state.hrCompany.list.filter(e =>
e.companyCode.toLowerCase().includes(this.search.toLowerCase()) ||
e.companyName.toLowerCase().includes(this.search.toLowerCase()) ||
e.branchName.toLowerCase().includes(this.search.toLowerCase()) ||
e.companySource.toLowerCase().includes(this.search.toLowerCase()))
}
getZeemeEmployeeProfileSyncList(companyId: string) {
this.state.employeeSync.loading = true
this.myhrcompanyservice.getZeemeEmployeeProfileSyncList(companyId).subscribe({
next: (result) => {
this.state.employeeSync.list = result.map(e => new MyEmployeeSyncModel(e))
this.state.employeeSync.loading = false
this.cdr.markForCheck()
},
error: (err) => {
this.state.employeeSync.loading = false
this.cdr.markForCheck()
}
})
}
employeeSyncFilter() {
return this.state.employeeSync.list.filter(e =>
e.employeeId.toLowerCase().includes(this.searchModal.toLowerCase()) ||
e.companyName.toLowerCase().includes(this.searchModal.toLowerCase()) ||
e.branchName.toLowerCase().includes(this.searchModal.toLowerCase()) ||
e.firstname.toLowerCase().includes(this.searchModal.toLowerCase()) ||
e.lastname.toLowerCase().includes(this.searchModal.toLowerCase()) ||
e.firstEngName.toLowerCase().includes(this.searchModal.toLowerCase()) ||
e.lastEngName.toLowerCase().includes(this.searchModal.toLowerCase()))
}
toggleSelect(key: keyof typeof this.state, idField: string, item: any, event: Event) {
const checked = (event.target as HTMLInputElement).checked;
const target = this.state[key];
const id = item[idField];
const input = event.target as HTMLInputElement;
if (input && 'checked' in input) {
const checked = input.checked;
if (checked) {
if (!target.selectedIds.includes(id)) target.selectedIds.push(id);
} else {
target.selectedIds = target.selectedIds.filter(x => x !== id);
}
} else {
if (target.selectedIds.includes(id)) {
target.selectedIds = target.selectedIds.filter(x => x !== id);
} else {
target.selectedIds.push(id);
}
}
}
toggleSelectAll(key: keyof typeof this.state, idField: string, event: Event) {
const checked = (event.target as HTMLInputElement).checked;
const target = this.state[key];
if (checked) {
target.selectedIds = target.list.map(item => item[idField as keyof typeof item]);
} else {
target.selectedIds = [];
}
}
openEmployeeModal(item: HrcompanyModel) {
this.getZeemeEmployeeProfileSyncList(item.companyId)
this.pageModal = 0;
this.pageSizeModal = 10;
if (this.employeeModal) {
this.employeeModalRef = this.modal.open(this.employeeModal, {
width: '1500px',
height: '700px',
maxWidth: 'none',
disableClose: true,
data: {}
});
this.employeeModalRef.afterClosed().subscribe(result => {
});
}
}
syncProfile() {
const selectedItems = this.state.employeeSync.list.filter(item =>
this.state.employeeSync.selectedIds.includes(item.employeeId)
).map(e => new MyEmployeeSyncModel(e))
swal({
title: 'คุณแน่ใจหรือไม่?',
text: 'คุณต้องการบันทึกหรือไม่',
icon: 'warning',
dangerMode: false,
buttons: ['ยกเลิก', 'ยืนยัน'],
}).then((willSave: any) => {
if (willSave) {
this.myhrcompanyservice.syncProfile(selectedItems).subscribe({
next: (result) => {
this.employeeModalRef?.close()
swal('บันทึกสำเร็จ!!', 'บันทึกข้อมูลสมาชิก', 'success');
this.state.employeeSync.selectedIds = []
this.ngOnInit();
},
error: (err) => {
swal('ข้อผิดพลาด!!', 'ไม่สามารถบันทึก/อัปเดตข้อมูลได้', 'error');
}
})
}
});
}
}
.bg-input-readonly {
background-color: #e5e7eb;
cursor: not-allowed;
}
.\!bg-input-readonly {
background-color: #e5e7eb !important;
cursor: not-allowed !important;
}
\ No newline at end of file
......@@ -19,6 +19,10 @@ export const MYLEARN_ROUTES: Routes = [
loadComponent: () => import('./myhrcompany/myhrcompany.component').then((m) => m.MyhrcompanyComponent),
},
{
path: 'employee-manage',
loadComponent: () => import('./employee-manage/employee-manage.component').then((m) => m.EmployeeManageComponent),
},
{
path: 'management-user',
loadComponent: () => import('./management-user/management-user.component').then((m) => m.ManagementUserComponent),
},
......
......@@ -5,6 +5,8 @@ import { environment } from '../../../../environments/environment';
import { HrcompanyModel } from '../../models/mylearn/myhrcompany.model';
import { AlertModel } from '../../models/alert.model';
import { ResponseModel } from '../../models/response.model.';
import { ZeemeCompanyModel } from '../../models/mylearn/zeeme-company.model';
import { EmployeeSyncModel } from '../../models/mylearn/employee-sync.model';
@Injectable({
providedIn: 'root',
......@@ -12,7 +14,7 @@ import { ResponseModel } from '../../models/response.model.';
export class MyhrcompanyService {
api = '/myhrcompany';
urlApi = environment.baseUrlMylearn + '/myhrcompany';
constructor(private http: HttpClient) {}
constructor(private http: HttpClient) { }
getCompany() {
return this.http.get<HrcompanyModel>(this.urlApi);
......@@ -40,4 +42,23 @@ export class MyhrcompanyService {
return this.http.get<ResponseModel>(`${this.urlApi}/generate-usersadmin?companyId=${companyId}`
);
}
getZeemeCompanyList(): Observable<ZeemeCompanyModel[]> {
return this.http.get<ZeemeCompanyModel[]>(`https://zeeme.myhr.co.th/ZeemeApi/rest/company/list`);
}
getZeemeCompanyConfig(companyId: string): Observable<any[]> {
return this.http.get<any[]>(`https://zeeme.myhr.co.th/ZeemeApi/rest/company/config-myhr/${companyId}`);
}
getZeemeEmployeeProfileSyncList(companyId: string): Observable<EmployeeSyncModel[]> {
return this.http.get<EmployeeSyncModel[]>(`https://zeeme.myhr.co.th/ZeemeApi/rest/employee/profile-sync/${companyId}`);
}
getZeemeEmployeeProfileSync(companyId: string, memberId: string): Observable<EmployeeSyncModel> {
return this.http.get<EmployeeSyncModel>(`https://zeeme.myhr.co.th/ZeemeApi/rest/employee/profile-sync/${companyId}/${memberId}`);
}
syncProfile(employeeSync: EmployeeSyncModel[]): Observable<ResponseModel> {
return this.http.put<ResponseModel>(`${environment.baseUrlMylearn}/sync/profile/v2`, employeeSync);
}
}
......@@ -30,7 +30,9 @@ export class HttpRequestInterceptor {
let token: string | null = null;
// ใช้ fixed token หาก url เป็น portal.myhr.co.th
if (fullUrl.startsWith(environment.url)) {
if (fullUrl.startsWith('https://zeeme.myhr.co.th/ZeemeApi/rest')) {
token = `Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJBdXRoIiwidWlkIjoiNWRhY2ZhNzAtZmNmMy0xMWU4LWIyM2UtODVlNjZkMDgwNzk5IiwiaXNzIjoiQ29tcHV0ZXIgU2NpZW5jZSBDb3Jwb3JhdGlvbiBMaW1pdGVkIiwiZGV2aWNlbm8iOiJzc3Nzc3NzIiwibWVtYmVySWQiOiI1ZGFjZmE3MC1mY2YzLTExZTgtYjIzZS04NWU2NmQwODA3OTkifQ.KghztZYthsmjaZ36vc6gOa0HJHLT3_i0sKJ_HY4OAaY`;
} else if (fullUrl.startsWith(environment.url)) {
token = `Bearer ${environment.portalFixedToken}`;
} else if (this.tokenService.getAppToken()) {
token = `Bearer ${this.tokenService.getAppToken()}`;
......
......@@ -325,6 +325,7 @@ export class NavService implements OnDestroy {
children: [
{ path: '/portal-manage/mylearn/mylearn-pdpa-manage', title: 'จัดการ PDPA', type: 'link' },
{ path: '/portal-manage/mylearn/myhrcompany', title: 'จัดการบริษัท', type: 'link' },
{ path: '/portal-manage/mylearn/employee-manage', title: 'จัดการพนักงาน', type: 'link' },
{ path: '/portal-manage/mylearn/management-user', title: 'การจัดการผู้ใช้งาน', type: 'link' },
{ path: '/portal-manage/mylearn/course-transfer', title: 'โอนย้ายคอร์ส', type: 'link' },
{ path: '/portal-manage/mylearn/timeout-screen-manage', title: 'จัดการเวลาหน้าจอ', type: 'link' },
......
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