feat: hr-org 新增 supervisorIndex(從組織資料查主管)
CI / build (push) Successful in 33s

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01VDJVpPiGiWjJP1yVvvGhzQ
This commit is contained in:
2026-11-03 02:47:18 +00:00
co-authored by Claude Opus 5
parent 387bf55114
commit edf625b0b4
+21
View File
@@ -1,3 +1,24 @@
// HR 的主管掛在組織單位上(集團/公司/部/組),一個人可能同時是多個單位的主管,
// 也可能是「次要」主管。兩者都算管理職。
export function supervisorIndex(organizations) {
const index = new Map();
for (const unit of Array.isArray(organizations) ? organizations : []) {
for (const supervisor of Array.isArray(unit?.supervisors) ? unit.supervisors : []) {
const number = supervisor?.EmployeeNumber;
if (!number) continue;
const entry = index.get(String(number)) || [];
entry.push({
deptCode: unit.deptCode,
deptName: unit.deptName,
levelName: unit.levelName,
secondary: supervisor.HierachyRelationshipName === '次要',
});
index.set(String(number), entry);
}
}
return index;
}
// Classify only units explicitly marked as a department or group in HR's tree.
export function splitOrganization(employee, organizations) {
const byCode = new Map(organizations.map(unit => [unit.deptCode, unit]));