import request from '@/utils/request';

// 分页
export async function getPage (params) {
  const res = await request.get(`/main/bom/page`, { params });
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

// 保存
export async function bomSave (pid) {
  const res = await request.post(`/main/bom/save`);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
// 详情
export async function getById (id) {
  const res = await request.get(`/main/bom/getById/${id}`);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
// 删除
export async function bomDelete (pid) {
  const res = await request.get(`/main/bom/delete`);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
// 详情分页
export async function detailPage (params) {
  const res = await request.get(`/main/bom/detail/page`, { params });
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
