import request from '@/utils/request'

// 采购合同列表
export function getPurchaseList(params) {
  return request({
    url: '/purchaseContract/pages',
    method: 'get',
    params
  })
}

// 上传合同
export function purchaseUpload(data) {
  return request({
    url: '/purchaseContract/upload',
    method: 'post',
    data
  })
}

// 采购合同详情
export function getContractDetail(id) {
  return request({
    url: '/purchaseContract/' + id,
    method: 'get'
  })
}

// 采购提交
export function submitPurchaseContract(params, data) {
  return request({
    url: '/purchaseContract/upsert',
    method: 'post',
    params,
    data
  })
}

// 电子签
export function purchaseContractSign(purchaseContractId) {
  return request({
    url: '/purchaseContract/esign?purchaseContractId=' + purchaseContractId,
    method: 'post'
  })
}

// 下载合同文件
export function downloadPurchaseContractFile(params) {
  return request({
    url: `/purchaseContract/download/${params.contractId}`,
    method: 'get',
    responseType: 'arraybuffer'
  })
}
