import request from '@/utils/request'
import state from '@/store'
import router from '@/router'
// var postData
// 初始化人员
export function initPickPerson() {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '3',
      name: 'select 姓名,人员编号 from 人事档案管理_人员名单 where 是否离职 = 0 order by 姓名 '
    }
  })
}
// 初始化机床项目
export function initMachineProject() {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: 'PDM_项目名称_查询数据'
    }
  })
}
// 组件查询
export function searchgroup(num) {
  // postData = new URLSearchParams()
  // postData.append('param', num)
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: 'PDM_组件名称_查询数据',
      param: '机床流水号=' + num
    }
  })
}
// 查询三表
export function searchTable(...params) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '车间装配管理_领料单_三表_查询数据',
      param: `机床流水号_check=${params[0]}&机床流水号=${params[1]}&组件流水号_check=${params[2]}&组件流水号=${params[3]}&名称_check=${params[4]}&名称=${params[5]}&领料情况_check=${params[6]}&领料情况=${params[7]}&零件类型=${params[10]}`,
      Pagination: params[8] + '&' + params[9]
    }
  })
}
export function searchPart(...params) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '库存管理_离线外购件_出库查询',
      param: `物料名称_check=${params[0]}&物料名称=${params[1]}`,
      Pagination: params[2] + '&' + params[3]
    }
  })
}
// 领料单查询
export function searchList(pageCurrent, pageSize, listPeople_check, listPeople, isElectrical, check1, time1, time2, order, partName) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '车间装配管理_领料单_加排序_查询数据',
      param: '制单人_check=' + listPeople_check + '&制单人=' + listPeople + '&是否电气=' + isElectrical + '&时间段_check=' + check1 + '&开始时间=' + time1 + '&结束时间=' + time2 + '&排序方式=' + order + '&排序名称=' + partName,
      Pagination: pageCurrent + '&' + pageSize
    }
  })
}
// 创建领料单
export function createList(num, remark, isElectrical, macnum, groupnum) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '车间装配管理_领料单_增加数据',
      param: '领料人流水号=' + num + '&领料单备注=' + remark + '&是否电气=' + isElectrical + '&机床流水号=' + macnum + '&组件流水号=' + groupnum
    }
  })
}
// 删除领料单
export function dropList(num) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '车间装配管理_领料单_删除数据',
      param: '领料单流水号=' + num
    }
  })
}
// 查询领料单明细
export function searchListDetail(...params) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '车间装配管理_领料单明细_查询数据_新',
      param: `领料单流水号=${params[0]}`
    }
  })
}
// 选入领料单
export function selectIntoList(...params) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '车间装配管理_领料单明细_增加数据',
      param: `基本件流水号组=${params[0]}&标准件和外购件流水号组=${params[1]}&领料单流水号=${params[2]}&领用数量组=${params[3]}`
    }
  })
}
// 选入领料单
export function IntoMateerial(...params) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '离线采购_领料明细_增加数据_循环',
      param: `物料流水号组=${params[0]}&组件零件基本件流水号组=${params[1]}&领料数量组=${params[2]}&领料单流水号=${params[3]}&机床流水号=${params[4]}`
    }
  })
}
// 删除领料单
export function dropListDetail(num) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '车间装配管理_领料单明细_删除数据',
      param: '领料单明细流水号=' + num
    }
  })
}
// 查询领料单明细详情
export function searchListDetailMX(...params) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '车间装配管理_领料单明细_详情_查询数据',
      param: `领料单流水号=${params[0]}&基本件流水号=${params[1]}&标准件和外购件流水号=${params[2]}&离线采购件流水号=${params[3]}`
    }
  })
}
// 查询三表明细领料详情
export function searchTableDetailMX(...params) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '车间装配管理_三表_领料详情_查询数据',
      param: `基本件流水号=${params[0]}&标准件和外购件流水号=${params[1]}`
    }
  })
}
export function submitApproval(num, num1, num2) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '车间装配管理_领料单审批_修改数据',
      param: '领料单流水号=' + num + '&审批情况流水号=' + num1 + '&未通过原因=' + num2
    }
  })
}
// 领料单审批查询
export function searchListApproval(pageCurrent, pageSize, listPeople_check, listPeople, isElectrical, check1, time1, time2) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '车间装配管理_领料单审批_查询数据',
      param: '制单人_check=' + listPeople_check + '&制单人=' + listPeople + '&是否电气=' + isElectrical + '&时间段_check=' + check1 + '&开始时间=' + time1 + '&结束时间=' + time2,
      Pagination: pageCurrent + '&' + pageSize
    }
  })
}
