import request from '@/utils/request';
import { download } from '@/utils/file';
/**
 * 获取信息列表分页
 */
export async function getSaleEntrustedReceivePageAPI(params) {
  const res = await request.get(`/eom/saleentrustedreceive/page`, { params });
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 获取信息详情
 */
export async function getPSaleEntrustedReceiveDetailAPI(id) {
  const res = await request.get(`/eom/saleentrustedreceive/getById/${id}`, {});
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 更新信息
 */
export async function updateSaleEntrustedReceiveAPI(data) {
  const res = await request.put(`/eom/saleentrustedreceive/update`, data);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 新增信息
 */
export async function saveSaleEntrustedReceiveAPI(data) {
  const res = await request.post(`/eom/saleentrustedreceive/save`, data);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 删除
 */
export async function deleteSaleEntrustedReceiveAPI(data) {
  const res = await request.delete('/eom/saleentrustedreceive/delete', { data });
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
/**
 * 获取受托物料的已收货数量
 */
export async function getReceiveCountAPI(data) {
  const res = await request.post('/eom/saleentrustedreceive/getReceiveCount', data);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}



/**
 * 提交
 */
export async function submit(data) {
  const res = await request.post(`/bpm/saleEntrustedReceiveApprove/submit`, data);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

