From 34b82bdbe72ea28f0ebc01d0151ca52e36dd3dc2 Mon Sep 17 00:00:00 2001 From: selfrelease Date: Sat, 15 Aug 2026 15:06:23 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=BB=BA=E7=AB=8B=E9=83=A8=E9=97=A8?= =?UTF-8?q?=E5=92=8C=E8=81=8C=E5=8A=A1=E5=85=B3=E8=81=94=E5=85=B3=E7=B3=BB?= =?UTF-8?q?=EF=BC=8C=E8=B0=83=E5=8A=A8=E6=97=B6=E6=8C=89=E9=83=A8=E9=97=A8?= =?UTF-8?q?=E8=BF=87=E6=BB=A4=E5=8F=AF=E9=80=89=E8=81=8C=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 17个部门专属职务绑定到对应部门(如工人→项目运营中心、会计→财务部) - 8个通用职务保持不绑定(部门经理/主管/组长等,所有部门可用) - 前端调动弹窗优化职务过滤:通用职务 + 该部门专属 + 父部门专属(子部门继承) Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com> --- frontend/src/pages/roster/modals.tsx | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/frontend/src/pages/roster/modals.tsx b/frontend/src/pages/roster/modals.tsx index 6d63023..6bf9523 100644 --- a/frontend/src/pages/roster/modals.tsx +++ b/frontend/src/pages/roster/modals.tsx @@ -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)