import request from '@/utils/request'

// 查询库存数
export function searchInventoryNum(pageCurrent, pageSize, check1, name, check2, state1, state2) {
  return request({
    url: '',
    method: 'post',
    data: {
      type: '1',
      name: '采购管理_离线合同_物料余量_查询数据',
      param: `物料名称_check=${check1}&物料名称=${name}&库存状态_check=${check2}&库存状态=${state1}&采购状态=${state2}`,
      Pagination: pageCurrent + '&' + pageSize
    }
  })
}
// 查询离线合同
export function searchOfflineContract(pageCurrent, pageSize, check1, num, check2, name) {
  return request({
    url: '',
    method: 'post',
    data: {
      type: '1',
      name: '采购管理_离线合同_查询数据',
      param: `离线合同编号_check=${check1}&离线合同编号=${num}&供应商名称_check=${check2}&供应商名称=${name}`,
      Pagination: pageCurrent + '&' + pageSize
    }
  })
}
// 查询离线合同 (不分页)
export function searchOfflineContract2() {
  return request({
    url: '',
    method: 'post',
    data: {
      type: '1',
      name: '采购管理_离线合同_查询数据',
      param: `离线合同编号_check=0&离线合同编号=0&供应商名称_check=0&供应商名称=0`
    }
  })
}
// 查询供应商
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: {
      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 addOfflineContract(contractNum, contractName, supplier, person, date, remark) {
  return request({
    url: '',
    method: 'post',
    data: {
      type: '2',
      name: '采购管理_离线合同_增加数据',
      param: `离线合同编号=${contractNum}&离线合同名称=${contractName}&供应商流水号=${supplier}&人员编号=${person}&规定到货时间=${date}&离线合同备注=${remark}`
    }
  })
}
// 编辑离线合同
export function editOfflineContract(contractNumValue, contractNum, contractName, supplier, person, date, remark) {
  return request({
    url: '',
    method: 'post',
    data: {
      type: '2',
      name: '采购管理_离线合同_修改数据',
      param: `离线合同流水号=${contractNumValue}&离线合同编号=${contractNum}&离线合同名称=${contractName}&供应商流水号=${supplier}&人员编号=${person}&规定到货时间=${date}&离线合同备注=${remark}`
    }
  })
}
// 作废离线合同
export function deleteOfflineContract(num) {
  return request({
    url: '',
    method: 'post',
    data: {
      type: '2',
      name: '采购管理_离线合同_删除数据',
      param: '离线合同流水号=' + num
    }
  })
}
// 查询离线合同明细
export function searchMateriel(num) {
  return request({
    url: '',
    method: 'post',
    data: {
      type: '1',
      name: '采购管理_离线合同明细_查询数据',
      param: `离线合同流水号=${num}`
    }
  })
}
// 增加离线合同明细
export function addMateriel(num1, num2) {
  return request({
    url: '',
    method: 'post',
    data: {
      type: '2',
      name: '采购管理_离线合同明细_增加数据',
      param: `离线合同流水号=${num1}&物料流水号组=${num2}`
    }
  })
}
// 删除离线合同明细
export function deleteMateriel(num) {
  return request({
    url: '',
    method: 'post',
    data: {
      type: '2',
      name: '采购管理_离线合同明细_删除数据',
      param: `离线合同明细流水号=${num}`
    }
  })
}
// 保存离线合同
export function saveOfflineContact(contractNum, total, partGroup, numGroup, priceGroup, dateGroup, remarkGroup) {
  return request({
    url: '',
    method: 'post',
    data: {
      type: '2',
      name: '采购管理_离线合同_保存合同',
      param: `离线合同流水号=${contractNum}&合同总额=${total}&离线合同明细流水号组=${partGroup}&数量组=${numGroup}&单价组=${priceGroup}&交货期要求组=${dateGroup}&备注组=${remarkGroup}`
    }
  })
}
// 生成离线合同
export function doneOfflineContact(contractNum, total, partGroup, numGroup, priceGroup, dateGroup, remarkGroup) {
  return request({
    url: '',
    method: 'post',
    data: {
      type: '2',
      name: '采购管理_离线合同_生成合同',
      param: `离线合同流水号=${contractNum}&合同总额=${total}&离线合同明细流水号组=${partGroup}&数量组=${numGroup}&单价组=${priceGroup}&交货期要求组=${dateGroup}&备注组=${remarkGroup}`
    }
  })
}
// 设置安全库存
export function setSafeValue(...params) {
  return request({
    url: '',
    method: 'post',
    data: {
      type: '2',
      name: '采购管理_离线合同_物料安全库存_修改数据',
      param: `物料流水号=${params[0]}&安全库存量=${params[1]}`
    }
  })
}
