import request from '@/utils/request'
import state from '@/store'
import router from '@/router'

// 查询项目名称
export function dialogtablevisible() {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '人事档案管理_部门关系_查询节点',
      param: '子节点=0'
    }
  })
}
export function dialogtablevisible1() {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '人事档案管理_部门关系_查询节点',
      param: '子节点=0'
    }
  })
}
export function addData1(code, groupNum) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: 2,
      name: '菜单系统模块_项目角色员工综合_增加数据',
      param: '人员编号=' + code + '=int&角色编号=' + groupNum + '=int&项目编号=10=int'
    }
  })
}
export function addData2(lsh, code, groupNum) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: 2,
      name: '菜单系统模块_项目角色员工综合_修改数据',
      param: '人员角色流水号=' + lsh + '&人员编号=' + code + '&角色编号=' + groupNum
    }
  })
}
// 初始化科室
export function initDepartment() {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '人事档案管理_部门关系_查询节点'
    }
  })
}
// 初始化人员信息 弹出框
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 fn(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 = fn(data, data[i].子节点)
      if (temp.length > 0) {
        obj.children = temp
      }
      result.push(obj)
    }
  }
  return result
}
export function getTable8(code) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: 1,
      name: '人事档案管理_人员_部门与人员_查询数据_根据部门编号',
      param: '考核部门编号=' + code + '=int'
    }
  })
}
export function handledelete(ryjslsh) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: 2,
      name: '菜单系统模块_项目角色员工综合_删除数据',
      param: '人员角色流水号=' + ryjslsh + '=string'
    }
  })
}
export function deleteData(Number) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '菜单系统模块_项目角色员工综合_删除数据',
      param: '人员角色流水号=' + Number + '=int'
    }
  })
}
export function searchdesigner(num2) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '人事档案管理_人员_部门与人员_查询数据_根据部门编号',
      param: '考核部门编号=' + num2 + '=int'
    }
  })
}
export function initOrderType() {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '菜单系统模块_项目角色_查询数据_new'
    }
  })
}
export function searchTable(check1, staffName, check2, systemAdministrator) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '菜单系统模块_项目角色员工综合_查询数据',
      param: '姓名_check=' + check1 + '=int&姓名=' + staffName + '=string&角色编号_check=' + check2 + ' =int&角色编号=' + systemAdministrator + '=int'
    }
  })
}
