import axios from '@/libs/axios.js'


export const listEmployee = (param) => {
  let params = param || {}
  return axios.request({
    url: `employee/findAll`,
    data: {
      'userType': (params.userType == undefined ? 1 : params.userType),
      'workFlag': (params.workFlag == undefined ? 1 : params.workFlag)
    },
    method: 'post'
  }).then(res => res.data)
}

// 删除员工
export const delEmployee = param => {
  return axios.request({
    url: `employee/del/${param.id}`,
    method: 'get'
  }).then(res => res)
}

// 
export const getEmployee = param => {
  return axios.request({
    url: `employee/${param.id}`,
    method: 'get'
  }).then(res => res.data)
}

// 修改完保存
export const saveEmployee = params => {
  return axios.request({
    url: 'employee/save',
    data: params,
    method: 'POST'
  }).then(res => res)
}

// 员工信息列表
export const searchEmployee = params => {
  let url = `employee/queryLike/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios.request({
    url: url,
    data: params,
    method: 'post'
  }).then(res => res)
}
// 获取员工信息
export const getEmployeeInfo = param => {
  return axios.request({
    url: `zycar-mgr/employee/findByUserId/${param.id}`,
    method: 'get'
  }).then(res => res)
}
// 设置为负责人setManager
export const setManager = params => {
  return axios.request({
    url: 'employee/setManager',
    data: params,
    method: 'POST'
  }).then(res => res.data)
}

// 重置密码
export const resetPSD = params => {
  return axios.request({
    url: 'employee/restPWD',
    data: params,
    method: 'POST'
  })
}
