/**
 * 设备管理接口
 */
import request from '@/utils/request'
import qs from 'qs'
// 设备查询
export function getDeviceList(params) {
  return request({
    url: 'nbdevice/list',
    method: 'get',
    params
  })
}

// 添加设备
export function addDevice(params) {
  return request({
    url: 'nbdevice/add',
    method: 'post',
    params
  })
}
// 修改设备
export function updateDevice(params) {
  return request({
    url: 'nbdevice/update',
    method: 'post',
    params
  })
}
// 删除设备
export function delDevice(ids) {
  return request({
    url: 'nbdevice/delete',
    method: 'post',
    params: {
      ids: ids
    },
    paramsSerializer: params => {
      return qs.stringify(params, { indices: false })
    }
  })
}// 批量导入
export function batchImportDevice(fileobj) {
  const param = new FormData()
  param.append('file', fileobj)
  return request({
    url: 'nbdevice/batchImport',
    method: 'post',
    headers: { 'Content-Type': 'multipart/form-data' },
    data: param
  })
}
// 批量导出
export function batchExportDevice(params) {
  return request({
    url: 'nbdevice/batchExport',
    method: 'get',
    params,
    responseType: 'blob' // 这一步也很关键，一定要加上 responseType 值为 blob
  })
}
