import request from '@/utils/request'

// 查询分配给指定用户的任务
export function getTaskByAssignee(params:any){
    return new Promise((resolve, reject) => {
        request({
            url: '/tansci/system/work/workflow/getTaskByAssignee',
            method: 'get',
            params: params
        }).then((res:any) => {
            resolve(res.data)
        }).catch((e:any) => {
            reject(e)
        })
    })
}

// 部署流程模型
export function deployProcess(data:any){
    return new Promise((resolve, reject) => {
        request({
            url: '/tansci/system/work/workflow/deployProcess',
            method: 'post',
            data: data
        }).then((res:any) => {
            resolve(res.data)
        }).catch((e:any) => {
            reject(e)
        })
    })
}

// 启动流程
export function startProcessInstance(data:any){
    return new Promise((resolve, reject) => {
        request({
            url: '/tansci/system/work/workflow/startProcessInstance',
            method: 'post',
            data: data
        }).then((res:any) => {
            resolve(res.data)
        }).catch((e:any) => {
            reject(e)
        })
    })
}


// 任务审批通过
export function approveTask(data:any){
    return new Promise((resolve, reject) => {
        request({
            url: '/tansci/system/work/workflow/approveTask',
            method: 'post',
            data: data
        }).then((res:any) => {
            resolve(res.data)
        }).catch((e:any) => {
            reject(e)
        })
    })
}


// 任务被拒绝
export function rejectTask(data:any){
    return new Promise((resolve, reject) => {
        request({
            url: '/tansci/system/work/workflow/rejectTask',
            method: 'post',
            data: data
        }).then((res:any) => {
            resolve(res.data)
        }).catch((e:any) => {
            reject(e)
        })
    })
}