import request from '@/utils/request';

/**
 * 列表
 */
export async function getList(data) {
  const res = await request.get('/mes/applyoutsource/page', {
    params: data
  });
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**
 * 发布
 */

export async function release(params) {
  const res = await request.post('/mes/applyoutsource/release', params);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

/**批量分批报工 */
export async function batchOutsourcing(params) {
  const res = await request.post('/mes/applyoutsource/splitBatchList', params);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

//发货列表
export async function sendGoodsList(params) {
  const res = await request.post('/mes/applyoutsource/listDetail', params);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

//物品清单列表
export async function itemsList(params) {
  const res = await request.post('/mes/applyoutsource/preDetail', params);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

//保存发货
export async function saveSend(params) {
  const res = await request.post('/mes/applyoutsource/saveDetail', params);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

//保存收货
export async function receivingGoodsList(params) {
  console.log(params, '保存的数据');
  const res = await request.post('/mes/applyoutsource/receiveDetail', params);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

//收货详情
export async function receivingGoodsDetailList(params) {
  const res = await request.post('/mes/applyoutsource/beReceiveDetail', params);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
