import request from '@/utils/request';

// 获取需求列表计划
export async function getRequirementListPlan(params) {
  const res = await request.get('/aps/materialrequirements/page', {
    params
  });
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

// 获取需求计划-详情分页
export async function getRequirementListPlanDetailPage(params) {
  const res = await request.get('/aps/materialrequirements/detailPage', {
    params
  });
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

// 获取需求计划-详情
export async function getRequirementListPlanDetail(id) {
  const res = await request.get(`/aps/materialrequirements/getById/${id}`);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

// 获取需求计划-保存
export async function saveRequirementListPlan(data) {
  const res = await request.post('/aps/materialrequirements/save', data);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

// 获取需求计划-修改
export async function updateRequirementListPlan(data) {
  const res = await request.put('/aps/materialrequirements/update', data);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

// 获取需求计划-删除
export async function deleteRequirementListPlan(data) {
  const res = await request.delete(`/aps/materialrequirements/delete`, {
    data
  });

  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

// 获取需求计划-导出
export async function dowloadRequirementListPlan(data) {
  const res = await request.get('/aps/materialrequirements/export', data);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

//领用单分页
export async function getBorrowOrderList(params) {
  const res = await request.get('/aps/borroworder/page', {
    params
  });
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

//领用单保存
export async function saveBorrowOrder(params) {
  const res = await request.post('/aps/borroworder/save', params);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

//领用单详细信息
export async function borrowOrderInfo(id) {
  const res = await request.get(`/aps/borroworder/getById/${id}`);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

//领用单删除
export async function deleteBorrowOrder(data) {
  const res = await request.delete(`/aps/borroworder/delete`, {
    data
  });

  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

//领料单分页
export async function getPickingOrderList(params) {
  const res = await request.get('/aps/pickingorder/page', {
    params
  });
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

//领料单保存
export async function savePickingOrder(params) {
  const res = await request.post('/aps/pickingorder/save', params);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

//领料单详细信息
export async function pickingOrderInfo(id) {
  const res = await request.get(`/aps/pickingorder/getById/${id}`);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

//领料单删除
export async function deletePickingOrder(data) {
  const res = await request.delete(`/aps/pickingorder/delete`, {
    data
  });

  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

//下料单分页
export async function getBlankingOrderList(params) {
  const res = await request.get('/aps/blankingorder/page', {
    params
  });
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

//下料单保存
export async function saveBlankingOrder(params) {
  const res = await request.post('/aps/blankingorder/save', params);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

//下料单详细信息
export async function blankingOrderInfo(id) {
  const res = await request.get(`/aps/blankingorder/getById/${id}`);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

//下料单删除
export async function deleteBlankingOrder(data) {
  const res = await request.delete(`/aps/blankingorder/delete`, {
    data
  });

  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

//退料单分页
export async function getReturnOrderList(params) {
  const res = await request.get('/aps/returnorder/page', {
    params
  });
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

//退料单保存
export async function saveReturnOrder(params) {
  const res = await request.post('/aps/returnorder/save', params);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

//退料单详细信息
export async function returnOrderInfo(id) {
  const res = await request.get(`/aps/returnorder/getById/${id}`);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

//退料单删除
export async function deleteReturnOrder(data) {
  const res = await request.delete(`/aps/returnorder/delete`, {
    data
  });

  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

// 资产
export async function assetPage(data) {
  const res = await request.get('/main/asset/pdaPage', {
    params: data
  });
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

// 在制品
export async function listInProduct(data) {
  const res = await request.post('/pda/mes/feed/listInProduct', data);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

//获取物品维度的库存数据
export async function getOutindetailtwo(params) {
  const res = await request.get(`wms/outInDetailPda/page`, { params });
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

// 父级ID查询分类树
export async function treeByPid(data) {
  const res = await request.get('/pda/main/categoryLevel/pdaTreeByPid', {
    params: data
  });
  if (res.data.code == 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}

//出库单详情
export async function getOutOrderList(params) {
  const res = await request.get('/aps/apsoutstoragedetail/page', {
    params
  });
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

