import request from "@/utils/request";
import qs from "qs";
import {
  upcloud_base_wh,
  upcloud_base_common,
  upcloud_base_wh_operate,
  upcloud_base_inventory,
  SERVICE_DATA_API_BASE,
  upcloud_base_strategy
} from "@/config/serviceSettings";

// export function wmsdcPage(params) {
//   // 仓配中心/分页查询
//   return request({
//     url: upcloud_base_wh + '/wmsdc/page',
//     method: 'get',
//     params: params,
//     headers: {
//       'Content-Type': 'x-www-form-urlencoded;'
//     }
//   })
// }
export function getSwatichValue(params) {
  return request({
    url: upcloud_base_strategy + "/registry/by-code",
    method: "get",
    params: params,
  });
}

export function updateByCode(params) {
  return request({
    url: upcloud_base_strategy + "/registry/updateByCode",
    method: "post",
    data: params,
  });
}

export function WmsLoctype(params) {
    return request({
      url: upcloud_base_common + `/dict/listbytype/?dicttypeCodes=wms_loctype`,
      method: "post",
    });
  }

export function MoveList(params) {
  // 仓库/分页查询
  return request({
    url: upcloud_base_wh_operate + "/move/v1/list",
    method: "get",
    params: params,
  });
}
export function warehousePage(params) {
  // 仓库/分页查询
  return request({
    url: upcloud_base_wh + "/warehouse/page",
    method: "get",
    params: params,
  });
}

export function invcheckAdd(params) {
  // 查询服务接口-分页查询con
  return request({
    url: upcloud_base_wh_operate + "/invcheck/add",
    method: "post",
    data: params,
  });
}

export function invcheckUpdate(params) {
  // 查询服务接口-分页查询
  return request({
    url: upcloud_base_wh_operate + "/invcheck/update",
    method: "post",
    data: params,
  });
}

export function invcheckExamine(params) {
  // 查询服务接口-分页查询
  return request({
    url: upcloud_base_wh_operate + "/invcheck/examine",
    method: "post",
    data: params,
  });
}

export function adjustUpdate(params) {
  // 修改
  return request({
    url: upcloud_base_wh_operate + "/adjust/update",
    method: "post",
    data: params,
  });
}
export function adjustReject(params) {
  // 驳回
  return request({
    url: upcloud_base_wh_operate + "/adjust/reject",
    method: "post",
    data: params,
  });
}
export function adjustExamine(params) {
  // 审核
  return request({
    url: upcloud_base_wh_operate + "/adjust/examine",
    method: "post",
    data: params,
  });
}

export function adjustAdd(params) {
  // 新增
  return request({
    url: upcloud_base_wh_operate + "/adjust/add",
    method: "post",
    data: params,
  });
}

export function lock(params) {
  // 锁定
  return request({
    url: upcloud_base_inventory + "/stock-lot/v1/lock",
    method: "post",
    data: params,
  });
}

export function unlock(params) {
  // 解锁
  return request({
    url: upcloud_base_inventory + "/stock-lot/v1/unlock",
    method: "post",
    data: params,
  });
}

export function batchNum(params) {
  // 分页查询商品库存批次
  return request({
    url: upcloud_base_inventory + "/batch-number/v1/page",
    method: "post",
    data: params,
  });
}

export function batchGoods(params) {
  // 分页查询商品库存
  return request({
    url: upcloud_base_inventory + "/batch-number/v1/page",
    method: "post",
    data: params,
  });
}

export function moveLocator(params) {
  // 移位保存
  return request({
    url: upcloud_base_wh_operate + "/move/v1/locator",
    method: "post",
    data: params,
  });
}

export function moveAdd(params) {
  // 移库新增
  return request({
    url: upcloud_base_wh_operate + "/move/v1/add",
    method: "post",
    data: params,
  });
}

export function queryMovePrintList(params) {
  // 立体库打印
  return request({
    url: upcloud_base_wh_operate + "/move/queryMovePrintList",
    method: "post",
    data: params,
  });
}

export function moveAudit(params) {
  // 移库审核
  return request({
    url: upcloud_base_wh_operate + "/move/v1/audit",
    method: "post",
    data: params,
  });
}

export function moveCancel(params) {
  // 移库作废
  return request({
    url: upcloud_base_wh_operate + "/move/v1/reject",
    method: "post",
    data: params,
  });
}

export function moveCheck(params) {
  // 移库确认
  return request({
    url: upcloud_base_wh_operate + "/move/v1/check",
    method: "post",
    data: params,
  });
}
export function invcheckAddRe(params) {
  //盘点管理-差异审核-复盘
  return request({
    url: upcloud_base_wh_operate + "/invcheck/add-re",
    method: "post",
    data: params,
  });
}

export function remoteData(params) {
  //月台/修改
  return request({
    url: upcloud_base_common + `/dict/listbytype/?dicttypeCodes=${params.type}`,
    method: "post",
  });
}

export function getLOCK_REASON(params) {
  //月台/修改
  return request({
    url: upcloud_base_common + `/dict/listbytype/?dicttypeCodes=WMS_INV_STOCK_LOCK_REASON`,
    method: "post",
  });
}

/* 主动补货、紧急补货
 通用带分页查询(接口id) post  */
export function search_page(params) {
  return request({
    url: SERVICE_DATA_API_BASE + "/search/page",
    method: "post",
    data: params,
  });
}

/* 通用不带分页查询(接口id)  post  */
export function search_noPage(params) {
  return request({
    url: SERVICE_DATA_API_BASE + "/search",
    method: "post",
    data: params,
  });
}

// 主动补货——保存
export function initiative_save(params) {
  return request({
    url: upcloud_base_wh_operate + "/replenish/v1/initiative",
    method: "post",
    data: params,
  });
}

// 紧急补货——保存
export function urgent_save(params) {
  return request({
    url: upcloud_base_wh_operate + "/replenish/v1/urgent",
    method: "post",
    data: params,
  });
}

// ERP提取移库单列表 get
export function move_erp_list(params) {
  return request({
    url: upcloud_base_wh_operate + "/move/v1/erp-list",
    method: "get",
    params: params,
  });
}

//  ERP移库单生成 post
export function move_erp_add(params) {
  return request({
    url: upcloud_base_wh_operate + "/move/v1/erp-add",
    method: "post",
    data: params,
  });
}

//  GSP移库单生成 post
export function move_gsp_add(params) {
  return request({
    url: upcloud_base_wh_operate + "/move/v1/gsp-add",
    method: "post",
    data: params,
  });
}

// 明细
export function postline(params) {
  return request({
    url: SERVICE_DATA_API_BASE + "/search/page",
    method: "post",
    data: params,
  });
}

// 数据字典
export function dict_listbytype(params) {
  return request({
    url: upcloud_base_common + "/dict/listbytype",
    method: "post",
    params: params,
  });
}

// 新增商品锁定（库存状态调整）
export function invAdjustStatusAdd(params) {
  return request({
    url: upcloud_base_wh_operate + "/invAdjustStatus/add",
    method: "post",
    data: params,
    headers: {
      "Content-Type": "application/json",
    },
  });
}

// 库存状态调整申请（库存状态调整）
export function invAdjustStatus(params) {
  return request({
    url: upcloud_base_wh_operate + "/invAdjustStatus/apply",
    method: "post",
    data: params,
    headers: {
      "Content-Type": "application/json",
    },
  });
}

// 库存状态调整审核（库存状态调整）
export function invAdjustStatusCheck(params) {
  return request({
    url: upcloud_base_wh_operate + "/invAdjustStatus/check",
    method: "post",
    data: params,
    headers: {
      "Content-Type": "application/json",
    },
  });
}

// 库存状态调整审核（库存状态调整）
export function invAdjustStatusConfirm(params) {
  return request({
    url: upcloud_base_wh_operate + "/invAdjustStatus/confirm",
    method: "post",
    data: params,
    headers: {
      "Content-Type": "application/json",
    },
  });
}

export function downLoadFromJar(params) {
  return request({
    url: upcloud_base_inventory + "/excel/downLoadFromJar",
    method: "get",
    data: params,
    responseType: "blob",
  });
}

// 盘点单录入-发送设备指令
export function sendToEis(params) {
  return request({
    url: upcloud_base_wh_operate + "/invcheck/sendDeviceOrder4Check",
    method: "post",
    data: params,
  });
}
// 盘点单录入-发送设备指令
export function mergeTrayQuery(params) {
  return request({
    url: upcloud_base_inventory + "/stock/v1/qty/biteContainerAvl",
    method: "post",
    data: params,
  });
}

// 盘点单录入-发送设备指令
export function getMovePrintData(params) {
  return request({
    url: upcloud_base_wh_operate + "/move/getMovePrintData",
    method: "post",
    data: params,
  });
}
