import request from '@/utils/request'

// 获取验收单列表
export function getAcceptanceFormList(params) {
  return request({
    url: '/acceptance/list',
    method: 'get',
    params
  })
}

// 获查询成的项目List
export function getCompletedProjectList(params) {
  return request({
    url: '/projectInfo/getLocalPurchCompletedProject',
    method: 'get',
    params
  })
}

// 根据业务编号查询项目具体信息
export function getCompletedProjectDetail(params) {
  return request({
    url: '/purchManagement/getPurchCompleted',
    method: 'get',
    params
  })
}

// 钢小二销售单号
export function getSteelBillNumber(params) {
  return request({
    url: '/steel/waiter/billNumbers',
    method: 'get',
    params
  })
}

// 新建验收单-验收经办人
export function getOperaterOfCore(params) {
  return request({
    url: '/acceptance/personInfoList',
    method: 'get',
    params
  })
}

// 货物信息
export function getGoodsBySaleNumber(data) {
  return request({
    url: '/steel/waiter/goods',
    method: 'post',
    data
  })
}

// 下载货物模板
export const download = (data) => (
  request({
    url: '/acceptance/downloadFile',
    method: 'get',
    params: data,
    responseType: 'arraybuffer'
  })
)

// 货物模板导入
export function importGoodsTemplate(data) {
  return request({
    url: '/acceptance/doImportGoodsInfo',
    method: 'post',
    data
  })
}

// 预览上游验收单
export function previewUpFile(data) {
  return request({
    url: '/acceptance/showPdf',
    method: 'post',
    data
  })
}

// 添加验收单
export function acceptanceAddInfo(data) {
  return request({
    url: '/acceptance/add',
    method: 'post',
    data
  })
}

// 退回录入--查询详情
export function getDetails(params) {
  return request({
    url: '/acceptance/findDetail',
    method: 'get',
    params
  })
}

// 修改验收单
export function acceptanceUpdateInfo(data) {
  return request({
    url: '/acceptance/updateDetail',
    method: 'post',
    data
  })
}

// 签署确认-获取详情
export function getSignDetails(params) {
  return request({
    url: '/acceptance/sign/confirm',
    method: 'get',
    params
  })
}

// 刷新认证状态
export function refreshReStatus(params) {
  return request({
    url: '/salesContractManagement/getAuthStatus',
    method: 'get',
    params
  })
}

// 刷新签署状态
export function refreshSiStatus(params) {
  return request({
    url: '/salesContractManagement/signType',
    method: 'get',
    params
  })
}

// 签署确认提交
export function submitSign(data) {
  return request({
    url: '/acceptance/add/sign/confirm',
    method: 'post',
    data
  })
}

// 下载货物模板
export const downloadAdjust = (data) => (
  request({
    url: '/acceptanceAdjust/downLoadGoodsFiles',
    method: 'get',
    params: data,
    responseType: 'arraybuffer'
  })
)

// 单价调整提交
export function acceptanceAdjust(data) {
  return request({
    url: '/acceptanceAdjust/doAdjust',
    method: 'post',
    data
  })
}

// 单价调整审核退回--查询调整详情
export function getAdjustDetails(params) {
  return request({
    url: '/acceptanceAdjust/getDetail',
    method: 'get',
    params
  })
}

// 删除验收单
export function deleteAcceptance(params) {
  return request({
    url: '/acceptance/deleteAcceptance',
    method: 'get',
    params
  })
}

// 验收单--查看历史
export function getHisDetails(params) {
  return request({
    url: '/businessProcessingTask/doBusinessCHistoryView',
    method: 'get',
    params
  })
}

// 验收单-申请审核
export function applyApproval(params) {
  return request({
    url: '/acceptance/applyApproval',
    method: 'get',
    params
  })
}

// 下载已完成附件
export const downloadFinishedFiles = (id) => (
  request({
    url: '/acceptance/downloadSignFile/' + id,
    method: 'get',
    responseType: 'arraybuffer'
  })
)

// 预览已完成附件
export const previewFinishedFiles = (id) => (
  request({
    url: '/acceptance/viewSignFile/' + id,
    method: 'get'
  })
)
