import { FlowFormVO } from './types';
import request from '/@/utils/request';

/**
 * 创建流程
 *
 * @param data
 */
export function addFlow(data: any) {
	return request({
		url: '/task/process/create',
		method: 'post',
		data: data,
	});
}

/**
 * 获取流程详细信息
 *
 * @param data
 */
export function getFlowDetail(flowId: string) {
	return request({
		url: '/task/process/getDetail',
		method: 'get',
		params: {flowId},
	});
}

/**
 * 停用流程
 *
 * @param data
 */
export function disableFlow(flowId: string) {
	return request({
		url: '/task/process/update/' + flowId + '?type=stop',
		method: 'put',
	});
}

/**
 * 删除流程
 *
 * @param data
 */
export function deleteFlow(flowId: string) {
	return request({
		url: '/task/process/update/' + flowId + '?type=delete',
		method: 'put',
	});
}

/**
 * 启用流程
 *
 * @param data
 */
export function enableFlow(flowId: string) {
	return request({
		url: '/task/process/update/' + flowId + '?type=using',
		method: 'put',
	});
}

/**
 * 发起流程
 *
 * @param data
 */
export function startFlow(obj: any) {
	return request({
		url: '/task/process-instance/startProcessInstance',
		method: 'post',
		data: {...obj},
	});
}

/**
 * 发起流程时附加的表单数据
 */
export function addFlowForm(obj: FlowFormVO) {
	return request({
		url: '/task/flow/form/add',
		method: 'post',
		data: {...obj},
	});
}

/**
 * 发起流程时附加的表单数据
 */
export function getFlowFormByProcessInstanceId(processInstanceId: string) {
	return request({
		url: '/task/flow/form/view',
		method: 'get',
		params: { processInstanceId },
	});
}


/**
 * 发起流程时附加的表单数据
 */
export function getTaskDetail(processInstanceId: string) {
	return request({
		url: '/task/process-instance/getTaskDetail',
		method: 'get',
		params: { processInstanceId },
	});
}
/**
 * 根据流程实例id查询
 * 项目储备审核数据
 * /admin/reserveInvestmentProjects/getByProcessInstanceId
 * */
export function getReserveInvestmentProjectsByProcessInstanceId(processInstanceId: string) {
	return request({
		url: '/admin/reserveInvestmentProjects/getByProcessInstanceId',
		method: 'get',
		params: { processInstanceId },
	});
}
/**
 * 根据流程实例id查询
 * 对外合作
 * /admin/externalCooperationUnits/getByProcessInstanceId
 * */
export function getExternalCooperationUnitsByProcessInstanceId(processInstanceId: string) {
	return request({
		url: '/admin/externalCooperationUnits/getByProcessInstanceId',
		method: 'get',
		params: { processInstanceId },
	});
}

/**
 * 获取业务流程ID列表
 * */
export function getBusinessFlowList() {
    return request<{ id: number, flowId: string }[]>({
        url: '/task/task/getBusinessFlowList',
        method: 'get'
    });
}