
import { axios } from '@/utils/request'
import request from 'axios'
// import api from './default.js'
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 request({
    url: upcloud_base_item + '/item/pagebyRelated',
    method: 'post',
    data: parameter,
	headers: {
	  'Authorization':'Bearer '+JSON.parse( localStorage.getItem("token") ),
	  'content-type': 'application/json'
	}
  })
}

const userApi = {
  Login: '/api/auth/login',
  Logout: '/api/auth/logout',
  UserMenu: '/api/user/nav',
  UserInfo: '/api/user/info',
  Renew: '/api/token/refresh',
}
//解锁权限
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: userApi.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: userApi.UserInfo,
    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',
    // headers: { 'Content-Type': 'application/json' },
    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',
    // headers: { 'Content-Type': 'application/json' },
    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
  })
}
//添加拼箱条形码
export function checkLclBarcode(params) {
  return axios({
    url: upcloud_base_wh_outbound+'/inner/check/lcl/barcode',
    method: 'post',
    // headers: { 'Content-Type': 'application/json' },
    params: params
  })
}
//拼箱条形查询
export function LclQuery(params) {
  return axios({
    url: upcloud_base_wh_outbound+'/inner/check/lcl/query',
    method: 'get',
    // headers: { 'Content-Type': 'application/json' },
    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 getDetailPrintInfo(params) {
  return axios({
    url: upcloud_base_wh_outbound+'/inner/check/lcl/detail/print',
    method: 'get',
    // headers: { 'Content-Type': 'application/json' },
    params: params
  })
}
//获取打印数据
export function getPrintInfo(params) {
  return axios({
    url: upcloud_base_wh_outbound+'/inner/check/lcl/print',
    method: 'get',
    // headers: { 'Content-Type': 'application/json' },
    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',
    // headers: { 'Content-Type': 'application/json' },
    params: params
  })
}
//获取复核台
export function getsearchPage(params) {
  return axios({
    url: upcloud_base_wh_control+'/checkWorkGroup/findByWorkCode',
    method: 'get',
    // headers: { 'Content-Type': 'application/json' },
    params: params
  })
}
//调整拼箱
export function eidtlclNum(params) {
  return axios({
    url: upcloud_base_wh_outbound+'/inner/check/lcl/adjust',
    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 request ({
		 url: SERVICE_DATA_API_BASE+'/search',
		 method: 'post',
		 data: params,
		 headers: {
		   'Authorization':'Bearer '+JSON.parse( localStorage.getItem("token") ),
		   'content-type': 'application/json'
		 }
	 })
 }
 
 
 export function getLocationType(parameter) {
  return request({
    method: 'get',
    url: upcloud_base_strategy+'/registry/by-code',
    params: parameter,
    headers: {
      'Authorization':'Bearer '+JSON.parse( localStorage.getItem("token") ),
      'content-type': 'application/json'
    }
  })
}

/* 条件分页查询(接口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 request({
    method: 'post',
    url: upcloud_base_common+'/dict/listbytype',
    params: parameter,
    replaceFields: {
      value: 'dictCode',
      label: 'dictName'
    },
    headers: {
      'Authorization':'Bearer '+JSON.parse( localStorage.getItem("token") ),
      'content-type': 'application/json'
    }
  })
}


/* 功能库房面单打印 post  */
export function  queryFuncRoomPrintList(params){
  return axios ({
    url: upcloud_base_wh_outbound+'/picktask/queryFuncRoomPrintList',
    method: 'post',
    data: params
  })
}