/**
 * 状态管理相关接口
 */
import request from '@/api/index'

// 不同状态的列表
export function getListPage(params: any, statusName: string) {
  if (statusName === '全部') {
    return request({
      url: `/status/allPage?limit=${params.limit}&offset=${params.offset}`,
      method: 'post',
      data: params,
    })
  }
  else if (statusName === '已审批') {
    return request({
      url: `/status/approval/approvedListPage?limit=${params.limit}&offset=${params.offset}`,
      method: 'post',
      data: params,
    })
  }
  else if (statusName === '待审批') {
    return request({
      url: `/status/approval/toApprovalListPage?limit=${params.limit}&offset=${params.offset}`,
      method: 'post',
      data: params,
    })
  }
  else {
    return request({
      url: `/status/approval/listPage?limit=${params.limit}&offset=${params.offset}`,
      method: 'post',
      data: params,
    })
  }
}
// 保存编辑
export function editStatus(data: object) {
  return request({
    url: '/status/approval/saveOrUpdate',
    method: 'post',
    data,
  })
}
// 提交
export function submitStatus(data: object) {
  return request({
    url: '/status/approval/submit',
    method: 'post',
    data,
  })
}
// 删除记录
export function deleteStatus(id: string) {
  return request({
    url: `/status/approval/delete?id=${id}`,
    method: 'post',
  })
}
// 取消
export function cancelStatus(data: object) {
  return request({
    url: '/status/approval/cancel',
    method: 'post',
    data,
  })
}
// 详情
export function detailStatus(params: object) {
  return request({
    url: '/status/approval/detail',
    method: 'get',
    params,
  })
}
// 审批操作
export function handlerApproval(type: string, data: { processId?: string; taskId?: string; comments: string }) {
  return request({
    url: `/status/approval/${type}`,
    method: 'post',
    data,
  })
}
