import request from '@/utils/request'
import qs from 'qs'
import { baseUrl } from "../../../config/baseUrl";
import { upcloud_base_common,upcloud_base_wh  } from "@/config/serviceSettings";

export const api = {
  addItem: baseUrl + '/rcvHeaders/v1.0/addWithRelated',
  queryContainerList: baseUrl + '/common/getContainerPage',
  getRecommendArea:baseUrl + '/rcvLines/v1.0/recommendArea',
}

export function addItem(parameter) {
  return request({
    method: 'post',
    url: api.addItem,
    data: parameter
  })
}

export function getBuildingList(parameter) {
  return request({
    method: 'get',
    url: upcloud_base_wh+'/wmsWhBldg/v1/page',
    params: parameter
  })
}

export let arrivalModeList = [];
getArrivalModeList();
export function getArrivalModeList(parameter) {
  return request({
    method: 'post',
    url: upcloud_base_common+'/dict/listbytype?dicttypeCodes=po_billh_arrivalmode',
  }).then(res => {
    arrivalModeList = res.data || [];
    return res;
  })
}

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

// 是否容器必填
export function getINBOUND_CONSTRAINT_CONTAINER(id) {
  return request({
    method: 'get',
    url: upcloud_base_strategy + '/registry/by-code?regCode=INBOUND_CONSTRAINT_CONTAINER&warehouseId=' + id,
  })
}

//控制参数
export function getRequired(parameter) {
  return request({
    method: 'get',
    url:  upcloud_base_strategy + '/registry/by-code',
    params: parameter,
  })
}