1
This commit is contained in:
parent
e59b14c90c
commit
d298a8770c
@ -112,6 +112,17 @@ const WorkflowDefinitionList: React.FC = () => {
|
||||
});
|
||||
};
|
||||
|
||||
const handleStartFlow = async (record: WorkflowDefinition) => {
|
||||
try {
|
||||
await service.startWorkflowInstance(record.key, record.category);
|
||||
message.success('流程启动成功');
|
||||
} catch (error) {
|
||||
if (error instanceof Error) {
|
||||
message.error(error.message);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const columns = [
|
||||
{
|
||||
title: '流程名称',
|
||||
@ -184,6 +195,9 @@ const WorkflowDefinitionList: React.FC = () => {
|
||||
<a onClick={() => handleDeploy(record.id)}>发布</a>
|
||||
)}
|
||||
<a onClick={() => handleDelete(record.id)}>删除</a>
|
||||
{record.status !== 'DRAFT' && (
|
||||
<a onClick={() => handleStartFlow(record)}>启动</a>
|
||||
)}
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
|
||||
@ -4,6 +4,7 @@ import {Page} from '@/types/base';
|
||||
import {WorkflowCategory} from './types'; // Add this line
|
||||
|
||||
const DEFINITION_URL = '/api/v1/workflow/definition';
|
||||
const INSTANCE_URL = '/api/v1/workflow/instance';
|
||||
|
||||
export const getDefinitions = (params?: WorkflowDefinitionQuery) =>
|
||||
request.get<Page<WorkflowDefinition>>(`${DEFINITION_URL}/page`, {params});
|
||||
@ -44,4 +45,16 @@ export const getWorkflowCategories = () =>
|
||||
* @returns Promise<WorkflowCategory> 工作流分类
|
||||
*/
|
||||
export const getWorkflowCategory = (id: number) =>
|
||||
request.get<WorkflowCategory>(`${DEFINITION_URL}/categories/${id}`);
|
||||
request.get<WorkflowCategory>(`${DEFINITION_URL}/categories/${id}`);
|
||||
|
||||
/**
|
||||
* 启动工作流实例
|
||||
* @param processKey 流程定义key
|
||||
* @param categoryCode 分类编码
|
||||
* @returns Promise<void>
|
||||
*/
|
||||
export const startWorkflowInstance = (processKey: string, categoryCode: string) =>
|
||||
request.post<void>(`${INSTANCE_URL}/start`, {
|
||||
processKey,
|
||||
businessKey: `${categoryCode}_${Date.now()}`,
|
||||
});
|
||||
Loading…
Reference in New Issue
Block a user