import request from '@/utils/request'
import axios from 'axios'
export function daobiao(工号组, 姓名组, OrgUnit组, Cost_Center组, Business_Area组, PSG组, Job_Title组, Payroll_Area组) {
  const param = new URLSearchParams()
  param.append('工号组', 工号组)
  param.append('姓名组', 姓名组)
  param.append('OrgUnit组', OrgUnit组)
  param.append('Cost_Center组', Cost_Center组)
  param.append('Business_Area组', Business_Area组)
  param.append('PSG组', PSG组)
  param.append('Job_Title组', Job_Title组)
  param.append('Payroll_Area组', Payroll_Area组)
  return axios({
    url: 'http://192.168.1.122:8055/submit/WebLED.ashx?type=PersonnelIntroduction',
    method: 'post',
    data: param
  })
}
export function getTree() {
  return request({
    url: '',
    method: 'post',
    data: {
      type: 1,
      name: '奖金绩效系统_人员维护_部门关系_查询节点',
      param: '子节点=0=int'
    }
  })
}
export function judgementLevel(code) {
  return request({
    url: '',
    method: 'post',
    data: {
      type: 1,
      name: '判断部门等级',
      param: '部门代码=' + code + '=int'
    }
  })
}
export function tree(data, pid) {
  const result = []
  let temp
  for (let i = 0; i < data.length; i++) {
    if (data[i].parentNode === pid) {
      const obj = { label: data[i].NodeName, id: data[i].subNode }
      temp = tree(data, data[i].subNode)
      if (temp.length > 0) {
        obj.children = temp
      }
      result.push(obj)
    }
  }
  return result
}
// 新增部门   LLJ lEV
export function addDepartmentName(num1, num2, num3, num4, num5) {
  return request({
    url: '',
    method: 'post',
    data: {
      type: 2,
      name: '奖金绩效系统_人员维护_部门关系_增加节点',
      param: '父节点=' + num1 + '\\&节点名称=' + num2 + '\\&子节点=' + num3 + '\\&Departments_State=' + num4 + '\\&lev=' + num5
    }
  })
}
// 编辑部门
export function editList(num1, num2) {
  return request({
    url: '',
    method: 'post',
    data: {
      type: 2,
      name: '奖金绩效系统_人员维护_部门关系_修改节点',
      param: '子节点=' + num1 + '\\&节点名称=' + num2
    }
  })
}
// 删除部门
export function delList(num1) {
  return request({
    url: '',
    method: 'post',
    data: {
      type: 1,
      name: '奖金绩效系统_人员维护_部门关系_删除节点',
      param: '子节点=' + num1 + '=int'
    }
  })
}
export function getTablePeople(code, pageCurrent, pageSize) {
  return request({
    url: '',
    method: 'post',
    data: {
      type: 1,
      name: '奖金绩效系统_人员维护_人员查询_根据部门编号',
      param: '部门编号=' + code + '=int',
      pagination: pageCurrent + '&' + pageSize
    }
  })
}
export function searchPeople() {
  return request({
    url: '',
    method: 'post',
    data: {
      type: 1,
      name: '奖金绩效系统_人员维护_人员查询_根据工号',
      param: '工号=' + arguments[0]
    }
  })
}
export function addPeople() {
  return request({
    url: '',
    method: 'post',
    data: {
      type: 2,
      name: '奖金绩效系统_人员维护_人员增加',
      param: '部门编号=' + arguments[0] + '&工号=' + arguments[1] + '&密码=' + arguments[2] + '&人员性质编号=' + arguments[3] + '&姓名=' + arguments[4]
    }
  })
}
export function editPeople() {
  return request({
    url: '',
    method: 'post',
    data: {
      type: 2,
      name: '奖金绩效系统_人员维护_人员修改',
      param: '工号=' + arguments[0] + '&密码=' + arguments[1] + '&人员性质编号=' + arguments[2] + '&姓名=' + arguments[3] + '&人员编号=' + arguments[4] + '&部门代码=' + arguments[5]
    }
  })
}
export function selectPersonnelNature() {
  return request({
    url: '',
    method: 'post',
    data: {
      type: 1,
      name: '奖金绩效系统_人员维护_人员性质查询'
    }
  })
}
export function delPeopleList(num1) {
  return request({
    url: '',
    method: 'post',
    data: {
      type: 2,
      name: '奖金绩效系统_人员维护_人员删除',
      param: '人员编号=' + arguments[0]
    }
  })
}
export function moveGroups(num1, num2) {
  return request({
    url: '',
    method: 'post',
    data: {
      type: 2,
      name: '奖金绩效系统_人员维护_人员移动',
      param: '人员编号=' + num1 + '=int&部门编号=' + num2 + '=int'
    }
  })
}
export function getTPeopleList() {
  return request({
    url: '',
    method: 'post',
    data: {
      type: 1,
      name: '奖金绩效系统_人员维护_人员查询'
    }
  })
}
export function allocationPeople_add(val1, val2, id) {
  return request({
    url: '',
    method: 'post',
    data: {
      type: 2,
      name: '奖金绩效系统_人员维护_人员分配',
      param: '人员编号=' + val1 + '=int&部门编号=' + id + '=int&人员性质=' + val2
    }
  })
}
export function deleteDepartmentPeopleList(num1, id) {
  return request({
    url: '',
    method: 'post',
    data: {
      type: 2,
      name: '奖金绩效系统_人员维护_人员部门删除',
      param: '人员编号=' + num1 + '=int&部门编号=' + id
    }
  })
}
// 人员整体录入
export function handleSave() {
  return request({
    url: '',
    method: 'post',
    data: {
      type: '1',
      name: '奖金绩效系统_人员导入_整体录入',
      param: `工号组=${arguments[0]}&姓名组=${arguments[1]}&OrgUnit组=${arguments[2]}&Cost_Center组=${arguments[3]}&Business_Area组=${arguments[4]}&PSG组=${arguments[5]}&Job_Title组=${arguments[6]}&Payroll_Area组=${arguments[7]}`
    }
  })
}

