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

// 初始化机床项目
export function initMachineProject() {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      // name: 'PDM_项目名称_查询数据'
      name: '采购管理_仓库采购_出库记录_机床图号_查询'
    }
  })
}
export function initMachine() {
  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_组件名称_查询数据',
      name: '采购管理_仓库采购_出库记录_组件名称_查询',
      param: '机床流水号=' + num
    }
  })
}
export function initLocateName() {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      // name: 'PDM_项目名称_查询数据'
      name: '库存管理_货位主文件_查询数据_查询全部'
    }
  })
}
// 查询记录
export function searchRecord(check1, project, check2, machine, check3, group, check4, name, check5, spec, check6, model, check7, time1, time2, pageCurrent, pageSize) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: `库存管理_出库记录_查询数据`,
      param: `项目流水号_check=${check1}&项目流水号=${project}&机床流水号_check=${check2}&机床流水号=${machine}&组件流水号_check=${check3}&组件流水号=${group}&名称_check=${check4}&名称=${name}&规格_check=${check5}&规格=${spec}&图号或型号_check=${check6}&图号或型号=${model}&出库时间_check=${check7}&出库开始时间=${time1}&出库结束时间=${time2}`,
      Pagination: pageCurrent + '&' + pageSize
    }
  })
}
export function submitMaterialReturn(materialNumber, basicNumber, number, name, id, type, floatNumber) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      // name: 'PDM_组件名称_查询数据',
      name: '采购管理_物料退货_增加数据',
      param: '物料流水号=' + materialNumber + '&组件零件基本件流水号=' + basicNumber + '&数量=' + number + '&货位流水号=' + name + '&入库人员流水号=' + id + '&退料类型=' + type + '&零件流水号=' + floatNumber
    }
  })
}
export function editsubmit(num, num1, num2, num3) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '库存管理_出库记录_编辑数据',
      param: '机床流水号=' + num + '&组件流水号=' + num1 + '&领料人=' + num2 + '&离线采购件出库流水号=' + num3
    }
  })
}
