diff --git a/frontend/src/pages/Workflow/Instance/components/DetailModal.tsx b/frontend/src/pages/Workflow/Instance/components/DetailModal.tsx index a0c697e4..6aeb1129 100644 --- a/frontend/src/pages/Workflow/Instance/components/DetailModal.tsx +++ b/frontend/src/pages/Workflow/Instance/components/DetailModal.tsx @@ -1,129 +1,115 @@ import React from 'react'; -import { Modal, Steps, Card, Tag, Row, Col } from 'antd'; -import { CheckCircleOutlined, LoadingOutlined, CloseCircleOutlined } from '@ant-design/icons'; -import './styles.css'; +import { Modal, Steps, Card, Descriptions, Tag, Timeline } from 'antd'; +import { WorkflowHistoricalInstance, WorkflowInstanceStage } from '../types'; +import dayjs from 'dayjs'; interface DetailModalProps { visible: boolean; onCancel: () => void; - instanceData?: any; + instanceData?: WorkflowHistoricalInstance; } -const mockInstanceDetail = { - nodes: [ - { - id: 'start', - name: '开始', - status: 'COMPLETED', - startTime: '2024-12-17 16:25:00', - endTime: '2024-12-17 16:25:01', - }, - { - id: 'script1', - name: '环境检查', - status: 'COMPLETED', - startTime: '2024-12-17 16:25:02', - endTime: '2024-12-17 16:25:10', - output: '环境检查完成,所有依赖已就绪' - }, - { - id: 'script2', - name: '部署应用', - status: 'RUNNING', - startTime: '2024-12-17 16:25:11', - output: '正在部署应用...' - }, - { - id: 'end', - name: '结束', - status: 'PENDING' - } - ] -}; +const DetailModal: React.FC = ({ visible, onCancel, instanceData }) => { + if (!instanceData) return null; -const getStepStatus = (status: string) => { - switch (status) { - case 'COMPLETED': - return 'finish'; - case 'RUNNING': - return 'process'; - case 'ERROR': - return 'error'; - default: - return 'wait'; - } -}; - -const getStatusTag = (status: string) => { - const statusConfig = { - COMPLETED: { color: 'success', icon: , text: '已完成' }, - RUNNING: { color: 'processing', icon: , text: '执行中' }, - ERROR: { color: 'error', icon: , text: '错误' }, - PENDING: { color: 'default', text: '等待中' } + const getStatusTag = (status: string) => { + const statusMap: Record = { + COMPLETED: { color: 'success', text: '已完成' }, + RUNNING: { color: 'processing', text: '运行中' }, + FAILED: { color: 'error', text: '失败' }, + TERMINATED: { color: 'warning', text: '已终止' }, + NOT_STARTED: { color: 'default', text: '未执行' } + }; + const statusInfo = statusMap[status] || { color: 'default', text: status }; + return {statusInfo.text}; }; - const config = statusConfig[status] || statusConfig.PENDING; - return ( - - {config.text} - - ); -}; + const getNodeTypeText = (nodeType: string) => { + const nodeTypeMap: Record = { + startEvent: '开始节点', + endEvent: '结束节点', + serviceTask: '服务任务', + userTask: '用户任务', + scriptTask: '脚本任务' + }; + return nodeTypeMap[nodeType] || nodeType; + }; -const DetailModal: React.FC = ({ visible, onCancel }) => { - const data = mockInstanceDetail; - const currentNodeIndex = data.nodes.findIndex(node => node.status === 'RUNNING'); - const currentNode = data.nodes[currentNodeIndex]; + const getStepStatus = (stage: WorkflowInstanceStage) => { + switch (stage.status) { + case 'COMPLETED': + return 'finish'; + case 'RUNNING': + return 'process'; + case 'FAILED': + return 'error'; + case 'TERMINATED': + return 'wait'; + default: + return 'wait'; + } + }; return ( -
+ + + {instanceData.businessKey} + {getStatusTag(instanceData.status)} + {dayjs(instanceData.startTime).format('YYYY-MM-DD HH:mm:ss')} + + {instanceData.endTime ? dayjs(instanceData.endTime).format('YYYY-MM-DD HH:mm:ss') : '暂无'} + + {instanceData.processInstanceId} + {instanceData.processDefinitionId} + + + + ({ - title: node.name, - status: getStepStatus(node.status) + progressDot + current={instanceData.stages.length} + items={instanceData.stages.map((stage) => ({ + title: stage.nodeName, + description: ( +
+
{getNodeTypeText(stage.nodeType)}
+
{getStatusTag(stage.status)}
+
+ ), + status: getStepStatus(stage) }))} /> -
+ - - {currentNode && ( - - -
-
节点名称
-
{currentNode.name}
-
- - -
-
状态
-
{getStatusTag(currentNode.status)}
-
- - -
-
开始时间
-
{currentNode.startTime || '-'}
-
- - {currentNode.output && ( - -
-
执行输出
-
{currentNode.output}
+ + ({ + color: stage.status === 'COMPLETED' ? 'green' : + stage.status === 'FAILED' ? 'red' : + stage.status === 'RUNNING' ? 'blue' : 'gray', + children: ( +
+
{stage.nodeName} ({getNodeTypeText(stage.nodeType)})
+
+ 开始:{dayjs(stage.startTime).format('YYYY-MM-DD HH:mm:ss')}
- - )} - - )} + {stage.endTime && ( +
+ 结束:{dayjs(stage.endTime).format('YYYY-MM-DD HH:mm:ss')} +
+ )} +
{getStatusTag(stage.status)}
+
+ ) + }))} + />
); diff --git a/frontend/src/pages/Workflow/Instance/components/HistoryModal.tsx b/frontend/src/pages/Workflow/Instance/components/HistoryModal.tsx index b8a5dc7e..79802478 100644 --- a/frontend/src/pages/Workflow/Instance/components/HistoryModal.tsx +++ b/frontend/src/pages/Workflow/Instance/components/HistoryModal.tsx @@ -17,13 +17,19 @@ const HistoryModal: React.FC = ({ visible, onCancel, workflow const [data, setData] = useState([]); const [total, setTotal] = useState(0); const [query, setQuery] = useState({ - pageNum: DEFAULT_CURRENT, + pageNum: DEFAULT_CURRENT - 1, pageSize: DEFAULT_PAGE_SIZE, - workflowDefinitionId }); const [detailVisible, setDetailVisible] = useState(false); const [selectedInstance, setSelectedInstance] = useState(); + useEffect(() => { + setQuery(prev => ({ + ...prev, + workflowDefinitionId + })); + }, [workflowDefinitionId]); + const loadData = async () => { setLoading(true); try { @@ -118,11 +124,11 @@ const HistoryModal: React.FC = ({ visible, onCancel, workflow current: query.pageNum + 1, pageSize: query.pageSize, total: total, - onChange: (page, pageSize) => setQuery({ - ...query, + onChange: (page, pageSize) => setQuery(prev => ({ + ...prev, pageNum: page - 1, pageSize - }), + })), showSizeChanger: true, showQuickJumper: true, }} diff --git a/frontend/src/pages/Workflow/Instance/index.tsx b/frontend/src/pages/Workflow/Instance/index.tsx index 4fb3b849..f69b49a0 100644 --- a/frontend/src/pages/Workflow/Instance/index.tsx +++ b/frontend/src/pages/Workflow/Instance/index.tsx @@ -63,7 +63,7 @@ const WorkflowInstanceList: React.FC = () => { render: (time: string) => time || '暂无' }, { - title: '状态', + title: '最后执行状态', dataIndex: 'lastExecutionStatus', key: 'lastExecutionStatus', render: (status: string) => { diff --git a/frontend/src/pages/Workflow/Instance/service.ts b/frontend/src/pages/Workflow/Instance/service.ts index 0de85ddd..49440b0d 100644 --- a/frontend/src/pages/Workflow/Instance/service.ts +++ b/frontend/src/pages/Workflow/Instance/service.ts @@ -17,4 +17,4 @@ export const getWorkflowInstances = (params?: WorkflowTemplateWithInstancesQuery * @param params 查询参数 */ export const getHistoricalInstances = (params?: WorkflowHistoricalInstanceQuery) => - request.post>(`${INSTANCE_URL}/historical-instances`, params); + request.get>(`${INSTANCE_URL}/historical-instances`, {params});