import request, { postBlob, getBlob, handleImport } from '@/utils/request'

export function goodsPurchaseList(data) {
  return request({
    url: `/goods/purchase/list?moduleId=${data.moduleId}`,
    method: 'post',
    data
  })
}

export function goodsPurchaseListExport(data, name) {
  return postBlob({
    url: '/goods/purchase/list/export',
    data,
    name
  })
}

export function goodsPurchaseItemList(data) {
  return request({
    url: `/goods/purchase/item/list?moduleId=${data.moduleId}`,
    method: 'post',
    data
  })
}

export function goodsPurchaseItemListExport(data, name) {
  return postBlob({
    url: '/goods/purchase/item/list/export',
    data,
    name
  })
}

export function goodsPurchaseCodeList(data) {
  return request({
    url: `/goods/purchase/code/list?moduleId=${data.moduleId}`,
    method: 'post',
    data
  })
}

export function goodsPurchaseCodeListExport(data, name) {
  return postBlob({
    url: '/goods/purchase/code/list/export',
    data,
    name
  })
}

export function goodsPurchaseAdd(data) {
  return request({
    url: `/goods/purchase/add`,
    method: 'post',
    data
  })
}

export function goodsPurchaseItemAddCode(data) {
  return request({
    url: `/goods/purchase/item/add/code`,
    method: 'post',
    data
  })
}

export function goodsPurchaseDetail(params) {
  return request({
    url: `/goods/purchase/detail`,
    method: 'post',
    params
  })
}

export function goodsPurchaseSubmit(params) {
  return request({
    url: `/goods/purchase/submit`,
    method: 'post',
    params
  })
}

export function goodsPurchaseConfirm(params) {
  return request({
    url: `/goods/purchase/confirm`,
    method: 'post',
    params
  })
}

export function goodsPurchaseItemDelCode(params) {
  return request({
    url: `/goods/purchase/item/del/code`,
    method: 'post',
    params
  })
}

export function goodsPurchaseDel(params) {
  return request({
    url: `/goods/purchase/del`,
    method: 'post',
    params
  })
}

export function goodsPurchaseItemImportCode(data) {
  return handleImport('/goods/purchase/item/import/code', data.formdata, data.id || '')
}
