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

/**
 * 获取信息详情
 */
export async function getSendSaleOrderrecordDetail(id) {
  const res = await request.get(`/eom/saleordersendrecord/getById/${id}`, {});
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
/**
 * 获取信息详情
 */
export async function getSendSaleOrderrecordDetailSplit(id) {
  const res = await request.get(`/eom/saleordersendrecord/getByIdSplit/${id}`, {});
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
/**
 * 获取多发货单信息详情
 */
export async function getSendSaleOrderCordList(params) {
  const res = await request.post(`/eom/saleordersendrecord/getList`, params);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

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

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

/**
 * 删除
 */
export async function deleteSendInformation(data) {
  const res = await request.delete('/eom/saleordersendrecord/delete', { data });
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 通过销售发货获取发货清单
 */
export async function getProductListByRecordId(recordId) {
  const res = await request.get(
    `/eom/saleordersendrecord/getProductListByRecordId/${recordId}`,
    {}
  );
  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/salesOrderSendApprove/submit`, data);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
