/**
 * 垃圾桶管理接口
 */
import request from '@/utils/request'
import qs from 'qs'
// 垃圾桶查询
export function getWastebinListPage(params) {
  return request({
    url: '/sanitation/wastebin/listPage',
    method: 'get',
    params
  })
}
// 垃圾桶查询
export function getWastebinList(pid) {
  return request({
    url: '/sanitation/wastebin/list',
    method: 'get',
    params: {
      pid: pid
    }
  })
}

// 添加垃圾桶
export function addWastebin(params) {
  return request({
    url: '/sanitation/wastebin/add',
    method: 'post',
    params
  })
}
// 修改垃圾桶机构
export function updateWastebin(params) {
  return request({
    url: '/sanitation/wastebin/update',
    method: 'post',
    params
  })
}
// 删除垃圾桶机构
export function delWastebin(ids) {
  return request({
    url: '/sanitation/wastebin/delete',
    method: 'post',
    params: {
      ids
    },
    paramsSerializer: params => {
      return qs.stringify(params, { indices: false })
    }
  })
}

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