import request from '@/utils/request';

/**
 * 列表
 */
export async function getList (data) {
  const res = await request.post('/aps/batchingplan/page', data);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
/**
 * 保存
 */
export async function save (data) {
  const res = await request.post('/aps/batchingplan/save', data);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 修改
 */
export async function del (data) {
  const res = await request.delete('/aps/batchingplan/delete', { data });
  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(`/aps/batchingplan/getById/${id}`);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
/**
 * 详情
 */
export async function getPlanInfoById (id) {
  const res = await request.get(`/aps/batchingplan/getPlanInfoById/${id}`);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
/**
 * 发布信息返显
 */
export async function getReleaseInfoById (id) {
  const res = await request.get(`/aps/batchingplan/getReleaseInfoById/${id}`);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}


// 获取列表
export async function getMaterialList(data) {
  const res = await request.get(`/wms/outin/getRealTimeInventory`, {
    params: data
  });
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}





// 批量根据生产计划计算bom列表信息

export async function listBomBySalesOrderIds(data) {
  const res = await request.post(`/aps/batchingplandetail/listBomBySalesOrderIds`,data);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}


// 根据销售订单计算bom列表信息
export async function listBomBySalesOrderId(data) {
  const res = await request.post(`/aps/batchingplandetail/listBomBySalesOrderId`,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/apspurchaseplan/submit`,data);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

