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

export function initProject() {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '合同信息管理_项目名称_总_查询'
    }
  })
}
export function initMarketingManager() {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '合同信息管理_营销人员_总_查询'
    }
  })
}
export function searchTable1(pageCurrent, pageSize, num1, num2, num3, num4, num5, num6, num7, num8, num9, num10, num11, num12) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '合同信息管理_合同信息_查询_分页',
      param: '合同ID=' + num1 + '=int&人员ID=' + num2 + '=int&项目流水号_check=' + num3 + '=int&营销经理流水号_check=' + num4 + '=int&开始日期_check=' + num5 + '=int&结束日期_check=' + num6 + '=int&开始日期=' + num7 + '=date&结束日期=' + num8 + '=date&机床型号_check=' + num9 + '=int&机床型号=' + num10 + '=string&客户名称_check=' + num11 + '=int&客户名称=' + num12 + `&PageCurrent=${pageCurrent}&PageSize=${pageSize}&PageCount=1111=int=output&ItemCount=1111=int=output`
    }
  })
}
export function fetchExecutionProgress(num) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '合同信息管理_执行进度_通过合同ID查_查询',
      param: '合同ID=' + num + '=int'
    }
  })
}
export function delList(num) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '合同信息管理_合同信息_删除_合同收款计划',
      param: '合同ID=' + num + '=int'
    }
  })
}
export function addList() {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '基础表_合同信息表_增加数据_新',
      param: '项目名称=' + arguments[0] + '&图纸会签节点=' + arguments[1] + '&设备预验收节点=' + arguments[2] + '&发货节点=' + arguments[3] + '&安装调试节点=' + arguments[4] + '&人员ID=' + arguments[5] + '&执行进度ID=' + arguments[6] + '&客户流水号=' + arguments[7] + '&备注=' + arguments[8] + '&付款方式代码=' + arguments[9] + '&合同签订日期=' + arguments[10] + '&招标保证金流水号=' + arguments[11] + '&合同总额=' + arguments[12]
    }
  })
}
export function fetchPersonnelID() {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '合同信息管理_营销人员_查询'
    }
  })
}
export function executionProgressID() {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '合同信息管理_执行进度_查询'
    }
  })
}
export function editchar() {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '合同信息管理_合同信息_编辑',
      param: '项目名称=' + arguments[0] + '&图纸会签节点=' + arguments[1] + '&设备预验收节点=' + arguments[2] + '&发货节点=' + arguments[3] + '&安装调试节点=' + arguments[4] + '&人员ID=' + arguments[5] + '&执行进度ID=' + arguments[6] + '&客户流水号=' + arguments[7] + '&合同信息备注=' + arguments[8] + '&项目流水号=' + arguments[9] + '&付款方式代码=' + arguments[10] + '&合同签订日期=' + arguments[11] + '&招标保证金流水号=' + arguments[12] + '&合同总额=' + arguments[13]
    }
  })
}
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) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: 1,
      name: '人事档案管理_人员_部门与人员_查询数据_根据部门编号',
      param: '考核部门编号=' + code + '=int'
    }
  })
}
export function fetchCustomerData(PageCurrent, PageSize, name) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: 1,
      name: '创建合同_客户信息查询',
      param: '客户名称=' + name + '=string',
      Pagination: PageCurrent + '&' + PageSize
    }
  })
}

export function getFileData(projectNum) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '合同管理_文件路径_查询数据',
      param: `项目流水号=${projectNum}`
    }
  })
}
export function deleteFileData(id) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '合同管理_文件路径_删除数据',
      param: `文件标识=${id}`
    }
  })
}
export function selectMachine(code) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: 'PDM_机床名称_查询数据_通过项目流水号',
      param: '项目流水号=' + code
    }
  })
}
export function selectProvince() {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '发货管理_省份查询'
    }
  })
}
export function SelectMarketingManager() {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '人事档案管理_人员_部门与人员_查询数据_根据部门编号',
      param: '考核部门编号=7'
    }
  })
}
export function submitMachine() {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '创建合同_机床名称_增加数据',
      param: '项目流水号=' + arguments[0] + '&机床图号=' + arguments[1] + '&机床名称=' + arguments[2] + '&机床数量=' + arguments[3]
    }
  })
}
export function editMachine() {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '创建合同_机床名称_修改数据',
      param: '机床流水号=' + arguments[0] + '&机床图号=' + arguments[1] + '&机床名称=' + arguments[2] + '&机床数量=' + arguments[3]
    }
  })
}
export function delMachine() {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: 'PDM_机床名称_删除数据',
      param: '机床流水号=' + arguments[0]
    }
  })
}
export function money() {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '合同信息管理_付款方式_查询'
    }
  })
}
export function changeExecutionProgressID() {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '创建合同_改变执行进度',
      param: '执行进度流水号=' + arguments[0] + '&项目流水号=' + arguments[1] + '&进度完成日期=' + arguments[2]
    }
  })
}
export function selectBidBond() {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '投标保证金管理_投标保证金查询',
      param: '保金类型_check=' + arguments[0] + '&保金类型=' + arguments[1] + '&投标人_check=' + arguments[2] + '&投标人=' + arguments[3] + '&招标企业_check=' + arguments[4] + '&招标企业=' + arguments[5] + '&开始日期_check=' + arguments[6] + '&开始日期=' + arguments[7] + '&结束日期_check=' + arguments[8] + '&结束日期=' + arguments[9]
    }
  })
}
export function searchTime() {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '创建合同_查询执行进度时间',
      param: '项目流水号=' + arguments[0] + '&执行进度流水号=' + arguments[1]
    }
  })
}
export function searchTimeAll() {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '创建合同_查询执行进度时间_总',
      param: '项目流水号=' + arguments[0]
    }
  })
}
export function SelectPartment() {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '选择营销经理_部门查询'
    }
  })
}
export function SelectMarketingManager1(num) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '人事档案管理_人员_部门与人员_查询数据_根据部门编号',
      param: '考核部门编号=' + num
    }
  })
}
export function addMarketingManager(MarketingManagerId, AdressID) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '客户关系管理系统_营销经理_增加数据_MESWORK',
      param: '营销经理流水号=' + MarketingManagerId + '&省份流水号=' + AdressID + '&导入类型=0=int=output'
    }
  })
}
