import request from '@/utils/request'

export function add(data) {
  return request({
    url: 'api/sData',
    method: 'post',
    data
  })
}

export function del(id) {
  return request({
    url: 'api/sData/' + id,
    method: 'delete'
  })
}

export function edit(data) {
  return request({
    url: 'api/sData',
    method: 'put',
    data
  })
}

export function getData(deviceid, item, starttime, endtime, params) {
  return request({
    url: 'api/getData',
    method: 'post',
    data: {
      deviceid,
      item,
      starttime,
      endtime
    },
    params
  })
}

export function getIllData(deviceid, item, starttime, endtime, params) {
  return request({
    url: 'api/getIllData',
    method: 'post',
    data: {
      deviceid,
      item,
      starttime,
      endtime
    },
    params
  })
}

export function exportExcel(deviceid, item, starttime, endtime) {
  return request({
    url: 'api/exportExcel',
    method: 'post',
    data: {
      deviceid,
      item,
      starttime,
      endtime
    },
    responseType: 'blob'
  })
}

export function loadCDataByDeviceid(deviceid) {
  return request({
    url: 'api/loadCDataByDeviceid',
    method: 'post',
    data: {
      deviceid
    }
  })
}

export function loadNowDataByDeviceid(deviceid) {
  return request({
    url: 'api/loadNowDataByDeviceid/' + deviceid,
    method: 'get'
  })
}

export function loadNowDataByUserid() {
  return request({
    url: 'api/loadNowDataByUserid',
    method: 'get'
  })
}
