/**
 * 延迟/送检申请接口
 */
import request from '@/api/index'

// 延迟/送检列表-（不同状态）
export function getListPage(params: any, statusName: string) {
  if (statusName === '全部') {
    return request({
      url: `/inspection/allPage?limit=${params.limit}&offset=${params.offset}`,
      method: 'post',
      data: {
        ...params,
      },
    })
  }
  else if (statusName === '已审批') {
    return request({
      url: `/inspection/approval/approvedListPage?limit=${params.limit}&offset=${params.offset}`,
      method: 'post',
      data: {
        ...params,
      },
    })
  }
  else if (statusName === '待审批') {
    return request({
      url: `/inspection/approval/toApprovalListPage?limit=${params.limit}&offset=${params.offset}`,
      method: 'post',
      data: {
        ...params,
      },
    })
  }
  else {
    return request({
      url: `/inspection/approval/listPage?limit=${params.limit}&offset=${params.offset}`,
      method: 'post',
      data: {
        ...params,
      },
    })
  }
}
// 保存编辑
export function editApply(data: object) {
  return request({
    url: '/inspection/approval/saveOrUpdate',
    method: 'post',
    data,
  })
}
// 导出
export function exportApply(data: object) {
  return request({
    url: '/inspection/allExport',
    method: 'post',
    data,
    responseType: 'blob',
  })
}
// 提交
export function submitApply(data: object) {
  return request({
    url: '/inspection/approval/submit',
    method: 'post',
    data,
  })
}
// 审批操作
export function handlerApproval(type: string, data: { processId?: string; taskId?: string; comments: string }) {
  return request({
    url: `/inspection/approval/${type}`,
    method: 'post',
    data,
  })
}
// 取消
export function cancelApply(data: object) {
  return request({
    url: '/inspection/approval/cancel',
    method: 'post',
    data,
  })
}
// 详情信息
export function detailApply(id: string) {
  return request({
    url: `/inspection/detail?id=${id}`,
    method: 'get',
  })
}
// 删除
export function delApply(data: any) {
  return request({
    url: `/inspection/approval/delete?id=${data.id}`,
    method: 'post',
    // data,
  })
}
