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

// 查询库存数
export function searchInventoryNum(pageCurrent, pageSize, check1, val1, check2, val2, check3, val3, check4, state1) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '采购管理_离线合同_物料余量_查询数据',
      param: `物料名称_check=${check1}&物料名称=${val1}&物料规格_check=${check2}&物料规格=${val2}&物料型号_check=${check3}&物料型号=${val3}&库存状态_check=${check4}&库存状态=${state1}`,
      Pagination: pageCurrent + '&' + pageSize
    }
  })
}
// 新增采购明细单
export function submitaddpurchasingdetailsform(name, applicant) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '采购管理_仓库采购_表单_新增',
      param: `表单名称=${name}&申请人=${applicant}`
    }
  })
}
// 查询采购明细单
export function searchpurchasingDetailsForm(pageCurrent, pageSize, name) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '采购管理_仓库采购_表单_查询',
      param: `表单名称=${name}`,
      Pagination: pageCurrent + '&' + pageSize
    }
  })
}
// 查询采购表单
export function confirmEditpurchasingDetailsForm(name, id) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '采购管理_仓库采购_表单_编辑',
      param: `表单名称=${name}&id=${id}`
    }
  })
}
// 查询采购表单
export function openDeletepurchasingDetailsForm(id) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '采购管理_仓库采购_表单_删除',
      param: `id=${id}`
    }
  })
}
// 选入物料信息
export function addmateriel(formNumber, materielGroup) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '采购管理_仓库采购_表单明细_增加数据',
      param: `表单流水号=${formNumber}&物料流水号组=${materielGroup}`
    }
  })
}
// 查询采购明细
export function searchtable2(formNumber) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '采购管理_仓库采购_表单明细_查询数据',
      param: `表单流水号=${formNumber}`
    }
  })
}
// 设置安全库存
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]}`
    }
  })
}
export function updateNumber(...params) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '采购管理_仓库采购_表单明细_编辑数据',
      param: `id=${params[0]}&数量=${params[1]}&备注=${params[2]}`
    }
  })
}
export function getperson(num) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '3',
      name: 'select * from dbo.人事档案管理_人员名单 inner join dbo.菜单系统模块_人员与角色 ' +
        'on 人事档案管理_人员名单.人员编号=菜单系统模块_人员与角色.人员编号 ' +
        'where 角色编号=3 or 角色编号=2'
    }
  })
}
export function tiaozheng(formNumber, PersonValue) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '采购管理_仓库采购_表单_采购分配',
      param: `表单流水号=${formNumber}&采购员编号=${PersonValue}`
    }
  })
}
export function deletematerial(id) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '采购管理_仓库采购_表单明细_删除',
      param: `id=${id}`
    }
  })
}
