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: 'PDM_项目名称_查询数据'
    }
  })
}
// 组件查询
export function searchGroup(num) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: 'PDM_组件名称_查询数据_装配',
      param: '机床流水号=' + num + '=int'
    }
  })
}
export function searchTable(machineNumberValue) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '车间管理_装配计划_查询数据',
      param: '机床流水号=' + machineNumberValue
    }
  })
}
export function searchTable2(machineNumberValue) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '车间管理_装配计划_分配后_查询数据',
      param: '机床流水号=' + machineNumberValue
    }
  })
}
export function deletedata(num) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '车间管理_工作计划_删除数据',
      param: '计划流水号=' + num
    }
  })
}
export function deleteTask(num) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '车间装配管理_分配后任务_删除数据',
      param: '计划流水号=' + num
    }
  })
}
export function getMachineNames(num) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: 'PDM_机床名称_查询数据_获取数量和名称_根据机床流水号',
      param: `机床流水号=${num}`
    }
  })
}
// 获取组号
export function getGroups(stepNumber) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '车间生产管理工艺_组件状态查询_查询所有组',
      param: '机床流水号=' + stepNumber
    }
  })
}
// 查询零件
export function selectParts(check1, stepNumber, check2, num) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '车间生产管理工艺_车间组件完成情况_查询数据_装配',
      param: '组件流水号_check=' + check1 + '&组件流水号=' + stepNumber + '&工艺计划流水号_check=' + check2 + '&工艺计划流水号=' + num
    }
  })
}
export function addData(num, name, type, num1, num2, process, quota) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '车间管理_工作计划_增加数据',
      param: '机床流水号=' + num + '&任务名称=' + name + '&计划类型=' + type + '&组件流水号=' + num1 + '&组号=' + num2 + '&装配工艺=' + process + '&装配工时=' + quota
    }
  })
}
// 获取装配人员
export function searchPeople() {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '人事档案管理_人员_部门与人员_查询数据_根据部门编号_装配',
      param: '考核部门编号=11'
    }
  })
}
// 获取分配后装配人员
export function searchName(num) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '车间管理_装配计划_装配工_查询数据',
      param: '计划流水号=' + num
    }
  })
}
export function submitPeople(num, people) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '车间装配管理_分配任务_循环执行',
      param: '计划流水号=' + num + '&人员编号组=' + people
    }
  })
}
export function submitTime(num, time) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '车间管理_装配任务_设置计划完成时间',
      param: '计划流水号=' + num + '&计划完成时间=' + time
    }
  })
}
export function submitOutPeople(num, people) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '车间装配管理_移出装配工_循环执行',
      param: '计划流水号=' + num + '&任务分配流水号组=' + people
    }
  })
}
export function submitEdit(num, num1) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '车间装配管理_部件数量_修改',
      param: '组件流水号=' + num + '&部件数量=' + num1
    }
  })
}
export function submitProcess(num, process, quota) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '车间管理_工作计划_编辑工艺定额',
      param: '计划流水号=' + num + '&装配工艺=' + process + '&装配工时=' + quota
    }
  })
}
export function getFileData(MachineDrawValue) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: 'PDM_机床总图_查询数据',
      param: `机床流水号=${MachineDrawValue}`
    }
  })
}
