diff --git a/src/controllers/OrganizationController.ts b/src/controllers/OrganizationController.ts index da712e14..71156c48 100644 --- a/src/controllers/OrganizationController.ts +++ b/src/controllers/OrganizationController.ts @@ -1973,7 +1973,6 @@ export class OrganizationController extends Controller { throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล"); } let _privilege = await new permission().PermissionOrgList(request, "SYS_ORG"); - // console.log("privilege>>>>",_privilege); const attrOwnership = _privilege.root === null ? true : false; @@ -1988,17 +1987,22 @@ export class OrganizationController extends Controller { ?.find((x) => x.orgRevisionId === id) ?.posMasterAssigns.find((x) => x.assignId === "SYS_ORG"); - // console.log("profileAssign>>>>",profileAssign); - if (orgRevision.orgRevisionIsDraft && !orgRevision.orgRevisionIsCurrent && !attrOwnership) { _data.root = profile.permissionProfiles.map((x) => x.orgRootId); } // กำหนดการเข้าถึงข้อมูลตามสถานะและสิทธิ์ const isCurrentActive = !orgRevision.orgRevisionIsDraft && orgRevision.orgRevisionIsCurrent; - if (isCurrentActive) { if (profileAssign && _privilege.privilege !== "OWNER") { - _data.root = [profile.current_holders.find((x) => x.orgRevisionId === id)?.orgRootId]; + if(_privilege.privilege == "NORMAL"){ + _data.root = [profile.current_holders.find((x) => x.orgRevisionId === id)?.orgRootId]; + _data.child1 = [profile.current_holders.find((x) => x.orgRevisionId === id)?.orgChild1Id]; + _data.child2 = [profile.current_holders.find((x) => x.orgRevisionId === id)?.orgChild2Id]; + _data.child3 = [profile.current_holders.find((x) => x.orgRevisionId === id)?.orgChild3Id]; + _data.child4 = [profile.current_holders.find((x) => x.orgRevisionId === id)?.orgChild4Id]; + }else{ + _data.root = [profile.current_holders.find((x) => x.orgRevisionId === id)?.orgRootId]; + } } else { if (!attrOwnership) _data = _privilege; } diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index d4e65f29..aebd8fa6 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -5262,6 +5262,7 @@ export class ProfileController extends Controller { if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์นี้"); Object.assign(record, body); + record.dateRetireLaw = calculateRetireLaw(record.birthDate); record.prefixMain = record.prefix; record.prefix = record.rank && record.rank.length > 0 ? record.rank : record.prefixMain; record.createdUserId = request.user.sub; diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index a7d905ad..52de0922 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -2002,6 +2002,7 @@ export class ProfileEmployeeController extends Controller { } Object.assign(record, body); + record.dateRetireLaw = calculateRetireLaw(record.birthDate); record.prefixMain = record.prefix; record.prefix = record.rank && record.rank.length > 0 ? record.rank : record.prefixMain; record.createdUserId = request.user.sub; diff --git a/src/controllers/ProfileEmployeeTempController.ts b/src/controllers/ProfileEmployeeTempController.ts index 46ef525b..6dc49b1a 100644 --- a/src/controllers/ProfileEmployeeTempController.ts +++ b/src/controllers/ProfileEmployeeTempController.ts @@ -994,6 +994,7 @@ export class ProfileEmployeeTempController extends Controller { } Object.assign(record, body); + record.dateRetireLaw = calculateRetireLaw(record.birthDate); record.prefixMain = record.prefix; record.createdUserId = request.user.sub; record.createdFullName = request.user.name;