import request from "@/utils/request";

// 创建出货
export function createbox(data) {
  return request({
    url: "/shipment/box/createAir",
    method: "post",
    data: data,
  });
}

// 更新出货
export function updatebox(data) {
  return request({
    url: "/shipment/box/update",
    method: "put",
    data: data,
  });
}

/**
 * 订舱
 *
 * @export
 * @param {*} data
 * @return {*}
 */
export function booking(data) {
  if (data.id) {
    return request({
      url: "/shipment/box-book-air/update",
      method: "put",
      data,
    });
  }

  return request({
    url: "/shipment/box-book-air/create",
    method: "post",
    data,
  });
}

/**
 * 获得待预装分页
 *
 * @export
 * @param {*} data
 * @return {*}
 */
export function preloadPage(data) {
  return request({
    url: "/ecw/box-preload-goods/preloadPageAir",
    method: "post",
    data,
  });
}

/**
 * 预装
 *
 * @export
 * @param {*} data
 * @return {*}
 */
export function createGoods(data) {
  return request({
    url: "/ecw/box-preload-goods/createAir",
    method: "post",
    data,
  });
}

/*****************************  合包 start **********************************/

/**
 * 获得获得合包箱分页
 *
 * @export
 * @param {*} data
 * @return {*}
 */
export function getMergePkgList(params) {
  return request({
    url: "/ecw/box-merge-pkg/page",
    method: "get",
    params,
  });
}

/**
 * 创建合包箱
 *
 * @export
 * @param {*} data
 * @return {*}
 */
export function createMergePkg(data) {
  return request({
    url: "/ecw/box-merge-pkg/create",
    method: "post",
    data,
  });
}

/**
 * 更新合包箱
 *
 * @export
 * @param {*} data
 * @return {*}
 */
export function updateMergePkg(data) {
  return request({
    url: "/ecw/box-merge-pkg/update",
    method: "put",
    data,
  });
}

/**
 * 删除合包箱
 *
 * @export
 * @param {*} data
 * @return {*}
 */
export function deleteMergePkg(id) {
  return request({
    url: `/ecw/box-merge-pkg/delete?id=`+id,
    method: "delete",
  });
}

/**
 * 获得未装箱列表分页
 *
 * @export
 * @param {*} data
 * @return {*}
 */
export function getUnPkgPage(params) {
  return request({
    url: "/ecw/box-merge-pkg/getUnPkgPage",
    method: "get",
    params,
  });
}

/**
 * 获得已装箱列表分页
 *
 * @export
 * @param {*} data
 * @return {*}
 */
export function getPkgPageByPkgId(params) {
  return request({
    url: "/ecw/box-merge-pkg/getPkgPageByPkgId",
    method: "get",
    params,
  });
}

/**
 * 创建合包订单
 *
 * @export
 * @param {*} data
 * @return {*}
 */
export function createPkgOrder(data) {
  return request({
    url: "/ecw/box-pkg-order/create",
    method: "post",
    data,
  });
}

/**
 * 批量创建合包订单
 *
 * @export
 * @param {*} data
 * @return {*}
 */
export function createBatchPkgOrder(data) {
  return request({
    url: "/ecw/box-pkg-order/createBatch",
    method: "post",
    data,
  });
}

/**
 * 移出合包订单
 *
 * @export
 * @param {*} data
 * @return {*}
 */
export function deleteRelate(pkgId, orderId) {
  return request({
    url: `/ecw/box-pkg-order/deleteRelate`,
    method: "delete",
    headers:{
      'Content-type': 'application/x-www-form-urlencoded'
    },
    data: 'pkgId='+pkgId+'&orderId='+orderId
  });
}

/**
 * 批量移出合包订单
 *
 * @export
 * @param {*} data
 * @return {*}
 */
export function deleteBatchRelate(data) {
  return request({
    url: `/ecw/box-pkg-order/deleteBatchRelate`,
    method: "post",
    data: data
  });
}

/**
 * 获得封箱数据
 *
 * @export
 * @param {*} data
 * @return {*}
 */
export function getMergePkgInfoById(id) {
  return request({
    url: "/ecw/box-merge-pkg/getMergePkgInfoById?id="+id,
    method: "get"
  });
}

/**
 * 获得封箱标签数据
 *
 * @export
 * @param {*} data
 * @return {*}
 */
export function getMergeTagById(id) {
  return request({
    url: "/ecw/box-merge-pkg/getMergeTagById?id="+id,
    method: "get"
  });
}

/**
 * 完成合包
 *
 * @export
 * @param {*} data
 * @return {*}
 */
export function finishMergePkg(shipmentId) {
  return request({
    url: "/ecw/box-merge-pkg/finishMergePkg?shipmentId="+shipmentId,
    method: "get"
  });
}

/*****************************  合包 end **********************************/



/*****************************  起运 start *******************************/
export function takeoffCreate(data) {
  if (data.id) {
    return request({
      url: "/ecw/box-air-fly/update",
      method: "put",
      data,
    });
  }
  return request({
    url: "/ecw/box-air-fly/create",
    method: "post",
    data,
  });
}
/*****************************  起运 end *******************************/

/**
 * 获取出货订单列表
 *
 * @export
 * @param {*} data
 * @return {*}
 */
export function shipmentOrderList(shipmentId) {
  return request({
    url: "/shipment/box/shipmentOrderList?shipmentId="+shipmentId,
    method: "get"
  });
}

/**
 * 更新订单到港状态
 *
 * @export
 * @param {*} data
 * @return {*}
 */
export function updateOrderArrival(data) {
  return request({
    url: `/ecw/box-arrival-air/updateOrderArrival`,
    method: "post",
    data: data
  });
}

/**
 * 创建到港订单
 *
 * @export
 * @param {*} data
 * @return {*}
 */
export function createOrderArrival(data) {
  return request({
    url: `/ecw/box-arrival-air/create`,
    method: "post",
    data: data
  });
}

/**
 * 更新所有订单到港状态
 *
 * @export
 * @param {*} data
 * @return {*}
 */
export function updateAllOrderArrival(data) {
  return request({
    url: `/ecw/box-arrival-air/updateAllOrderArrival`,
    method: "post",
    data: data
  });
}

/**
 * 更新订单清关状态
 *
 * @export
 * @param {*} data
 * @return {*}
 */
export function updateOrderClearance(data) {
  return request({
    url: `/ecw/box-clearance/updateOrderClearance`,
    method: "post",
    data: data
  });
}

/**
 * 更新所有订单清关状态
 *
 * @export
 * @param {*} data
 * @return {*}
 */
export function updateAllOrderClearance(data) {
  return request({
    url: `/ecw/box-clearance/updateAllOrderClearance`,
    method: "post",
    data: data
  });
}

/**
 * 获取线路配置
 *
 * @export
 * @param {*} data
 * @return {*}
 */
export function getLineInfo(params) {
  return request({
    url: `/ecw/warehouse/getLineInfo`,
    method: "get",
    params
  });
}