import request from '@/utils/request'

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

// 查询有效员工亲属下拉选项
export function listFamilyOptions(query) {
  return request({
    url: '/ccdi/staffEnterpriseRelation/familyOptions',
    method: 'get',
    params: { query }
  })
}

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

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

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

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

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

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

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

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