
/**
 * 车辆管理接口
 */
import request from '@/utils/request'
import qs from 'qs'
// import Vue from 'vue'
// 车辆查询
export function getCarListPage(params) {
  // const baseUrl = Vue.prototype.baseConfig.carUrl
  return request({
    // baseURL: baseUrl,
    url: '/car/busCarInfo/listPage',
    method: 'get',
    params
  })
}
// 车辆查询
export function getCarList(params) {
  return request({
    url: '/car/busCarPosition/list',
    method: 'get',
    params
  })
}
// 车辆详情
export function getCarDetail(id) {
  return request({
    url: '/car/busCarInfo/detail/' + id,
    method: 'get'
  })
}

// 添加车辆
export function addCar(params) {
  return request({
    url: '/car/busCarInfo/add',
    method: 'post',
    params
  })
}
// 修改车辆机构
export function updateCar(params) {
  return request({
    url: '/car/busCarInfo/update',
    method: 'post',
    params
  })
}
// 删除车辆机构
export function delCar(ids) {
  return request({
    url: '/car/busCarInfo/batchDelete',
    method: 'post',
    params: {
      busCarInfoIds: ids
    },
    paramsSerializer: params => {
      return qs.stringify(params, { indices: false })
    }
  })
}

// 批量导入
export function batchImportCar(fileobj) {
  const param = new FormData()
  param.append('file', fileobj)
  return request({
    url: '/car/busCarInfo/import',
    method: 'post',
    headers: { 'Content-Type': 'multipart/form-data' },
    data: param
  })
}
// 批量导出
export function batchExportCar(params, config) {
  return request({
    url: '/car/busCarInfo/export',
    method: 'get',
    timeout: 120000,
    params,
    ...config,
    responseType: 'blob' // 这一步也很关键，一定要加上 responseType 值为 blob
  })
}

// 车辆作业查询
export function getCarJobRecords(params) {
  return request({
    url: '/sanitation/carJobRecord/listPage',
    method: 'get',
    params
  })
}
// 车辆作业查询
export function exportCarJobRecords(params) {
  return request({
    url: '/sanitation/carJobRecord/export',
    method: 'get',
    params
  })
}
