import request from '@/utils/request'

// 查询出库单主列表
export function listWmsOutboundOrder(query) {
  return request({
    url: '/ware/wmsOutboundOrder/list',
    method: 'get',
    params: query
  })
}

// 查询出库单主详细
export function getWmsOutboundOrder(orderId) {
  return request({
    url: '/ware/wmsOutboundOrder/' + orderId,
    method: 'get'
  })
}

// 新增出库单主
export function addWmsOutboundOrder(data) {
  return request({
    url: '/ware/wmsOutboundOrder',
    method: 'post',
    data: data
  })
}

// 修改出库单主
export function updateWmsOutboundOrder(data) {
  return request({
    url: '/ware/wmsOutboundOrder',
    method: 'put',
    data: data
  })
}

// 删除出库单主
export function delWmsOutboundOrder(orderId) {
  return request({
    url: '/ware/wmsOutboundOrder/' + orderId,
    method: 'delete'
  })
}

// 确认出库
export function confirmOutbound(data) {
  return request({
    url: '/ware/wmsOutboundOrder/rfidPicking',
    method: 'post',
    data: data
  })
}

/**
 * 按照出库明细撤销
 * @param {*} data 出库单明细
 * @param {*} operatorId 操作人ID
 * @returns 
 */
export function cancelByDetailId(data, operatorId) {
  return request({
    url: '/ware/wmsOutboundOrder/cancelItem/' + data.itemId,
    method: 'post',
    data: {
       operatorId: operatorId
    }
  })
}

/**
 * 按照出库记录撤销
 * @param {*} data 出库记录
 * @param {*} operatorId 操作人ID
 * @returns 
 */
export function cancelByRelationId(data, operatorId) {
  return request({
    url: '/ware/wmsOutboundOrder/cancelOutboundRelations/' + data.relationId,
    method: 'post',
    data: {
      operatorId: operatorId
    }
  })
}