/**
 * 公厕管理接口
 */
import request from '@/utils/request'
import qs from 'qs'
// 公厕查询
export function getToiletListPage(params) {
  return request({
    url: '/sanitation/toilet/listPage',
    method: 'get',
    params
  })
}
// 公厕查询
export function getToiletList(pid) {
  return request({
    url: '/sanitation/toilet/list',
    method: 'get',
    params: {
      pid: pid
    }
  })
}

// 添加公厕
export function addToilet(params) {
  return request({
    url: '/sanitation/toilet/add',
    method: 'post',
    params
  })
}
// 修改公厕机构
export function updateToilet(params) {
  return request({
    url: '/sanitation/toilet/update',
    method: 'post',
    params
  })
}
// 删除公厕机构
export function delToilet(ids) {
  return request({
    url: '/sanitation/toilet/delete',
    method: 'post',
    params: {
      ids
    },
    paramsSerializer: params => {
      return qs.stringify(params, { indices: false })
    }
  })
}

// 公厕查询
export function getToiletCleanListPage(params) {
  return request({
    url: '/sanitation/toilet/jobRecord',
    method: 'get',
    params
  })
}

// 批量导入
export function batchImportToilet(fileobj) {
  const param = new FormData()
  param.append('file', fileobj)
  return request({
    url: '/sanitation/toilet/import',
    method: 'post',
    headers: { 'Content-Type': 'multipart/form-data' },
    data: param
  })
}
// 批量导出
export function batchExportToilet(params, config) {
  return request({
    url: '/sanitation/toilet/export',
    method: 'get',
    timeout: 120000,
    params,
    ...config,
    responseType: 'blob' // 这一步也很关键，一定要加上 responseType 值为 blob
  })
}

// 公厕保洁记录查询
export function getToiletJobRecords(params) {
  return request({
    url: '/sanitation/toilet/jobRecord',
    method: 'get',
    params
  })
}

// 批量导出
export function batchExportToiletJobRecords(params, config) {
  return request({
    url: '/sanitation/toilet/exportJobRecord',
    method: 'get',
    timeout: 120000,
    params,
    ...config,
    responseType: 'blob' // 这一步也很关键，一定要加上 responseType 值为 blob
  })
}
