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

// 创建领料单
export function addList(peopleNumber) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '车间生产管理工艺_备料管理_领料单增加',
      param: '领料人流水号=' + peopleNumber
    }
  })
}
// 领料单查询
export function searchList(pageCurrent, pageSize, listNumber_check, listNumber) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '车间生产管理工艺_备料管理_查询备料领料单',
      param: '领料单编号_check=' + listNumber_check + '&领料单编号=' + listNumber,
      Pagination: pageCurrent + '&' + pageSize
    }
  })
}
// 删除领料单明细/基本件
export function dropListDetailBasic(...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]}`
    }
  })
}
// 初始化项目
export function initProject() {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '车间生产管理工艺_项目查询'
    }
  })
}
// 机床查询
export function searchmachine(check, num) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: 'PDM_机床名称_查询数据',
      param: '项目流水号_check=' + check + '=int&项目流水号=' + num
    }
  })
}
// 分组查询
export function searchTeam(machineNumber) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: 'PDM_组件名称_查询数据',
      param: '机床流水号=' + machineNumber
    }
  })
}
// 自家备料零件
export function searchBasicPart(pageCurrent, pageSize, project_check, project, machine_check, machine, group_check, group) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '车间生产管理工艺_备料管理_自家备料零件查询',
      param: '项目流水号_check=' + project_check + '&项目流水号=' + project + '&机床流水号_check=' + machine_check + '&机床流水号=' + machine + '&组件流水号_check=' + group_check + '&组件流水号=' + group,
      Pagination: pageCurrent + '&' + pageSize
    }
  })
}
// 外购备料零件
export function searchPurchasePart(pageCurrent, pageSize, project_check, project, machine_check, machine, group_check, group) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '车间生产管理工艺_备料管理_外购备料零件查询',
      param: '项目流水号_check=' + project_check + '&项目流水号=' + project + '&机床流水号_check=' + machine_check + '&机床流水号=' + machine + '&组件流水号_check=' + group_check + '&组件流水号=' + group,
      Pagination: pageCurrent + '&' + pageSize
    }
  })
}
// 自家备料选入
export function addBasicList(listNumber, num1) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '车间生产管理工艺_备料管理_自家备料选入',
      param: '备料领料单流水号=' + listNumber + '&工艺计划流水号=' + num1
    }
  })
}
// 外购备料选入
export function addPurchaseList(listNumber, num1) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '车间生产管理工艺_备料管理_外购备料选入',
      param: '备料领料单流水号=' + listNumber + '&工艺计划流水号=' + num1
    }
  })
}
// 领料单明细查询
export function searchListDetail(listNumber) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '车间生产管理工艺_备料管理_备料领料单明细查询',
      param: '备料领料单流水号=' + listNumber
    }
  })
}
// 删除领料单
export function dropList(PickingListNumberx) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '车间生产管理工艺_备料管理_备料领料单删除',
      param: '备料领料单流水号=' + PickingListNumberx
    }
  })
}
