import request from '@/utils/request'

// 查询待办任务列表
export const todoList = async (query: any) => {
  return await request({
    url: '/flowable/task/todoList',
    method: 'get',
    params: query
  })
}

// 完成任务
export const complete = async (data: any) => {
	return await request({
		url: "/flowable/task/complete",
		method: "post",
		data: data,
	});
}

// 委派任务
export const delegate = async (data: any) => {
	return await request({
		url: "/flowable/task/delegate",
		method: "post",
		data: data,
	});
}

// 退回任务
export const returnTask = async (data: any) => {
	return await request({
		url: "/flowable/task/return",
		method: "post",
		data: data,
	});
}

// 驳回任务
export const rejectTask = async (data: any) => {
	return await request({
		url: "/flowable/task/reject",
		method: "post",
		data: data,
	});
}

// 可退回任务列表
export const returnList = async (data: any) => {
	return await request({
		url: "/flowable/task/returnList",
		method: "post",
		data: data,
	});
}

// 下一节点
export const getNextFlowNode = async (data: any) => {
	return await request({
		url: "/flowable/task/nextFlowNode",
		method: "post",
		data: data,
	});
}

// 下一节点
export const getNextFlowNodeByStart = async (data: any) => {
	return await request({
		url: "/flowable/task/nextFlowNodeByStart",
		method: "post",
		data: data,
	});
}

// 部署流程实例
export const deployStart = async (deployId: string) => {
	return await request({
		url: "/flowable/process/startFlow/" + deployId,
		method: "get",
	});
}

// 查询流程定义详细
export const getDeployment = async (id: string) => {
	return await request({
		url: "/system/deployment/" + id,
		method: "get",
	});
}

// 新增流程定义
export const addDeployment = async (data: any) => {
	return await request({
		url: "/system/deployment",
		method: "post",
		data: data,
	});
}

// 修改流程定义
export const updateDeployment = async (data: any) => {
	return await request({
		url: "/system/deployment",
		method: "put",
		data: data,
	});
}

// 删除流程定义
export const delDeployment = async (id: string) => {
	return await request({
		url: "/system/deployment/" + id,
		method: "delete",
	});
}

// 导出流程定义
export const exportDeployment = async (query: any) => {
	return await request({
		url: "/system/deployment/export",
		method: "get",
		params: query,
	});
}
// 流程节点表单
export const flowTaskForm = async (query: any) => {
	return await request({
		url: "/flowable/task/flowTaskForm",
		method: "get",
		params: query,
	});
};
