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

export function searchCailiao(name) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '备料管理_外购备料到货_材料查询',
      param: `供应商=${name}`
    }
  })
}
// 获取新到货单编号
export function searchNewOrder() {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '备料管理_获取新到货单编号'
    }
  })
}
// 查询采购单
export function searchPurchaseOrder(pageCurrent, pageSize, check1, num, check2, name, check, num1) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '备料管理_采购计划_查询数据_到货',
      param: `采购单号_check=${check1}&采购单号=${num}&供应商_check=${check2}&供应商=${name}&零件图号_check=${check}&零件图号=${num1}`,
      Pagination: pageCurrent + '&' + pageSize
    }
  })
}
// 查询离线采购单
export function searchLxPurchaseOrder(pageCurrent, pageSize, check1, num, check2, name, check, num1) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '备料管理_离线采购计划_查询数据_到货',
      param: `离线采购计划编号_check=${check1}&离线采购计划编号=${num}&供应商流水号_check=${check2}&供应商流水号=${name}&零件图号_check=${check}&零件图号=${num1}`,
      Pagination: pageCurrent + '&' + pageSize
    }
  })
}
// 查询采购计划明细
export function searchMateriel(num, check, num1) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '备料管理_采购计划明细_查询数据_未选入',
      param: `供应商=${num}&零件图号_check=${check}&零件图号=${num1}`
    }
  })
}
// 查询离线采购计划明细
export function searchLxMateriel(num, check, num1) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '备料管理_离线采购计划明细_查询数据_未选入',
      param: `供应商流水号=${num}&零件图号_check=${check}&零件图号=${num1}`
    }
  })
}
// 查询到货单
export function searchArriveOrder(num8, num9, num6, num7, datecheck, starttime, endtime, check, part) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '备料管理_到货单查询_新',
      param: `供应商流水号_check=${num8}&供应商流水号=${num9}&是否关联_check=${num6}&是否关联=${num7}&日期check=${datecheck}&开始时间=${starttime}&结束时间=${endtime}&零件图号_check=${check}&零件图号=${part}`
    }
  })
}
// 新增到货单
export function addPurchaseOrder(num5, num6, num7) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '备料管理_新增到货单',
      param: `备注=${num5}&供应商流水号=${num6}&日期=${num7}`
    }
  })
}
// 编辑采购单
export function editPurchaseOrder(num5, num6, num8) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '备料管理_编辑到货单',
      param: `备注=${num5}&到货单流水号=${num6}&日期=${num8}`
    }
  })
}
// 删除采购单
export function deletePurchaseOrder(PurchaseOrderNameValue, ArrivalOrderGroup, ArrivalOrderMXNumberGroup, numberGroup, LxnumberGroup) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '备料管理_删除到货单',
      param: `到货单流水号=${PurchaseOrderNameValue}&到货单明细流水号组=${ArrivalOrderGroup}&到货单明细绑定流水号组=${ArrivalOrderMXNumberGroup}&采购计划明细流水号组=${numberGroup}&离线采购计划明细流水号组=${LxnumberGroup}`
    }
  })
}
// 查询采购计划明细
export function searchTable5(num, check, part) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '备料管理_到货单明细查询',
      param: `到货单流水号=${num}&零件图号_check=${check}&零件图号=${part}`
    }
  })
}
export function deleteArrivalMX(num, group, group1, group2) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '备料管理_删除到货单明细',
      param: `到货单明细流水号=${num}&到货单明细绑定流水号组=${group}&采购计划明细流水号组=${group1}&离线采购计划明细流水号组=${group2}`
    }
  })
}
export function EditArrivalOrderMX(num, num2, num3, num4, num5) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '备料管理_编辑到货单明细',
      param: `到货单明细流水号=${num}&数量=${num2}&单位=${num3}&单价=${num4}&金额=${num5}`
    }
  })
}
export function AddArrivalOrderMX(num, num1, num2, num3, num4, num5, num6, num7, num8, num9, num10, num11, id) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '备料管理_新增到货单明细',
      param: `到货单流水号=${num}&材料=${num1}&数量=${num2}&单位=${num3}&单价=${num4}&金额=${num5}&工艺计划流水号组=${num6}&采购计划明细流水号组=${num7}&本次到货数量组=${num8}&离线采购计划明细流水号组=${num9}&到货重量组=${num10}&到货金额组=${num11}&考勤编号=${id}`
    }
  })
}
// 取消关联
export function deleteMateriel(num1, num2, num3) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '备料管理_取消到货单明细绑定',
      param: `到货单明细绑定流水号=${num1}&采购计划明细流水号=${num2}&离线采购计划明细流水号=${num3}`
    }
  })
}
// 关联材料
export function addMateriel(num1, num2, num3, num4, num5, num6, num7, id) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '备料管理_到货单明细关联',
      param: `到货单明细流水号=${num1}&工艺计划流水号组=${num2}&采购计划明细流水号组=${num3}&本次到货数量组=${num4}&离线采购计划明细流水号组=${num5}&到货重量组=${num6}&到货金额组=${num7}&考勤编号=${id}`
    }
  })
}
export function searchTable6(num1, check, part) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '备料管理_关联材料_查询数据',
      param: `到货单明细流水号=${num1}&零件图号_check=${check}&零件图号=${part}`
    }
  })
}
// 查询供应商
export function searchSupplier(check1, value1, check2, value2, check3, value3, check4, value4, check5, value5, check6, value6, check7, value7, check8, value8, check9, value9, check10, value10, check11, value11, check12, value12) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '采购管理_供应商_查询数据_根据条件',
      param: '供应商名称_check=' + check1 + '&供应商名称=' + value1 + '&企业性质_check=' + check2 + '&企业性质=' + value2 + '&创立日期_check=' + check3 + '&创立日期=' + value3 + '&注册资本_check=' + check4 + '&注册资本=' + value4 + '&税号_check=' + check5 + '&税号=' + value5 + '&电子信箱_check=' + check6 + '&电子信箱=' + value6 + '&地址_check=' + check7 + '&地址=' + value7 + '&帐号_check=' + check8 + '&帐号=' + value8 + '&开户行_check=' + check9 + '&开户行=' + value9 + '&电话号码_check=' + check10 + '&电话号码=' + value10 + '&传真_check=' + check11 + '&传真=' + value11 + '&货期_check=' + check12 + '&货期=' + value12
    }
  })
}
export function saveWeight(num1, num3, num4) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '备料管理_到货明细关联备料_保存单件重量和总重量',
      param: `采购计划明细流水号=${num1}&总重量=${num3}&总金额=${num4}`
    }
  })
}
export function saveWeight1(num1, num3, num4) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '备料管理_到货明细关联备料_保存单件重量和总重量_离线',
      param: `离线采购计划明细流水号=${num1}&总重量=${num3}&总金额=${num4}`
    }
  })
}
