// import request from "@/utils/request";
import request, { axios } from "@/utils/request";
import qs from "qs";
import { upcloud_base_wh_inbound, upcloud_base_common, upcloud_base_strategy } from "@/config/serviceSettings";

export const api = {
  findCodesByAllRefBillLineId: upcloud_base_wh_inbound + "/supervisionCode/findCodesByAllRefBillLineId",
  delIds: upcloud_base_wh_inbound + "/supervisionCode/delIds",
  addItem: upcloud_base_wh_inbound + "/rqcHeaders/addWithRelated",
  taskSplit: upcloud_base_wh_inbound + "/rqcHeaders/taskSplit",
  doException: upcloud_base_wh_inbound + "/rqcHeaders/doException",
  getPreList: upcloud_base_wh_inbound + "/wmsInRqcSample/v1/get-prelist",
  batchAdd: upcloud_base_wh_inbound + "/wmsInRqcSample/v1/batchAdd",
  addSupervisionCode: upcloud_base_wh_inbound + "/supervisionCode/addSupervisionCode",
  findCodesByBill: upcloud_base_wh_inbound + "/supervisionCode/findCodesByBill",
  isSupervised: upcloud_base_wh_inbound + "/supervisionCode/isSupervised",
  extractSelectedRqcTask: upcloud_base_wh_inbound + "/rqcHeaders/extractSelectedRqcTask",
  deleteCodesByBill: upcloud_base_wh_inbound + "/supervisionCode/deleteCodesByBill",
  isSupervisedReject: upcloud_base_wh_inbound + "/supervisionCode/isSupervised-reject",
};

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

export function taskSplit(parameter) {
  return request({
    method: "post",
    url: api.taskSplit,
    data: parameter,
  });
}

export function doException(parameter) {
  return request({
    method: "post",
    url: api.doException,
    data: parameter,
  });
}

export function getPrintInfo(data) {
  return request({
    method: "post",
    url: upcloud_base_common + "/print/getPrintInfo",
    data,
  });
}

//获取预抽样集合
export function getPreList(parameter) {
  return request({
    method: "post",
    url: api.getPreList,
    data: parameter,
  });
}
//抽检
export function batchAdd(parameter) {
  return request({
    method: "post",
    url: api.batchAdd,
    data: parameter,
  });
}
//扫描监管码
export function addSupervisionCode(parameter) {
  return request({
    method: "post",
    url: api.addSupervisionCode,
    data: parameter,
  });
}

// 获取已扫码监管码列表
export function findCodesByBill(parameter) {
  return request({
    method: "get",
    url: api.findCodesByBill,
    contentType: "x-www-form-urlencoded",
    params: parameter,
  });
}
// 是否完成扫描监管码
export function isSupervised(parameter) {
  return request({
    method: "post",
    url: api.isSupervised,
    data: parameter,
  });
}
// 更新监管码数据
export function extractSelectedRqcTask(parameter) {
  return request({
    method: "post",
    url: upcloud_base_wh_inbound + "/supervisionCode/querySupervisionCodedList",
    data: parameter,
  });
}
// 字典
export function getDicts(parameter) {
  return request({
    method: "post",
    url: upcloud_base_common + "/dict/listbytype",
    params: parameter,
    replaceFields: {
      value: "dictCode",
      label: "dictName",
    },
  });
}

// 获取入库结论-策略
export const getStockStatusOptions = (params) => {
  return axios.get(upcloud_base_strategy + "/strategy/v1/execute", { params });
};
export const IS_AGV = () => {
  return axios.post(upcloud_base_common + "/dict/listbytype?dicttypeCodes=IS_AGV");
};

// remoteUrl: { url: upcloud_base_strategy + "/strategy/v1/execute", method: "get" },

export function strategyExecute(data) {
  return request({
    method: "get",
    url: upcloud_base_strategy + "/strategy/v1/execute",
    params: data,
  });
}

export function findCodesByAllRefBillLineId(parameter) {
  return request({
    method: "post",
    url: api.findCodesByAllRefBillLineId,
    // contentType: 'x-www-form-urlencoded',
    data: parameter,
  });
}

export function delIds(parameter) {
  return request({
    method: "post",
    url: api.delIds,
    data: parameter,
  });
}

export function deleteCodesByBill(parameter) {
  return request({
    method: "post",
    url: api.deleteCodesByBill,
    data: parameter,
  });
}

export function isSupervisedReject(parameter) {
  return request({
    method: "post",
    url: api.isSupervisedReject,
    data: parameter,
  });
}
