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

// 初始化机床项目
export function initProject() {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: 'PDM_项目名称_查询数据'
    }
  })
}

// 查询机床
export function searchmachine(num, check) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: 'PDM_机床名称_查询数据',
      param: '项目流水号_check=' + check + '=int&项目流水号=' + num + '&机床类型代码_check=0=int&机床类型代码=1=int&机床流水号_check=0'
    }
  })
}
// 获取组号
export function searchgroup(num, pageCurrent, pageSize) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: 'PDM_组件名称_查询数据',
      param: '机床流水号=' + num
    }
  })
}
// 获取表单
export function searchdata(entryNameValue_check, entryNameValue, machineToolValue_check, machineToolValue, groupNumberValue_check, groupNumberValue, partNumber_check, partNumber, time_check, time1, time2, pageCurrent, pageSize) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '自制件出库_查询数据',
      param: '项目流水号_check=' + entryNameValue_check + '&项目流水号=' + entryNameValue + '&机床流水号_check=' + machineToolValue_check + '&机床流水号=' + machineToolValue + '&组件流水号_check=' + groupNumberValue_check + '&组件流水号=' + groupNumberValue + '&零件图号_check=' + partNumber_check + '&零件图号=' + partNumber + '&入库时间_check=' + time_check + '&入库时间开始=' + time1 + '&入库时间结束=' + time2,
      Pagination: pageCurrent + '&' + pageSize
    }
  })
}
// 自制件出库
export function warehousing(processPlanSerialNumber, outgoingQuantity, leader, remarks) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '自制件出库_循环执行_新',
      param: '工艺计划流水号组=' + processPlanSerialNumber + '&出库数量组=' + outgoingQuantity + '&考勤编号=' + leader + '&出库备注=' + remarks
    }
  })
}
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
    }
  })
}
