From 29de22b5758f61543f460587c0c453016489a1d4 Mon Sep 17 00:00:00 2001 From: yueli Date: Fri, 17 Jul 2026 16:22:59 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20crossDomain=20=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E6=94=B6=E9=9B=86=20=E2=80=94=20=E7=9C=9F=E5=AE=9E=E6=A0=91?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=20system=5Fmgmt/crossDomain=20=E4=B8=8E?= =?UTF-8?q?=E8=99=9A=E6=8B=9F=20global=5Fprivileges=20=E5=86=B2=E7=AA=81?= =?UTF-8?q?=EF=BC=8C=E4=BB=8E=E7=9C=9F=E5=AE=9E=E6=A0=91=E4=B8=AD=E7=A7=BB?= =?UTF-8?q?=E9=99=A4=20crossDomain=20=E9=81=BF=E5=85=8D=E5=8F=8C=E9=87=8D?= =?UTF-8?q?=E6=94=B6=E9=9B=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/services/permission_service.py | 11 ---------- .../src/views/system/PermissionConfig.vue | 20 ++++++++++++------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/inventory-backend/app/services/permission_service.py b/inventory-backend/app/services/permission_service.py index a89c5ba..9024154 100644 --- a/inventory-backend/app/services/permission_service.py +++ b/inventory-backend/app/services/permission_service.py @@ -152,9 +152,6 @@ class PermissionService: ) ).all() - crossDomain_deleted = any(p.target_code == 'crossDomain' for p in old_perms) - print(f"[权限保存] company_name={repr(company_name)} role={role_code}") - print(f"[权限保存] 删除旧权限 {len(old_perms)} 条, crossDomain 在其中: {crossDomain_deleted}") for p in old_perms: db.session.delete(p) @@ -183,16 +180,8 @@ class PermissionService: if new_records: session.add_all(new_records) - crossDomain_inserted = 'crossDomain' in (permissions or []) - print(f"[权限保存] 新权限 {len(permissions or [])} 条, crossDomain 在提交列表中: {crossDomain_inserted}") - # 4. 提交 session.commit() - # 验证:提交后 crossDomain 是否还在 - after = SysRolePermission.query.filter_by( - role_code=role_code, target_code='crossDomain' - ).first() - print(f"[权限保存] 提交后 crossDomain 仍在: {after is not None} (company_name={repr(after.company_name) if after else 'N/A'})") return True except SQLAlchemyError as e: diff --git a/inventory-web/src/views/system/PermissionConfig.vue b/inventory-web/src/views/system/PermissionConfig.vue index 6926289..d421657 100644 --- a/inventory-web/src/views/system/PermissionConfig.vue +++ b/inventory-web/src/views/system/PermissionConfig.vue @@ -256,8 +256,19 @@ const fetchTree = async () => { ] }; // 将虚拟节点放在最前面,然后交给 transformData 处理 - const rawData = [globalNode, ...(res.data || [])]; - + // ★ 从真实树中移除 crossDomain(已由虚拟节点 global_privileges 统一管理,避免重复) + const stripCrossDomain = (nodes: any[]) => { + nodes.forEach(node => { + if (node.children) { + node.children = node.children.filter((c: any) => c.code !== 'crossDomain') + stripCrossDomain(node.children) + } + }) + } + const realData = res.data || [] + stripCrossDomain(realData) + const rawData = [globalNode, ...realData]; + rawTreeData.value = rawData; tableData.value = transformData(rawData); } @@ -468,13 +479,8 @@ const handleSave = async () => { // 2. 操作权限 (crossDomain 不依赖页面可读) if (row.hasWrite && row.operationCode) { if (row.operationCode === 'crossDomain' || row.hasRead) { - if (row.operationCode === 'crossDomain') { - console.log('[DEBUG crossDomain] hasWrite=true, 将被加入提交列表. row.code=', row.code) - } permissions.push(row.operationCode) } - } else if (row.operationCode === 'crossDomain') { - console.log('[DEBUG crossDomain] hasWrite=', row.hasWrite, ', hasRead=', row.hasRead, ', 不会被加入提交列表') } // 3. 字段权限 (只有当页面可读时才有效)