import axios from "@/utils/request";
import {filterDeptsOptimize} from "@/api/auth/authDept";


// 获取列表
export function filterList(query) {
  return axios({
    url: "/spms/inv/warehouse/filter",
    method: "get",
    params: query
  });
}

export function filterAll(query) {
  return axios({
    url: "/spms/inv/warehouse/filterAll",
    method: "get",
    params: query
  });
}

export function filterNext(query) {
  return axios({
    url: "/spms/inv/warehouse/filterNext",
    method: "get",
    params: query
  });
}


export function filterAllByLoc(query) {
  return axios({
    url: "/spms/inv/warehouse/filterAllLocInv",
    method: "get",
    params: query
  });
}

export function filterAllByUser(query) {
  return axios({
    url: "/spms/inv/warehouse/filterAllByUser",
    method: "get",
    params: query
  });
}

export function filterUplLocInv(query) {
  return axios({
    url: "/spms/inv/warehouse/filterUplLocInv",
    method: "get",
    params: query
  });
}


// 保存
export function saveWarehouse(data, formName, method = "post") {
  let url =
    formName !== "edit"
      ? "/spms/inv/warehouse/save"
      : "/spms/inv/warehouse/edit";
  return axios({
    url: url,
    method: method,
    data: data
  });
}

// 删除
export function deleteWarehouse(data) {
  return axios({
    url: "/spms/inv/warehouse/delete",
    method: "post",
    data: data
  });
}

export function selectByCode(data) {
  return axios({
    url: "/spms/inv/warehouse/selectByCode",
    method: "post",
    data: data
  });
}

export function disableWarehouse(data) {
  return axios({
    url: "/spms/inv/warehouse/disable",
    method: "post",
    data: data
  });
}

export function uploadStatus(data) {
  return axios({
    url: "/spms/inv/warehouse/upload",
    method: "post",
    data: data
  });
}


export function exportJson(query) {
  return axios({
    url: "/spms/inv/warehouse/exportJson",
    method: "post",
    data: query,
    headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'},
    responseType: 'arraybuffer',   //一定要设置响应类型，否则页面会是空白pdf
  });
}

//加载仓库字典关联用户数据
export function warehouseUserList(query) {
  return axios({
    url: '/warehouse/inout/warehouseUserList',
    method: 'post',
    data: query
  });
}

//加载仓库字段关联单据类型数据
export function warehouseBussinessTypeList(query) {
  return axios({
    url: '/warehouse/inout/warehouseBussniessTypeList',
    method: 'post',
    data: query
  });
}

//管理仓库关联单据类型数据
export function invRelBusTypeList(query) {
  return axios({
    url: '/warehouse/invRelBusType/manageList',
    method: 'post',
    data: query
  });
}

//修改仓库单管理据类型
export function updateInvRelBusType(query) {
  return axios({
    url: '/spms/invRelBusType/warehouse/post',
    method: 'post',
    data: query
  });
}


//保存用户
export function saveWarehouseUser(query) {
  return axios({
    url: '/warehouse/inout/saveWarehouseUser',
    method: 'post',
    data: query
  });
}

//保存用户
export function addWarehouseUser(query) {
  return axios({
    url: '/warehouse/inout/addWarehouseUser',
    method: 'post',
    data: query
  });
}

//添加单据类型
export function saveWarehouseBussinessType(query) {
  return axios({
    url: '/warehouse/inout/saveWarehouseBussinessType',
    method: 'post',
    data: query
  });
}


export function deleteWarehouseUser(params) {
  return axios({
    url: '/warehouse/inout/delWarehouseUser',
    method: 'post',
    params: params
  });
}

export function deleteWarehouseBussinessType(params) {
  return axios({
    url: '/warehouse/inout/delWarehouseBussinessType',
    method: 'post',
    params: params
  });
}

//绑定第三方仓库
export function bindThrWarehouse(params) {
  return axios({
    url: "/spms/inv/warehouse/bindThrWarehouse",
    method: "post",
    params: params
  });
}

//解绑第三方仓库
export function unbindThrWarehouse(params) {
  return axios({
    url: "/spms/inv/warehouse/unbindThrWarehouse",
    method: "post",
    params: params
  });
}

//查询第三方系统和仓库数据关联信息
export function getThrsysDetail(params) {
  return axios({
    url: "/spms/inv/warehouse/thridSys/detail",
    method: "get",
    params: params
  });
}

//替换单据条码
export function replaceCodes(data) {
  return axios({
    url: "/warehouse/inout/replaceCodes",
    method: "post",
    data: data
  })
}

export function filterThridSubByInv(params) {
  return axios({
    url: "/spms/sub/inv/warehouse/filterThridInv",
    method: "get",
    params: params
  });
}

export function getInvListByUser(params) {
  return axios({
    url: "/spms/inv/warehouse/findInvListByUser",
    method: "get",
    params: params
  });
}

export function getInvListByUserOptimize(params) {
  return axios({
    url: "/spms/inv/warehouse/findInvListByUserOptimize",
    method: "get",
    params: params
  });
}

export function findAllInvByUser(params) {
  return axios({
    url: "/spms/inv/warehouse/findAllInvByUser",
    method: "get",
    params: params
  });
}

export function findAllInvByUserOptimize(params) {
  return axios({
    url: "/spms/inv/warehouse/findAllInvByUserOptimize",
    method: "get",
    params: params
  });
}



export function selectInvById(params) {
  return axios({
    url: "/spms/inv/warehouse/selectInvById",
    method: "post",
    data: params
  });
}

export function getDeptById(params) {
  return axios({
    url: "/warehouse/inout/getDeptById",
    method: "post",
    data: params
  });
}



