/**
 * 人员管理接口
 */
import request from '@/utils/request'
import qs from 'qs'
// 人员查询
export function getStaffListPage(params) {
  return request({
    url: '/sanitation/staff/listPage',
    method: 'get',
    params
  })
}
// 人员查询
export function getStaffList(pid) {
  return request({
    url: '/sanitation/staff/list',
    method: 'get',
    params: {
      pid: pid
    }
  })
}

// 添加人员
export function addStaff(params) {
  return request({
    url: '/sanitation/staff/add',
    method: 'post',
    params,
    paramsSerializer: params => {
      return qs.stringify(params, { indices: false })
    }
  })
}
// 修改人员机构
export function updateStaff(params) {
  return request({
    url: '/sanitation/staff/update',
    method: 'post',
    params,
    paramsSerializer: params => {
      return qs.stringify(params, { indices: false })
    }
  })
}
// 删除人员机构
export function delStaff(ids) {
  return request({
    url: '/sanitation/staff/delete',
    method: 'post',
    params: {
      ids
    },
    paramsSerializer: params => {
      return qs.stringify(params, { indices: false })
    }
  })
}
// 批量导入
export function batchImportStaff(fileobj) {
  const param = new FormData()
  param.append('file', fileobj)
  return request({
    url: '/sanitation/staff/import',
    method: 'post',
    headers: { 'Content-Type': 'multipart/form-data' },
    data: param
  })
}
// 批量导出
export function batchExportStaff(params, config) {
  return request({
    url: '/sanitation/staff/export',
    method: 'get',
    timeout: 120000,
    params,
    ...config,
    responseType: 'blob' // 这一步也很关键，一定要加上 responseType 值为 blob
  })
}
// 人员出勤记录查询
export function getAttendanceList(params) {
  return request({
    url: '/sanitation/staff/attendanceList',
    method: 'get',
    params
  })
}

// 人员出勤记录查询
export function exportAttendanceList(params, config) {
  return request({
    url: '/sanitation/staff/attendance/export',
    method: 'get',
    timeout: 120000,
    params,
    ...config,
    responseType: 'blob' // 这一步也很关键，一定要加上 responseType 值为 blob
  })
}
