import request from '@/utils/request'
import qs from "qs"
import Vue from 'vue'

// 路灯状态统计
export function getLampStatus() {
  const basetConfig = Vue.prototype.baseConfig // 注意该行应放在export里面，否则获取不到值
  const lampPath = basetConfig.lampBasePath
  return request({
    url: lampPath + 'overview/lampStatus',
    method: 'get'
  })
}

//  路灯总览列表
export function getLampList(params) {
  const basetConfig = Vue.prototype.baseConfig // 注意该行应放在export里面，否则获取不到值
  const lampPath = basetConfig.lampBasePath
  return request({
    url: lampPath + 'overview/lampList',
    method: 'get',
    params
  })
}

// 路灯详情
export function getlampDetail(lampId) {
  const basetConfig = Vue.prototype.baseConfig // 注意该行应放在export里面，否则获取不到值
  const lampPath = basetConfig.lampBasePath
  return request({
    url: lampPath + 'overview/lampDetail',
    method: 'get',
    params: {
      lampId: lampId
    }
  })
}

// 回路列表
export function getCircuitList(params) {
  const basetConfig = Vue.prototype.baseConfig // 注意该行应放在export里面，否则获取不到值
  const lampPath = basetConfig.lampBasePath
  return request({
    url: lampPath + 'overview/circuitList',
    method: 'get',
    params
  })
}

// 灯箱列表
export function getLampBoxList(params) {
  const basetConfig = Vue.prototype.baseConfig // 注意该行应放在export里面，否则获取不到值
  const lampPath = basetConfig.lampBasePath
  return request({
    url: lampPath + 'overview/lampBoxList',
    method: 'get',
    params
  })
}
// 灯箱详情
export function getLampBoxDetail(lampBoxId) {
  const basetConfig = Vue.prototype.baseConfig // 注意该行应放在export里面，否则获取不到值
  const lampPath = basetConfig.lampBasePath
  return request({
    url: lampPath + 'overview/lampBoxDetail',
    method: 'get',
    params: {
      lampBoxId: lampBoxId
    }
  })
}

// 报警总览列表
export function getAlarmList(params) {
  const basetConfig = Vue.prototype.baseConfig // 注意该行应放在export里面，否则获取不到值
  const lampPath = basetConfig.lampBasePath
  return request({
    url: lampPath + 'overview/alarmList',
    method: 'get',
    params
  })
}

// 报警详情
export function getAlarmDetail(alarmId) {
  const basetConfig = Vue.prototype.baseConfig // 注意该行应放在export里面，否则获取不到值
  const lampPath = basetConfig.lampBasePath
  return request({
    url: lampPath + 'overview/alarmDetail',
    method: 'get',
    params: {
      alarmId: alarmId
    }
  })
}

// 路灯控制
export function lampControl(params) {
  const basetConfig = Vue.prototype.baseConfig // 注意该行应放在export里面，否则获取不到值
  const lampPath = basetConfig.lampBasePath
  return request({
    url: lampPath + 'overview/lampControl',
    method: 'post',
    params,
    paramsSerializer: params => {
      return qs.stringify(params, { indices: false })
    }
  })
}
