import fetch from 'utils/fetch';

export function page(query) {
  return fetch({
    url: '/vehicle/vehicleInfo/page',
    method: 'get',
    params: {vehiclePageQueryVoJson: query}
  });
}

export function getObj(id) {
  return fetch({
    url: '/vehicle/vehicleInfo/' + id,
    method: 'get'
  });
}


export function addObj(obj) {
  return fetch({
    url: '/vehicle/vehicleInfo',
    method: 'post',
    data: [obj]
  });
}

/*
* 删除一条车辆数据
* */
export function delObj(id) {
  return fetch({
    url: '/vehicle/vehicleInfo/del/' + id,
    method: 'delete'
  });
}

export function book(param) {
  return fetch({
    url: '/vehicle/vehicleInfo/apply/book/vehicle',
    method: 'post',
    data: param
  })
}

export function putObj(obj) {
  return fetch({
    url: '/vehicle/vehicleInfo',
    method: 'put',
    data: [obj]
  })
}

export function getBookedInfoIn2Month(vehicleId) {
  return fetch({
    url: '/vehicle/vehicleInfo/bookedInfo/' + vehicleId,
    method: 'get'
  });
}

export function getBookedInfo(vehicleId, yearMonth) {
  return fetch({
    url: '/vehicle/vehicleInfo/bookedInfo/' + vehicleId + '/' + yearMonth,
    method: 'get'
  });
}

/*
* 根据id获取片区下省份
* */
export function getSysRegionByIds(ids) {
  return fetch({
    url: '/vehicle/sysRegion/getSysRegionByIds/' + ids,
    method: 'get'
  });

}

export function getSysRegionById(id) {
  return fetch({
    url: '/vehicle/sysRegion/getSysRegionById/' + id,
    method: 'get'
  });
}

//重新配车
export function editObj(param) {
  return fetch({
    url: '/api/order/baseOrder/bg/change-vehicle',
    method: 'post',
    data: param
  });
}

//检查车辆编码是否存在
export function checkCode(code, id) {
  return fetch({
    url: '/vehicle/vehicleInfo/exist_code/' + code + '?id=' + id,
    method: 'get'
  });
}
