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

// 请购单查询
export function searchRequestCard(pageCurrent, pageSize, card_check, card) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '库存管理_离线请购单_请购单查询',
      param: '请购单编号_check=' + card_check + '&请购单编号=' + card,
      Pagination: pageCurrent + '&' + pageSize
    }
  })
}
// 请购单增加
export function addRequestCard(peoplenumber, housenumber) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '库存管理_离线请购单_请购单增加',
      param: '请购人编号=' + peoplenumber + '&仓库流水号=' + housenumber
    }
  })
}
// 查询仓库
export function initWarehouse() {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '库存管理_货位仓库_仓库_查询数据'
    }
  })
}
// 查询库存数
export function searchInventoryNum(pageCurrent, pageSize, check1, name, check2, state1) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '库存管理_离线物料_物料余量_查询数据',
      param: `物料名称_check=${check1}&物料名称=${name}&库存状态_check=${check2}&库存状态=${state1}`,
      Pagination: pageCurrent + '&' + pageSize
    }
  })
}
// 查询请购单明细
export function SeeDetail(data) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '库存管理_离线请购单_请购单明细查询',
      param: '离线请购单流水号=' + data
    }
  })
}
// 请购单明细增加
export function addRequestCardDetail(data1, data2) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '库存管理_离线请购单_请购单明细增加',
      param: '离线请购单流水号=' + data1 + '&物料流水号组=' + data2
    }
  })
}
// 请购单明细修改
export function alterNumber(data2, data3) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '库存管理_离线请购单_请购单明细修改',
      param: '离线请购单明细流水号组=' + data2 + '&数量组=' + data3
    }
  })
}
// 请购单删除
export function deleteRequest(data1) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '库存管理_离线请购单_请购单删除',
      param: '离线请购单流水号=' + data1
    }
  })
}
// 请购单明细删除
export function deleteRequestDetail(data1) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '库存管理_离线请购单_请购单明细删除',
      param: '离线请购单明细流水号=' + data1
    }
  })
}
// 设置安全库存
export function setSafeValue(...params) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '采购管理_离线合同_物料安全库存_修改数据',
      param: `物料流水号=${params[0]}&安全库存量=${params[1]}`
    }
  })
}
