import request from '@/utils/request'

// 查询岗位列表http://192.168.31.230:6209/api/v1/occupations
export function listJobs(query) {
  return request({
    url: '/api/v3/occupations',
    method: 'get',
    params: query
  })
}

// 新增岗位 http://192.168.31.230:6209/api/v1/occupations/batch
export function addJobs(data) {
  return request({
    url: '/api/v3/occupations/batch',
    method: 'post',
    data: data
  })
}

// 修改岗位   http://192.168.31.230:6209/api/v1/occupations/{occID}
export function updateJobs(data, id) {
  return request({
    url: '/api/v3/occupations/' + id,
    method: 'put',
    data: data
  })
}

// 删除岗位 http://192.168.31.230:6209/api/v1/occupations/{occID}
// export function delJobs(id) {
//   return request({
//     url: '/api/v3/occupations/' + id,
//     method: 'delete',
//   })
// }
// 批量删除
export function delJobs(query) {
  return request({
    url: '/api/v3/occupations/batch',
    method: 'delete',
    params: query
  })
}


// 查询关联用户列表http://192.168.31.230:6209/api/v1/occupations/{occID}/users
export function listOccUser(query, id) {
  return request({
    url: `/api/v3/occupations/${id}/employees`,
    method: 'get',
    params: query
  })
}

//批量关联用户到某岗位 http://192.168.31.230:6209/api/v1/occupations/{occID}/users
// export function userAndOcc(data, id) {  
//   return request({
//     url: `/api/v3/occupations/${id}/users`,
//     method: 'post',
//     data: data
//   })
// }

export function userAndOcc(data) { //部分字段去掉
  return request({
    url: '/api/v3/employees/tag/batch',
    method: 'post',
    data: data
  })
}

//获取组织  http://192.168.31.230:6209/api/v1/departments
export function listDepartments() {
  return request({
    url: '/api/v3/departments',
    method: 'get',
  })
}


//获取部门下的员工http://192.168.31.230:6209/api/v3/api/v3/departments/employees   deptID
export function departmentsUsers(query) {
  return request({
    url: '/api/v3/departments/employees',
    method: 'get',
    params: query
  })
}

//获取员工列表，主要用于添加用户中的搜索 http://192.168.31.230:6209/api/v3/api/v3/employees

export function listUser(query) {
  return request({
    url: '/api/v3/employees',
    method: 'get',
    params: query
  })
}
