import request from '@/utils/request'

const api = {
  add: '/process/task',
  abandon: '/process/task/abandon',

  taskParticipant: '/process/task/participant/list',

  flow: '/process/task/flow/page',
  recipient: '/process/task/recipient/page',
  finish: '/process/task/finish/page',
  transferRecord: '/process/task/instance/flow/list',
  editStatus: '/process/task/update/status',
  userAuth: '/process/task/userAuthInfo'
}

export function editTask(data) {
  return request({
    url: api.add,
    method: data.id ? 'put' : 'post',
    data
  })
}
// 逻辑刪除
export function abandonTask(ids) {
  return request({
    url: `${api.abandon}/${ids}`,
    method: 'put'
  })
}
// 获取项目参与人员
export function fetchTaskParticipant(params) {
  return request({
    url: api.taskParticipant,
    method: 'get',
    params
  })
}
// 查询流转给我的任务
export function fetchFlowTask(params) {
  return request({
    url: api.flow,
    method: 'get',
    params
  })
}
// 查询抄送给我的任务
export function fetchRecipientTask(params) {
  return request({
    url: api.recipient,
    method: 'get',
    params
  })
}
// 查询处理完成我的任务
export function fetchFinishTask(params) {
  return request({
    url: api.finish,
    method: 'get',
    params
  })
}

export function fetchTaskFlowRecord(params) {
  return request({
    url: api.transferRecord,
    method: 'get',
    params
  })
}

export function editStatus(params) {
  return request({
    url: api.editStatus,
    method: 'put',
    params
  })
}

export function fetchTaskAuth(params) {
  return request({
    url: api.userAuth,
    method: 'get',
    params
  })
}
