import request from '@/utils/request';

// 领料保存
export async function batchSave(data) {
  const res = await request.post(`/mes/pickorder/pcBatchSave`, data);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

// 中能领料保存
export async function znfindVoucherList(data) {
  const res = await request.post(`/mes/workorder/findVoucherList`, data);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

// 领料单详细信息
export async function pickDetails(data) {
  const res = await request.post(`/pda/mes/pickorder/list`, data);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

// 非生产性领料保存
export async function unproductive(data) {
  const res = await request.post(`/mes/pickorder/unproductive`, data);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

export async function checkOutsource(param) {
  const res = await request.get(`/mes/applyoutsource/checkOutsource/`, param);

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

// 根据工单工序查已入库的委外申请

export async function listOutsource(wordId, taskId) {
  const res = await request.get(
    `/mes/applyoutsource/listOutsource?workOrderId=${wordId}&taskId=${taskId}`
  );

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

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