import request from '@/utils/request'

// 查询员工亲属关系列表
export function listRelation(query) {
  return request({
    url: '/ccdi/staffFmyRelation/list',
    method: 'get',
    params: query
  })
}

// 查询员工亲属关系详情
export function getRelation(id) {
  return request({
    url: '/ccdi/staffFmyRelation/' + id,
    method: 'get'
  })
}

// 新增员工亲属关系
export function addRelation(data) {
  return request({
    url: '/ccdi/staffFmyRelation',
    method: 'post',
    data: data
  })
}

// 修改员工亲属关系
export function updateRelation(data) {
  return request({
    url: '/ccdi/staffFmyRelation',
    method: 'put',
    data: data
  })
}

// 删除员工亲属关系
export function delRelation(ids) {
  return request({
    url: '/ccdi/staffFmyRelation/' + ids,
    method: 'delete'
  })
}

// 下载导入模板
export function importTemplate() {
  return request({
    url: '/ccdi/staffFmyRelation/importTemplate',
    method: 'post'
  })
}

// 导入员工亲属关系
export function importData(file, updateSupport) {
  const formData = new FormData()
  formData.append('file', file)
  formData.append('updateSupport', updateSupport)
  return request({
    url: '/ccdi/staffFmyRelation/importData',
    method: 'post',
    data: formData
  })
}

// 查询导入状态
export function getImportStatus(taskId) {
  return request({
    url: '/ccdi/staffFmyRelation/importStatus/' + taskId,
    method: 'get'
  })
}

// 查询导入失败记录
export function getImportFailures(taskId, pageNum, pageSize) {
  return request({
    url: '/ccdi/staffFmyRelation/importFailures/' + taskId,
    method: 'get',
    params: { pageNum, pageSize }
  })
}

// 获取员工列表（用于下拉选择）
export function getStaffList(name) {
  return request({
    url: '/ccdi/staffFmyRelation/staffList',
    method: 'get',
    params: { name }
  })
}
