import createAxios from '@/utils/request'

import { BPM_BOOT } from '@/utils/constantRequest'

const MAPPING_PATH = BPM_BOOT + '/bpm/task'

/**
 * 通过任务
 */
export const approveTask = (data: any) => {
    return createAxios({
        url: MAPPING_PATH + '/approve',
        method: 'POST',
        data: data
    })
}

/**
 * 不通过任务
 */
export const rejectTask = (data: any) => {
    return createAxios({
        url: MAPPING_PATH + '/reject',
        method: 'POST',
        data: data
    })
}

/**
 * 委派任务
 */
export const delegateTask = (data: any) => {
    return createAxios({
        url: MAPPING_PATH + '/delegate',
        method: 'POST',
        data: data
    })
}

/**
 * 回退任务
 */
export const returnTask = (data: any) => {
    return createAxios({
        url: MAPPING_PATH + '/return',
        method: 'POST',
        data: data
    })
}

/**
 * 加签
 */
export const createSignTask = (data: any) => {
    return createAxios({
        url: MAPPING_PATH + '/createSign',
        method: 'POST',
        data: data
    })
}

/**
 * 减签
 */
export const deleteSignTask = (data: any) => {
    return createAxios({
        url: MAPPING_PATH + '/deleteSign',
        method: 'POST',
        data: data
    })
}

/**
 * 转派任务
 */
export const transferTask = (data: any) => {
    return createAxios({
        url: MAPPING_PATH + '/transfer',
        method: 'POST',
        data: data
    })
}


/**
 * 加签
 */
export const getTaskListByParentTaskId = (parentTaskId: any) => {
    return createAxios({
        url: MAPPING_PATH + '/listByParentTaskId?parentTaskId='+parentTaskId,
        method: 'GET'
    })
}


/**
 * 获取所有可回退的节点
 */
export const getTaskListByReturn = (id: string) => {
    return createAxios({
        url: MAPPING_PATH + '/listByReturn?id='+id,
        method: 'GET'
    })
}



/**
 * 获得指定流程实例的任务列表
 */
export const listByProcessInstanceId = (parentTaskId: string) => {
    return createAxios({
        url: MAPPING_PATH + '/listByParentTaskId?parentTaskId='+parentTaskId,
        method: 'GET'
    })
}


/**
 * 获得指定流程实例的任务列表
 */
export const getTaskListByProcessInstanceId = (processInstanceId: string) => {
    return createAxios({
        url: MAPPING_PATH + '/listByProcessInstanceId?processInstanceId='+processInstanceId,
        method: 'GET'
    })
}
