- {summary.recent_requests.map((r) => (
-
-
-
- {r.request_type === 'quota'
- ? t('提额申请')
- : r.request_type}
- {r.reason ? ` · ${r.reason}` : ''}
-
-
-
- {r.created_at ? timestamp2string(r.created_at) : ''}
-
-
-
- {reqStatusTag(t, r.status)}
+ summary.recent_requests.map((r) => (
+
+
+
+
+
+
+ {r.request_type === 'quota' ? t('提额申请') : r.request_type}
+ {r.reason ? ` · ${r.reason}` : ''}
+
+
+ {r.created_at ? timestamp2string(r.created_at) : ''}
+
- ))}
-
+ {reqStatusTag(t, r.status)}
+
+ ))
) : (
)}
-
+
{/* 提额申请弹窗 */}
{
okText={t('提交申请')}
cancelText={t('取消')}
>
-
-
- {t(
+ extraText={t(
'个人额度用于解除您自己的使用上限;部门/项目额度属于预算上限,可能有独立周期。',
)}
-
+ style={{ width: '100%' }}
+ />
{
]}
style={{ width: '100%' }}
/>
-
+
diff --git a/src/pages/Organization/components/OrgAnalyticsPanel.jsx b/src/pages/Organization/components/OrgAnalyticsPanel.jsx
index 1a4448ca..7faaf2e9 100644
--- a/src/pages/Organization/components/OrgAnalyticsPanel.jsx
+++ b/src/pages/Organization/components/OrgAnalyticsPanel.jsx
@@ -19,30 +19,23 @@ For commercial licensing, please contact support@quantumnous.com
import React, { useCallback, useEffect, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import {
- Table,
- Button,
- Select,
- Empty,
- Spin,
- Progress,
- Typography,
-} from '@/components/ui';
-import OrgPanel from './OrgPanel';
+ Button as AntButton,
+ Card as AntCard,
+ Segmented,
+ Select as AntSelect,
+ Tabs as AntTabs,
+ Tag as AntTag,
+} from 'antd';
+import { Table, Empty, Spin, Progress } from '@/components/ui';
+import '../../../styles/org-center.css';
import { VChart } from '@visactor/react-vchart';
import { initVChartTheme } from '@/components/ui/chartTheme';
-import {
- RefreshCw,
- PieChart,
- TrendingUp,
- BarChart3,
- Crown,
-} from 'lucide-react';
+import { RefreshCw } from 'lucide-react';
import { API } from '../../../helpers/api';
import { showError } from '../../../helpers';
import { renderQuota } from '../../../helpers/render';
import { useActualTheme } from '../../../context/Theme';
-const { Text } = Typography;
const getOrgHeaders = (orgId) => ({ 'X-Org-Id': String(orgId) });
/* 系列色运行时读取品牌 token(--brand-*),随主题预设整套切换。
@@ -95,37 +88,20 @@ const chartGrid = (tokens) => ({
style: { stroke: tokens.grid, lineDash: [4, 4] },
});
-// 环比徽标:本期 vs 上期。增长绿、下降红;无上期数据时灰显。
-// 状态色统一走 Semi 语义 token(与页面各处使用进度条同一套红绿,且随明暗主题自适应)。
+// 环比徽标:本期 vs 上期。增长绿、下降红;无上期数据时灰显(语义色沿用原实现)。
const DeltaBadge = ({ cur, prev, t }) => {
if (!prev || prev <= 0) {
- return
{t('无上期对比')};
+ return
{t('无上期对比')};
}
const pct = ((cur - prev) / prev) * 100;
const up = pct >= 0;
return (
-
- {up ? '▲' : '▼'} {Math.abs(pct).toFixed(1)}%
- {t('较上期')}
-
+
+ {up ? '↑' : '↓'} {Math.abs(pct).toFixed(1)}%{t('较上期')}
+
);
};
-const KpiCard = ({ label, value, sub }) => (
-
-
{label}
-
- {value}
-
- {sub ?
{sub}
: null}
-
-);
-
// 把 time 维度的小时行聚合成趋势序列:>7 天按天汇总,否则按小时。
const buildTrend = (rows, rangeDays, field) => {
if (!rows || rows.length === 0) return [];
@@ -156,20 +132,28 @@ const localizeAnalyticsRows = (rows, dimension, t) =>
department: t('未分配部门'),
project: t('未绑定项目'),
member: t('未归属成员'),
- token: t('未绑定令牌'),
+ token: t('未绑定密钥'),
}[dimension];
if (zeroName) name = zeroName;
} else if (dimension === 'member' && name === `成员#${row.key}`) {
name = `${t('成员')}#${row.key}`;
- } else if (dimension === 'token' && name === `令牌#${row.key}`) {
- name = `${t('令牌')}#${row.key}`;
+ } else if (dimension === 'token' && name === `\u4ee4\u724c#${row.key}`) {
+ name = `${t('密钥')}#${row.key}`;
}
return name === row.name ? row : { ...row, name };
});
// 多维用量分析面板(§5.6):经营看板视角——KPI+环比、消耗趋势折线、维度分布柱状、明细表。
// 仅 admin + analytics 特性开启时挂载(前端门控),后端接口仍 admin+feature 鉴权。
-const OrgAnalyticsPanel = ({ orgId }) => {
+// memberUsage:数据看板传入的“成员用量明细”卡,作为明细页签之一(原型 .ea-detail-tabs);
+// detailTab / onDetailTabChange:明细页签受控(数据看板“成员用量”按钮切换并定位)。
+const OrgAnalyticsPanel = ({
+ orgId,
+ memberUsage = null,
+ detailTab,
+ onDetailTabChange,
+ detailsRef,
+}) => {
const { t } = useTranslation();
const actualTheme = useActualTheme();
const isDarkMode = actualTheme === 'dark';
@@ -189,6 +173,11 @@ const OrgAnalyticsPanel = ({ orgId }) => {
const [trendRows, setTrendRows] = useState([]);
const [prevRows, setPrevRows] = useState([]);
const [loading, setLoading] = useState(false);
+ const [detailPage, setDetailPage] = useState(1);
+
+ useEffect(() => {
+ setDetailPage(1);
+ }, [breakdownRows, dimension, rangeDays]);
useEffect(() => {
initVChartTheme({ isWatchingThemeSwitch: true });
@@ -200,7 +189,7 @@ const OrgAnalyticsPanel = ({ orgId }) => {
{ label: t('项目'), value: 'project' },
{ label: t('部门'), value: 'department' },
{ label: t('成员'), value: 'member' },
- { label: t('令牌'), value: 'token' },
+ { label: t('密钥'), value: 'token' },
{ label: t('时间'), value: 'time' },
],
[t],
@@ -298,7 +287,11 @@ const OrgAnalyticsPanel = ({ orgId }) => {
data: [{ id: 'trend', values: trendData }],
xField: 'date',
yField: 'value',
- point: { visible: trendData.length <= 60, size: 3 },
+ point: {
+ visible: trendData.length <= 60,
+ size: 3,
+ style: { fill: brandColors.brand },
+ },
line: { style: { lineWidth: 2, stroke: brandColors.brand } },
area: {
style: {
@@ -375,7 +368,7 @@ const OrgAnalyticsPanel = ({ orgId }) => {
direction: 'horizontal',
xField: 'value',
yField: 'name',
- color: [brandColors.brand2],
+ color: [brandColors.brand],
barMaxWidth: 22,
label: {
visible: true,
@@ -428,33 +421,52 @@ const OrgAnalyticsPanel = ({ orgId }) => {
);
const columns = useMemo(
() => [
- { title: dimLabel, dataIndex: 'name', width: 200 },
{
- title: t('消耗占比'),
+ title: dimLabel,
+ dataIndex: 'name',
+ width: 228,
+ render: (v) =>
{v},
+ },
+ {
+ title: t('消费占比'),
+ width: 300,
render: (_, r) => {
const pct =
breakdownTotal > 0 ? ((r.quota || 0) / breakdownTotal) * 100 : 0;
return (
-
+
+
+ {renderQuota(r.quota || 0, 2)}
+ {pct.toFixed(1)}%
+
-
- {renderQuota(r.quota || 0, 2)} ({pct.toFixed(1)}%)
-
);
},
},
- { title: t('请求数'), dataIndex: 'request_count', width: 100 },
{
- title: t('Token (入/出)'),
- width: 160,
- render: (_, r) =>
- `${r.prompt_tokens || 0} / ${r.completion_tokens || 0}`,
+ title: t('请求数'),
+ dataIndex: 'request_count',
+ width: 110,
+ align: 'right',
+ render: (v) => Number(v || 0).toLocaleString(),
+ },
+ {
+ title: t('Token(入 / 出)'),
+ width: 240,
+ align: 'right',
+ render: (_, r) => (
+
+ {Number(r.prompt_tokens || 0).toLocaleString()}
+ /
+ {Number(r.completion_tokens || 0).toLocaleString()}
+
+ ),
},
],
[dimLabel, breakdownTotal, t, brandColors],
@@ -466,180 +478,215 @@ const OrgAnalyticsPanel = ({ orgId }) => {
{ label: t('近 90 天'), value: 90 },
];
+ const [innerTab, setInnerTab] = useState('models');
+ const activeDetail = detailTab ?? innerTab;
+ const changeDetail = (key) => {
+ setInnerTab(key);
+ onDetailTabChange?.(key);
+ };
+
+ const detailCard = (
+
+
+
{t('{{dim}}明细', { dim: dimLabel })}
+
+ {loading ? (
+
+
+
+ ) : breakdownRows.length === 0 ? (
+
+ ) : (
+ t('共 {{total}} 条', { total: n }),
+ }}
+ />
+ )}
+
+ );
+
return (
-
- {/* 控制区 */}
-
-
-
-
-
{t('企业用量分析')}
-
- {t('趋势 · 结构 · 与消耗明细一致')}
-
+ <>
+ {/* 多维用量分析(原型 .ea-analysis):标题 + 维度 / 时间 / 刷新 */}
+
+
+
+
{t('多维用量分析')}
+
{t('趋势、结构与调用明细')}
-
-
-
-
- {/* KPI + 环比 */}
-
- }
- />
- }
- />
- 0 ? curQuota / rangeDays : 0, 2)}
- sub={
-
- {t('近 {{n}} 天均值', { n: rangeDays })}
-
- }
- />
-
- {renderQuota(topRow.quota || 0, 2)}
-
- ) : (
-
- {dimension === 'time' ? t('按时间维度无排名') : '-'}
-
- )
- }
- />
-
-
-
- {/* 消耗趋势折线 */}
-
-
- {loading ? (
-
-
-
- ) : trendSpec ? (
-
-
- ) : (
-
- )}
-
+
- {/* 维度分布柱状(time 维度不展示,趋势图已覆盖) */}
- {dimension !== 'time' && (
-
-
-
-
{t('{{dim}}消耗分布', { dim: dimLabel })}
-
- {t('Top 10')}
-
+ {/* 汇总指标(原型 .ea-summary) */}
+
+
+ {t('本期总消费')}
+ {renderQuota(curQuota, 2)}
+
- {loading ? (
-
-
-
- ) : barSpec ? (
-
-
+ {t('本期总请求')}
+ {curReq.toLocaleString()}
+
+
+
+ {t('日均消费')}
+
+ {renderQuota(rangeDays > 0 ? curQuota / rangeDays : 0, 2)}
+
+ {t('近 {{n}} 天均值', { n: rangeDays })}
+
+
+ {t('消费最高')}
+ {topRow ? topRow.name : '-'}
+
+ {topRow
+ ? renderQuota(topRow.quota || 0, 2)
+ : dimension === 'time'
+ ? t('按时间维度无排名')
+ : '-'}
+
+
+
+
+
+ {/* 用量趋势 */}
+
+
+
+
{t('用量趋势')}
+
+ {rangeDays > 7
+ ? t('按天查看企业调用消耗')
+ : t('逐小时查看企业调用消耗')}
+
+
+
- ) : (
-
- )}
-
- )}
+ {loading ? (
+
+
+
+ ) : trendSpec ? (
+
+ ) : (
+
+ )}
+
- {/* 明细表 */}
-
-
-
{t('{{dim}}明细', { dim: dimLabel })}
+ {/* 维度分布柱状(time 维度不展示,趋势图已覆盖) */}
+ {dimension !== 'time' && (
+
+
+
+
{t('{{dim}}消费分布', { dim: dimLabel })}
+ {t('Top 10')}
+
+
{t('按消费排序')}
+
+ {loading ? (
+
+
+
+ ) : barSpec ? (
+
+ ) : (
+
+ )}
+
+ )}
- {loading ? (
-
-
-
- ) : breakdownRows.length === 0 ? (
-
- ) : (
- 20
- ? { pageSize: 20, showSizeChanger: false }
- : false
- }
- />
- )}
-
-
+
+
+ {/* 明细(原型 .ea-details:维度明细 / 成员用量 页签) */}
+
+ >
);
};
diff --git a/src/pages/Organization/components/OrgAvatarSection.jsx b/src/pages/Organization/components/OrgAvatarSection.jsx
deleted file mode 100644
index e22a597c..00000000
--- a/src/pages/Organization/components/OrgAvatarSection.jsx
+++ /dev/null
@@ -1,221 +0,0 @@
-/*
-Copyright (C) 2025 QuantumNous
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU Affero General Public License as
-published by the Free Software Foundation, either version 3 of the
-License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU Affero General Public License for more details.
-
-You should have received a copy of the GNU Affero General Public License
-along with this program. If not, see .
-
-For commercial licensing, please contact support@quantumnous.com
-*/
-import React from 'react';
-import { Button, Input, Radio, RadioGroup } from '@/components/ui';
-import { Check, Image as ImageIcon, Palette, Type, UserRound } from 'lucide-react';
-import OrgPanel from './OrgPanel';
-import {
- CARTOON_AVATAR_PRESETS,
- USER_AVATAR_TYPES,
- getCartoonAvatarDataUrl,
- getInitialAvatarDataUrl,
-} from '../../../helpers';
-
-const AVATAR_TYPE_OPTIONS = [
- {
- value: USER_AVATAR_TYPES.PRESET,
- label: '卡通形象',
- desc: '从系统内置卡通头像中选择,适合默认展示',
- icon: Palette,
- },
- {
- value: USER_AVATAR_TYPES.INITIAL,
- label: '姓名首字',
- desc: '根据用户名自动生成简洁文字头像',
- icon: Type,
- },
- {
- value: USER_AVATAR_TYPES.CUSTOM,
- label: '图片链接',
- desc: '填写公网图片 URL,使用自己的头像',
- icon: ImageIcon,
- },
-];
-
-/*
- * 企业中心头像设置区块。
- * 与个人中心的 AvatarSection 分开:企业空间是实底卡片 + 品牌色体系(OrgPanel),
- * 而非个人中心的毛玻璃 + 玫红渐变,避免颜色与整站主体色冲突。
- */
-const OrgAvatarSection = ({
- t,
- userState,
- avatarSettings,
- handleAvatarSettingChange,
- saveAvatarSettings,
- saving,
-}) => {
- const username =
- userState?.user?.display_name || userState?.user?.username || 'User';
-
- const previewUrl =
- avatarSettings.avatarType === USER_AVATAR_TYPES.CUSTOM &&
- avatarSettings.customAvatarUrl
- ? avatarSettings.customAvatarUrl
- : avatarSettings.avatarType === USER_AVATAR_TYPES.INITIAL
- ? getInitialAvatarDataUrl(username, 128)
- : getCartoonAvatarDataUrl(avatarSettings.avatarPreset, 128);
-
- const customAvatarInvalid =
- avatarSettings.avatarType === USER_AVATAR_TYPES.CUSTOM &&
- !avatarSettings.customAvatarUrl?.trim();
-
- const activeDesc =
- AVATAR_TYPE_OPTIONS.find(
- (item) => item.value === avatarSettings.avatarType,
- )?.desc || '';
-
- return (
-
- {t('保存头像')}
-
- }
- >
-
- {/* 实时预览:品牌色描边,实底卡面 */}
-
-
-

-
-
-
- {username}
-
-
- {t('该头像会同步展示在右上角用户入口和体验中心文本对话中。')}
-
-
- {t('实时预览')}
-
-
-
- {/* 头像类型 + 具体选择 */}
-
-
-
- handleAvatarSettingChange('avatarType', e.target.value)
- }
- className='!flex !flex-wrap !gap-2'
- >
- {AVATAR_TYPE_OPTIONS.map((option) => {
- const Icon = option.icon;
- return (
-
-
-
- {t(option.label)}
-
-
- );
- })}
-
-
- {t(activeDesc)}
-
-
- {avatarSettings.avatarType === USER_AVATAR_TYPES.PRESET && (
-
-
-
- {CARTOON_AVATAR_PRESETS.map((preset) => {
- const selected = avatarSettings.avatarPreset === preset.id;
- return (
-