feat: 自行开发设计 ui样式优化 超管端-控制台 相关的页面
This commit is contained in:
@@ -16,18 +16,18 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
import TableEmpty from '../../components/common/table/TableEmpty';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { getQuotaPerUnit } from '../../helpers';
|
||||
import { timestamp2string } from '../../helpers/utils';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { RefreshCw, ScrollText, Search } from 'lucide-react';
|
||||
import { RefreshCw, Search } from 'lucide-react';
|
||||
import { Form as AntForm, Tabs as AntTabs } from 'antd';
|
||||
import { Table, Select, Button, Tag, Tooltip } from '@/components/ui';
|
||||
import { API } from '../../helpers/api';
|
||||
import { useOrgAuditLogs } from '../../hooks/org/useOrgData';
|
||||
import OrgPageHeader from './components/OrgPageHeader';
|
||||
import { OrgFilterCard, OrgListCard } from './components/OrgListCard';
|
||||
import OrgStateBlock from './components/OrgStateBlock';
|
||||
import OrgPromptRecords from './OrgPromptRecords';
|
||||
import {
|
||||
formatQuotaAsCNY,
|
||||
@@ -212,6 +212,7 @@ const OrgAudit = ({ orgId }) => {
|
||||
const quotaPerUnit = getQuotaPerUnit();
|
||||
const { logs, total, loading, fetch } = useOrgAuditLogs(orgId);
|
||||
const [page, setPage] = useState(1);
|
||||
const [pageSize, setPageSize] = useState(20);
|
||||
const [actionFilter, setActionFilter] = useState('');
|
||||
const [activeTab, setActiveTab] = useState('operations');
|
||||
// 提示词记录 tab 由企业 feature flag(prompt_archive)控制显隐
|
||||
@@ -220,8 +221,8 @@ const OrgAudit = ({ orgId }) => {
|
||||
const [canViewPromptRecords, setCanViewPromptRecords] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
fetch(page, 20, actionFilter);
|
||||
}, [fetch, page, actionFilter]);
|
||||
fetch(page, pageSize, actionFilter);
|
||||
}, [fetch, page, pageSize, actionFilter]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!orgId) return;
|
||||
@@ -386,7 +387,7 @@ const OrgAudit = ({ orgId }) => {
|
||||
},
|
||||
];
|
||||
|
||||
const refresh = () => fetch(page, 20, actionFilter);
|
||||
const refresh = () => fetch(page, pageSize, actionFilter);
|
||||
// 选择即筛选(原交互):与原页头 Select 的 onChange 相同
|
||||
const applyAction = (v) => {
|
||||
setActionFilter(v ?? '');
|
||||
@@ -445,13 +446,17 @@ const OrgAudit = ({ orgId }) => {
|
||||
scroll={{ x: 1140 }}
|
||||
pagination={{
|
||||
currentPage: page,
|
||||
pageSize: 20,
|
||||
pageSize,
|
||||
showSizeChanger: false,
|
||||
total,
|
||||
onPageChange: setPage,
|
||||
onPageSizeChange: (size) => {
|
||||
setPage(1);
|
||||
setPageSize(size);
|
||||
},
|
||||
showTotal: (n) => t('共 {{total}} 条', { total: n }),
|
||||
}}
|
||||
empty={<OrgStateBlock icon={ScrollText} title={t('暂无审计日志')} />}
|
||||
empty={<TableEmpty />}
|
||||
/>
|
||||
</OrgListCard>
|
||||
</>
|
||||
|
||||
@@ -16,6 +16,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
import TableEmpty from '../../components/common/table/TableEmpty';
|
||||
import React, {
|
||||
useCallback,
|
||||
useEffect,
|
||||
@@ -461,6 +462,7 @@ const OrgBudgets = ({ orgId }) => {
|
||||
}
|
||||
>
|
||||
<Table
|
||||
empty={<TableEmpty />}
|
||||
columns={columns}
|
||||
dataSource={list}
|
||||
loading={loading}
|
||||
|
||||
@@ -124,15 +124,16 @@ const MemberUsageSheet = ({ visible, onClose, member, orgId, t }) => {
|
||||
modelName: '',
|
||||
});
|
||||
const requestSeq = useRef(0);
|
||||
const pageSize = 20;
|
||||
const [pageSize, setPageSize] = useState(20);
|
||||
const pageSizeRef = useRef(20);
|
||||
|
||||
const fetchLogs = useCallback(
|
||||
async (p = 1, filters = appliedFilters) => {
|
||||
async (p = 1, filters = appliedFilters, size = pageSize) => {
|
||||
if (!member || !orgId) return;
|
||||
const seq = ++requestSeq.current;
|
||||
setLoading(true);
|
||||
try {
|
||||
let url = `/api/org/logs?user_id=${member.user_id}&p=${p}&page_size=${pageSize}`;
|
||||
let url = `/api/org/logs?user_id=${member.user_id}&p=${p}&page_size=${size}`;
|
||||
if (filters.dateRange && filters.dateRange.length === 2) {
|
||||
if (filters.dateRange[0])
|
||||
url += `&start_timestamp=${Math.floor(filters.dateRange[0].getTime() / 1000)}`;
|
||||
@@ -161,7 +162,7 @@ const MemberUsageSheet = ({ visible, onClose, member, orgId, t }) => {
|
||||
if (seq === requestSeq.current) setLoading(false);
|
||||
}
|
||||
},
|
||||
[member, orgId, appliedFilters],
|
||||
[member, orgId, appliedFilters, pageSize],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -171,6 +172,8 @@ const MemberUsageSheet = ({ visible, onClose, member, orgId, t }) => {
|
||||
setModelName('');
|
||||
setAppliedFilters({ dateRange: [], modelName: '' });
|
||||
setPage(1);
|
||||
setPageSize(20);
|
||||
pageSizeRef.current = 20;
|
||||
setLogs([]);
|
||||
setTotal(0);
|
||||
// 直接发起无过滤的请求(不依赖 state 更新)
|
||||
@@ -178,7 +181,7 @@ const MemberUsageSheet = ({ visible, onClose, member, orgId, t }) => {
|
||||
const seq = ++requestSeq.current;
|
||||
setLoading(true);
|
||||
try {
|
||||
const url = `/api/org/logs?user_id=${member.user_id}&p=1&page_size=${pageSize}`;
|
||||
const url = `/api/org/logs?user_id=${member.user_id}&p=1&page_size=${pageSizeRef.current}`;
|
||||
const res = await API.get(url, { headers: getOrgHeaders(orgId) });
|
||||
if (seq !== requestSeq.current) return;
|
||||
if (res.data.success) {
|
||||
@@ -330,12 +333,17 @@ const MemberUsageSheet = ({ visible, onClose, member, orgId, t }) => {
|
||||
size='small'
|
||||
loading={loading}
|
||||
pagination={
|
||||
total > pageSize
|
||||
total > pageSize || pageSize !== 20
|
||||
? {
|
||||
currentPage: page,
|
||||
pageSize,
|
||||
total,
|
||||
onPageChange: (p) => fetchLogs(p),
|
||||
onPageSizeChange: (size) => {
|
||||
pageSizeRef.current = size;
|
||||
setPageSize(size);
|
||||
fetchLogs(1, appliedFilters, size);
|
||||
},
|
||||
}
|
||||
: false
|
||||
}
|
||||
@@ -373,6 +381,10 @@ const renderBudgetAmount = (quota) => {
|
||||
};
|
||||
|
||||
const OrgDashboard = ({ orgId, orgRole, orgName, featureFlags }) => {
|
||||
const quotaPaginationSizeRef = useRef(null);
|
||||
useEffect(() => {
|
||||
quotaPaginationSizeRef.current = null;
|
||||
}, [orgId]);
|
||||
const { t } = useTranslation();
|
||||
const navigate = useNavigate();
|
||||
const [statusState] = useContext(StatusContext);
|
||||
@@ -601,13 +613,18 @@ const OrgDashboard = ({ orgId, orgRole, orgName, featureFlags }) => {
|
||||
rowKey='member_id'
|
||||
scroll={{ x: 860 }}
|
||||
pagination={
|
||||
memberQuotaTotal > memberQuotaPageSize
|
||||
memberQuotaTotal > memberQuotaPageSize ||
|
||||
quotaPaginationSizeRef.current !== null
|
||||
? {
|
||||
currentPage: memberQuotaPage,
|
||||
pageSize: memberQuotaPageSize,
|
||||
total: memberQuotaTotal,
|
||||
showSizeChanger: false,
|
||||
onPageChange: (page) => fetchQuota(page, memberQuotaPageSize),
|
||||
onPageSizeChange: (size) => {
|
||||
quotaPaginationSizeRef.current = size;
|
||||
fetchQuota(1, size);
|
||||
},
|
||||
showTotal: (n) => t('共 {{total}} 条', { total: n }),
|
||||
}
|
||||
: false
|
||||
|
||||
@@ -16,16 +16,15 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
import TableEmpty from '../../components/common/table/TableEmpty';
|
||||
import React, { useEffect, useState, useMemo, useCallback } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import {
|
||||
RefreshCw,
|
||||
Receipt,
|
||||
Wallet,
|
||||
Zap,
|
||||
BarChart3,
|
||||
Download,
|
||||
Trophy,
|
||||
Search,
|
||||
} from 'lucide-react';
|
||||
import { Card as AntCard, Form as AntForm, Tabs as AntTabs } from 'antd';
|
||||
@@ -47,7 +46,8 @@ import {
|
||||
import OrgPageHeader from './components/OrgPageHeader';
|
||||
import { OrgFilterCard, OrgListCard } from './components/OrgListCard';
|
||||
import OrgModal from './components/OrgModal';
|
||||
import TaskLogsTable from '../../components/table/task-logs';
|
||||
import OrgTaskRecords from './components/OrgTaskRecords';
|
||||
import { useOrgLogsThemeStyle } from './components/useOrgLogsThemeStyle';
|
||||
import {
|
||||
API,
|
||||
showError,
|
||||
@@ -220,6 +220,7 @@ function rangeToFilters(range) {
|
||||
// ========== 主组件 ==========
|
||||
const OrgLogs = ({ orgId, orgRole, isDeptManager = false }) => {
|
||||
const { t } = useTranslation();
|
||||
const themeStyle = useOrgLogsThemeStyle();
|
||||
const { logs, total, loading, fetch } = useOrgMemberLogs(orgId);
|
||||
const {
|
||||
stat,
|
||||
@@ -232,9 +233,8 @@ const OrgLogs = ({ orgId, orgRole, isDeptManager = false }) => {
|
||||
fetch: fetchRanking,
|
||||
} = useOrgMemberRanking(orgId);
|
||||
const [page, setPage] = useState(1);
|
||||
const pageSize = 20;
|
||||
const [pageSize, setPageSize] = useState(20);
|
||||
const [activeTab, setActiveTab] = useState('logs');
|
||||
const [taskFilterRevision, setTaskFilterRevision] = useState(0);
|
||||
const isAdmin =
|
||||
orgRole === 'owner' || orgRole === 'admin' || orgRole === 'super_admin';
|
||||
const canViewTeamUsage = isAdmin || isDeptManager;
|
||||
@@ -312,8 +312,9 @@ const OrgLogs = ({ orgId, orgRole, isDeptManager = false }) => {
|
||||
setDateRange(range);
|
||||
setIsDefaultRange(true);
|
||||
setPage(1);
|
||||
setPageSize(20);
|
||||
setAppliedFilters(filters);
|
||||
fetch(1, pageSize, filters);
|
||||
fetch(1, 20, filters);
|
||||
fetchStat(filters);
|
||||
if (canViewTeamUsage) {
|
||||
fetchRanking({
|
||||
@@ -321,7 +322,7 @@ const OrgLogs = ({ orgId, orgRole, isDeptManager = false }) => {
|
||||
endTimestamp: filters.endTimestamp,
|
||||
});
|
||||
}
|
||||
}, [fetch, fetchStat, fetchRanking, canViewTeamUsage, pageSize]);
|
||||
}, [fetch, fetchStat, fetchRanking, canViewTeamUsage]);
|
||||
|
||||
// forceRefresh=true(点击「刷新」)时绕过后端聚合缓存,拿到最新数据;
|
||||
// 普通「查询」走缓存,相同条件重复查询不再压数据库。
|
||||
@@ -346,7 +347,6 @@ const OrgLogs = ({ orgId, orgRole, isDeptManager = false }) => {
|
||||
);
|
||||
}
|
||||
setPage(1);
|
||||
setTaskFilterRevision((revision) => revision + 1);
|
||||
};
|
||||
|
||||
// 重置:回到默认状态(滚动最近 7 天、不限成员/模型)
|
||||
@@ -367,7 +367,6 @@ const OrgLogs = ({ orgId, orgRole, isDeptManager = false }) => {
|
||||
});
|
||||
}
|
||||
setPage(1);
|
||||
setTaskFilterRevision((revision) => revision + 1);
|
||||
};
|
||||
|
||||
// 导出弹窗状态(导出方式 + 字段勾选从 localStorage 恢复)
|
||||
@@ -679,6 +678,17 @@ const OrgLogs = ({ orgId, orgRole, isDeptManager = false }) => {
|
||||
);
|
||||
|
||||
// ========== 排行榜表格列(原型 90/200/190/150/160)==========
|
||||
// 后端排行可能对同一成员返回多行(如成员改名前后分组),user_id 不唯一会导致 React 重复 key;
|
||||
// 仅为行键附加名次序号,数据、排序与展示不变
|
||||
const rankingRows = useMemo(
|
||||
() =>
|
||||
(ranking || []).map((row, index) => ({
|
||||
...row,
|
||||
rank_row_key: `${row.user_id ?? 'unknown'}-${index}`,
|
||||
})),
|
||||
[ranking],
|
||||
);
|
||||
|
||||
const rankingColumns = useMemo(
|
||||
() => [
|
||||
{
|
||||
@@ -747,7 +757,7 @@ const OrgLogs = ({ orgId, orgRole, isDeptManager = false }) => {
|
||||
];
|
||||
|
||||
return (
|
||||
<div className='uc-page oc-page'>
|
||||
<div className='uc-page oc-page oc-expenses' style={themeStyle}>
|
||||
{/* 标题栏 */}
|
||||
<OrgPageHeader
|
||||
title={canViewTeamUsage ? t('消耗明细') : t('我的消耗明细')}
|
||||
@@ -782,21 +792,16 @@ const OrgLogs = ({ orgId, orgRole, isDeptManager = false }) => {
|
||||
onChange={setActiveTab}
|
||||
items={[
|
||||
{ key: 'logs', label: t('明细日志') },
|
||||
{ key: 'tasks', label: t('绘图与视频') },
|
||||
...(canViewTeamUsage
|
||||
? [{ key: 'ranking', label: t('成员排行') }]
|
||||
: []),
|
||||
{ key: 'tasks', label: t('绘图与视频') },
|
||||
]}
|
||||
/>
|
||||
|
||||
{activeTab === 'tasks' ? (
|
||||
<TaskLogsTable
|
||||
usageRecordMode
|
||||
organizationMode
|
||||
sharedStartTimestamp={appliedFilters.startTimestamp}
|
||||
sharedEndTimestamp={appliedFilters.endTimestamp}
|
||||
sharedFilterRevision={taskFilterRevision}
|
||||
/>
|
||||
// 绘图与视频使用自身筛选卡(与原型一致,时间范围独立可编辑)
|
||||
<OrgTaskRecords />
|
||||
) : (
|
||||
<>
|
||||
{/* 筛选栏(原型 .ee-filter-card / .eex-filter-grid) */}
|
||||
@@ -881,24 +886,12 @@ const OrgLogs = ({ orgId, orgRole, isDeptManager = false }) => {
|
||||
{activeTab === 'ranking' && canViewTeamUsage ? (
|
||||
<Table
|
||||
columns={rankingColumns}
|
||||
dataSource={ranking}
|
||||
dataSource={rankingRows}
|
||||
loading={rankingLoading}
|
||||
rowKey='user_id'
|
||||
rowKey='rank_row_key'
|
||||
pagination={false}
|
||||
scroll={{ x: 790 }}
|
||||
empty={
|
||||
<div className='py-10 text-center'>
|
||||
<div className='inline-flex p-3 rounded-full bg-gray-100 dark:bg-neutral-800 mb-3'>
|
||||
<Trophy
|
||||
size={24}
|
||||
className='text-gray-400 dark:text-gray-500'
|
||||
/>
|
||||
</div>
|
||||
<p className='text-gray-400 dark:text-gray-500 text-sm'>
|
||||
{t('暂无排行数据')}
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
empty={<TableEmpty />}
|
||||
/>
|
||||
) : (
|
||||
<Table
|
||||
@@ -913,35 +906,29 @@ const OrgLogs = ({ orgId, orgRole, isDeptManager = false }) => {
|
||||
total,
|
||||
showSizeChanger: false,
|
||||
onPageChange: (p) => doPageFetch(p),
|
||||
onPageSizeChange: (size) => {
|
||||
setPage(1);
|
||||
setPageSize(size);
|
||||
fetch(1, size, appliedFilters);
|
||||
},
|
||||
showTotal: (n) => t('共 {{total}} 条', { total: n }),
|
||||
}}
|
||||
empty={
|
||||
<div className='py-10 text-center'>
|
||||
<div className='inline-flex p-3 rounded-full bg-gray-100 dark:bg-neutral-800 mb-3'>
|
||||
<Receipt
|
||||
size={24}
|
||||
className='text-gray-400 dark:text-gray-500'
|
||||
/>
|
||||
</div>
|
||||
<p className='text-gray-400 dark:text-gray-500 text-sm'>
|
||||
{t('暂无消耗记录')}
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
empty={<TableEmpty />}
|
||||
/>
|
||||
)}
|
||||
</OrgListCard>
|
||||
</>
|
||||
)}
|
||||
|
||||
{/* 导出弹窗:汇总 / 按用户 + 字段选择 */}
|
||||
{/* 导出弹窗:汇总 / 按用户 + 字段选择(原型无此弹窗:Ant 默认 + token 语义色) */}
|
||||
<OrgModal
|
||||
className='oc-dialog oc-export-dialog'
|
||||
title={t('导出消耗明细')}
|
||||
visible={exportModalVisible}
|
||||
onCancel={() => setExportModalVisible(false)}
|
||||
maskClosable={!exporting}
|
||||
footer={
|
||||
<div className='flex justify-end gap-2'>
|
||||
<div className='oc-export-footer'>
|
||||
<Button
|
||||
onClick={() => setExportModalVisible(false)}
|
||||
disabled={exporting}
|
||||
@@ -960,29 +947,22 @@ const OrgLogs = ({ orgId, orgRole, isDeptManager = false }) => {
|
||||
}
|
||||
>
|
||||
{/* 导出范围概览(与表格当前展示一致) */}
|
||||
<div className='mb-4 rounded-lg p-3 bg-gray-50 dark:bg-neutral-800/50'>
|
||||
<div className='text-xs text-gray-500 dark:text-gray-400 mb-1.5'>
|
||||
<div className='oc-export-scope'>
|
||||
<div className='oc-export-scope-title'>
|
||||
{t('导出范围(与当前查询结果一致)')}
|
||||
</div>
|
||||
{exportScope.map((s) => (
|
||||
<div
|
||||
key={s.label}
|
||||
className='text-xs text-gray-600 dark:text-gray-300'
|
||||
>
|
||||
<span className='text-gray-400 dark:text-gray-500'>
|
||||
{s.label}:
|
||||
</span>
|
||||
<div key={s.label} className='oc-export-scope-row'>
|
||||
<span>{s.label}:</span>
|
||||
{s.value}
|
||||
</div>
|
||||
))}
|
||||
<div className='text-xs text-gray-600 dark:text-gray-300 mt-1.5'>
|
||||
<span className='text-gray-400 dark:text-gray-500'>
|
||||
{t('记录数')}:
|
||||
</span>
|
||||
<span className='font-medium'>{total}</span>
|
||||
<div className='oc-export-scope-row oc-export-scope-count'>
|
||||
<span>{t('记录数')}:</span>
|
||||
<strong>{total}</strong>
|
||||
</div>
|
||||
{total > EXPORT_LIMIT && (
|
||||
<div className='text-xs text-amber-600 dark:text-amber-400 mt-1.5'>
|
||||
<div className='oc-export-scope-warning'>
|
||||
{t(
|
||||
'超过单次导出上限,仅导出最新 {{limit}} 条,建议缩小时间范围。',
|
||||
{
|
||||
@@ -993,10 +973,8 @@ const OrgLogs = ({ orgId, orgRole, isDeptManager = false }) => {
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className='mb-4'>
|
||||
<div className='text-sm font-medium text-gray-700 dark:text-gray-300 mb-2'>
|
||||
{t('导出方式')}
|
||||
</div>
|
||||
<div className='oc-export-section'>
|
||||
<div className='oc-export-label'>{t('导出方式')}</div>
|
||||
<RadioGroup
|
||||
type='card'
|
||||
value={exportMode}
|
||||
@@ -1015,11 +993,9 @@ const OrgLogs = ({ orgId, orgRole, isDeptManager = false }) => {
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div className='flex items-center justify-between mb-2'>
|
||||
<span className='text-sm font-medium text-gray-700 dark:text-gray-300'>
|
||||
{t('导出字段')}
|
||||
</span>
|
||||
<div className='flex gap-2'>
|
||||
<div className='oc-export-fields-head'>
|
||||
<span className='oc-export-label'>{t('导出字段')}</span>
|
||||
<div className='oc-export-fields-actions'>
|
||||
<Button
|
||||
size='small'
|
||||
theme='borderless'
|
||||
@@ -1036,22 +1012,18 @@ const OrgLogs = ({ orgId, orgRole, isDeptManager = false }) => {
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
className='flex flex-wrap rounded-lg p-3'
|
||||
style={{ border: '1px solid var(--ui-color-border)' }}
|
||||
>
|
||||
<div className='oc-export-fields'>
|
||||
{EXPORT_FIELDS.map((f) => (
|
||||
<div key={f.id} className='w-1/2 mb-2'>
|
||||
<Checkbox
|
||||
checked={!!exportFields[f.id]}
|
||||
onChange={(e) => toggleExportField(f.id, e.target.checked)}
|
||||
>
|
||||
{t(f.label)}
|
||||
</Checkbox>
|
||||
</div>
|
||||
<Checkbox
|
||||
key={f.id}
|
||||
checked={!!exportFields[f.id]}
|
||||
onChange={(e) => toggleExportField(f.id, e.target.checked)}
|
||||
>
|
||||
{t(f.label)}
|
||||
</Checkbox>
|
||||
))}
|
||||
</div>
|
||||
<p className='text-xs text-gray-400 dark:text-gray-500 mt-2'>
|
||||
<p className='oc-export-note'>
|
||||
{t('消耗额度以人民币(¥)金额导出。')}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
@@ -16,6 +16,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
import TableEmpty from '../../components/common/table/TableEmpty';
|
||||
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import {
|
||||
@@ -490,6 +491,7 @@ const OrgMemberAccounts = ({
|
||||
{embedded ? (
|
||||
<OrgListCard title={t('员工账号')} tools={actions}>
|
||||
<Table
|
||||
empty={<TableEmpty />}
|
||||
columns={columns}
|
||||
dataSource={members}
|
||||
loading={loading}
|
||||
@@ -702,7 +704,7 @@ const OrgMemberAccounts = ({
|
||||
</Tag>{' '}
|
||||
<Text
|
||||
size='small'
|
||||
copyable={{ content: r.initial_password }}
|
||||
copyable={{ text: r.initial_password }}
|
||||
>
|
||||
{t('初始密码')}
|
||||
</Text>
|
||||
|
||||
@@ -16,6 +16,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
import TableEmpty from '../../components/common/table/TableEmpty';
|
||||
import React, { useEffect, useState, useCallback, useRef } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Users, RefreshCw, Layers, Pencil, ShieldCheck } from 'lucide-react';
|
||||
@@ -65,6 +66,7 @@ const OrgMembers = ({
|
||||
updateMemberInList,
|
||||
} = useOrgMembers(orgId);
|
||||
const [page, setPage] = useState(1);
|
||||
const [pageSize, setPageSize] = useState(20);
|
||||
const [quotaModalVisible, setQuotaModalVisible] = useState(false);
|
||||
const [quotaMemberId, setQuotaMemberId] = useState(null);
|
||||
const [quotaMemberName, setQuotaMemberName] = useState('');
|
||||
@@ -107,9 +109,9 @@ const OrgMembers = ({
|
||||
|
||||
useEffect(() => {
|
||||
if (showMemberList) {
|
||||
fetch(page);
|
||||
fetch(page, pageSize);
|
||||
}
|
||||
}, [fetch, page, showMemberList]);
|
||||
}, [fetch, page, pageSize, showMemberList]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!showMemberList && activeTab === 'members') setActiveTab('accounts');
|
||||
@@ -121,10 +123,10 @@ const OrgMembers = ({
|
||||
const ok = await removeMember(memberId);
|
||||
if (ok) {
|
||||
Toast.success(t('成员已移除'));
|
||||
fetch(page);
|
||||
fetch(page, pageSize);
|
||||
}
|
||||
},
|
||||
[removeMember, fetch, page, t],
|
||||
[removeMember, fetch, page, pageSize, t],
|
||||
);
|
||||
|
||||
const handleRoleChange = useCallback(
|
||||
@@ -132,10 +134,10 @@ const OrgMembers = ({
|
||||
const ok = await updateMemberRole(memberId, role);
|
||||
if (ok) {
|
||||
Toast.success(t('角色已更新'));
|
||||
fetch(page);
|
||||
fetch(page, pageSize);
|
||||
}
|
||||
},
|
||||
[updateMemberRole, fetch, page, t],
|
||||
[updateMemberRole, fetch, page, pageSize, t],
|
||||
);
|
||||
|
||||
const handleStatusChange = useCallback(
|
||||
@@ -143,10 +145,10 @@ const OrgMembers = ({
|
||||
const ok = await updateMemberStatus(memberId, status);
|
||||
if (ok) {
|
||||
Toast.success(t('状态已更新'));
|
||||
fetch(page);
|
||||
fetch(page, pageSize);
|
||||
}
|
||||
},
|
||||
[updateMemberStatus, fetch, page, t],
|
||||
[updateMemberStatus, fetch, page, pageSize, t],
|
||||
);
|
||||
|
||||
const handleQuotaLimitSave = useCallback(async () => {
|
||||
@@ -155,7 +157,7 @@ const OrgMembers = ({
|
||||
if (ok) {
|
||||
Toast.success(t('配额已更新'));
|
||||
setQuotaModalVisible(false);
|
||||
fetch(page);
|
||||
fetch(page, pageSize);
|
||||
}
|
||||
}, [
|
||||
quotaMemberId,
|
||||
@@ -165,6 +167,7 @@ const OrgMembers = ({
|
||||
fetch,
|
||||
page,
|
||||
t,
|
||||
pageSize,
|
||||
]);
|
||||
|
||||
const handleModelLimitsSave = useCallback(async () => {
|
||||
@@ -182,7 +185,7 @@ const OrgMembers = ({
|
||||
if (ok) {
|
||||
Toast.success(t('模型限制已更新'));
|
||||
setModelLimitsModalVisible(false);
|
||||
fetch(page);
|
||||
fetch(page, pageSize);
|
||||
}
|
||||
}, [
|
||||
modelLimitsMemberId,
|
||||
@@ -192,6 +195,7 @@ const OrgMembers = ({
|
||||
fetch,
|
||||
page,
|
||||
t,
|
||||
pageSize,
|
||||
]);
|
||||
|
||||
// 解析成员管理员权限:兼容 JSON 字符串/对象;为空表示未授予任何权限
|
||||
@@ -221,7 +225,7 @@ const OrgMembers = ({
|
||||
if (ok) {
|
||||
Toast.success(t('权限已更新'));
|
||||
setPermModalVisible(false);
|
||||
fetch(page);
|
||||
fetch(page, pageSize);
|
||||
}
|
||||
}, [
|
||||
permMemberId,
|
||||
@@ -234,6 +238,7 @@ const OrgMembers = ({
|
||||
fetch,
|
||||
page,
|
||||
t,
|
||||
pageSize,
|
||||
]);
|
||||
|
||||
// 解析成员分组:兼容 JSON 字符串/数组;为空表示"继承企业全部分组"
|
||||
@@ -284,7 +289,7 @@ const OrgMembers = ({
|
||||
if (ok) {
|
||||
Toast.success(t('成员分组已更新'));
|
||||
setGroupsModalVisible(false);
|
||||
fetch(page);
|
||||
fetch(page, pageSize);
|
||||
}
|
||||
}, [
|
||||
groupsMemberId,
|
||||
@@ -293,6 +298,7 @@ const OrgMembers = ({
|
||||
fetch,
|
||||
page,
|
||||
t,
|
||||
pageSize,
|
||||
]);
|
||||
|
||||
const handleRemarkSave = useCallback(
|
||||
@@ -713,7 +719,7 @@ const OrgMembers = ({
|
||||
tools={
|
||||
<Button
|
||||
icon={<RefreshCw size={16} />}
|
||||
onClick={() => fetch(page)}
|
||||
onClick={() => fetch(page, pageSize)}
|
||||
loading={loading}
|
||||
>
|
||||
{t('刷新')}
|
||||
@@ -726,21 +732,16 @@ const OrgMembers = ({
|
||||
loading={loading}
|
||||
rowKey='id'
|
||||
scroll={{ x: 1500 }}
|
||||
empty={
|
||||
<div className='py-10 text-center'>
|
||||
<div className='inline-flex p-3 rounded-full bg-gray-100 dark:bg-neutral-800 mb-3'>
|
||||
<Users size={24} className='text-gray-400 dark:text-gray-500' />
|
||||
</div>
|
||||
<p className='text-gray-400 dark:text-gray-500 text-sm'>
|
||||
{t('暂无成员数据')}
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
empty={<TableEmpty />}
|
||||
pagination={{
|
||||
currentPage: page,
|
||||
pageSize: 20,
|
||||
pageSize,
|
||||
total,
|
||||
onPageChange: setPage,
|
||||
onPageSizeChange: (size) => {
|
||||
setPage(1);
|
||||
setPageSize(size);
|
||||
},
|
||||
showTotal: (n) => t('共 {{total}} 条', { total: n }),
|
||||
}}
|
||||
/>
|
||||
|
||||
@@ -16,6 +16,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
import TableEmpty from '../../components/common/table/TableEmpty';
|
||||
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Switch } from 'antd';
|
||||
@@ -397,6 +398,7 @@ const OrgProjects = ({ orgId }) => {
|
||||
}
|
||||
>
|
||||
<Table
|
||||
empty={<TableEmpty />}
|
||||
columns={columns}
|
||||
dataSource={list}
|
||||
loading={loading}
|
||||
|
||||
@@ -170,6 +170,7 @@ const OrgPromptRecords = ({ orgId }) => {
|
||||
const quotaPerUnit = getQuotaPerUnit();
|
||||
const { records, total, loading, error, fetch } = useOrgPromptRecords(orgId);
|
||||
const [page, setPage] = useState(1);
|
||||
const [pageSize, setPageSize] = useState(20);
|
||||
const [members, setMembers] = useState([]);
|
||||
const [membersLoading, setMembersLoading] = useState(true);
|
||||
const [selectedMemberId, setSelectedMemberId] = useState('');
|
||||
@@ -228,8 +229,8 @@ const OrgPromptRecords = ({ orgId }) => {
|
||||
|
||||
useEffect(() => {
|
||||
if (membersLoading) return;
|
||||
fetch(page, 20, appliedFilters);
|
||||
}, [appliedFilters, fetch, membersLoading, page]);
|
||||
fetch(page, pageSize, appliedFilters);
|
||||
}, [appliedFilters, fetch, membersLoading, page, pageSize]);
|
||||
|
||||
const applyFilter = () => {
|
||||
setAppliedFilters(buildFilters());
|
||||
@@ -602,7 +603,7 @@ const OrgPromptRecords = ({ orgId }) => {
|
||||
actions={
|
||||
<Button
|
||||
icon={<RefreshCw size={14} />}
|
||||
onClick={() => fetch(page, 20, appliedFilters)}
|
||||
onClick={() => fetch(page, pageSize, appliedFilters)}
|
||||
loading={loading || membersLoading}
|
||||
>
|
||||
{t('刷新')}
|
||||
@@ -624,9 +625,13 @@ const OrgPromptRecords = ({ orgId }) => {
|
||||
scroll={{ x: 'max(100%, 1400px)' }}
|
||||
pagination={{
|
||||
currentPage: page,
|
||||
pageSize: 20,
|
||||
pageSize,
|
||||
total,
|
||||
onPageChange: setPage,
|
||||
onPageSizeChange: (size) => {
|
||||
setPage(1);
|
||||
setPageSize(size);
|
||||
},
|
||||
}}
|
||||
empty={
|
||||
<OrgStateBlock
|
||||
|
||||
@@ -123,6 +123,7 @@ const OrgRecharge = ({ orgId }) => {
|
||||
const [history, setHistory] = useState([]);
|
||||
const [historyTotal, setHistoryTotal] = useState(0);
|
||||
const [historyPage, setHistoryPage] = useState(1);
|
||||
const [historyPageSize, setHistoryPageSize] = useState(10);
|
||||
const [historyLoading, setHistoryLoading] = useState(false);
|
||||
const [refreshHistory, setRefreshHistory] = useState(0);
|
||||
|
||||
@@ -186,21 +187,26 @@ const OrgRecharge = ({ orgId }) => {
|
||||
async (page = 1) => {
|
||||
setHistoryLoading(true);
|
||||
try {
|
||||
const res = await API.get(`/api/org/topup?p=${page}&page_size=10`, {
|
||||
headers: orgHeaders,
|
||||
});
|
||||
const res = await API.get(
|
||||
`/api/org/topup?p=${page}&page_size=${historyPageSize}`,
|
||||
{
|
||||
headers: orgHeaders,
|
||||
},
|
||||
);
|
||||
if (res.data.success) {
|
||||
const data = res.data.data;
|
||||
setHistory(data.items || []);
|
||||
setHistoryTotal(data.total || 0);
|
||||
} else {
|
||||
showError(res.data.message);
|
||||
}
|
||||
} catch (e) {
|
||||
// ignore
|
||||
showError(e.message);
|
||||
} finally {
|
||||
setHistoryLoading(false);
|
||||
}
|
||||
},
|
||||
[orgId],
|
||||
[orgId, historyPageSize],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -772,8 +778,12 @@ const OrgRecharge = ({ orgId }) => {
|
||||
pagination={{
|
||||
currentPage: historyPage,
|
||||
total: historyTotal,
|
||||
pageSize: 10,
|
||||
pageSize: historyPageSize,
|
||||
onPageChange: setHistoryPage,
|
||||
onPageSizeChange: (size) => {
|
||||
setHistoryPage(1);
|
||||
setHistoryPageSize(size);
|
||||
},
|
||||
showTotal: (n) => t('共 {{total}} 条', { total: n }),
|
||||
}}
|
||||
empty={<Text type='tertiary'>{t('暂无充值记录')}</Text>}
|
||||
|
||||
@@ -16,6 +16,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
import TableEmpty from '../../components/common/table/TableEmpty';
|
||||
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Form as AntForm, Tabs as AntTabs } from 'antd';
|
||||
@@ -268,7 +269,7 @@ const OrgRequests = ({ orgId, orgRole, featureFlags }) => {
|
||||
columns={columns}
|
||||
dataSource={list}
|
||||
loading={loading}
|
||||
empty={t('暂无申请')}
|
||||
empty={<TableEmpty />}
|
||||
pagination={{
|
||||
pageSize: 15,
|
||||
showSizeChanger: false,
|
||||
|
||||
@@ -16,6 +16,8 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import { writeClipboardText } from '../../helpers/clipboard';
|
||||
import React, {
|
||||
useEffect,
|
||||
useState,
|
||||
@@ -542,8 +544,7 @@ const OrgSettings = ({ orgId, orgRole }) => {
|
||||
);
|
||||
|
||||
const copyCode = () => {
|
||||
navigator.clipboard
|
||||
.writeText(orgInfo.code)
|
||||
writeClipboardText(orgInfo.code)
|
||||
.then(() => {
|
||||
setCodeCopied(true);
|
||||
Toast.success(t('企业代码已复制到剪贴板'));
|
||||
@@ -555,8 +556,7 @@ const OrgSettings = ({ orgId, orgRole }) => {
|
||||
};
|
||||
|
||||
const copyLink = () => {
|
||||
navigator.clipboard
|
||||
.writeText(orgLoginLink)
|
||||
writeClipboardText(orgLoginLink)
|
||||
.then(() => {
|
||||
setLinkCopied(true);
|
||||
Toast.success(t('企业登录链接已复制到剪贴板'));
|
||||
|
||||
@@ -510,7 +510,7 @@ const OrgSidebar = ({
|
||||
>
|
||||
{!collapsed && (
|
||||
<div className='ui-org-identity'>
|
||||
<LayoutGrid size={22} strokeWidth={1.5} aria-hidden='true' />
|
||||
<LayoutGrid size={24} strokeWidth={1.65} aria-hidden='true' />
|
||||
<div className='ui-org-identity-copy'>
|
||||
<span className='ui-org-name' title={orgName || t('企业中心')}>
|
||||
{orgName || t('企业中心')}
|
||||
|
||||
@@ -16,6 +16,9 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import { writeClipboardText } from '../../helpers/clipboard';
|
||||
import TableEmpty from '../../components/common/table/TableEmpty';
|
||||
import React, {
|
||||
useEffect,
|
||||
useState,
|
||||
@@ -33,7 +36,6 @@ import {
|
||||
Layers,
|
||||
Check,
|
||||
RefreshCw,
|
||||
Settings,
|
||||
} from 'lucide-react';
|
||||
import {
|
||||
Table,
|
||||
@@ -63,15 +65,13 @@ import {
|
||||
Alert as AntAlert,
|
||||
Button as AntButton,
|
||||
Collapse,
|
||||
Checkbox,
|
||||
Divider,
|
||||
Form as AntForm,
|
||||
Radio,
|
||||
Popover,
|
||||
} from 'antd';
|
||||
import { OrgListCard, OrgRowActions } from './components/OrgListCard';
|
||||
import OrgSideSheet from './components/OrgSideSheet';
|
||||
import OrgStateBlock from './components/OrgStateBlock';
|
||||
import TableColumnSettings from '../../components/common/table/ColumnSettings';
|
||||
|
||||
// 获取当前登录用户ID
|
||||
const getCurrentUserId = () => {
|
||||
@@ -95,6 +95,7 @@ const OrgTokens = ({ orgId, orgRole }) => {
|
||||
updateToken,
|
||||
} = useOrgTokens(orgId);
|
||||
const [page, setPage] = useState(1);
|
||||
const [pageSize, setPageSize] = useState(20);
|
||||
const [visibleColumns, setVisibleColumns] = useState([
|
||||
'name',
|
||||
'key',
|
||||
@@ -129,8 +130,8 @@ const OrgTokens = ({ orgId, orgRole }) => {
|
||||
}, [projects]);
|
||||
|
||||
useEffect(() => {
|
||||
fetch(page);
|
||||
}, [fetch, page]);
|
||||
fetch(page, pageSize);
|
||||
}, [fetch, page, pageSize]);
|
||||
|
||||
useEffect(() => {
|
||||
let alive = true;
|
||||
@@ -149,10 +150,10 @@ const OrgTokens = ({ orgId, orgRole }) => {
|
||||
const ok = await deleteToken(tokenId);
|
||||
if (ok) {
|
||||
Toast.success(t('密钥已删除'));
|
||||
fetch(page);
|
||||
fetch(page, pageSize);
|
||||
}
|
||||
},
|
||||
[deleteToken, fetch, page, t],
|
||||
[deleteToken, fetch, page, pageSize, t],
|
||||
);
|
||||
|
||||
const handleStatusToggle = useCallback(
|
||||
@@ -161,27 +162,19 @@ const OrgTokens = ({ orgId, orgRole }) => {
|
||||
const ok = await updateToken(tokenId, { status: newStatus });
|
||||
if (ok) {
|
||||
Toast.success(t('状态已更新'));
|
||||
fetch(page);
|
||||
fetch(page, pageSize);
|
||||
}
|
||||
},
|
||||
[updateToken, fetch, page, t],
|
||||
[updateToken, fetch, page, pageSize, t],
|
||||
);
|
||||
|
||||
const copyToClipboard = (text) => {
|
||||
navigator.clipboard
|
||||
.writeText(text)
|
||||
writeClipboardText(text)
|
||||
.then(() => {
|
||||
Toast.success(t('已复制到剪贴板'));
|
||||
})
|
||||
.catch(() => {
|
||||
// 降级方案
|
||||
const textarea = document.createElement('textarea');
|
||||
textarea.value = text;
|
||||
document.body.appendChild(textarea);
|
||||
textarea.select();
|
||||
document.execCommand('copy');
|
||||
document.body.removeChild(textarea);
|
||||
Toast.success(t('已复制到剪贴板'));
|
||||
Toast.error(t('复制失败,请手动复制'));
|
||||
});
|
||||
};
|
||||
|
||||
@@ -392,20 +385,6 @@ const OrgTokens = ({ orgId, orgRole }) => {
|
||||
visibleColumns.includes(column.key),
|
||||
);
|
||||
const tableColumns = selectedColumns.length ? selectedColumns : [columns[0]];
|
||||
const columnSettings = (
|
||||
<Checkbox.Group
|
||||
className='oc-token-column-options'
|
||||
value={tableColumns.map((column) => column.key)}
|
||||
options={columns.map((column) => ({
|
||||
value: column.key,
|
||||
label: column.title,
|
||||
disabled:
|
||||
tableColumns.length === 1 && tableColumns[0].key === column.key,
|
||||
}))}
|
||||
onChange={setVisibleColumns}
|
||||
/>
|
||||
);
|
||||
|
||||
return (
|
||||
<div className='uc-page oc-page'>
|
||||
<OrgPageHeader
|
||||
@@ -434,7 +413,7 @@ const OrgTokens = ({ orgId, orgRole }) => {
|
||||
<>
|
||||
<Button
|
||||
icon={<RefreshCw size={16} />}
|
||||
onClick={() => fetch(page)}
|
||||
onClick={() => fetch(page, pageSize)}
|
||||
loading={loading}
|
||||
>
|
||||
{t('刷新')}
|
||||
@@ -448,18 +427,12 @@ const OrgTokens = ({ orgId, orgRole }) => {
|
||||
{t('创建密钥')}
|
||||
</Button>
|
||||
)}
|
||||
<Popover
|
||||
trigger='click'
|
||||
placement='bottomRight'
|
||||
title={t('列设置')}
|
||||
content={columnSettings}
|
||||
>
|
||||
<AntButton
|
||||
type='text'
|
||||
aria-label={t('列设置')}
|
||||
icon={<Settings size={16} />}
|
||||
/>
|
||||
</Popover>
|
||||
<TableColumnSettings
|
||||
columns={columns}
|
||||
value={tableColumns.map((column) => column.key)}
|
||||
defaultValue={columns.map((column) => column.key)}
|
||||
onChange={setVisibleColumns}
|
||||
/>
|
||||
</>
|
||||
}
|
||||
>
|
||||
@@ -472,12 +445,16 @@ const OrgTokens = ({ orgId, orgRole }) => {
|
||||
scroll={{
|
||||
x: tableColumns.reduce((sum, column) => sum + column.width, 0),
|
||||
}}
|
||||
empty={<OrgStateBlock icon={Key} title={t('暂无密钥')} />}
|
||||
empty={<TableEmpty />}
|
||||
pagination={{
|
||||
currentPage: page,
|
||||
pageSize: 20,
|
||||
pageSize,
|
||||
total,
|
||||
onPageChange: setPage,
|
||||
onPageSizeChange: (size) => {
|
||||
setPage(1);
|
||||
setPageSize(size);
|
||||
},
|
||||
showTotal: (n) => t('共 {{total}} 条', { total: n }),
|
||||
}}
|
||||
/>
|
||||
@@ -489,7 +466,7 @@ const OrgTokens = ({ orgId, orgRole }) => {
|
||||
onClose={() => setCreateModalVisible(false)}
|
||||
createToken={createToken}
|
||||
projects={projects}
|
||||
onSuccess={() => fetch(page)}
|
||||
onSuccess={() => fetch(page, pageSize)}
|
||||
t={t}
|
||||
/>
|
||||
|
||||
@@ -507,7 +484,7 @@ const OrgTokens = ({ orgId, orgRole }) => {
|
||||
// 前端按角色粗判以决定是否展示控件;真正的授权判定在后端
|
||||
// checkOrgSkillBindingPermission(skill_manage 权限),前端放宽不会造成越权。
|
||||
canBindSkills={isAdmin}
|
||||
onSuccess={() => fetch(page)}
|
||||
onSuccess={() => fetch(page, pageSize)}
|
||||
t={t}
|
||||
/>
|
||||
|
||||
@@ -861,19 +838,12 @@ const CreateTokenModal = ({
|
||||
};
|
||||
|
||||
const copyKey = (key) => {
|
||||
navigator.clipboard
|
||||
.writeText(key)
|
||||
writeClipboardText(key)
|
||||
.then(() => {
|
||||
Toast.success(t('已复制到剪贴板'));
|
||||
})
|
||||
.catch(() => {
|
||||
const el = document.createElement('textarea');
|
||||
el.value = key;
|
||||
document.body.appendChild(el);
|
||||
el.select();
|
||||
document.execCommand('copy');
|
||||
document.body.removeChild(el);
|
||||
Toast.success(t('已复制到剪贴板'));
|
||||
Toast.error(t('复制失败,请手动复制'));
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1383,24 +1353,14 @@ const ModelsSideSheet = ({ visible, onClose, token, orgId, t }) => {
|
||||
});
|
||||
|
||||
const handleCopyModel = (model) => {
|
||||
navigator.clipboard
|
||||
.writeText(model)
|
||||
writeClipboardText(model)
|
||||
.then(() => {
|
||||
setCopiedModel(model);
|
||||
Toast.success(t('已复制模型名称'));
|
||||
setTimeout(() => setCopiedModel(null), 1500);
|
||||
})
|
||||
.catch(() => {
|
||||
// fallback
|
||||
const textarea = document.createElement('textarea');
|
||||
textarea.value = model;
|
||||
document.body.appendChild(textarea);
|
||||
textarea.select();
|
||||
document.execCommand('copy');
|
||||
document.body.removeChild(textarea);
|
||||
setCopiedModel(model);
|
||||
Toast.success(t('已复制模型名称'));
|
||||
setTimeout(() => setCopiedModel(null), 1500);
|
||||
Toast.error(t('复制失败,请手动复制'));
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,280 @@
|
||||
/*
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import TableEmpty from '../../../components/common/table/TableEmpty';
|
||||
import React, { useMemo } from 'react';
|
||||
import { Card, Table, Tag } from 'antd';
|
||||
import { Clock, Download, RefreshCw } from 'lucide-react';
|
||||
import { Button, Pagination } from '@/components/ui';
|
||||
import { useTaskLogsData } from '../../../hooks/task-logs/useTaskLogsData';
|
||||
import { useIsMobile } from '../../../hooks/common/useIsMobile';
|
||||
import { timestamp2string } from '../../../helpers';
|
||||
import { getTaskLogsColumns } from '../../../components/table/task-logs/TaskLogsColumnDefs';
|
||||
import TaskLogsFilters from '../../../components/table/task-logs/TaskLogsFilters';
|
||||
import {
|
||||
exportTaskLogsPageCsv,
|
||||
useTaskPageStats,
|
||||
} from '../../../components/table/task-logs/TaskLogsActions';
|
||||
import ColumnSelectorModal from '../../../components/table/task-logs/modals/ColumnSelectorModal';
|
||||
import ContentModal from '../../../components/table/task-logs/modals/ContentModal';
|
||||
import { OrgListCard } from './OrgListCard';
|
||||
import { ColumnSettingsButton } from '../../../components/common/table/ColumnSettings';
|
||||
|
||||
// 原型 EnterpriseExpenseTasks 列宽(提交 / 结束 185、花费 110、类型 110、模型 250、任务 ID 330、状态 110、进度 155、费用 145、末列 150)
|
||||
const COLUMN_WIDTHS = {
|
||||
submit_time: 185,
|
||||
finish_time: 185,
|
||||
duration: 110,
|
||||
channel: 85,
|
||||
type: 110,
|
||||
model: 250,
|
||||
task_id: 330,
|
||||
task_status: 110,
|
||||
progress: 155,
|
||||
quota: 145,
|
||||
fail_reason: 150,
|
||||
};
|
||||
|
||||
/**
|
||||
* 企业中心「消耗明细 → 绘图与视频」(原型 .eex-task-records:筛选卡 + “任务记录”列表卡)。
|
||||
* 与原型一致,本页签使用自身筛选卡中的时间范围(默认最近 7 天,可编辑),不受“明细日志”筛选影响;
|
||||
* 数据、请求、URL 同步、分页、列显隐、复制与预览回调全部来自原 useTaskLogsData(organizationMode);
|
||||
* 列渲染复用 getTaskLogsColumns 的使用记录分支,只包一层企业页类名与原型列宽。
|
||||
*/
|
||||
const OrgTaskRecords = () => {
|
||||
const taskLogsData = useTaskLogsData({ organizationMode: true });
|
||||
const {
|
||||
t,
|
||||
logs,
|
||||
loading,
|
||||
isAdminUser,
|
||||
isRootUser,
|
||||
COLUMN_KEYS,
|
||||
copyText,
|
||||
openContentModal,
|
||||
openVideoModal,
|
||||
visibleColumns,
|
||||
} = taskLogsData;
|
||||
const isMobile = useIsMobile();
|
||||
// 仅用于“实时更新中”提示(存在进行中任务时轮询);原型无“本页统计”区块,不渲染
|
||||
const pageStats = useTaskPageStats(logs);
|
||||
|
||||
const configurableColumns = useMemo(() => {
|
||||
const base = getTaskLogsColumns({
|
||||
t,
|
||||
COLUMN_KEYS,
|
||||
copyText,
|
||||
openContentModal,
|
||||
openVideoModal,
|
||||
isAdminUser,
|
||||
usageRecordMode: true,
|
||||
isRootUser,
|
||||
});
|
||||
return base.map((column) => {
|
||||
const width = COLUMN_WIDTHS[column.key];
|
||||
switch (column.key) {
|
||||
// 原型为单行“YYYY-MM-DD HH:mm:ss”
|
||||
case COLUMN_KEYS.SUBMIT_TIME:
|
||||
case COLUMN_KEYS.FINISH_TIME:
|
||||
return {
|
||||
...column,
|
||||
width,
|
||||
render: (value) =>
|
||||
value ? (
|
||||
<span className='oc-number'>{timestamp2string(value)}</span>
|
||||
) : (
|
||||
'-'
|
||||
),
|
||||
};
|
||||
case COLUMN_KEYS.DURATION:
|
||||
return {
|
||||
...column,
|
||||
width,
|
||||
render: (...args) => (
|
||||
<span className='oc-number'>{column.render(...args)}</span>
|
||||
),
|
||||
};
|
||||
case COLUMN_KEYS.MODEL:
|
||||
return {
|
||||
...column,
|
||||
width,
|
||||
render: (...args) => (
|
||||
<span className='oc-task-model'>{column.render(...args)}</span>
|
||||
),
|
||||
};
|
||||
case COLUMN_KEYS.TASK_ID:
|
||||
return {
|
||||
...column,
|
||||
// 原型列名“任务 ID”(与筛选标签同一文案)
|
||||
title: t('任务 ID'),
|
||||
width,
|
||||
render: (...args) => {
|
||||
const node = column.render(...args);
|
||||
return (
|
||||
<span className='oc-task-id'>
|
||||
{node?.props?.children ?? node}
|
||||
</span>
|
||||
);
|
||||
},
|
||||
};
|
||||
case COLUMN_KEYS.QUOTA:
|
||||
return {
|
||||
...column,
|
||||
width,
|
||||
align: 'right',
|
||||
render: (...args) => {
|
||||
const node = column.render(...args);
|
||||
return node?.type === 'span' ? (
|
||||
<span className='oc-exp-cost'>{node.props.children}</span>
|
||||
) : (
|
||||
node
|
||||
);
|
||||
},
|
||||
};
|
||||
case COLUMN_KEYS.FAIL_REASON: {
|
||||
// 原型末列“操作”:随表格横向滚动(不固定),无可操作内容时显示“-”;
|
||||
// 预览视频链接与失败原因查看保持原节点与回调
|
||||
const { fixed: _fixed, ...rest } = column;
|
||||
return {
|
||||
...rest,
|
||||
title: t('操作'),
|
||||
width,
|
||||
render: (...args) => {
|
||||
const node = column.render(...args);
|
||||
return (
|
||||
<span className='oc-task-detail'>
|
||||
{node?.type === 'span' ? '-' : node}
|
||||
</span>
|
||||
);
|
||||
},
|
||||
};
|
||||
}
|
||||
default:
|
||||
return width ? { ...column, width } : column;
|
||||
}
|
||||
});
|
||||
}, [
|
||||
t,
|
||||
COLUMN_KEYS,
|
||||
copyText,
|
||||
openContentModal,
|
||||
openVideoModal,
|
||||
isAdminUser,
|
||||
isRootUser,
|
||||
]);
|
||||
|
||||
const columns = configurableColumns.filter(
|
||||
(column) => visibleColumns[column.key],
|
||||
);
|
||||
const scrollX = columns.reduce(
|
||||
(total, column) => total + (column.width || 120),
|
||||
0,
|
||||
);
|
||||
|
||||
return (
|
||||
<div className='oc-task-records'>
|
||||
<ColumnSelectorModal
|
||||
{...taskLogsData}
|
||||
usageRecordMode
|
||||
columns={configurableColumns}
|
||||
/>
|
||||
<ContentModal {...taskLogsData} isVideo={false} />
|
||||
{/* 视频预览弹窗:复用 ContentModal */}
|
||||
<ContentModal
|
||||
isModalOpen={taskLogsData.isVideoModalOpen}
|
||||
setIsModalOpen={taskLogsData.setIsVideoModalOpen}
|
||||
modalContent={taskLogsData.videoUrl}
|
||||
sourceUrl={taskLogsData.videoSourceUrl}
|
||||
isVideo={true}
|
||||
/>
|
||||
|
||||
{/* 原型移动端筛选卡直接展开(与“明细日志”页签一致),不设收起开关 */}
|
||||
<Card className='oc-filter-card oc-task-filter'>
|
||||
<TaskLogsFilters {...taskLogsData} usageRecordMode />
|
||||
</Card>
|
||||
|
||||
<OrgListCard
|
||||
className='oc-task-list'
|
||||
title={t('任务记录')}
|
||||
tools={
|
||||
<>
|
||||
{/* 只有真实存在进行中任务时才显示,避免误导 */}
|
||||
{pageStats.pendingCount > 0 && (
|
||||
<Tag
|
||||
bordered={false}
|
||||
color='processing'
|
||||
icon={<Clock size={12} />}
|
||||
>
|
||||
{t('实时更新中')}
|
||||
</Tag>
|
||||
)}
|
||||
{/* 导出当前页为 CSV,空列表时禁用 */}
|
||||
<Button
|
||||
icon={<Download size={16} />}
|
||||
onClick={() => exportTaskLogsPageCsv(logs, isAdminUser, t)}
|
||||
disabled={!logs || logs.length === 0}
|
||||
>
|
||||
{t('导出本页')}
|
||||
</Button>
|
||||
{/* 与筛选“搜索”同一处理函数(同步 URL 筛选条件并重新加载第 1 页) */}
|
||||
<Button
|
||||
icon={<RefreshCw size={16} />}
|
||||
onClick={() => taskLogsData.refresh()}
|
||||
loading={loading}
|
||||
>
|
||||
{t('刷新')}
|
||||
</Button>
|
||||
<ColumnSettingsButton
|
||||
open={taskLogsData.showColumnSelector}
|
||||
onClick={() => taskLogsData.setShowColumnSelector(true)}
|
||||
/>
|
||||
</>
|
||||
}
|
||||
>
|
||||
<Table
|
||||
columns={columns}
|
||||
dataSource={logs}
|
||||
rowKey='key'
|
||||
loading={loading}
|
||||
pagination={false}
|
||||
scroll={{ x: scrollX }}
|
||||
locale={{
|
||||
emptyText: <TableEmpty />,
|
||||
}}
|
||||
/>
|
||||
{taskLogsData.logCount > 0 && (
|
||||
<Pagination
|
||||
currentPage={taskLogsData.activePage}
|
||||
pageSize={taskLogsData.pageSize}
|
||||
total={taskLogsData.logCount}
|
||||
pageSizeOpts={[10, 20, 50]}
|
||||
showSizeChanger
|
||||
onPageSizeChange={taskLogsData.handlePageSizeChange}
|
||||
onPageChange={taskLogsData.handlePageChange}
|
||||
preventPageChangeOnPageSizeChange={false}
|
||||
showQuickJumper={isMobile}
|
||||
showTotal={(total) => t('共 {{total}} 条', { total })}
|
||||
/>
|
||||
)}
|
||||
</OrgListCard>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default OrgTaskRecords;
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
|
||||
import { useMemo } from 'react';
|
||||
import { theme } from 'antd';
|
||||
import { useActualTheme } from '../../../context/Theme';
|
||||
import { brandAccentFromToken } from '../../../components/ui/UiThemeProvider';
|
||||
|
||||
/**
|
||||
* 消耗明细页(/org/logs)主题桥:只从 Ant token 推导页面局部变量,挂在页面根节点 style 上。
|
||||
* - --oc-brand:原型 --brand(页签、额度、统计图标等强调色),浅色 / 深色 / 自定义主色三态跟随 token。
|
||||
* - --oc-stat-brand-bg:统计图标浅底(原型 #b9650810 = 品牌色 6.3% 透明度)。
|
||||
* - --ur-progress-done:任务进度满格描边(原型 strokeColor = var(--brand))。
|
||||
* - --oc-task-{success|failure|pending}-{text|bg|border}:绘图与视频“本页统计”语义色(Ant success / error / warning)。
|
||||
* 不新增 ConfigProvider / 主题状态 / 存储 key;JSX 中不出现颜色字面量。
|
||||
*/
|
||||
export function useOrgLogsThemeStyle() {
|
||||
const { token } = theme.useToken();
|
||||
const dark = useActualTheme() === 'dark';
|
||||
return useMemo(
|
||||
() => ({
|
||||
'--oc-brand': brandAccentFromToken(token.colorPrimary, dark),
|
||||
'--oc-stat-brand-bg':
|
||||
'color-mix(in srgb, var(--oc-brand) 6.3%, transparent)',
|
||||
'--ur-progress-done': 'var(--oc-brand)',
|
||||
'--oc-task-success-text': token.colorSuccessText,
|
||||
'--oc-task-success-bg': token.colorSuccessBg,
|
||||
'--oc-task-success-border': token.colorSuccessBorder,
|
||||
'--oc-task-failure-text': token.colorErrorText,
|
||||
'--oc-task-failure-bg': token.colorErrorBg,
|
||||
'--oc-task-failure-border': token.colorErrorBorder,
|
||||
'--oc-task-pending-text': token.colorWarningText,
|
||||
'--oc-task-pending-bg': token.colorWarningBg,
|
||||
'--oc-task-pending-border': token.colorWarningBorder,
|
||||
}),
|
||||
[token, dark],
|
||||
);
|
||||
}
|
||||
|
||||
export default useOrgLogsThemeStyle;
|
||||
@@ -16,7 +16,13 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
For commercial licensing, please contact support@quantumnous.com
|
||||
*/
|
||||
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import React, {
|
||||
useCallback,
|
||||
useEffect,
|
||||
useMemo,
|
||||
useRef,
|
||||
useState,
|
||||
} from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { History } from 'lucide-react';
|
||||
import { Button, Spin, Table, Tag, Typography } from '@/components/ui';
|
||||
@@ -24,8 +30,6 @@ import { API } from '../../../helpers/api';
|
||||
import { showError } from '../../../helpers';
|
||||
import OrgPanel from '../components/OrgPanel';
|
||||
|
||||
const PAGE_SIZE = 20;
|
||||
|
||||
const fmtTime = (v) => (v ? new Date(v * 1000).toLocaleString() : '-');
|
||||
|
||||
// 审计 target 前缀 → 人类可读标签(与后端 afterOrgRuleChange / applyOrgConfig* 的写入口径对应)
|
||||
@@ -55,9 +59,13 @@ const OrgDsChanges = ({ orgId }) => {
|
||||
|
||||
const [requests, setRequests] = useState([]);
|
||||
const [reqPage, setReqPage] = useState(1);
|
||||
const [reqPageSize, setReqPageSize] = useState(20);
|
||||
const reqSizeRef = useRef(20);
|
||||
const [reqTotal, setReqTotal] = useState(0);
|
||||
const [audits, setAudits] = useState([]);
|
||||
const [auditPage, setAuditPage] = useState(1);
|
||||
const [auditPageSize, setAuditPageSize] = useState(20);
|
||||
const auditSizeRef = useRef(20);
|
||||
const [auditTotal, setAuditTotal] = useState(0);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [loadError, setLoadError] = useState(false);
|
||||
@@ -68,9 +76,9 @@ const OrgDsChanges = ({ orgId }) => {
|
||||
setLoadError(false);
|
||||
try {
|
||||
// 后端同一端点按 page 同步分页两个分区;此处按需各取所需分区,互不干扰。
|
||||
const load = async (p) => {
|
||||
const load = async (p, size) => {
|
||||
const res = await API.get(
|
||||
`/api/org/data-security/changes?page=${p}&page_size=${PAGE_SIZE}`,
|
||||
`/api/org/data-security/changes?page=${p}&page_size=${size}`,
|
||||
{ headers },
|
||||
);
|
||||
if (!res.data.success) {
|
||||
@@ -82,8 +90,10 @@ const OrgDsChanges = ({ orgId }) => {
|
||||
// 两分区页码可能不同(各自独立翻页后重试):并发取两页、各取所需分区,
|
||||
// 避免"重试"退化成只刷其中一个分区(review R38 发现)。
|
||||
const [dReq, dAudit] = await Promise.all([
|
||||
load(reqP),
|
||||
auditP === reqP ? null : load(auditP),
|
||||
load(reqP, reqSizeRef.current),
|
||||
auditP === reqP && auditSizeRef.current === reqSizeRef.current
|
||||
? null
|
||||
: load(auditP, auditSizeRef.current),
|
||||
]);
|
||||
const auditSource = dAudit || dReq;
|
||||
setRequests(dReq.requests?.items || []);
|
||||
@@ -93,12 +103,12 @@ const OrgDsChanges = ({ orgId }) => {
|
||||
setAuditTotal(auditSource.audits?.total || 0);
|
||||
setAuditPage(auditP);
|
||||
} else if (section === 'requests') {
|
||||
const d = await load(reqP);
|
||||
const d = await load(reqP, reqSizeRef.current);
|
||||
setRequests(d.requests?.items || []);
|
||||
setReqTotal(d.requests?.total || 0);
|
||||
setReqPage(reqP);
|
||||
} else {
|
||||
const d = await load(auditP);
|
||||
const d = await load(auditP, auditSizeRef.current);
|
||||
setAudits(d.audits?.items || []);
|
||||
setAuditTotal(d.audits?.total || 0);
|
||||
setAuditPage(auditP);
|
||||
@@ -224,7 +234,12 @@ const OrgDsChanges = ({ orgId }) => {
|
||||
}
|
||||
pagination={{
|
||||
currentPage: reqPage,
|
||||
pageSize: PAGE_SIZE,
|
||||
pageSize: reqPageSize,
|
||||
onPageSizeChange: (size) => {
|
||||
reqSizeRef.current = size;
|
||||
setReqPageSize(size);
|
||||
fetchChanges({ reqP: 1, auditP: auditPage, section: 'requests' });
|
||||
},
|
||||
total: reqTotal,
|
||||
onPageChange: (p) =>
|
||||
fetchChanges({ reqP: p, auditP: auditPage, section: 'requests' }),
|
||||
@@ -247,7 +262,12 @@ const OrgDsChanges = ({ orgId }) => {
|
||||
}
|
||||
pagination={{
|
||||
currentPage: auditPage,
|
||||
pageSize: PAGE_SIZE,
|
||||
pageSize: auditPageSize,
|
||||
onPageSizeChange: (size) => {
|
||||
auditSizeRef.current = size;
|
||||
setAuditPageSize(size);
|
||||
fetchChanges({ reqP: reqPage, auditP: 1, section: 'audits' });
|
||||
},
|
||||
total: auditTotal,
|
||||
onPageChange: (p) =>
|
||||
fetchChanges({ reqP: reqPage, auditP: p, section: 'audits' }),
|
||||
|
||||
@@ -30,7 +30,6 @@ import { API } from '../../../helpers/api';
|
||||
import { showError } from '../../../helpers';
|
||||
import OrgPanel from '../components/OrgPanel';
|
||||
|
||||
const PAGE_SIZE = 20;
|
||||
const WINDOW_OPTIONS = [
|
||||
{ value: 24, label: '近 24 小时' },
|
||||
{ value: 24 * 7, label: '近 7 天' },
|
||||
@@ -49,6 +48,7 @@ const OrgDsHitLogs = ({ orgId }) => {
|
||||
const [windowHours, setWindowHours] = useState(24);
|
||||
const [logs, setLogs] = useState([]);
|
||||
const [page, setPage] = useState(1);
|
||||
const [pageSize, setPageSize] = useState(20);
|
||||
const [total, setTotal] = useState(0);
|
||||
const [onlySensitive, setOnlySensitive] = useState(false);
|
||||
const [loading, setLoading] = useState(true);
|
||||
@@ -94,7 +94,7 @@ const OrgDsHitLogs = ({ orgId }) => {
|
||||
setLoadError(false);
|
||||
try {
|
||||
const res = await API.get(
|
||||
`/api/org/data-security/logs?page=${p}&page_size=${PAGE_SIZE}&only_sensitive=${sensitiveOnly}`,
|
||||
`/api/org/data-security/logs?page=${p}&page_size=${pageSize}&only_sensitive=${sensitiveOnly}`,
|
||||
{ headers },
|
||||
);
|
||||
if (seq !== logsSeqRef.current) return;
|
||||
@@ -114,7 +114,7 @@ const OrgDsHitLogs = ({ orgId }) => {
|
||||
if (seq === logsSeqRef.current) setLoading(false);
|
||||
}
|
||||
},
|
||||
[headers, t],
|
||||
[headers, t, pageSize],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
@@ -261,9 +261,13 @@ const OrgDsHitLogs = ({ orgId }) => {
|
||||
}
|
||||
pagination={{
|
||||
currentPage: page,
|
||||
pageSize: PAGE_SIZE,
|
||||
pageSize,
|
||||
total,
|
||||
onPageChange: (p) => fetchLogs(p, onlySensitive),
|
||||
onPageSizeChange: (size) => {
|
||||
setPage(1);
|
||||
setPageSize(size);
|
||||
},
|
||||
}}
|
||||
/>
|
||||
</Spin>
|
||||
|
||||
Reference in New Issue
Block a user