feat: 同步权限管理、企业成员排行与消费计费明细
- 接入平台与企业角色权限,按权限展示菜单、页面及操作。 - 企业成员排行按需加载,翻页沿用同一榜单快照,保留连续名次与前三名样式。 - 更新消费日志的费用明细、超管指标和官方价格汇率设置,补齐翻译与回归测试。
This commit is contained in:
@@ -31,12 +31,22 @@ import {
|
||||
Check,
|
||||
Activity,
|
||||
Route as RouteIcon,
|
||||
UserCog,
|
||||
} from 'lucide-react';
|
||||
import { useSidebarCollapsed } from '../../hooks/common/useSidebarCollapsed';
|
||||
import { StatusContext } from '../../context/Status';
|
||||
import { normalizeSidebarModulesAdmin } from '../../constants/sidebarModules';
|
||||
import { canAccessOrgSettings } from './orgFeatureFlags';
|
||||
import OrgCommissionNavigation from './OrgCommissionNavigation';
|
||||
import { usePerm, useAuthzView } from '../../authz';
|
||||
import {
|
||||
gateOrgRoute,
|
||||
hasEnforcedModules,
|
||||
isOrgMenuEnforced,
|
||||
orgGroupLayout,
|
||||
orgMenuLayout,
|
||||
orgRouteKey,
|
||||
} from './orgMenuAccess';
|
||||
import {
|
||||
isMiniProgramPaymentPath,
|
||||
isMiniProgramWebView,
|
||||
@@ -91,6 +101,8 @@ const OrgSidebar = ({
|
||||
canViewSmartRouter = false,
|
||||
smartRouterConsentOnly = false,
|
||||
isMemberActor = true,
|
||||
// 路由守卫算好的可进入表(Organization/index.jsx 的 routeAccess):已切到新体系的菜单以它为准,保证与路由一致
|
||||
routeAccess = null,
|
||||
onNavigate,
|
||||
mobile = false,
|
||||
}) => {
|
||||
@@ -107,10 +119,17 @@ const OrgSidebar = ({
|
||||
[statusState?.status?.SidebarModulesAdmin],
|
||||
);
|
||||
|
||||
// 企业视图(权限重构 P2-7):有模块切到新体系后,菜单显示、名称、分组与排序按后端菜单树
|
||||
// (/api/authz/me 的 menus);未切换的菜单沿用下方的旧判断
|
||||
const orgView = useAuthzView('org');
|
||||
const menuTreeMode = hasEnforcedModules(orgView);
|
||||
|
||||
const isAdmin =
|
||||
orgRole === 'owner' || orgRole === 'admin' || orgRole === 'super_admin';
|
||||
// owner/超管可管理完整设置;普通管理员仅在平台授权数据安全自助配置时进入该页。
|
||||
const canManageSettings = canAccessOrgSettings(orgRole, featureFlags);
|
||||
// 角色管理入口:只在角色模块已切新体系时按 org.role.query 显示;未切换时企业角色不生效,不提供入口
|
||||
const canQueryRoles = usePerm('org.role.query', false);
|
||||
const roleLabel = useMemo(() => {
|
||||
if (orgRole === 'super_admin') return t('超级管理员');
|
||||
if (orgRole === 'owner') return t('所有者');
|
||||
@@ -123,17 +142,28 @@ const OrgSidebar = ({
|
||||
}, [t, orgRole, isDeptManager, isProjectManager]);
|
||||
|
||||
// 菜单分组(云平台风格的分组导航,给扁平的十几个入口建立层次)
|
||||
const groups = useMemo(
|
||||
() => [
|
||||
const groups = useMemo(() => {
|
||||
const base = [
|
||||
{ key: 'overview', label: t('概览') },
|
||||
{ key: 'ai', label: t('AI 能力管理') },
|
||||
{ key: 'org', label: t('组织管理') },
|
||||
{ key: 'governance', label: t('额度与治理') },
|
||||
{ key: 'records', label: t('财务与日志') },
|
||||
{ key: 'settings', label: t('系统设置') },
|
||||
],
|
||||
[t],
|
||||
);
|
||||
];
|
||||
if (!menuTreeMode) return base;
|
||||
// 菜单树模式:分组即后端目录,名称与排序取后端(未持有该目录时用前端文案与默认排序)
|
||||
return base
|
||||
.map((g) => {
|
||||
const layout = orgGroupLayout(orgView, g.key);
|
||||
return {
|
||||
...g,
|
||||
label: layout.name ? t(layout.name) : g.label,
|
||||
sort: layout.sort,
|
||||
};
|
||||
})
|
||||
.sort((a, b) => a.sort - b.sort);
|
||||
}, [t, menuTreeMode, orgView]);
|
||||
|
||||
// 统一单一品牌色高亮(云平台风格),不再每项一种颜色
|
||||
const items = useMemo(() => {
|
||||
@@ -250,9 +280,16 @@ const OrgSidebar = ({
|
||||
group: 'org',
|
||||
adminOnly: true,
|
||||
},
|
||||
{
|
||||
itemKey: '/org/roles',
|
||||
text: t('角色管理'),
|
||||
icon: UserCog,
|
||||
group: 'org',
|
||||
roleManage: true,
|
||||
},
|
||||
{
|
||||
itemKey: '/org/dept-manage',
|
||||
text: t('部门管理'),
|
||||
text: t('我管辖的部门'),
|
||||
icon: Network,
|
||||
group: 'org',
|
||||
deptScope: true,
|
||||
@@ -266,7 +303,7 @@ const OrgSidebar = ({
|
||||
},
|
||||
{
|
||||
itemKey: '/org/departments',
|
||||
text: t('组织架构'),
|
||||
text: t('部门管理'),
|
||||
icon: Network,
|
||||
group: 'org',
|
||||
adminOnly: true,
|
||||
@@ -293,7 +330,7 @@ const OrgSidebar = ({
|
||||
},
|
||||
{
|
||||
itemKey: '/org/tokens',
|
||||
text: t('密钥管理'),
|
||||
text: t('令牌管理'),
|
||||
icon: Key,
|
||||
group: 'governance',
|
||||
},
|
||||
@@ -366,14 +403,26 @@ const OrgSidebar = ({
|
||||
'/org/settings': 'settings',
|
||||
};
|
||||
|
||||
return all.filter((item) => {
|
||||
const visible = all.filter((item) => {
|
||||
if (!CLOUD_BRAIN_UI_ENABLED && isCloudBrainOrgPath(item.itemKey)) {
|
||||
return false;
|
||||
}
|
||||
if (item.adminOnly && !isAdmin) return false;
|
||||
// WeyAi 小程序里不出现付费入口(helpers/miniProgram.js)。
|
||||
if (isMiniProgramWebView() && isMiniProgramPaymentPath(item.itemKey))
|
||||
return false;
|
||||
// 仅授权模式:功能已关闭但所有者仍有生效中的出境同意,入口保留以便撤回(与路由守卫同口径)
|
||||
if (item.itemKey === '/org/smart-router' && smartRouterConsentOnly)
|
||||
return true;
|
||||
// 菜单所属模块已切到新体系:以菜单树为准(与路由守卫共用 routeAccess),不再看角色与 can_*。
|
||||
// 后端目录里没有对应菜单的入口(如企业分佣)不会进入该分支,继续走下面的旧判断
|
||||
const routeKey = orgRouteKey(item.itemKey);
|
||||
if (isOrgMenuEnforced(orgView, routeKey)) {
|
||||
return routeAccess
|
||||
? !!routeAccess[routeKey]
|
||||
: gateOrgRoute(orgView, routeKey, false);
|
||||
}
|
||||
if (item.adminOnly && !isAdmin) return false;
|
||||
if (item.roleManage && !canQueryRoles) return false;
|
||||
// 平台超管(无成员身份)访问成员型入口必被 member_actor_required 拒绝。
|
||||
if (!isMemberActor && item.itemKey === '/org/my-capabilities')
|
||||
return false;
|
||||
@@ -398,9 +447,6 @@ const OrgSidebar = ({
|
||||
if (item.effectView && !canViewAgentEffect) return false;
|
||||
if (item.qualityView && !canViewQuality) return false;
|
||||
if (item.commissionAccess && !canViewCommission) return false;
|
||||
// 仅授权模式:功能已关闭但所有者仍有生效中的出境同意,入口保留以便撤回(与路由守卫同口径)
|
||||
if (item.itemKey === '/org/smart-router' && smartRouterConsentOnly)
|
||||
return true;
|
||||
if (item.smartRouterView && !canViewSmartRouter) return false;
|
||||
if (item.connectorManage && !canManageConnectors) return false;
|
||||
// 与路由守卫一致:管理员只有 data_security 授权后才显示设置入口。
|
||||
@@ -439,9 +485,24 @@ const OrgSidebar = ({
|
||||
isFeatureEnabled(featureFlags, requiredFeature)
|
||||
);
|
||||
});
|
||||
if (!menuTreeMode) return visible;
|
||||
// 菜单树模式:分组按后端目录、名称与排序取后端;未切换的菜单按目录默认位置排列
|
||||
return visible
|
||||
.map((item) => {
|
||||
const layout = orgMenuLayout(orgView, orgRouteKey(item.itemKey));
|
||||
if (!layout) return item;
|
||||
return {
|
||||
...item,
|
||||
group: layout.group || item.group,
|
||||
sort: layout.sort,
|
||||
text: layout.name ? t(layout.name) : item.text,
|
||||
};
|
||||
})
|
||||
.sort((a, b) => (a.sort ?? 0) - (b.sort ?? 0));
|
||||
}, [
|
||||
t,
|
||||
isAdmin,
|
||||
canQueryRoles,
|
||||
canManageSettings,
|
||||
isDeptManager,
|
||||
isProjectManager,
|
||||
@@ -459,6 +520,9 @@ const OrgSidebar = ({
|
||||
canManageConnectors,
|
||||
orgConfig,
|
||||
featureFlags,
|
||||
orgView,
|
||||
menuTreeMode,
|
||||
routeAccess,
|
||||
]);
|
||||
|
||||
// 按分组聚合,保持 groups 顺序,自动跳过空组
|
||||
|
||||
Reference in New Issue
Block a user