91 lines
3.0 KiB
TypeScript
91 lines
3.0 KiB
TypeScript
import request from '@/utils/request';
|
|
import type { Page } from '@/types/base';
|
|
import type {
|
|
WorkflowInstance,
|
|
WorkflowInstanceQuery,
|
|
TaskInstance,
|
|
TaskQuery,
|
|
InstanceStatistics
|
|
} from './types';
|
|
|
|
// 获取工作流实例列表
|
|
export async function getInstances(params: WorkflowInstanceQuery): Promise<Page<WorkflowInstance>> {
|
|
return request.get('/api/v1/workflow/instances/page', { params });
|
|
}
|
|
|
|
// 获取单个工作流实例详情
|
|
export async function getInstanceDetail(id: number): Promise<WorkflowInstance> {
|
|
return request.get(`/api/v1/workflow/instances/${id}`);
|
|
}
|
|
|
|
// 启动工作流实例
|
|
export async function startInstance(data: {
|
|
workflowKey: string;
|
|
businessKey?: string;
|
|
variables?: Record<string, any>;
|
|
}): Promise<WorkflowInstance> {
|
|
return request.post('/api/v1/workflow/instances/start', data);
|
|
}
|
|
|
|
// 终止工作流实例
|
|
export async function terminateInstance(id: number, reason?: string): Promise<void> {
|
|
return request.post(`/api/v1/workflow/instances/${id}/terminate`, { reason });
|
|
}
|
|
|
|
// 挂起工作流实例
|
|
export async function suspendInstance(id: number, reason?: string): Promise<void> {
|
|
return request.post(`/api/v1/workflow/instances/${id}/suspend`, { reason });
|
|
}
|
|
|
|
// 激活工作流实例
|
|
export async function activateInstance(id: number): Promise<void> {
|
|
return request.post(`/api/v1/workflow/instances/${id}/activate`);
|
|
}
|
|
|
|
// 删除工作流实例
|
|
export async function deleteInstance(id: number): Promise<void> {
|
|
return request.delete(`/api/v1/workflow/instances/${id}`);
|
|
}
|
|
|
|
// 获取工作流实例的任务列表
|
|
export async function getInstanceTasks(instanceId: number): Promise<TaskInstance[]> {
|
|
return request.get(`/api/v1/workflow/instances/${instanceId}/tasks`);
|
|
}
|
|
|
|
// 获取任务列表
|
|
export async function getTasks(params: TaskQuery): Promise<Page<TaskInstance>> {
|
|
return request.get('/api/v1/workflow/tasks/page', { params });
|
|
}
|
|
|
|
// 完成任务
|
|
export async function completeTask(taskId: number, variables?: Record<string, any>): Promise<void> {
|
|
return request.post(`/api/v1/workflow/tasks/${taskId}/complete`, { variables });
|
|
}
|
|
|
|
// 委派任务
|
|
export async function delegateTask(taskId: number, assignee: string): Promise<void> {
|
|
return request.post(`/api/v1/workflow/tasks/${taskId}/delegate`, { assignee });
|
|
}
|
|
|
|
// 认领任务
|
|
export async function claimTask(taskId: number): Promise<void> {
|
|
return request.post(`/api/v1/workflow/tasks/${taskId}/claim`);
|
|
}
|
|
|
|
// 获取实例统计信息
|
|
export async function getInstanceStatistics(): Promise<InstanceStatistics> {
|
|
return request.get('/api/v1/workflow/instances/statistics');
|
|
}
|
|
|
|
// 获取实例执行历史
|
|
export async function getInstanceHistory(instanceId: number): Promise<any[]> {
|
|
return request.get(`/api/v1/workflow/instances/${instanceId}/history`);
|
|
}
|
|
|
|
// 获取实例流程图
|
|
export async function getInstanceDiagram(instanceId: number): Promise<string> {
|
|
return request.get(`/api/v1/workflow/instances/${instanceId}/diagram`, {
|
|
responseType: 'text'
|
|
});
|
|
}
|