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

// 初始化人员
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'
    }
  })
}
// 初始化机床项目
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) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: 'PDM_组件名称_查询数据',
      param: '机床流水号=' + num
    }
  })
}
// 领料单查询
export function searchList(pageCurrent, pageSize, listPeople_check, listPeople, 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 + '&时间段_check=' + check1 + '&开始时间=' + time1 + '&结束时间=' + time2 + '&是否审批=1',
      Pagination: pageCurrent + '&' + pageSize
    }
  })
}
// 查询领料单明细
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 searchStockNumber1(...params) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '库存管理_物料出库_标准件和外购件_查询数据',
      param: `物料流水号=${params[0]}`
    }
  })
}
// 查看领料单明细相关的物料货位数量
export function searchStockNumber2(...params) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '库存管理_物料出库_基本件_查询数据',
      param: `基本件流水号=${params[0]}`
    }
  })
}
// 出库
export function submitOutStore(...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]}&组件流水号组=${params[5]}&机床流水号组=${params[6]}&出库数量组=${params[7]}&出库人流水号=${params[8]}&领料人编号=${params[9]}&出库类别=${params[10]}&领料单流水号组=${params[11]}&离线采购件流水号组=${params[12]}&领料部门=${params[13]}`
    }
  })
}
// 异常出库
export function errorRecord(...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 initOutType() {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '3',
      name: 'select * from 库存管理_出库类别'
    }
  })
}
// 领料确认
export function pickingSubmit(...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 updateRemark(...params) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '车间装配管理_领料单明细_编辑数据',
      param: `领料单明细流水号=${params[0]}&备注=${params[1]}`
    }
  })
}
// 归还
export function sendBack(...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]}&标准件和外购件流水号=${params[5]}&请购单明细流水号=${params[6]}&仓库流水号=${params[7]}&领料单流水号=${params[8]}`
    }
  })
}
export function getPickingList() {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '车间装配管理_领料单_查询数据_提示'
    }
  })
}
export function setPickingList() {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '车间装配管理_领料单_查询数据_修改提示'
    }
  })
}
export function selectdepartment() {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '出库管理_部门查询'
    }
  })
}
export function selectleaders(department) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '出库管理_人员查询',
      param: '考核部门编号=' + department
    }
  })
}
// 领料单查询
export function searchList222(listPeople_check, listPeople, pageCurrent, pageSize) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '车间装配管理_领料单明细_查询数据_新2',
      param: '图号_check=' + listPeople_check + '&图号=' + listPeople,
      Pagination: pageCurrent + '&' + pageSize
    }
  })
}
