import request from '@/utils/request'

// 查询采购申请列表
export function listProcurement(query) {
  return request({
    url: '/resources/procurement/list',
    method: 'get',
    params: query
  })
}

// 查询采购申请详细
export function getProcurement(id) {
  return request({
    url: '/resources/procurement/' + id,
    method: 'get'
  })
}

// 新增采购申请
export function addProcurement(data) {
  return request({
    url: '/resources/procurement',
    method: 'post',
    data: data
  })
}

// 修改采购申请
export function updateProcurement(data) {
  return request({
    url: '/resources/procurement',
    method: 'put',
    data: data
  })
}

// 删除采购申请
export function delProcurement(ids) {
  return request({
    url: '/resources/procurement/' + ids,
    method: 'delete'
  })
}

// 提交采购申请
export function submitProcurement(id) {
  return request({
    url: '/resources/procurement/' + id + '/submit',
    method: 'post'
  })
}

// 审核通过
export function approveProcurement(id, comment) {
  return request({
    url: '/resources/procurement/' + id + '/approve',
    method: 'post',
    data: { comment }
  })
}

// 审核驳回
export function rejectProcurement(id, comment) {
  return request({
    url: '/resources/procurement/' + id + '/reject',
    method: 'post',
    data: { comment }
  })
}

// 重新提交
export function resubmitProcurement(id) {
  return request({
    url: '/resources/procurement/' + id + '/resubmit',
    method: 'post'
  })
}

// 确认中标
export function awardProcurement(id, quoteId) {
  return request({
    url: '/resources/procurement/' + id + '/award',
    method: 'post',
    data: { quoteId }
  })
}

// 采购入库
export function receiveProcurement(id, warehouseId) {
  return request({
    url: '/resources/procurement/' + id + '/receive',
    method: 'post',
    data: { warehouseId }
  })
}

// 查询采购明细列表
export function listProcurementItem(procurementId, query) {
  return request({
    url: '/resources/procurement/' + procurementId + '/items',
    method: 'get',
    params: query
  })
}

// 查询采购明细详细
export function getProcurementItem(itemId) {
  return request({
    url: '/resources/procurement/items/' + itemId,
    method: 'get'
  })
}

// 新增采购明细
export function addProcurementItem(procurementId, data) {
  return request({
    url: '/resources/procurement/' + procurementId + '/items',
    method: 'post',
    data: data
  })
}

// 修改采购明细
export function updateProcurementItem(procurementId, itemId, data) {
  return request({
    url: '/resources/procurement/' + procurementId + '/items/' + itemId,
    method: 'put',
    data: data
  })
}

// 删除采购明细
export function delProcurementItem(procurementId, itemId) {
  return request({
    url: '/resources/procurement/' + procurementId + '/items/' + itemId,
    method: 'delete'
  })
}

// 供应商报价
export function submitQuote(procurementId, data) {
  return request({
    url: '/resources/procurement/' + procurementId + '/quote',
    method: 'post',
    data: data
  })
}

// 查询报价列表
export function listProcurementQuote(procurementId, query) {
  return request({
    url: '/resources/procurement/' + procurementId + '/quotes',
    method: 'get',
    params: query
  })
}

// 查询报价详细
export function getProcurementQuote(quoteId) {
  return request({
    url: '/resources/procurement/quotes/' + quoteId,
    method: 'get'
  })
}