import { axios } from '@/utils/request'
import request from 'axios'
import qs from 'qs'
import {
  upcloud_base_wh,
  upcloud_base_common,
  upcloud_base_wh_outbound,
  upcloud_base_wh_control,
  upcloud_base_item,
  SERVICE_DATA_API_BASE,
  upcloud_base_strategy
} from '@/config/serviceSettings'

// left join查询商品
export function pagebyRelated(parameter) {
  return axios({
    url: upcloud_base_item + '/item/pagebyRelated',
    method: 'post',
    data: parameter
  })
}

//解锁权限
export function postunlock(params) {
  return axios({
    url: upcloud_base_wh_control + '/workgroup/unlock',
    method: 'post',
    headers: { 'Content-Type': 'application/json' },
    data: params
  })
}

//复核登录权限确认
export function postchecLogin(params) {
  return axios({
    url: upcloud_base_wh_control + '/workgroup/verify-permission',
    method: 'post',
    headers: { 'Content-Type': 'application/json' },
    data: params
  })
}

//复核登录
export function login(parameter) {
  return axios({
    url: '/api/auth/login',
    method: 'post',
    data: qs.stringify(parameter),
    headers: {
      'content-type': 'application/x-www-form-urlencoded'
    }
  })
}

// 是否完成扫描监管码
export function isSupervised(parameter) {
  return axios({
    method: 'post',
    url: upcloud_base_wh_outbound + '/supervisionCode/isSupervised',
    data: parameter
  })
}

// 是否显示扫描监管码
export function isShowSupervised(parameter) {
  return axios({
    method: 'get',
    url: upcloud_base_wh + '/warehouse',
    params: parameter
  })
}

// 是否显示扫描监管码
export function innerCheckConfig(parameter) {
  return axios({
    method: 'get',
    url: upcloud_base_wh_outbound + '/inner/check/innerCheckConfig',
    params: parameter
  })
}

//获取用户信息
export function getInfo(token) {
  return request({
    url: '/api/user/info',
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8',
      'Authorization': `Bearer ${token}`
    }
  })
}

//复核退出
export function postchecLogout(params) {
  return axios({
    url: upcloud_base_wh_outbound + '/inner/check/logout',
    method: 'post',
    headers: { 'Content-Type': 'application/json' },
    data: params
  })
}

//根据容器号获取容器信息
export function getContainer(params) {
  return axios({
    url: upcloud_base_wh_outbound + '/inner/check/container',
    method: 'get',
    params: params
  })
}

//根据容器号获取容器信息
export function getContainer2(params) {
  return axios({
    url: upcloud_base_wh_outbound + '/inner/check/v2/container',
    method: 'get',
    params: params
  })
}

//获取复核商品详情
export function getItemdetail(params) {
  return axios({
    url: upcloud_base_wh_outbound + '/inner/check/item',
    method: 'post',
    headers: { 'Content-Type': 'application/json' },
    data: params
  })
}

//获取复核商品确认
export function getItemConfirm(params) {
  return axios({
    url: upcloud_base_wh_outbound + '/inner/check/confirm',
    method: 'post',
    headers: { 'Content-Type': 'application/json' },
    data: params
  })
}

//获取复核商品信息
export function getItem(params) {
  return axios({
    url: upcloud_base_wh_outbound + '/inner/check/item/info',
    method: 'get',
    params: params
  })
}

//获取复核商品确认
export function getItemnum(params) {
  return axios({
    url: upcloud_base_wh_outbound + '/inner/check/item/number',
    method: 'post',
    headers: { 'Content-Type': 'application/json' },
    data: params
  })
}

//获取复核商品确认2
export function getItemnum2(params) {
  return axios({
    url: upcloud_base_wh_outbound + '/inner/check/v2/item',
    method: 'post',
    headers: { 'Content-Type': 'application/json' },
    data: params
  })
}
// 容器复核确认
export function checkContainerConfirm(params) {
  return axios({
    url: upcloud_base_wh_outbound + '/inner/check/v2/container/confirm/check',
    method: 'post',
    headers: { 'Content-Type': 'application/json' },
    data: params
  })
}

//添加拼箱条形码
export function checkLclBarcode(params) {
  return axios({
    url: upcloud_base_wh_outbound + '/inner/check/lcl/barcode',
    method: 'post',
    params: params
  })
}

//拼箱条形查询
export function LclQuery(params) {
  return axios({
    url: upcloud_base_wh_outbound + '/inner/check/v2/lcl/query',
    method: 'get',
    params: params
  })
}

//冲红保存
export function saveRedhc(params) {
  return axios({
    url: upcloud_base_wh_outbound + '/inner/check/red',
    method: 'post',
    headers: { 'Content-Type': 'application/json' },
    data: params
  })
}

//新冲红保存
export function saveRedhc2(params) {
  return axios({
    url: upcloud_base_wh_outbound + '/inner/check/v2/red',
    method: 'post',
    headers: { 'Content-Type': 'application/json' },
    data: params
  })
}

//获取详细打印数据
export function getDetailPrintInfo(params) {
  return axios({
    url: upcloud_base_wh_outbound + '/inner/check/v2/lcl/detail/print',
    method: 'get',
    params: params
  })
}

//获取打印数据
export function getPrintInfo(params) {
  return axios({
    url: upcloud_base_wh_outbound + '/inner/check/v2/lcl/print',
    method: 'get',
    params: params
  })
}

//获取整件打印数据
export function getWholePrintInfo(params) {
  return axios({
    url: upcloud_base_wh_outbound + '/picktask/print-whole-labels',
    method: 'post',
    headers: { 'Content-Type': 'application/json' },
    data: params
  })
}

//拼箱删除
export function deleteLclNo(params) {
  return axios({
    url: upcloud_base_wh_outbound + '/inner/check/lcl/delete',
    method: 'post',
    params: params
  })
}

//获取复核台
export function getsearchPage(params) {
  return axios({
    url: upcloud_base_wh_control + '/checkWorkGroup/findByWorkCode',
    method: 'get',
    params: params
  })
}

//调整拼箱
export function eidtlclNum(params) {
  return axios({
    url: upcloud_base_wh_outbound + '/inner/check/v2/lcl/adjustV2',
    method: 'post',
    headers: { 'Content-Type': 'application/json' },
    data: params
  })
}

//整件拆分
export function postpieceBreak(params) {
  return axios({
    url: upcloud_base_wh_outbound + '/inner/check/pieceBreak',
    method: 'post',
    headers: { 'Content-Type': 'application/json' },
    params: params
  })
}

/* 条件分页查询(接口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 axios({
    url: SERVICE_DATA_API_BASE + '/search',
    method: 'post',
    data: params
  })
}


export function getLocationType(parameter) {
  return axios({
    method: 'get',
    url: upcloud_base_strategy + '/registry/by-code',
    params: parameter
  })
}

/* 条件分页查询(接口id) post  */
export function postsaveInnerCheckDetails(params) {
  return axios({
    url: upcloud_base_wh_outbound + '/inner/check/saveInnerCheckDetails',
    method: 'post',
    data: params
  })
}

// 字典
export function getDicts(parameter) {
  return axios({
    method: 'post',
    url: upcloud_base_common + '/dict/listbytype',
    params: parameter,
    replaceFields: {
      value: 'dictCode',
      label: 'dictName'
    }
  })
}


/* 功能库房面单打印 post  */
export function queryFuncRoomPrintList(params) {
  return axios({
    url: upcloud_base_wh_outbound + '/picktask/queryFuncRoomPrintList',
    method: 'post',
    data: params
  })
}
/* 内复核标签打印 post  */
export function innerPrintLabel(params) {
  return axios({
    url: upcloud_base_wh_outbound + '/inner/check/v2/lcl/print',
    method: 'get',
    params
  })
}

/* 差异处理批量新增 post  */
export function batchAdd(params) {
  return axios({
    url: upcloud_base_wh_outbound + '/difference/batchAdd',
    method: 'post',
    data: params
  })
}

//取消复核
export function pickTaskCancel(params) {
  return axios({
    url: upcloud_base_wh_outbound + '/inner/check/v2/pickTaskCancel',
    method: 'post',
    data: params
  })
}

//明细拆分
export function pickTaskDetailSplit(params) {
  return axios({
    url: upcloud_base_wh_outbound + '/inner/check/v2/task/split',
    method: 'post',
    data: params
  })
}
