import request from '@/utils/request';

/*  费用申请  */


// 列表
export async function logistictrakplanPageListAPI(data) {
  let par = new URLSearchParams(data);
  const res = await request.get(`/eom/logistictrakplan/page?` + par, {});
  if (res.data.code == 0) {
    return res.data.data.list;
  }
  return Promise.reject(new Error(res.data.message));
}


// 新增
export async function logistictrakplanSaveAPI(data) {
  const res = await request.post(`/eom/logistictrakplan/save`, data);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

// 编辑
export async function logistictrakplanUpdateAPI(data) {
  const res = await request.put(`/eom/logistictrakplan/update`, data);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

// 信息
export async function logistictrakplanInfoAPI(id) {
  const res = await request.get(`/eom/logistictrakplan/getById/${id}`);
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}

// 删除
export async function logistictrakplanRemoveAPI(data) {
  const res = await request.delete('/eom/logistictrakplan/delete', {data});
  if (res.data.code == 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}
// 手动派单
export async function logistictrakplanDistributionAPI(data) {
  const res = await request.post('/eom/logistictrakplan/distribution', data);
  if (res.data.code == 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}
// 撤回
export async function logistictrakplanwithdrawAPI(data) {
  const res = await request.put('/eom/logistictrakplan/withdraw', data);
  if (res.data.code == 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}
// 检查司机/车辆在该时间段是否在运
export async function checkDriverIsBusyAPI(params) {
  const res = await request.get('/eom/logistictraknote/checkDriverIsBusy', {params});
  if (res.data.code == 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
// 提交-开启流程
export async function logisticSubmit(data) {
  const res = await request.post('/bpm/logistic/submit', data);
  if (res.data.code == 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}
