feat: 建立部门和职务关联关系,调动时按部门过滤可选职务

- 17个部门专属职务绑定到对应部门(如工人→项目运营中心、会计→财务部)
- 8个通用职务保持不绑定(部门经理/主管/组长等,所有部门可用)
- 前端调动弹窗优化职务过滤:通用职务 + 该部门专属 + 父部门专属(子部门继承)

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
selfrelease
2026-08-15 15:06:23 +08:00
parent e3d46d9142
commit 34b82bdbe7
+15 -2
View File
@@ -110,9 +110,22 @@ export function DeptChangeModal({ employee, onClose, onSubmit, loading, error }:
}
buildDeptOptions(departments, null, 0)
// 选中新部门后,过滤该部门下的职务(如果职务有 departmentId 关联)
// 选中新部门后,过滤该部门下的职务
// 1. 通用职务(departmentId 为空)所有部门可用
// 2. 该部门专属职务
// 3. 父部门专属职务(子部门继承父部门职务,如铁矿继承项目运营中心的工人/施工员等)
const getDeptAncestorIds = (deptId: string): string[] => {
const ids: string[] = []
let cur: any = departments.find((d: any) => d.id === deptId)
while (cur) {
ids.push(cur.id)
cur = cur.parentId ? departments.find((d: any) => d.id === cur.parentId) : null
}
return ids
}
const ancestorIds = form.departmentId ? getDeptAncestorIds(form.departmentId) : []
const filteredPositions = form.departmentId
? positions.filter((p: any) => !p.departmentId || p.departmentId === form.departmentId)
? positions.filter((p: any) => !p.departmentId || ancestorIds.includes(p.departmentId))
: positions
const selectedDept = departments.find((d: any) => d.id === form.departmentId)