/**
 * 闸井管理接口
 */
import request from '@/utils/request'
import qs from 'qs'

// 闸井查询
export function getWellList(params) {
  return request({
    url: 'well/list',
    method: 'get',
    params
  })
}
// 获取闸井详情
export function getWellInfo(id) {
  return request({
    url: 'well/info',
    method: 'get',
    params: {
      id: id
    }
  })
}

// 闸井类别
export function getWellType(params) {
  return request({
    url: 'dict/code/sluicewellType',
    method: 'get',
    params
  })
}

// 添加闸井
export function addWell(params) {
  return request({
    url: 'well/add',
    method: 'post',
    params
  })
}
// 修改闸井
export function updateWell(params) {
  return request({
    url: 'well/update',
    method: 'post',
    params
  })
}
// 删除闸井
export function delWell(ids) {
  return request({
    url: 'well/delete',
    method: 'post',
    params: {
      ids: ids
    },
    paramsSerializer: params => {
      return qs.stringify(params, { indices: false })
    }
  })
}// 批量导入
export function batchImportWell(fileobj) {
  const param = new FormData()
  param.append('file', fileobj)
  return request({
    url: 'well/batchImport',
    method: 'post',
    headers: { 'Content-Type': 'multipart/form-data' },
    data: param
  })
}
// 批量导出
export function batchExportWell(params) {
  return request({
    url: 'well/batchExport',
    method: 'get',
    timeout: 120000,
    params,
    responseType: 'blob' // 这一步也很关键，一定要加上 responseType 值为 blob
  })
}
// 获取某井内监控数据
export function watchDataByWell(id) {
  return request({
    url: 'well/watchDataByWell',
    method: 'get',
    params: {
      id: id
    }
  })
}
