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

export function batchAdd(params) {
  const basetConfig = Vue.prototype.baseConfig // 注意该行应放在export里面，否则获取不到值
  const lampPath = basetConfig.lampBasePath
  return request({
    url: lampPath + 'busStrategyInfo/add',
    method: 'post',
    // headers: { 'Content-Type': 'multipart/form-data' },
    data: params
  })
}
export function batchUpdate(params) {
  const basetConfig = Vue.prototype.baseConfig // 注意该行应放在export里面，否则获取不到值
  const lampPath = basetConfig.lampBasePath
  return request({
    url: lampPath + 'busStrategyInfo/update',
    method: 'post',
    // headers: { 'Content-Type': 'application/json' },
    data: params
  })
}
export function batchDetail(busStrategyInfoIds) {
  const basetConfig = Vue.prototype.baseConfig // 注意该行应放在export里面，否则获取不到值
  const lampPath = basetConfig.lampBasePath
  return request({
    url: lampPath + 'busStrategyInfo/detail/' + busStrategyInfoIds,
    method: 'get'
    // params: {
    //   busStrategyInfoIds: busStrategyInfoIds
    // }
  })
}
export function batchDelete(busStrategyInfoIds) {
  const basetConfig = Vue.prototype.baseConfig // 注意该行应放在export里面，否则获取不到值
  const lampPath = basetConfig.lampBasePath
  return request({
    url: lampPath + 'busStrategyInfo/batchDelete',
    method: 'post',
    params: {
      busStrategyInfoIds: busStrategyInfoIds
    },
    paramsSerializer: params => {
      return qs.stringify(params, { indices: false })
    }
  })
}
export function batchIssue(busStrategyInfoIds) {
  const basetConfig = Vue.prototype.baseConfig // 注意该行应放在export里面，否则获取不到值
  const lampPath = basetConfig.lampBasePath
  return request({
    url: lampPath + 'deviceConfig/batchIssue',
    method: 'post',
    params: {
      busStrategyInfoIds: busStrategyInfoIds
    },
    paramsSerializer: params => {
      return qs.stringify(params, { indices: false })
    }
  })
}
// 设置光照阈值
export function setThreshold(params) {
  const basetConfig = Vue.prototype.baseConfig // 注意该行应放在export里面，否则获取不到值
  const lampPath = basetConfig.lampBasePath
  return request({
    url: lampPath + 'lightThreshold/setThreshold',
    method: 'post',
    params
  })
}
// 查询光照阈值
export function getThreshold(params) {
  const basetConfig = Vue.prototype.baseConfig // 注意该行应放在export里面，否则获取不到值
  const lampPath = basetConfig.lampBasePath
  return request({
    url: lampPath + 'lightThreshold/getThreshold',
    method: 'get'
  })
}

// 设置config
export function setConfig(params) {
  const basetConfig = Vue.prototype.baseConfig // 注意该行应放在export里面，否则获取不到值
  const lampPath = basetConfig.lampBasePath
  return request({
    url: lampPath + 'deviceConfig/setConfig',
    method: 'post',
    params
  })
}
// 查询config
export function getConfig(deviceType) {
  const basetConfig = Vue.prototype.baseConfig // 注意该行应放在export里面，否则获取不到值
  const lampPath = basetConfig.lampBasePath
  return request({
    url: lampPath + 'deviceConfig/getConfig',
    method: 'get',
    params: {
      deviceType: deviceType
    }
  })
}

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

export function getExecLog(params) {
  const basetConfig = Vue.prototype.baseConfig // 注意该行应放在export里面，否则获取不到值
  const lampPath = basetConfig.lampBasePath
  return request({
    url: lampPath + 'strategyRecord/execLog',
    method: 'get',
    params
  })
}
export function getOperationLog(params) {
  const basetConfig = Vue.prototype.baseConfig // 注意该行应放在export里面，否则获取不到值
  const lampPath = basetConfig.lampBasePath
  return request({
    url: lampPath + 'strategyRecord/operationLog',
    method: 'get',
    params
  })
}
export function getDeviceLog(params) {
  const basetConfig = Vue.prototype.baseConfig // 注意该行应放在export里面，否则获取不到值
  const lampPath = basetConfig.lampBasePath
  return request({
    url: lampPath + 'strategyRecord/deviceLog',
    method: 'get',
    params
  })
}
export function deviceLogDetail(params) {
  const basetConfig = Vue.prototype.baseConfig // 注意该行应放在export里面，否则获取不到值
  const lampPath = basetConfig.lampBasePath
  return request({
    url: lampPath + 'strategyRecord/deviceLogDetail',
    method: 'get',
    params
  })
}

// 查询识别报警列表
export function getDetail(id) {
  const basetConfig = Vue.prototype.baseConfig // 注意该行应放在export里面，否则获取不到值
  const lampPath = basetConfig.lampBasePath
  return request({
    url: lampPath + 'alarm/detail/' + id,
    method: 'get'
  })
}

export function getAlarmType() {
  const basetConfig = Vue.prototype.baseConfig // 注意该行应放在export里面，否则获取不到值
  const lampPath = basetConfig.lampBasePath
  return request({
    url: lampPath + 'dict/code/alarmType',
    method: 'get'
  })
}

