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

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

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

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

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


/**
 * 流程作废
 */
export async function cancel(data) {
  const res = await request.put(`/bpm/purchaseOutsourceSendApprove/cancel`, data);
  if (res.data.code == 0) {
    return Promise.resolve(res.data);
  }
  return Promise.reject(new Error(res.data.message));
}
