import request from '@/utils/request'
import state from '@/store'
import router from '@/router'
// 物料类别
export function initMaterialCategory(check, DepartmentValue) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '库存管理_物料类别编号_查询数据_根据物料部门编号',
      param: '物料部门流水号_check=' + check + '=int&物料部门流水号=' + DepartmentValue
    }
  })
}
// 物料品种
export function initMaterialVariety(MaterialCategoryValue) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '库存管理_物料品种编号_查询数据',
      param: '物料类别流水号=' + MaterialCategoryValue
    }
  })
}
// 初始化项目（车间传递来的）
export function initProject() {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: 'PDM_项目名称_采购部采购_查询数据'
    }
  })
}
// 初始化采购员
export function initBuyer() {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '人事档案管理_人员与角色_查询数据_采购员'
    }
  })
}
// 机床查询
export function searchMachine(num) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: 'PDM_机床名称_查询数据',
      param: '项目流水号_check=0&项目流水号=' + num
    }
  })
}
// 分组查询
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
    }
  })
}
// 查询表1标准件和外购件
export function searchTable1(...params) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: 'xqs_采购管理_采购部采购_查询物料_分配后_采购任务分配',
      param: `物料类别流水号_check=${params[2]}&物料类别流水号=${params[3]}&物料品种流水号_check=${params[4]}&物料品种流水号=${params[5]}&项目流水号_check=${params[6]}&项目流水号=${params[7]}&机床流水号_check=${params[8]}&机床流水号=${params[9]}&组件流水号_check=${params[10]}&组件流水号=${params[11]}&物料名称_check=${params[12]}&物料名称=${params[13]}&物料状态编号=${params[14]}&物料规格_check=${params[15]}&物料规格=${params[16]}&物料型号_check=${params[17]}&物料型号=${params[18]}&零件类型=${params[19]}&时间段_check=${params[20]}&开始时间=${params[21]}&结束时间=${params[22]}&PageCurrent=${params[0]}&PageSize=${params[1]}&TotalCount=1111=int=output`
    }
  })
}
// 查询表1基本件
export function searchTable2(...params) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '采购管理_采购部采购_查询物料_基本件_分配后_采购任务分配',
      param: `项目流水号_check=${params[2]}&项目流水号=${params[3]}&机床流水号_check=${params[4]}&机床流水号=${params[5]}&组件流水号_check=${params[6]}&组件流水号=${params[7]}&物料状态编号=${params[8]}&零件图号_check=${params[9]}&零件图号=${params[10]}&零件名称_check=${params[11]}&零件名称=${params[12]}&零件规格_check=${params[13]}&零件规格=${params[14]}&材料_check=${params[15]}&材料=${params[16]}&PageCurrent=${params[0]}&PageSize=${params[1]}&TotalCount=1111=int=output`
    }
  })
}
// 分配任务1标准件和外购件
export function allocateTask1(group, person) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '采购部采购_分配任务',
      param: `标准件和外购件流水号组=${group}&人员编号=${person}`
    }
  })
}
// 分配任务2基本件
export function allocateTask2(group, person) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '采购部采购_分配任务_基本件',
      param: `基本件流水号组=${group}&人员编号=${person}`
    }
  })
}
// 执行退回1标准件和外购件
export function executeReturn1(...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]}`
    }
  })
}
// 执行退回1基本件
export function executeReturn2(...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]}`
    }
  })
}
// 执行退回1标准件和外购件
export function retract1(num) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '采购部采购_撤回物料',
      param: `标准件和外购件流水号=${num}`
    }
  })
}
// 执行退回1基本件
export function retract2(num) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '采购部采购_撤回物料_基本件',
      param: `基本件流水号=${num}`
    }
  })
}
