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

// 查询采购单列表
export function initPurchaseOrder(check1, num, check2, name) {
  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}`
    }
  })
}
// 查询采购单
export function searchPurchaseOrder(pageCurrent, pageSize, check1, num, check2, name) {
  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}`,
      Pagination: pageCurrent + '&' + pageSize
    }
  })
}
// 查询采购单明细
export function searchMateriel(num) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '备料管理_采购计划明细_查询数据',
      param: `采购计划流水号=${num}`
    }
  })
}
// 到货
export function Arrival(num, num1, num2) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '备料管理_采购计划_到货',
      param: `采购计划明细流水号=${num}&重量=${num1}&单价=${num2}`
    }
  })
}
// 总价
export function totalChange(num, num1) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '备料管理_采购计划_保存总价',
      param: `采购计划流水号=${num}&总价=${num1}`
    }
  })
}
