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

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

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

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

/**
 * 删除
 */
export async function deleteReturnInformation(data) {
  const res = await request.delete('/eom/saleorderreturnrecord/delete', { 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/salesOrderReturnApprove/submit`, data);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}







// /**
//  * 根据退货单编码获取出库单详情
//  */
// export async function getOutInBySourceBizNoAPI(id) {
//   const res = await request.get(`/wms/outin/getOutInBySourceBizNo/${id}`);
//   if (res.data.code == 0) {
//     return res.data.data;
//   }
//   return Promise.reject(new Error(res.data.message));
// }
/**
 * 获取客户退货列表
 */
export async function saleReturnPageList(params) {
  const res = await request.get(`/eom/salereturnhandle/page`,{ params });
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
/**
 * 客户退货处理单-保存
 */
export async function saleReturnSaveAPI(data) {
  const res = await request.post(`/eom/salereturnhandle/save`,data);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
/**
 * 客户退货处理单-修改
 */
export async function saleReturnUpdateAPI(data) {
  const res = await request.post(`/eom/salereturnhandle/update`,data);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
/**
 * 客户退货处理单-详情
 */
export async function saleReturnGetByIdAPI(id) {
  const res = await request.get(`/eom/salereturnhandle/getById/${id}`);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
/**
 * 客户退货处理单-删除
 */
export async function deleteSaleReturnAPI(data) {
  const res = await request.delete('/eom/salereturnhandle/delete', { data });
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 客户退货处理单-提交开启流程
 */
export async function salesOrderReturnSubmit(data) {
  const res = await request.post(`/bpm/salesOrderReturnHandle/submit`,data);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
/**
 * 客户退货处理单-获取销售发货单数据
 */
export async function getSaleOrderSendInfoAPI(returnHandleId) {
  const res = await request.get(`/eom/salereturnhandle/getSaleOrderSendInfo/${returnHandleId}`);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
/**
 * 客户退货处理单-更新各种单据字段
 */
export async function saleReturnHandleUpdateReceipt(data) {
  const res = await request.post(`/eom/salereturnhandle/updateReceipt`,data);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}



