From c7c2f3a6c266a20fe8039ffcc132a23e4ddcfe95 Mon Sep 17 00:00:00 2001 From: harid Date: Wed, 4 Mar 2026 14:39:02 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=A3=E0=B8=B2=E0=B8=A2=E0=B8=81=E0=B8=B2?= =?UTF-8?q?=E0=B8=A3=E0=B8=AD=E0=B8=AD=E0=B8=81=E0=B8=84=E0=B8=B3=E0=B8=AA?= =?UTF-8?q?=E0=B8=B1=E0=B9=88=E0=B8=87=20owner=20=E0=B9=80=E0=B8=AB?= =?UTF-8?q?=E0=B9=87=E0=B8=99=E0=B8=AB=E0=B8=A1=E0=B8=94=20=20#1551=20&=20?= =?UTF-8?q?Fix=20Bug=20=E0=B8=A5=E0=B8=B9=E0=B8=81=E0=B8=88=E0=B9=89?= =?UTF-8?q?=E0=B8=B2=E0=B8=87=E0=B8=9B=E0=B8=A3=E0=B8=B0=E0=B8=88=E0=B8=B3?= =?UTF-8?q?=E0=B8=AA=E0=B8=A1=E0=B8=B1=E0=B8=84=E0=B8=A3=E0=B8=AA=E0=B8=AD?= =?UTF-8?q?=E0=B8=9A=E0=B9=80=E0=B8=9B=E0=B9=87=E0=B8=99=20=E0=B8=82?= =?UTF-8?q?=E0=B8=A3=E0=B8=81.=20#2343?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/CommandController.ts | 31 ++++++++++++++++------------ 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index 857d6d55..a62ddadc 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -187,17 +187,27 @@ export class CommandController extends Controller { (x) => x.orgRevision?.orgRevisionIsCurrent == true && x.orgRevision?.orgRevisionIsDraft == false, )[0]?.isDirector || false; - if (isDirector) { - let _data: any = { + let _data: any = { root: null, child1: null, child2: null, child3: null, child4: null, }; - if (!request.user.role.includes("SUPER_ADMIN")) { - _data = await new permission().PermissionOrgList(request, "COMMAND"); - } + if (!request.user.role.includes("SUPER_ADMIN")) { + _data = await new permission().PermissionOrgList(request, "COMMAND"); + } + if (isDirector || _data.privilege == "OWNER") { + // let _data: any = { + // root: null, + // child1: null, + // child2: null, + // child3: null, + // child4: null, + // }; + // if (!request.user.role.includes("SUPER_ADMIN")) { + // _data = await new permission().PermissionOrgList(request, "COMMAND"); + // } const profiles = await this.profileRepository .createQueryBuilder("profile") .leftJoinAndSelect("profile.current_holders", "current_holders") @@ -6208,7 +6218,6 @@ export class CommandController extends Controller { }); const list = await getRoles(); if (!Array.isArray(list)) throw new Error("Failed. Cannot get role(s) data from the server."); - const _null: any = null; let _posNumCodeSit: string = ""; let _posNumCodeSitAbb: string = ""; const _command = await this.commandRepository.findOne({ @@ -6362,6 +6371,7 @@ export class CommandController extends Controller { relations: ["roleKeycloaks", "profileInsignias", "profileAvatars"], }); let _oldInsigniaIds: string[] = []; + //ลูกจ้างประจำ หรือ บุคคลภายนอก if (!profile) { //กรณีลูกจ้างประจำมาสอบเป็นข้าราชการ ต้อง update สถานะโปรไฟล์เดิม let profileEmployee: any = await this.profileEmployeeRepository.findOne({ @@ -6393,7 +6403,7 @@ export class CommandController extends Controller { await this.salaryHistoryRepo.save(history, { data: req }); if (profileEmployee.profileInsignias.length > 0) { - _oldInsigniaIds = profileEmployee.profileInsignias.filter().map((x: any) => x.id); + _oldInsigniaIds = profileEmployee.profileInsignias?.map((x: any) => x.id) ?? []; } await removeProfileInOrganize(profileEmployee.id, "EMPLOYEE"); if (profileEmployee.keycloak != null) { @@ -6469,7 +6479,7 @@ export class CommandController extends Controller { ["PLACEMENT_TRANSFER", "RETIRE_RESIGN"].includes(profile.leaveType) ) { if (profile.profileInsignias.length > 0) { - _oldInsigniaIds = profile.profileInsignias.map((x: any) => x.id); + _oldInsigniaIds = profile.profileInsignias?.map((x: any) => x.id) ?? []; } profile = Object.assign({ ...item.bodyProfile, ...meta }); profile.dateRetire = _dateRetire; @@ -6627,7 +6637,6 @@ export class CommandController extends Controller { }), ); } - //Certificates if (item.bodyCertificates && item.bodyCertificates.length > 0) { await Promise.all( @@ -6644,7 +6653,6 @@ export class CommandController extends Controller { }), ); } - //FamilyCouple if (item.bodyMarry != null) { const profileCouple = new ProfileFamilyCouple(); @@ -6666,7 +6674,6 @@ export class CommandController extends Controller { coupleHistory.profileFamilyCoupleId = profileCouple.id; await this.profileFamilyCoupleHistoryRepo.save(coupleHistory, { data: req }); } - //FamilyFather if (item.bodyFather != null) { const profileFather = new ProfileFamilyFather(); @@ -6687,7 +6694,6 @@ export class CommandController extends Controller { fatherHistory.profileFamilyFatherId = profileFather.id; await this.profileFamilyFatherHistoryRepo.save(fatherHistory, { data: req }); } - //FamilyMother if (item.bodyMother != null) { const profileMother = new ProfileFamilyMother(); @@ -6708,7 +6714,6 @@ export class CommandController extends Controller { motherHistory.profileFamilyMotherId = profileMother.id; await this.profileFamilyMotherHistoryRepo.save(motherHistory, { data: req }); } - //Salary if (item.bodySalarys && item.bodySalarys != null) { const dest_item = await this.salaryRepo.findOne({