import axios from '@/utils/request'
const baseURL = import.meta.env.VITE_APP_BASE_PROCESS_API;
// 查询分页数据：
export const getMyTaskPage = (arg) => {
  return axios.request({
    baseURL: baseURL,
    url: '/engine-rest/task',
    method: 'get',
    params: {
      ...arg,
      latestVersion: true
    },
    dataType: 'json'
  })
}
// 查询详情数据：
export const getMyTaskDetail = (arg) => {
  return axios.request({
    baseURL: baseURL,
    url: `/sys/MyTask/${arg}`,
    method: 'get',
    params: arg,
    dataType: 'json'
  })
}

// 添加数据：
export const addMyTask = (arg) => {
  return axios.request({
    baseURL: baseURL,
    url: '/sys/MyTask',
    method: 'post',
    data: arg,
    dataType: 'json'
  })
}

// 修改数据：
export const updateMyTask = (arg) => {
  return axios.request({
    baseURL: baseURL,
    url: '/sys/MyTask',
    method: 'put',
    data: arg,
    dataType: 'json'
  })
}

// 删除数据:
export const deleteMyTask = (arg) => {
  return axios.request({
    baseURL: baseURL,
    url: `/engine-rest/process-definition/${arg.id[0]}`,
    method: 'delete',
    // data: arg,
    dataType: 'json'
  })
}


// 领取任务:
export const claim = (arg) => {
  return axios.request({
    baseURL: baseURL,
    url: `/engine-rest/task/${arg.taskId}/claim`,
    method: 'post',
    data: arg,
    dataType: 'json'
  })
}
// 取消任务执行人:
export const unclaim = (arg) => {
  return axios.request({
    baseURL: baseURL,
    url: `/engine-rest/task/${arg.taskId}/unclaim`,
    method: 'post',
    data: arg,
    dataType: 'json'
  })
}

// 执行任务:
export const complete = (arg) => {
  return axios.request({
    baseURL: baseURL,
    url: `/engine-rest/task/${arg.taskId}/complete`,
    method: 'post',
    data: arg.data,
    dataType: 'json'
  })
}
//创建任务评论
export const setComment = (arg) => {
  return axios.request({
    baseURL: baseURL,
    url: `/engine-rest/task/${arg.taskId}/comment/create`,
    method: 'post',
    data: arg,
    dataType: 'json'
  })
}


 