import { request } from 'umi';
import { getDataBaseUrl } from '@/global_data';
/** 获取设备列表  */
export async function GetDeviceInfoPage(data) {
  return request(getDataBaseUrl()+`/api/device/page`, {
    method: 'POST',
    data: data,
  });
}
/**获取产品 */
export async function GetProductList() {
  return request(getDataBaseUrl()+`/api/product/list`, {
    method: 'Get',
  });
}
/** 添加设备  */
export async function AddDeviceInfo(data) {
  return request(getDataBaseUrl()+`/api/device/add`, {
    method: 'POST',
    data: data,
  });
}
export async function PushDeviceGoods(data) {
  return request(getDataBaseUrl()+`/api/device/PushDeviceGoods?DeviceId=`+data, {
    method: 'Get',
  });
}
/** 修改  */
export async function UpdateDeviceInfo(data) {
  return request(getDataBaseUrl()+`/api/device/update`, {
    method: 'POST',
    data: data,
  });
}
/** 修改  */
export async function CopyDevice(data) {
  return request(getDataBaseUrl()+`/api/device/CopyDevice`, {
    method: 'POST',
    data: data,
  });
}
/** 删除  */
export async function DelDeviceInfo(data) {
  return request(getDataBaseUrl()+`​​/api/device/delete`, {
    method: 'POST',
    data: data,
  });
}
/** 获取所有设备标签  */
export async function GetDeviceType() {
  return request(getDataBaseUrl()+`​/api/device/getdevicetypelist`, {
    method: 'GET',
  });
}
/** 添加设备标签  */
export async function AddDeviceType(data) {
  return request(getDataBaseUrl()+`​/api/device/adddevicetype`, {
    method: 'POST',
    data: data,
  });
}
/** 获取所有设备版本  */
export async function GetDeviceVersions() {
  return request(getDataBaseUrl()+`​/api/devicevesion/getdevicevesionlist`, {
    method: 'GET',
  });
}

/**
 * 获取当前设备绑定的商品
 * @param {*} params 
 * @param {*} options 
 * @returns 
 */
export async function GetDeviceGoods(params, options) {
  return request(getDataBaseUrl()+'/api/device/GetDeviceGoods', {
    method: 'POST',
    data: {
      ...params,
    },
  });
}

/**
 * 为设备添加商品 
 * @param {*} params 
 * @returns 
 */
export async function AddDeviceGood(params) {
  return request(getDataBaseUrl()+'/api/device/AddDeviceGood', {
    method: 'POST',
    data: {
      ...params,
    },
  });
}

/**
 * 获取所有商品
 * @param {*} params 
 * @returns 
 */
export async function GetGoods(params) {
  return request(getDataBaseUrl()+'/​api/device/GetGoods', {
    method: 'POST',
    data: {
      ...params,
    },
  });
}

/**
 * 获取所有商品
 * @param {*} params 
 * @returns 
 */
export async function GetByDeviceGoods(params) {
  return request(getDataBaseUrl()+'/​api/device/GetByDeviceGoods', {
    method: 'POST',
    data: {
      ...params,
    },
  });
}

/** 获取商品物料库存  */
export async function GetDeviceStorePage(data) {
  return request(getDataBaseUrl()+`/api/device/GetDeviceStorePage`, {
    method: 'POST',
    data: data,
  });
}

/**
 * 删除库存原料
 * @param {*} data 
 * @returns 
 */
export async function removeSingleStockAdjust(data) {
  return request(getDataBaseUrl()+`/api/device/DelStockAdjust?Id=${data}`, {
    method: 'DELETE',
    // data: data,
    // ...(options || {}),
  });
}

/** 添加商品物料库存  */
export async function AddStoreBatchingStocAsync(data) {
  return request(getDataBaseUrl()+`/api/device/AddUpdateDeviceStocAsync`, {
    method: 'POST',
    data: data,
  });
}

/** 修改商品物料库存  */
export async function UpdateStoreBatchingStocAsync(data) {
  return request(getDataBaseUrl()+`/api/device/AddUpdateDeviceStocAsync`, {
    method: 'put',
    data: data,
  });
}

/**获取位置配置 */
export async function getloc(data) {
  return request(getDataBaseUrl()+`/api/deviceconfig/getlocs?Code=${data}`, {
    method: 'GET',
  });
}

/** 获取原料  */
export async function GetBatchingAsync(data) {
  return request(getDataBaseUrl()+`/api/device/GetProductList`, {
    method: 'post',
    data: data,
  });
}

/**
 * 获取菜谱列表
 * @param {*} params 
 * @returns 
 */
export async function getFoodMenuList(params) {
  return request(getDataBaseUrl()+'/​api/FoodMenu/tree', {
    data: {
      ...params,
    },
  });
}

/** 同步库存  */
export async function PushStockAsync(data) {
  return request(getDataBaseUrl()+`/api/device/PushDevice?DeviceId=${data}`, {
    method: 'post',
  });
}

/** 获取实时库存  */
export async function CheckStockAdjust(data) {
  return request(getDataBaseUrl()+`/api/device/CheckStockAdjust?DeviceId=${data}`, {
    method: 'POST',
  });
}
export async function GetDeviceVesion(TypeCode) {
  return request(getDataBaseUrl()+`/api/DeviceVesion/GetDeviceVesion?productId=${TypeCode}`, {
    method: 'Get',
  });
}

export async function TechnologyTemplateExport(data) {
  return request(getDataBaseUrl()+`/api/goods/TechnologyTemplateExport?deviceId=${data}`, {
    method: 'post',
    // responseType: 'blob'
  });
}


