import fetch from 'utils/fetch';

/**
 * 获取车型列表
 * @param query
 */
export function page(query) {
  return fetch({
    url: '/vehicle/vehicleModel/app/unauth/findVehicleModelPage',
    method: 'post',
    data: query
  });
}
/**
 * 根据车型id获取车型详情
 */
export function getOneTypeById(id) {
  return fetch({
    url: '/vehicle/vehicleModel/' + id,
    method: 'get'
  });
}

/**
 * 获取全部一级标签
 */
export function getAllParentLabel() {
  return fetch({
    url: '/vehicle/cata/add/fingCatasByParentId/' + 0,
    method: 'get'
  });
}

/**
 * 根据parentId获取子标签
 */
export function getLabelByParentId(id) {
  return fetch({
    url: '/vehicle/cata/add/fingCatasByParentId/' + id,
    method: 'get'
  });
}

/**
 * 获取标签列表
 */
// 0-不分页,1-分页(标签列表)
export function getLabelList(query) {
  return fetch({
    url: '/vehicle/cata/add/getCascades/' + query.page + '/' + query.limit + '/' + query.sort,
    method: 'get'
  });
}
/**
 * 删除车型标签deleteVehicleType
 */
export function deleteVehicleType(id) {
  return fetch({
    url: '/vehicle/cata/add/deleteCascadeById/' + id,
    method: 'delete'
  });
}

/**
 * 获取全部车型
 * */
export function getAllVehicleList() {
  return fetch({
    url: '/vehicle/vehicleModel/findAll',
    method: 'get'
  });
}

/**
 * 根据sort排序,获取全部车型
 * */
export function getAllVehicleModelList() {
  return fetch({
    url: '/vehicle/vehicleModel/list',
    method: 'get'
  });
}

/**
 * 车型标签是否多选
 */
export function setIsMoreById(query) {
  return fetch({
    url: '/vehicle/cata/add/setIsMore/' + query.id + '/' + query.isMore,
    method: 'put'
  });
}
/**
 * 是否是筛选条件
 * */
export function setStartUsingById(query) {
  return fetch({
    url: '/vehicle/cata/add/setStartUsingById/' + query.id + '/' + query.startUsing,
    method: 'put'
  });
}

/**
 * 修改标签排序
 */
export function updateParentRank(query) {
  return fetch({
    url: '/vehicle/cata/add/updateParentRank/' + query.id + '/' + query.rank,
    method: 'put'
  });
}

/**
 * 修改和增加一二级标签
 * */
export function updateAndAdd(params) {
  return fetch({
    url: '/vehicle/cata/add/updateAndAdd',
    method: 'post',
    data: params
  });
}

/**
 * 编辑一条车型数据
 * */
export function updateVehicleModel(params) {
  return fetch({
    url: '/vehicle/vehicleModel/app/update',
    method: 'put',
    data: params
  });
}

/*
* 新建一条车型数据
* */
export function addVehicleModel(params) {
  return fetch({
    url: '/vehicle/vehicleModel/app/add',
    method: 'post',
    data: params
  });
}

/**
 * App是否展示
 * @param {Object} params
 */
export function updateAppShow(params) {
  return fetch({
    url: '/vehicle/vehicleModel/bg/updateAppShow',
    method: 'post',
    data: params
  });
}
/*
* 删除一条车型数据
* */
export function delVehicleModel(id) {
  return fetch({
    url: '/vehicle/vehicleModel/app/' + id,
    method: 'delete'
  });
}

/**
 * 上架、下架
 * */
export function upStatusChange(query) {
  return fetch({
    url: '/vehicle/vehicleModel/setStatus/' + query.id + '/' + query.status,
    method: 'put'
  });
}

// 日历价格月份查询
export function priceList(month) {
  return fetch({
    url: '/vehicle/admin/vehicle_model/calendar_price/month?date=' + month,
    method: 'get'
  });
}

// 日历价格具体日期查询
export function dayList(day) {
  return fetch({
    url: '/vehicle/admin/vehicle_model/calendar_price/day?date=' + day,
    method: 'get'
  });
}

// 日历价格设置
export function add_edit(params) {
  return fetch({
    url: '/vehicle/admin/vehicle_model/calendar_price/add_edit',
    method: 'post',
    data: params
  });
}

// 会员等级
export function levels() {
  return fetch({
    url: 'api/admin/member/app/unauth/levels',
    method: 'get'
  });
}

// 节假日设置
export function add_edit_set(params) {
  return fetch({
    url: '/vehicle/admin/vehicle_model/holiday_price/add_edit',
    method: 'post',
    data: params
  });
}

// 节假日列表
export function pageList(params) {
  return fetch({
    url: '/vehicle/admin/vehicle_model/holiday_price/page',
    method: 'post',
    data: params
  });
}

// 节假日删除
export function deleteList(id) {
  return fetch({
    url: '/vehicle/admin/vehicle_model/holiday_price/'+id,
    method: 'delete'
  });
}

// 通用规则设置
export function rule(query) {
  return fetch({
    url: 'vehicle/admin/vehicle_model/holiday_price/update',
    method: 'put',
    params: query
  });
}