diff --git a/src/controllers/OrganizationController.ts b/src/controllers/OrganizationController.ts index 18a65e8d..da712e14 100644 --- a/src/controllers/OrganizationController.ts +++ b/src/controllers/OrganizationController.ts @@ -1973,6 +1973,8 @@ 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; const profile = await this.profileRepo.findOne({ @@ -1986,6 +1988,8 @@ 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); } @@ -1993,7 +1997,7 @@ export class OrganizationController extends Controller { const isCurrentActive = !orgRevision.orgRevisionIsDraft && orgRevision.orgRevisionIsCurrent; if (isCurrentActive) { - if (profileAssign) { + if (profileAssign && _privilege.privilege !== "OWNER") { _data.root = [profile.current_holders.find((x) => x.orgRevisionId === id)?.orgRootId]; } else { if (!attrOwnership) _data = _privilege;