import { axios } from '@/utils/request'
import { stringify } from 'qs'

/**
 * user page func
 * parameter: {
 *     keyword: '',
 * }
 * @param parameter
 * @returns {*}
 */
export function getUserDeptPage (parameter) {
  return axios({
    url: `/upms/user-depts/page?${stringify(parameter)}`,
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

export function queryUserDept (parameter) {
  return axios({
    url: `/upms/user-depts/user-dept/dept-code?${stringify(parameter)}`,
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

export function queryUserDeptByUserDeptId (parameter) {
  return axios({
    url: `/upms/user-depts/users/dept/${parameter.deptId}`,
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * 获取用户所在 部门
 * @returns {AxiosPromise}
 */
export function selectUserDept () {
  return axios({
    url: `/upms/user-depts/user/dept`,
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}

/**
 * 获取用户所在 部门
 */
export function selectUserNatureDept (parameter) {
  return axios({
    url: `/upms/user-depts/user/dept/${parameter.nature}`,
    method: 'get',
    headers: {
      'Content-Type': 'application/json;charset=UTF-8'
    }
  })
}
