fix ส่งรายชื่อไปยังรายการอื่น ๆ #2571
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m10s

This commit is contained in:
harid 2026-06-22 13:32:26 +07:00
parent bbc6a5e6a9
commit 00c35e8974
2 changed files with 181 additions and 78 deletions

View file

@ -6462,6 +6462,92 @@ export class ProfileEmployeeController extends Controller {
? null
: profile.current_holders.find((x) => x.orgRevisionId == orgRevisionPublish.id)?.orgChild4;
const _numPart = posMaster ? [posMaster.posMasterNoPrefix, posMaster.posMasterNo, posMaster.posMasterNoSuffix].filter((p) => p !== null && p !== undefined && p !== '').join(' ') : '';
// org / posNo — ล้อ fallback ของ officer (ProfileController.getProfileByProfileid)
// employee ไม่มี profile.org / profile.posMasterNo จึงแยกตาม isLeave โดยตรง
let _Org: string | null = null;
let _PosNo: string | null = null;
if (profile.isLeave) {
const profileWithSalary = await this.profileRepo.findOne({
where: {
id: id,
profileSalary: {
commandCode: In([
"0",
"9",
"1",
"2",
"3",
"4",
"8",
"10",
"11",
"12",
"13",
"14",
"15",
"16",
"20",
]),
},
},
relations: { profileSalary: true },
order: {
profileSalary: {
order: "DESC",
createdAt: "DESC",
},
},
});
const profileSalaryList = profileWithSalary?.profileSalary || [];
if (profileSalaryList.length > 0) {
const _profileSalary =
profile.leaveType == "RETIRE"
? profileSalaryList.length > 1
? profileSalaryList[1]
: profileSalaryList[0]
: profileSalaryList[0];
if (_profileSalary) {
_Org = [
_profileSalary.orgChild4 ?? null,
_profileSalary.orgChild3 ?? null,
_profileSalary.orgChild2 ?? null,
_profileSalary.orgChild1 ?? null,
_profileSalary.orgRoot ?? null,
]
.filter((x: any) => x !== undefined && x !== null)
.join("\n");
_PosNo = `${_profileSalary.posNoAbb} ${_profileSalary.posNo}`;
}
}
} else {
_Org = [
child4?.orgChild4Name,
child3?.orgChild3Name,
child2?.orgChild2Name,
child1?.orgChild1Name,
root?.orgRootName,
]
.filter((x) => x != null && x !== "")
.join("\n");
_PosNo =
posMaster == null
? null
: child4 != null
? `${child4.orgChild4ShortName} ${_numPart}`
: child3 != null
? `${child3.orgChild3ShortName} ${_numPart}`
: child2 != null
? `${child2.orgChild2ShortName} ${_numPart}`
: child1 != null
? `${child1.orgChild1ShortName} ${_numPart}`
: root != null
? `${root.orgRootShortName} ${_numPart}`
: null;
}
const _profile: any = {
profileId: profile.id,
prefix: profile.prefix,
@ -6474,7 +6560,7 @@ export class ProfileEmployeeController extends Controller {
position: profile.position,
leaveDate: profile.dateLeave,
posMasterNo: posMaster == null ? null : posMaster.posMasterNo,
posLevelName: `${profile?.posType?.posTypeShortName ?? ""} ${profile?.posLevel?.posLevelName ?? ""}`,
posLevelName: `${profile?.posType?.posTypeShortName ?? ""} ${profile?.posLevel?.posLevelName ?? ""}`.trim(),
posLevelRank: profile.posLevel == null ? null : profile.posLevel.posLevelRank,
posLevelId: profile.posLevel == null ? null : profile.posLevel.id,
posTypeName: profile.posType == null ? null : profile.posType.posTypeName,
@ -6503,7 +6589,8 @@ export class ProfileEmployeeController extends Controller {
child4ShortName: child4 == null ? null : child4.orgChild4ShortName,
node: null,
nodeId: null,
posNo: null,
posNo: _PosNo,
org: _Org,
salary: profile.amount,
education:
profile && profile.profileEducations.length > 0
@ -6518,27 +6605,22 @@ export class ProfileEmployeeController extends Controller {
_profile.node = 4;
_profile.nodeId = _profile.child4Id;
_profile.nodeShortName = _profile.child4ShortName;
_profile.posNo = `${_profile.child4ShortName} ${_numPart}`;
} else if (_profile.child3Id != null) {
_profile.node = 3;
_profile.nodeId = _profile.child3Id;
_profile.nodeShortName = _profile.child3ShortName;
_profile.posNo = `${_profile.child3ShortName} ${_numPart}`;
} else if (_profile.child2Id != null) {
_profile.node = 2;
_profile.nodeId = _profile.child2Id;
_profile.nodeShortName = _profile.child2ShortName;
_profile.posNo = `${_profile.child2ShortName} ${_numPart}`;
} else if (_profile.child1Id != null) {
_profile.node = 1;
_profile.nodeId = _profile.child1Id;
_profile.nodeShortName = _profile.child1ShortName;
_profile.posNo = `${_profile.child1ShortName} ${_numPart}`;
} else if (_profile.rootId != null) {
_profile.node = 0;
_profile.nodeId = _profile.rootId;
_profile.nodeShortName = _profile.rootShortName;
_profile.posNo = `${_profile.rootShortName} ${_numPart}`;
}
return new HttpSuccess(_profile);
}