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

// 查询询价单号
export function getBillNum() {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '采购管理_创建询价单单号_查询数据'
    }
  })
}
export function getGongyings(num) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '采购管理_创建询价单单号_查询数据'
    }
  })
}
// 查询全部未询价的标准件和外购件
export function getExport1(num) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '3',
      name: `	SELECT distinct
	[项目名称]
      ,[机床图号]
      ,[组号]
      ,[姓名]
      ,[人员编号]
      ,[物料名称]
      ,[物料规格]
      ,[物料型号]
      ,[零件数量]
      ,[询价状态编号]
      ,[备注]
      ,[供货商]
      ,[使用滞货数量]
      ,[任务分配时间]
      ,[零件数量] - [使用滞货数量] as 待询价数量
	FROM MRP_计划订单_组件零件清单_标准件和外购件_视图
	where 询价状态编号 = 1  and 人员编号 = ${num}`
    }
  })
}
// 查询全部未询价的基本件
export function getExport2(num) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '3',
      name: `		SELECT distinct [项目名称]
      ,[机床图号]
      ,[组号]
      ,[材料]
      ,[零件名称]
      ,[零件图号]
      ,[备注]
      ,[供货商]
      ,[规格]
      ,[零件数量] as 待询价数量
      ,[询价状态编号]
      ,[姓名]
      ,[人员编号]
      ,[任务分配时间]
	FROM MRP_计划订单_组件零件清单_基本件_视图 
	where 询价状态编号 = 1 and 人员编号=${num}`
    }
  })
}
// 使用库存
export function changeNum(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 searchMaterial(pageCurrent, pageSize, num1, check1, val1, check2, val2, check3, val3, person, check4, val4, check5, val5, check6, val6, val8, val9, val10, check8, val11, ordername, order) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      // name: 'xqs_采购管理_采购部采购_查询物料_分配后_带库存_创建询价单',
      name: 'xqs_采购管理_采购部采购_查询物料_分配后_带库存_创建询价单_分页',
      param: `物料状态编号=${num1}=int&物料名称_check=${check1}=int&物料名称=${val1}&物料规格_check=${check2}=int&物料规格=${val2}&物料型号_check=${check3}=int&物料型号=${val3}&人员编号=${person}&项目流水号_check=${check4}=int&项目流水号=${val4}&机床流水号_check=${check5}=int&机床流水号=${val5}&组件流水号_check=${check6}&组件流水号=${val6}&时间_check=${val8}=int&开始时间=${val9}&结束时间=${val10}&供货商_check=${check8}=int&供货商=${val11}&排序名称=${ordername}=int&排序方式=${order}=int&PageCurrent=${pageCurrent}=int&PageSize=${pageSize}=int&PageCount=1=int=output&ItemCount=1=int=output`
      // Pagination: pageCurrent + '&' + pageSize
    }
  })
}

// export function searchmaterial(check1, MaterialName, check2, FullNameOfMaterial, check3, MaterialSpecification, check4, MaterialModel, pageCurrent, pageSize, check5, MaterialCategoryValue, check6, MaterialVarietyValue, check7, MeasurementUnitValue, check8, MaterialSourceValue, check9, supplierValue) {
//   return request({
//     url: '',
//     method: 'post',
//     data: {
//       UserID: state.state.user.id,
//       ModularID: router.currentRoute.path,
//       type: '1',
//       name: '库存管理_物料主文件_基本_采购部_查询数据_分页',
//       param: '物料流水号_check=0&物料代码_check=0&物料名称_check=' + check1 + '=int&物料名称=' + MaterialName + '&物料全名_check=' + check2 + '=int&物料全名=' + FullNameOfMaterial + '&物料规格_check=' + check3 + '=int&物料规格=' + MaterialSpecification + '&物料型号_check=' + check4 + '=int&物料型号=' + MaterialModel + '&物料类别流水号_check=' + check5 + '=int&物料类别流水号=' + MaterialCategoryValue + '&物料品种流水号_check=' + check6 + '=int&物料品种流水号=' + MaterialVarietyValue + '&供货商流水号_check=' + check9 + '&供货商流水号=' + supplierValue + '&计量单位流水号_check=' + check7 + '&计量单位流水号=' + MeasurementUnitValue + '&物料来源流水号_check=' + check8 + '&物料来源流水号=' + MaterialSourceValue + '&PageCurrent=' + pageCurrent + '=int&PageSize=' + pageSize + '=int&PageCount=1=int=output&ItemCount=1=int=output'
//     }
//   })
// }

// 查询分配后的基本件
export function searchPart(pageCurrent, pageSize, num1, check1, val1, check2, val2, check3, val3, person, check4, val4, check5, val5, check6, val6, val8, val9, val10, check8, val11, ordername, order) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '采购管理_采购部采购_查询物料_基本件_分配后_创建询价单',
      param: `物料状态编号=${num1}&零件图号_check=${check1}=int&零件图号=${val1}&零件名称_check=${check2}=int&零件名称=${val2}&零件规格_check=${check3}=int&零件规格=${val3}&人员编号=${person}&项目流水号_check=${check4}=int&项目流水号=${val4}&机床流水号_check=${check5}=int&机床流水号=${val5}&组件流水号_check=${check6}=int&组件流水号=${val6}&时间_check=${val8}=int&开始时间=${val9}&结束时间=${val10}&供货商_check=${check8}=int&供货商=${val11}&排序名称=${ordername}=int&排序方式=${order}=int&PageCurrent=${pageCurrent}=int&PageSize=${pageSize}=int&PageCount=1=int=output&ItemCount=1=int=output`
    }
  })
}
// 查询供应商
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 searchCreateInquirySheet(pageCurrent, pageSize, check2, num, id) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '采购管理_询价单_查询数据',
      param: `询价单编号_check=${check2}&询价单编号=${num}&采购员流水号_check=1&采购员流水号=${id}`,
      Pagination: pageCurrent + '&' + pageSize
    }
  })
}
// 查询询价单--不分页
export function searchCreateInquirySheet2() {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '采购管理_询价单_查询数据',
      param: `供应商名称_check=0&供应商名称=0&询价单编号_check=0&询价单编号=0&采购员流水号_check=0&采购员流水号=0`
    }
  })
}
// 查询询价单明细
export function searchSheetDetail(num2) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '采购管理_询价单明细_查询数据',
      param: '询价单流水号=' + num2
    }
  })
}
// 创建询价单
export function createInquirySheet(num1, id, num2, remark) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '采购管理_询价单_增加数据',
      param: `询价单编号=${num1}&采购员=${id}&供应商流水号=${num2}&备注=${remark}`
    }
  })
}
// 删除询价单
export function deleteInquirySheet(num1) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '采购管理_询价单_删除数据',
      param: '询价单流水号=' + num1
    }
  })
}
// 将标准件和外购件追加现有询价单
export function addInquirySheet1(num1, num2, num3) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '采购管理_询价单明细_增加数据',
      param: '询价单流水号=' + num1 + '&组件零件流水号=' + num2 + '&数量=' + num3
    }
  })
}
// 将基本件追加现有询价单
export function addInquirySheet2(num1, num2, num3) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '采购管理_询价单明细_增加数据',
      param: '询价单流水号=' + num1 + '&组件零件基本件流水号=' + num2 + '&数量=' + num3
    }
  })
}
// 移出询价单
export function outInquirySheet(num1, num2, num3) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '采购管理_询价单明细_删除数据',
      param: '询价单明细流水号=' + num1 + '&组件零件流水号=' + num2 + '&组件零件基本件流水号=' + num3
    }
  })
}
// 查询物料
export function searchAllMaterial(check1, MaterialName, check2, MaterialSpec, check3, MaterialModel, pageCurrent, pageSize) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '库存管理_物料主文件_基本_查询数据_分页',
      param: `物料名称_check=${check1}&物料名称=${MaterialName}&物料规格_check=${check2}&物料规格=${MaterialSpec}&物料型号_check=${check3}&物料型号=${MaterialModel}&PageCurrent=${pageCurrent}=int&PageSize=${pageSize}=int&PageCount=1=int=output&ItemCount=1=int=output`
    }
  })
}
// 物料变更
export function materialChange(num1, num2, num3, num4, person) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '采购管理_采购物料修改_修改数据',
      param: `组件零件流水号=${num1}&标准件和外购件流水号=${num2}&原物料流水号=${num3}&新物料流水号=${num4}&申请人=${person}`
    }
  })
}
// 编辑询价单
export function editInquirySheet(num1, num2, num3) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '采购管理_询价单_修改数据',
      param: `询价单流水号=${num1}&询价单编号=${num2}&供应商流水号=${num3}`
    }
  })
}
// 编辑询价单
export function saveOrder(num1, num2, num3) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '采购管理_询价单明细_保存数据',
      param: `询价单明细流水号=${num1}&数量=${num2}&单价=${num3}`
    }
  })
}
// 使用滞货
export function submitUseInventory(...params) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '采购管理_使用滞货',
      param: `物料流水号=${params[0]}&使用滞货数量=${params[1]}&组件零件流水号=${params[2]}&使用人编号=${params[3]}`
    }
  })
}
// 取消使用滞货
export function cancelUseInventory(...params) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '采购管理_取消使用滞货',
      param: `物料流水号=${params[0]}&取消数量=${params[1]}&组件零件流水号=${params[2]}`
    }
  })
}
// 初始化项目
export function initProject() {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: 'PDM_项目名称_查询数据_按时间排序'
    }
  })
}
// 机床查询
export function searchMachine(num) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: 'PDM_机床名称_查询数据',
      param: '项目流水号_check=0&项目流水号=' + num
    }
  })
}
// 分组查询
export function searchGroup(num) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: 'PDM_组件名称_查询数据',
      param: '机床流水号=' + num
    }
  })
}
// 查询询价单基础信息维护
export function searchBaseInfo(id) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '采购管理_询价单基础信息_查询数据',
      param: '人员编号=' + id
    }
  })
}
// 查询询价单基础信息维护
export function editBaseInfo(...params) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '采购管理_询价单基础信息_增改数据',
      param: `人员编号=${params[0]}&手机=${params[1]}&传真=${params[2]}&邮箱=${params[3]}&公司地址=${params[4]}&邮编=${params[5]}&公司电话=${params[6]}&税号=${params[7]}&送货地址=${params[8]}&帐号=${params[9]}&开户行=${params[10]}`
    }
  })
}
// 查询询价单基础信息维护
export function searchMerge(num) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '采购管理_询价单明细合并_查询数据',
      param: '询价单流水号=' + num
    }
  })
}
export function getPerson() {
  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 tiaozheng1(num1, num2) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '采购件入库_创建询价单_调整采购任务_循环执行',
      param: '人员编号=' + num1 + '&标准件和外购件流水号组=' + num2
    }
  })
}
export function tiaozheng2(num1, num2) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '采购件入库_创建询价单_调整采购任务_基本件_循环执行',
      param: '人员编号=' + num1 + '&基本件流水号组=' + num2
    }
  })
}
// 查询时间@change修改
export function timeChange1(num1, num2) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '采购管理_创建询价单_外购件时间修改',
      param: '外购件开始时间=' + num1 + '&外购件结束时间=' + num2
    }
  })
}
// 查询时间@change修改
export function timeChange2(num1, num2) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '采购管理_创建询价单_基本件时间修改',
      param: '基本件开始时间=' + num1 + '&基本件结束时间=' + num2
    }
  })
}
// 查询时间初始化查询
export function timeSearch() {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '采购管理_创建询价单_时间查询'
    }
  })
}
// 拆分基本件
export function summitSplit(basicNumber, basicGroupNumber, id, partNumberGroup, partName1Group, partNumGroup, SpecificationsGroup, remarkGroup) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '采购管理_基本件_拆分物料',
      param: '基本件流水号=' + basicNumber + '&组件零件基本件流水号=' + basicGroupNumber + '&拆分人员=' + id + '&零件图号组=' + partNumberGroup + '&零件名称组=' + partName1Group + '&零件数量组=' + partNumGroup + '&规格组=' + SpecificationsGroup + '&备注组=' + remarkGroup
    }
  })
}
// 查询拆分记录
export function searchSplit(check, name, check1, machine, people) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '车间采购管理_拆分记录_查询数据',
      param: '名称_check=' + check + '&名称=' + name + '&机床_check=' + check1 + '&机床流水号=' + machine + '&人员编号=' + people
    }
  })
}
// 撤销拆分
export function submitRevoke(num) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '车间采购管理_拆分记录_撤销拆分',
      param: '基本件流水号=' + num
    }
  })
}
// 拆分外购件
export function summitSplit3(standardAndPurchaseValue, groupPartNumValue, id, partNumberGroup, partName1Group, partNumGroup, SpecificationsGroup, remarkGroup) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '采购管理_标准件和外购件_拆分物料',
      param: '标准件和外购件流水号=' + standardAndPurchaseValue + '&组件零件流水号=' + groupPartNumValue + '&拆分人员=' + id + '&物料型号组=' + partNumberGroup + '&物料名称组=' + partName1Group + '&零件数量组=' + partNumGroup + '&物料规格组=' + SpecificationsGroup + '&备注组=' + remarkGroup
    }
  })
}
// 查询外购件拆分记录
export function searchSplit3(check, name, check1, machine, people) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '车间采购管理_拆分记录_标准件和外购件_查询数据',
      param: '名称_check=' + check + '&名称=' + name + '&机床_check=' + check1 + '&机床流水号=' + machine + '&人员编号=' + people
    }
  })
}
// 撤销外购件拆分
export function submitRevoke3(num) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '车间采购管理_拆分记录_标准件和外购件_撤销拆分',
      param: '标准件和外购件流水号=' + num
    }
  })
}
// 查询外购件拆分记录详情
export function searchPurchaseMx(number) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '车间采购管理_拆分记录_标准件和外购件_查询数据_详情',
      param: '标准件和外购件流水号=' + number
    }
  })
}
// 查询基本件拆分记录详情
export function searchBasicMx(number) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '车间采购管理_拆分记录_查询数据_详情',
      param: '基本件流水号=' + number
    }
  })
}
