feat(org): expose enterprise drawing and task logs
(cherry picked from commitb80afd273c) (cherry picked from commit72bec4f8f1)
This commit is contained in:
+146
-129
@@ -47,6 +47,7 @@ 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 {
|
||||
API,
|
||||
showError,
|
||||
@@ -233,6 +234,7 @@ const OrgLogs = ({ orgId, orgRole, isDeptManager = false }) => {
|
||||
const [page, setPage] = useState(1);
|
||||
const pageSize = 20;
|
||||
const [activeTab, setActiveTab] = useState('logs');
|
||||
const [taskFilterRevision, setTaskFilterRevision] = useState(0);
|
||||
const isAdmin =
|
||||
orgRole === 'owner' || orgRole === 'admin' || orgRole === 'super_admin';
|
||||
const canViewTeamUsage = isAdmin || isDeptManager;
|
||||
@@ -344,6 +346,7 @@ const OrgLogs = ({ orgId, orgRole, isDeptManager = false }) => {
|
||||
);
|
||||
}
|
||||
setPage(1);
|
||||
setTaskFilterRevision((revision) => revision + 1);
|
||||
};
|
||||
|
||||
// 重置:回到默认状态(滚动最近 7 天、不限成员/模型)
|
||||
@@ -364,6 +367,7 @@ const OrgLogs = ({ orgId, orgRole, isDeptManager = false }) => {
|
||||
});
|
||||
}
|
||||
setPage(1);
|
||||
setTaskFilterRevision((revision) => revision + 1);
|
||||
};
|
||||
|
||||
// 导出弹窗状态(导出方式 + 字段勾选从 localStorage 恢复)
|
||||
@@ -778,144 +782,157 @@ const OrgLogs = ({ orgId, orgRole, isDeptManager = false }) => {
|
||||
onChange={setActiveTab}
|
||||
items={[
|
||||
{ key: 'logs', label: t('明细日志') },
|
||||
{ key: 'tasks', label: t('绘图与视频') },
|
||||
...(canViewTeamUsage
|
||||
? [{ key: 'ranking', label: t('成员排行') }]
|
||||
: []),
|
||||
]}
|
||||
/>
|
||||
|
||||
{/* 筛选栏(原型 .ee-filter-card / .eex-filter-grid) */}
|
||||
<OrgFilterCard
|
||||
className='oc-exp-filter'
|
||||
actions={
|
||||
<>
|
||||
<Button onClick={handleReset}>{t('重置')}</Button>
|
||||
<Button
|
||||
type='primary'
|
||||
icon={<Search size={16} />}
|
||||
onClick={() => handleSearch(false)}
|
||||
loading={loading}
|
||||
>
|
||||
{t('搜索')}
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
>
|
||||
<AntForm layout='vertical' requiredMark={false} component='div'>
|
||||
<AntForm.Item label={t('成员')}>
|
||||
{canViewTeamUsage ? (
|
||||
<Select
|
||||
value={selectedUserId}
|
||||
onChange={setSelectedUserId}
|
||||
optionList={memberOptions}
|
||||
style={{ width: '100%' }}
|
||||
placeholder={isAdmin ? t('全部成员') : t('全部部门成员')}
|
||||
filter
|
||||
{activeTab === 'tasks' ? (
|
||||
<TaskLogsTable
|
||||
usageRecordMode
|
||||
organizationMode
|
||||
sharedStartTimestamp={appliedFilters.startTimestamp}
|
||||
sharedEndTimestamp={appliedFilters.endTimestamp}
|
||||
sharedFilterRevision={taskFilterRevision}
|
||||
/>
|
||||
) : (
|
||||
<>
|
||||
{/* 筛选栏(原型 .ee-filter-card / .eex-filter-grid) */}
|
||||
<OrgFilterCard
|
||||
className='oc-exp-filter'
|
||||
actions={
|
||||
<>
|
||||
<Button onClick={handleReset}>{t('重置')}</Button>
|
||||
<Button
|
||||
type='primary'
|
||||
icon={<Search size={16} />}
|
||||
onClick={() => handleSearch(false)}
|
||||
loading={loading}
|
||||
>
|
||||
{t('搜索')}
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
>
|
||||
<AntForm layout='vertical' requiredMark={false} component='div'>
|
||||
<AntForm.Item label={t('成员')}>
|
||||
{canViewTeamUsage ? (
|
||||
<Select
|
||||
value={selectedUserId}
|
||||
onChange={setSelectedUserId}
|
||||
optionList={memberOptions}
|
||||
style={{ width: '100%' }}
|
||||
placeholder={isAdmin ? t('全部成员') : t('全部部门成员')}
|
||||
filter
|
||||
/>
|
||||
) : (
|
||||
<div className='oc-exp-self'>{t('仅本人')}</div>
|
||||
)}
|
||||
</AntForm.Item>
|
||||
</AntForm>
|
||||
<AntForm layout='vertical' requiredMark={false} component='div'>
|
||||
<AntForm.Item label={t('时间范围')}>
|
||||
<DatePicker
|
||||
type='dateTimeRange'
|
||||
value={dateRange}
|
||||
onChange={(v) => {
|
||||
setDateRange(v);
|
||||
setIsDefaultRange(false);
|
||||
}}
|
||||
placeholder={[t('开始时间'), t('结束时间')]}
|
||||
style={{ width: '100%' }}
|
||||
/>
|
||||
</AntForm.Item>
|
||||
</AntForm>
|
||||
<AntForm layout='vertical' requiredMark={false} component='div'>
|
||||
<AntForm.Item label={t('模型名称')}>
|
||||
<Input
|
||||
placeholder={t('请输入模型名称')}
|
||||
value={modelName}
|
||||
onChange={setModelName}
|
||||
onEnterPress={() => handleSearch(false)}
|
||||
/>
|
||||
</AntForm.Item>
|
||||
</AntForm>
|
||||
</OrgFilterCard>
|
||||
|
||||
<OrgListCard
|
||||
title={activeTab === 'ranking' ? t('成员排行') : t('明细日志')}
|
||||
tools={
|
||||
<>
|
||||
<Button
|
||||
icon={<Download size={16} />}
|
||||
onClick={() => setExportModalVisible(true)}
|
||||
>
|
||||
{t('导出')}
|
||||
</Button>
|
||||
<Button
|
||||
icon={<RefreshCw size={16} />}
|
||||
onClick={() => handleSearch(true)}
|
||||
loading={loading}
|
||||
>
|
||||
{t('刷新')}
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
>
|
||||
{activeTab === 'ranking' && canViewTeamUsage ? (
|
||||
<Table
|
||||
columns={rankingColumns}
|
||||
dataSource={ranking}
|
||||
loading={rankingLoading}
|
||||
rowKey='user_id'
|
||||
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>
|
||||
}
|
||||
/>
|
||||
) : (
|
||||
<div className='oc-exp-self'>{t('仅本人')}</div>
|
||||
<Table
|
||||
columns={logColumns}
|
||||
dataSource={logs}
|
||||
loading={loading}
|
||||
rowKey='id'
|
||||
scroll={{ x: 1285 }}
|
||||
pagination={{
|
||||
currentPage: page,
|
||||
pageSize,
|
||||
total,
|
||||
showSizeChanger: false,
|
||||
onPageChange: (p) => doPageFetch(p),
|
||||
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>
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</AntForm.Item>
|
||||
</AntForm>
|
||||
<AntForm layout='vertical' requiredMark={false} component='div'>
|
||||
<AntForm.Item label={t('时间范围')}>
|
||||
<DatePicker
|
||||
type='dateTimeRange'
|
||||
value={dateRange}
|
||||
onChange={(v) => {
|
||||
setDateRange(v);
|
||||
setIsDefaultRange(false);
|
||||
}}
|
||||
placeholder={[t('开始时间'), t('结束时间')]}
|
||||
style={{ width: '100%' }}
|
||||
/>
|
||||
</AntForm.Item>
|
||||
</AntForm>
|
||||
<AntForm layout='vertical' requiredMark={false} component='div'>
|
||||
<AntForm.Item label={t('模型名称')}>
|
||||
<Input
|
||||
placeholder={t('请输入模型名称')}
|
||||
value={modelName}
|
||||
onChange={setModelName}
|
||||
onEnterPress={() => handleSearch(false)}
|
||||
/>
|
||||
</AntForm.Item>
|
||||
</AntForm>
|
||||
</OrgFilterCard>
|
||||
|
||||
<OrgListCard
|
||||
title={activeTab === 'ranking' ? t('成员排行') : t('明细日志')}
|
||||
tools={
|
||||
<>
|
||||
<Button
|
||||
icon={<Download size={16} />}
|
||||
onClick={() => setExportModalVisible(true)}
|
||||
>
|
||||
{t('导出')}
|
||||
</Button>
|
||||
<Button
|
||||
icon={<RefreshCw size={16} />}
|
||||
onClick={() => handleSearch(true)}
|
||||
loading={loading}
|
||||
>
|
||||
{t('刷新')}
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
>
|
||||
{activeTab === 'ranking' && canViewTeamUsage ? (
|
||||
<Table
|
||||
columns={rankingColumns}
|
||||
dataSource={ranking}
|
||||
loading={rankingLoading}
|
||||
rowKey='user_id'
|
||||
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>
|
||||
}
|
||||
/>
|
||||
) : (
|
||||
<Table
|
||||
columns={logColumns}
|
||||
dataSource={logs}
|
||||
loading={loading}
|
||||
rowKey='id'
|
||||
scroll={{ x: 1285 }}
|
||||
pagination={{
|
||||
currentPage: page,
|
||||
pageSize,
|
||||
total,
|
||||
showSizeChanger: false,
|
||||
onPageChange: (p) => doPageFetch(p),
|
||||
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>
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</OrgListCard>
|
||||
</OrgListCard>
|
||||
</>
|
||||
)}
|
||||
|
||||
{/* 导出弹窗:汇总 / 按用户 + 字段选择 */}
|
||||
<OrgModal
|
||||
|
||||
Reference in New Issue
Block a user