import { axios } from '@/utils/request'

//  采购 列表  有分页
export const purchaseList = (params) => {
  const url = `/purchase/queryPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post'
  })
}
// 采购入库子单列表
export const receivingQuery = (params) => {
  return axios({
    url: `/receiving/query`,
    data: params,
    method: 'post'
  })
}
// 采购入库详细列表
export const receivingDetail = (params) => {
  return axios({
    url: `/receivingDetail/queryPage/${params.pageNo}/${params.pageSize}`,
    data: params,
    method: 'post'
  })
}
//  采购 详情
export const purchaseDetail = (params) => {
  return axios({
    url: `/purchase/findById/${params.id}`,
    data: params,
    method: 'get'
  })
}
//  采购 详情
export const purchaseDetailBySn = (params) => {
  return axios({
    url: `/purchase/findBySn/${params.sn}`,
    data: params,
    method: 'get'
  })
}
//  采购明细 统计
export const purchaseCount = (params) => {
  return axios({
    url: `/purchase/queryCount`,
    data: params,
    method: 'post'
  })
}
//  采购 打印
export const purchasePrint = (params) => {
  return axios({
    url: '/purchase/print',
    data: params,
    method: 'post'
  })
}
//  采购 打印预览
export const purchasePrintPreview = (params) => {
  return axios({
    url: '/purchase/printPreview',
    data: params,
    method: 'post'
  })
}
//  采购 付款
export const purchaseWritePay = (params) => {
  return axios({
    url: '/purchase/pay',
    data: params,
    method: 'post'
  })
}
//  采购 入库
export const purchaseWriteStockIn = (params) => {
  return axios({
    url: '/receiving/stockIn',
    data: params,
    method: 'post'
  })
}
//  采购 提交
export const purchaseWriteSubmit = (params) => {
  return axios({
    url: `/purchase/submit/${params.id}`,
    method: 'get'
  })
}
//  采购 保存
export const purchaseSave = (params) => {
  return axios({
    url: '/purchase/save',
    data: params,
    method: 'post'
  })
}
//  采购 删除
export const purchaseDel = (params) => {
  return axios({
    url: `/purchase/delete/${params.id}`,
    method: 'get'
  })
}
//  采购 导出
export const purchaseExport = (params) => {
  return axios({
    url: '/purchase/export',
    data: params,
    method: 'post'
  })
}
//  采购 查询上级经销商名称
export const getParentDealer = (params) => {
  return axios({
    url: `/dealer/findParentDealer`,
    method: 'get'
  })
}
// 采购 详情  打印
export const purchaseDetailPrint = params => {
  const data = {
    url: `purchase/print/${params.sn}/${params.type}`,
    method: 'get'
  }
  // 喷墨打印
  if (params.type == 'INK') {
    data.responseType = 'blob'
  }
  return axios.request(data)
}
export const purchaseTargetList = (params) => {
  return axios({
    url: '/purchaseTarget/queryList',
    data: params,
    method: 'post'
  })
}
// 采购管理 下载模板
export const purchaseDetailDownload = params => {
  return axios.request({
    url: `/purchaseDetail/downloadExcel`,
    method: 'post',
    responseType: 'blob'
  })
}
// 采购管理  解析导入的文件
export const purchaseDetailParseProducts = params => {
  return axios({
    url: '/purchaseDetail/parseProducts',
    data: params,
    method: 'post'
  })
}
// 采购管理  批量插入
export const purchaseDetailBatchInsert = params => {
  return axios({
    url: '/purchaseDetail/batchInsert',
    data: params,
    method: 'post'
  })
}
// 采购 详情  导出
export const purchaseDetailExport = params => {
  return axios.request({
    url: `/purchase/excel/${params.sn}`,
    method: 'get',
    responseType: 'blob'
  })
}
// 采购 详情 导出产品
export const purchaseExportDetail = params => {
  return axios.request({
    url: `/purchase/exportDetail/${params.sn}`,
    method: 'get',
    responseType: 'blob'
  })
}
// 采购管理  修改收货地址
export const purchaseDetailAddress = params => {
  return axios({
    url: '/purchase/updateAddress',
    data: params,
    method: 'post'
  })
}
