/**
 * 分包评审表管理接口
 */
import request from '@/api/index'

// 不同状态列表分页
export function getListPage(params: any, statusName: string) {
  if (statusName === '全部') {
    return request({
      url: `/subcontract/review/allPage?limit=${params.limit}&offset=${params.offset}`,
      method: 'post',
      data: params,
    })
  }
  else if (statusName === '已审批') {
    return request({
      url: `/subcontract/review/approval/approvedListPage?limit=${params.limit}&offset=${params.offset}`,
      method: 'post',
      data: params,
    })
  }
  else if (statusName === '待审批') {
    return request({
      url: `/subcontract/review/approval/toApprovalListPage?limit=${params.limit}&offset=${params.offset}`,
      method: 'post',
      data: params,
    })
  }
  else {
    return request({
      url: `/subcontract/review/approval/listPage?limit=${params.limit}&offset=${params.offset}`,
      method: 'post',
      data: params,
    })
  }
}
// 详情
export function getDetail(params: object) {
  return request({
    url: '/subcontract/review/detail',
    method: 'get',
    params,
  })
}
// 保存编辑
export function editReview(data: object) {
  return request({
    url: '/subcontract/review/approval/saveOrUpdate',
    method: 'post',
    data,
  })
}
// 导出
export function exportReview(data: object) {
  return request({
    url: '/subcontract/review/allExport',
    method: 'post',
    data,
    responseType: 'blob',
  })
}
// 提交
export function submitReview(data: object) {
  return request({
    url: '/subcontract/review/approval/submit',
    method: 'post',
    data,
  })
}
// 删除记录
export function deleteReview(data: object) {
  return request({
    url: `/subcontract/review/approval/delete?id=${data.id}`,
    method: 'post',
  })
}
// 取消
export function cancelReview(data: object) {
  return request({
    url: '/subcontract/review/approval/cancel',
    method: 'post',
    data,
  })
}
// 审批操作
export function handlerApproval(type: string, data: { processId?: string; taskId?: string; comments: string }) {
  return request({
    url: `/subcontract/review/approval/${type}`,
    method: 'post',
    data,
  })
}
