import request from '@/utils/request';
import store from '@/store';
import { baseURL } from '@/config';
//分页查询报警记录
export function getAlarm(data) {
  var param = '?page=' + data.page + '&size=' + data.size;
  if (data.projectId != '') {
    param += '&projectId=' + data.projectId;
  }
  if (data.deviceName != '') {
    param += '&deviceName=' + data.deviceName;
  }
  if (data.handlerName != '') {
    param += '&handlerName=' + data.handlerName;
  }
  if (data.alarmLevel != '') {
    param += '&alarmLevel=' + data.alarmLevel;
  }
  if (data.alarmCategory != '') {
    param += '&alarmCategory=' + data.alarmCategory;
  }
  if (data.start != '' && data.end != '') {
    param += '&start=' + data.start + '&end=' + data.end;
  }
  if (data.status != 3) {
    param += '&status=' + data.status;
  }
  return request({
    url: '/alarmRecord/listPage' + param,
    method: 'get',
    data,
  });
}
//当前/实时报警查询
export function getCurrentData(data) {
  var param = '?page=' + data.page + '&size=' + data.size;
  if (data.projectId != undefined && data.projectId != '') {
    param += '&projectId=' + data.projectId;
  }
  return request({
    url: '/alarmRecord/current' + param,
    method: 'get',
    data,
  });
}
//报警级别字典数据查询
export function alarmLevelDict(data) {
  return request({
    url: '/alarmRecord/alarmLevelDict',
    method: 'get',
    data,
  });
}
//报警类别字典数据查询
export function alarmCategoryDict(data) {
  return request({
    url: '/alarmRecord/alarmCategoryDict',
    method: 'get',
    data,
  });
}
//报警类别字典数据查询
export function doAdd(data) {
  return request({
    url: '/alarmRecord/insert?token=' + store.getters['user/token'],
    method: 'post',
    data,
  });
}
//报警转工单
export function toTask(data) {
  return request({
    url: '/alarmRecord/toTask',
    method: 'post',
    data,
  });
}
//处理人
export function handlers(data) {
  return request({
    url: '/task/handlers?deviceCode=' + data.deviceCode,
    method: 'get',
    data,
  });
}
//获取途强车辆设备列表
export function tqDevices(data) {
  return request({
    url: '/task/tqDevices?projectId=' + data.projectId,
    method: 'get',
    data,
  });
}
//删除
export function doDelete(data) {
  return request({
    url: '/alarmRecord/remove',
    method: 'post',
    data,
  });
}
//导出
export function alarmExport(data) {
  var param = '?projectId=' + data.projectId;
  if (data.deviceName != '') {
    param += '&deviceName=' + data.deviceName;
  }
  if (data.handlerName != '') {
    param += '&handlerName=' + data.handlerName;
  }
  if (data.alarmLevel != '') {
    param += '&alarmLevel=' + data.alarmLevel;
  }
  if (data.alarmCategory != '') {
    param += '&alarmCategory=' + data.alarmCategory;
  }
  if (data.date != '') {
    param += '&date=' + data.date;
  }
  return baseURL + 'alarmRecordReport/export' + param;
}
