/**
 * 井管理接口
 */
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, config) {
  return request({
    url: 'well/batchExport',
    method: 'get',
    timeout: 120000,
    params,
    ...config,
    responseType: 'blob' // 这一步也很关键，一定要加上 responseType 值为 blob
  })
}

// 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
    }
  })
}
// 布防撤防
export function bfcf(wellId, bfzt) {
  return request({
    url: 'well/bfcf',
    method: 'post',
    params: {
      wellId: wellId,
      bfzt: bfzt
    }
  })
}
// 井批量布防
export function batchBfcf(params) {
  return request({
    url: 'well/batchBfcf',
    method: 'post',
    params
  })
}

// 根据布防状态统计井数量
export function wellCountByBfzt() {
  return request({
    url: 'well/countByBfzt',
    method: 'get'
  })
}

// 单个井查询
export function getWellOne(params) {
  return request({
    url: 'well/selectOne',
    method: 'get',
    params
  })
}
