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 UpdateInformation(data) {
  const res = await request.put(`/eom/purchaseplan/update`, data);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

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

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

/**
 * 计划是否生成过核价单
 */
export async function isHasGeneratedInquiryAPI(id) {
  const res = await request.get(`/eom/purchaseplan/hasGeneratedInquiry/${id}`);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.resolve(0);
}
/**
 * 计划是否生成过合同
 */
export async function isHasGeneratedContractPI(id) {
  const res = await request.get(`/eom/purchaseplan/hasGeneratedContract/${id}`);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.resolve(0);
}
/**
 * 拆分采购计划数据
 */
export async function savePurchasePlanCutAPI(data) {
  const res = await request.post(`/eom/purchaseplan/savePurchasePlanCutDetails`,data);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.resolve(0);
}
