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

// 查询合同模板
export function searchContractDemo(num1 = null) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '采购管理_合同模板_查询数据',
      param: '合同模板流水号=' + num1
    }
  })
}
export function initPurchaseOrder() {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '车间管理_基本件采购_请购单_查询数据'
    }
  })
}
export function searchContract(check, part) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '车间管理_基本件采购_请购单_通过零件查询数据',
      param: '零件图号_check=' + check + '&零件图号=' + part
    }
  })
}
export function initGroupNum(machineValue) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: 'PDM_零件明细表_组件流水号_查询数据_根据机床',
      param: `机床流水号=${machineValue}`
    }
  })
}
export function searchData(num) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '车间管理_基本件采购_请购单明细_查询数据',
      param: '请购单流水号=' + num
    }
  })
}
export function searchData1(num) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '车间采购管理_成组采购_查询数据',
      param: '请购单流水号=' + num
    }
  })
}
export function searchData2(num) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '车间管理_基本件采购_请购单明细_查询数据_基本件',
      param: '请购单流水号=' + num
    }
  })
}
export function update(num, time, remarks) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '车间管理_基本件采购_请购单明细_编辑数据',
      param: '请购单明细流水号=' + num + '&物料计划到货时间=' + time + '&备注=' + remarks
    }
  })
}
// 查询供应商
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 doneContract(num1, RequisitionNumber, name1, time1, time2, num2, text, type, freight, num3, partsNum, priceGroup, taxGroup, currency, num4, id, singleQuota, readyQuota, AdvanceCharge, group) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '车间管理_基本件采购_请购单和请购单明细_增加数据',
      param: `请购单流水号=${num1}&请购单编号=${RequisitionNumber}&采购合同名称=${name1}&预到货时间=${time1}&规定到货时间=${time2}&采购员=${id}&供应商流水号=${num2}&合同文本=${text}&模板类型=${type}&运费=${freight}&物料流水号组=${num3}&请购单明细流水号组=${num4}&数量组=${partsNum}&单价组=${priceGroup}&税率组=${taxGroup}&币种流水号组=${currency}&单件定额工时组=${singleQuota}&准结定额工时组=${readyQuota}&预付款=${AdvanceCharge}&未选请购单明细流水号组=${group}`
    }
  })
}
export function doneContract1(num1, RequisitionNumber, name1, time2, group, id, num2, text, type, freight, AdvanceCharge, partsNum, priceGroup, taxGroup, currency, remark) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '车间管理_基本件采购_请购单和请购单明细_增加数据_成组采购',
      param: `请购单流水号=${num1}&请购单编号=${RequisitionNumber}&采购合同名称=${name1}&规定到货时间=${time2}&组号=${group}&采购员=${id}&供应商流水号=${num2}&合同文本=${text}&模板类型=${type}&运费=${freight}&预付款=${AdvanceCharge}&数量=${partsNum}&单价=${priceGroup}&税率=${taxGroup}&币种流水号=${currency}&备注=${remark}`
    }
  })
}
export function submitGroup(num, num1) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '车间采购管理_成组采购_生成数据',
      param: '请购单流水号=' + num + '&组件流水号=' + num1
    }
  })
}
export function update1(num, num1, num2, num3, num4) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '车间采购管理_成组采购_更新数据',
      param: '组件流水号=' + num + '&数量=' + num1 + '&单价=' + num2 + '&交货期=' + num3 + '&备注=' + num4
    }
  })
}
export function unLinkGroup(num) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '车间采购管理_成组采购_取消数据',
      param: '请购单流水号=' + num
    }
  })
}
export function changeTime(num, time) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '车间管理_基本件采购_请购单明细_编辑数据_整体',
      param: '请购单流水号=' + num + '&物料计划到货时间=' + time
    }
  })
}
