feat: 累积功能变更 — 聊天集成、租户管理、小程序更新、ETL 增强、迁移脚本
包含多个会话的累积代码变更: - backend: AI 聊天服务、触发器调度、认证增强、WebSocket、调度器最小间隔 - admin-web: ETL 状态页、任务管理、调度配置、登录优化 - miniprogram: 看板页面、聊天集成、UI 组件、导航更新 - etl: DWS 新任务(finance_area_daily/board_cache)、连接器增强 - tenant-admin: 项目初始化 - db: 19 个迁移脚本(etl_feiqiu 11 + zqyy_app 8) - packages/shared: 枚举和工具函数更新 - tools: 数据库工具、报表生成、健康检查 - docs: PRD/架构/部署/合约文档更新 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
*/
|
||||
|
||||
import React, { useEffect, useState, useCallback, useRef } from 'react';
|
||||
import { useSearchParams } from 'react-router-dom';
|
||||
import {
|
||||
Tabs, Table, Tag, Button, Popconfirm, Space, message, Drawer,
|
||||
Typography, Descriptions, Empty, Spin,
|
||||
@@ -14,12 +15,12 @@ import {
|
||||
import {
|
||||
ReloadOutlined, DeleteOutlined, StopOutlined,
|
||||
UnorderedListOutlined, ClockCircleOutlined, HistoryOutlined,
|
||||
FileTextOutlined,
|
||||
FileTextOutlined, PlayCircleOutlined,
|
||||
} from '@ant-design/icons';
|
||||
import type { ColumnsType } from 'antd/es/table';
|
||||
import type { QueuedTask, ExecutionLog } from '../types';
|
||||
import {
|
||||
fetchQueue, fetchHistory, deleteFromQueue, cancelExecution,
|
||||
fetchQueue, fetchHistory, deleteFromQueue, cancelExecution, rerunExecution,
|
||||
} from '../api/execution';
|
||||
import { apiClient } from '../api/client';
|
||||
import LogStream from '../components/LogStream';
|
||||
@@ -37,6 +38,7 @@ const STATUS_COLOR: Record<string, string> = {
|
||||
success: 'success',
|
||||
failed: 'error',
|
||||
cancelled: 'warning',
|
||||
interrupted: 'volcano',
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
@@ -62,7 +64,7 @@ function fmtDuration(ms: number | null | undefined): string {
|
||||
/* 队列 Tab */
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
||||
const QueueTab: React.FC = () => {
|
||||
export const QueueTab: React.FC = () => {
|
||||
const [data, setData] = useState<QueuedTask[]>([]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
@@ -236,7 +238,7 @@ const QueueTab: React.FC = () => {
|
||||
/* 历史 Tab */
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
||||
const HistoryTab: React.FC = () => {
|
||||
export const HistoryTab: React.FC = () => {
|
||||
const [data, setData] = useState<ExecutionLog[]>([]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [detail, setDetail] = useState<ExecutionLog | null>(null);
|
||||
@@ -263,6 +265,16 @@ const HistoryTab: React.FC = () => {
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
// CHANGE 2026-03-22 | 重新执行历史任务
|
||||
const handleRerun = useCallback(async (id: string) => {
|
||||
try {
|
||||
const { execution_id } = await rerunExecution(id);
|
||||
message.success(`已重新执行,新 ID: ${execution_id.slice(0, 8)}…`);
|
||||
load();
|
||||
} catch { message.error('重新执行失败'); }
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, []);
|
||||
|
||||
const load = useCallback(async () => {
|
||||
setLoading(true);
|
||||
try { setData(await fetchHistory()); }
|
||||
@@ -330,6 +342,23 @@ const HistoryTab: React.FC = () => {
|
||||
}
|
||||
}, [closeHistoryWs, load]);
|
||||
|
||||
// CHANGE 2026-03-27 | 支持 URL 参数 openExecution 自动打开任务详情
|
||||
const [searchParams, setSearchParams] = useSearchParams();
|
||||
const openExecutionHandled = useRef(false);
|
||||
useEffect(() => {
|
||||
const openId = searchParams.get('openExecution');
|
||||
if (!openId || openExecutionHandled.current || loading || data.length === 0) return;
|
||||
openExecutionHandled.current = true;
|
||||
const target = data.find((r) => r.id === openId);
|
||||
if (target) {
|
||||
handleRowClick(target);
|
||||
} else {
|
||||
handleRowClick({ id: openId, status: 'running' } as ExecutionLog);
|
||||
}
|
||||
searchParams.delete('openExecution');
|
||||
setSearchParams(searchParams, { replace: true });
|
||||
}, [data, loading, searchParams, setSearchParams, handleRowClick]);
|
||||
|
||||
const columns: ColumnsType<ExecutionLog> = [
|
||||
{
|
||||
title: '执行 ID', dataIndex: 'id', key: 'id', width: 120,
|
||||
@@ -366,19 +395,25 @@ const HistoryTab: React.FC = () => {
|
||||
) : '—',
|
||||
},
|
||||
{
|
||||
title: '操作', key: 'action', width: 80, align: 'center',
|
||||
render: (_: unknown, record: ExecutionLog) => {
|
||||
if (record.status === 'running') {
|
||||
return (
|
||||
title: '操作', key: 'action', width: 140, align: 'center',
|
||||
render: (_: unknown, record: ExecutionLog) => (
|
||||
<Space size={0}>
|
||||
{record.status === 'running' && (
|
||||
<Popconfirm title="确认终止该任务?" onConfirm={(e) => { e?.stopPropagation(); handleCancelHistory(record.id); }} onCancel={(e) => e?.stopPropagation()}>
|
||||
<Button type="link" danger icon={<StopOutlined />} size="small" onClick={(e) => e.stopPropagation()}>
|
||||
终止
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
);
|
||||
}
|
||||
return null;
|
||||
},
|
||||
)}
|
||||
{record.status !== 'running' && (
|
||||
<Popconfirm title="确认重新执行该任务?" onConfirm={(e) => { e?.stopPropagation(); handleRerun(record.id); }} onCancel={(e) => e?.stopPropagation()}>
|
||||
<Button type="link" icon={<PlayCircleOutlined />} size="small" onClick={(e) => e.stopPropagation()}>
|
||||
重新执行
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
)}
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user