import request from '@/utils/request';

/**
 * 获取信息列表
 */
export async function getTableList(params) {
  const res = await request.get(`/eom/purchaseplan/page`, { params });
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

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


/**
 * 新增信息
 */
export async function assign(data) {
  const res = await request.post(`/bpm/purchasePlanApprove/assign`, data);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
/**
 * 通过合同ID获取采购计划
 */
export async function getPurchasePlanByContractIdAPI(id) {
  const res = await request.get(`/eom/purchaseplan/getByContractId/${id}`);
  if (res.data.code == 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}
/**
 * 流程作废
 */
export async function cancel(data) {
  const res = await request.put(`/bpm/purchasePlanApprove/cancel`, data);
  if (res.data.code == 0) {
    return Promise.resolve(res.data);
  }
  return Promise.reject(new Error(res.data.message));
}
