import request from '@/utils/request'
import state from '@/store'
import router from '@/router'
export function getTree() {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: 1,
      name: '人事档案管理_部门关系_查询节点',
      param: '子节点=0=int'
    }
  })
}
export function tree(data, pid) {
  const result = []
  let temp
  for (let i = 0; i < data.length; i++) {
    if (data[i].父节点 === pid) {
      const obj = { label: data[i].节点名称, id: data[i].子节点 }
      temp = tree(data, data[i].子节点)
      if (temp.length > 0) {
        obj.children = temp
      }
      result.push(obj)
    }
  }
  return result
}
export function getTablePeople(code, pageCurrent, pageSize) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: 1,
      name: '人事档案管理_人员_部门与人员_查询数据_根据部门编号',
      param: '考核部门编号=' + code + '=int',
      pagination: pageCurrent + '&' + pageSize
    }
  })
}
export function getTablePeopleForName(name) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: 1,
      name: '人事档案管理_人员名单_查询数据_根据姓名_MESWORK',
      param: '姓名=' + name + '=string'
    }
  })
}
// 新增部门
export function addDepartmentName(num1, num2, num3) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: 2,
      name: '人事档案管理_部门关系_增加节点',
      param: '父节点=' + num1 + '=int&节点名称=' + num2 + '=string&子节点=' + num3
    }
  })
}
// 删除部门
export function delList(num1) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: 2,
      name: '人事档案管理_部门关系_删除节点',
      param: '子节点=' + num1 + '=int'
    }
  })
}
// 编辑部门
export function editList(num1, num2) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: 2,
      name: '人事档案管理_部门关系_修改节点',
      param: '子节点=' + num1 + '=int&节点名称=' + num2 + '=string'
    }
  })
}
export function delPeopleList(num1) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: 2,
      name: '人事档案管理_人员名单_删除数据_MESWORK',
      param: '人员编号=' + num1 + '=int'
    }
  })
}
export function initUniversity() {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: 1,
      name: '人事档案管理_基础表_毕业院校_查询数据'
    }
  })
}
export function fetchEducationData() {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: 1,
      name: '人事档案管理_基础表_学历_查询数据'
    }
  })
}
export function initMajor() {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: 1,
      name: '人事档案管理_基础表_所学专业_查询数据'
    }
  })
}
export function fetchForeignLanguageLevelDate() {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: 1,
      name: '人事档案管理_基础表_外语及熟练程度_查询数据'
    }
  })
}
export function fetchTitleData() {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: 1,
      name: '人事档案管理_基础表_职称_查询数据'
    }
  })
}
export function fetchPostData() {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: 1,
      name: '人事档案管理_基础表_人员岗位_查询数据'
    }
  })
}
export function fetchPositionStatusData() {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: 1,
      name: '人事档案管理_基础表_岗位状态_查询数据'
    }
  })
}
export function addPeople(id, Sex, Education, Address, Nation, Post, AccountNumber, Password, Name, IDcard, TimeOfEntry, Birthday, ContactInformation, TeamValue) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: 2,
      name: '人事档案管理_人员名单_增加数据_MESWORK',
      param: '考核部门编号=' + id + '=int&性别编号=' + Sex + '=int&学历编号=' + Education + '=int&家庭住址=' + Address + '&民族=' + Nation + '&岗位编号=' + Post + '=int&考勤编号=' + AccountNumber + '=string&密码=' + Password + '=string&姓名=' + Name + '=string&身份证号=' + IDcard + '=string&入公司时间=' + TimeOfEntry + '=string&出生日期=' + Birthday + '=string&联系电话=' + ContactInformation + '=string&班组=' + TeamValue
    }
  })
}
export function editPeople(id, Sex, Education, Address, Nation, Post, AccountNumber, Password, Name, IDcard, TimeOfEntry, Birthday, ContactInformation, TeamValue) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: 2,
      name: '人事档案管理_人员名单_修改数据_MESWORK',
      param: '人员编号=' + id + '=int&性别编号=' + Sex + '=int&学历编号=' + Education + '=int&家庭住址=' + Address + '&民族=' + Nation + '&岗位编号=' + Post + '=int&考勤编号=' + AccountNumber + '=string&密码=' + Password + '=string&姓名=' + Name + '=string&身份证号=' + IDcard + '=string&入公司时间=' + TimeOfEntry + '=string&出生日期=' + Birthday + '=string&联系电话=' + ContactInformation + '=string&班组=' + TeamValue
    }
  })
}
export function moveGroups(num1, num2) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: 2,
      name: '人事档案管理_人员名单_移动数据_MESWORK',
      param: '人员编号=' + num1 + '=int&考核部门编号=' + num2 + '=int'
    }
  })
}
export function feacthUniversity(num1) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: 1,
      name: '人事档案管理_基础表_毕业院校_查询数据_根据学校名_MESWORK',
      param: '毕业院校名称=' + num1 + '=string'
    }
  })
}
export function addUniversity(num1) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: 2,
      name: '人事档案管理_基础表_毕业院校_增加数据',
      param: '毕业院校名称=' + num1 + '=string'
    }
  })
}
export function editUniversity(num1, num2) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: 2,
      name: '人事档案管理_基础表_毕业院校_修改数据',
      param: '毕业院校编号=' + num1 + '=int&毕业院校名称=' + num2 + '=string'
    }
  })
}
export function delUniversity(num1) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: 2,
      name: '人事档案管理_基础表_毕业院校_删除数据',
      param: '毕业院校编号=' + num1 + '=int'
    }
  })
}
export function fetchMajor(num1) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: 1,
      name: '人事档案管理_基础表_所学专业_查询数据_根据专业名_MESWORK',
      param: '专业名称=' + num1 + '=string'
    }
  })
}
export function addMajor(num1) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: 2,
      name: '人事档案管理_基础表_所学专业_增加数据',
      param: '专业名称=' + num1 + '=string'
    }
  })
}
export function editMajor(num1, num2) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: 2,
      name: '人事档案管理_基础表_所学专业_修改数据',
      param: '专业编号=' + num1 + '=int&专业名称=' + num2 + '=string'
    }
  })
}
export function delMajor(num1) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: 2,
      name: '人事档案管理_基础表_所学专业_删除数据',
      param: '专业编号=' + num1 + '=int'
    }
  })
}
export function fetchPost(num1) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: 1,
      name: '人事档案管理_基础表_人员岗位_查询数据_根据岗位名_MESWORK',
      param: '岗位名称=' + num1 + '=string'
    }
  })
}
export function addPost(num1) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: 2,
      name: '人事档案管理_基础表_人员岗位_增加数据',
      param: '岗位名称=' + num1 + '=string'
    }
  })
}
export function editPost(num1, num2) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: 2,
      name: '人事档案管理_基础表_人员岗位_修改数据',
      param: '岗位编号=' + num1 + '=int&岗位名称=' + num2 + '=string'
    }
  })
}
export function delPost(num1) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: 2,
      name: '人事档案管理_基础表_人员岗位_删除数据',
      param: '岗位编号=' + num1 + '=int'
    }
  })
}
export function quit(num1) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: 2,
      name: '人事档案管理_人员_离职操作',
      param: '人员编号=' + num1 + '=int'
    }
  })
}
export function searchLeavingList(pageCurrent, pageSize) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: 1,
      name: '人事档案管理_人员_离职人员查询',
      pagination: pageCurrent + '&' + pageSize
    }
  })
}
export function fetchteamviwer() {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: 1,
      name: '班组管理_班组查询'
    }
  })
}
