This commit is contained in:
dengqichen 2024-12-16 18:03:31 +08:00
parent e59b14c90c
commit d298a8770c
2 changed files with 28 additions and 1 deletions

View File

@ -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>
),
},

View File

@ -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()}`,
});