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

// 初始化合同号
export function initContract() {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '采购管理_采购合同_查询_采购部采购'
    }
  })
}
// 初始化采购员
export function initBuyer() {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '人事档案管理_人员与角色_查询数据_采购员'
    }
  })
}
// 采购合同查询
export function searchTable1(pageCurrent, pageSize, check1, start, end, check2, contract, check3, name, check4, supplier, check5, approval, numberCheck, number, check6, review) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '采购管理_合同_查询数据_采购部采购_新',
      param: '时间段_check=' + check1 + '&开始时间=' + start + '=datetime&结束时间=' + end + '=datetime&采购合同流水号_check=' + check2 + '&采购合同流水号=' + contract + '&人员编号_check=' + check3 + '&人员编号=' + name + '&供应商名称_check=' + check4 + '&供应商名称=' + supplier + '&审批情况流水号_check=' + check5 + '&审批情况流水号=' + approval + '&采购合同编号_check=' + numberCheck + '&采购合同编号=' + number + '&审核情况流水号_check=' + check6 + '&审核情况流水号=' + review,
      Pagination: pageCurrent + '&' + pageSize
    }
  })
}
// 采购合同内容查询
export function searchTable2(num) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '1',
      name: '采购管理_采购合同内容_查询数据',
      param: '采购合同流水号=' + num
    }
  })
}
// 删除采购合同
export function deleteContract(num) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '2',
      name: '采购管理_采购合同_删除_采购部采购',
      param: '采购合同流水号=' + num
    }
  })
}
// 删除采购合同
export function handleDone(num) {
  return request({
    url: '',
    method: 'post',
    data: {
      UserID: state.state.user.id,
      ModularID: router.currentRoute.path,
      type: '4',
      name: `update 采购管理_采购合同_采购部 set 不通过处理 = 1 where 采购合同流水号 = '${num}'`
    }
  })
}
