diff --git a/frontend/src/pages/Workflow/Definition/index.tsx b/frontend/src/pages/Workflow/Definition/index.tsx
index dcaaed0a..855ee205 100644
--- a/frontend/src/pages/Workflow/Definition/index.tsx
+++ b/frontend/src/pages/Workflow/Definition/index.tsx
@@ -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 = () => {
handleDeploy(record.id)}>发布
)}
handleDelete(record.id)}>删除
+ {record.status !== 'DRAFT' && (
+ handleStartFlow(record)}>启动
+ )}
),
},
diff --git a/frontend/src/pages/Workflow/Definition/service.ts b/frontend/src/pages/Workflow/Definition/service.ts
index 905fe4d5..764a9123 100644
--- a/frontend/src/pages/Workflow/Definition/service.ts
+++ b/frontend/src/pages/Workflow/Definition/service.ts
@@ -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>(`${DEFINITION_URL}/page`, {params});
@@ -44,4 +45,16 @@ export const getWorkflowCategories = () =>
* @returns Promise 工作流分类
*/
export const getWorkflowCategory = (id: number) =>
- request.get(`${DEFINITION_URL}/categories/${id}`);
\ No newline at end of file
+ request.get(`${DEFINITION_URL}/categories/${id}`);
+
+/**
+ * 启动工作流实例
+ * @param processKey 流程定义key
+ * @param categoryCode 分类编码
+ * @returns Promise
+ */
+export const startWorkflowInstance = (processKey: string, categoryCode: string) =>
+ request.post(`${INSTANCE_URL}/start`, {
+ processKey,
+ businessKey: `${categoryCode}_${Date.now()}`,
+ });
\ No newline at end of file