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

//  销售 列表  有分页
export const salesList = (params) => {
  const url = `/sales/queryPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post'
  })
}
//  销售 详情
export const salesDetail = (params) => {
  return axios({
    url: `/sales/findById/${params.id}`,
    data: params,
    method: 'get'
  })
}
//  销售 详情bysn
export const salesDetailBySn = (params) => {
  return axios({
    url: `/sales/findBySn`,
    data: params,
    method: 'post'
  })
}
//  销售 打印
export const salesPrint = (params) => {
  return axios({
    url: '/sales/print',
    data: params,
    method: 'post'
  })
}
//  销售 打印预览
export const salesPrintPreview = (params) => {
  return axios({
    url: '/sales/printPreview',
    data: params,
    method: 'post'
  })
}
//  销售 冲减
export const salesWriteDown = (params) => {
  return axios({
    url: '/sales/writeDown',
    data: params,
    method: 'post'
  })
}
//  销售 审核
export const salesWriteAudit = (params) => {
  return axios({
    url: '/sales/audit',
    data: params,
    method: 'post'
  })
}
//  销售 折扣
export const salesWriteDiscount = (params) => {
  return axios({
    url: '/sales/discount',
    data: params,
    method: 'post'
  })
}
//  销售 备货审核
export const salesWritePrepareAudit = (params) => {
  return axios({
    url: '/sales/prepareAudit',
    data: params,
    method: 'post'
  })
}
//  销售 收款
export const salesWriteReceipt = (params) => {
  return axios({
    url: '/sales/receipt',
    data: params,
    method: 'post'
  })
}
//  销售 出库
export const salesWriteStockOut = (params) => {
  return axios({
    url: `/sales/stockOut/${params.salesBillSn}`,
    method: 'get'
  })
}
//  销售 提交
export const salesWriteSubmit = (params) => {
  return axios({
    url: '/sales/submit',
    data: params,
    method: 'post'
  })
}
//  销售 新增或编辑
export const salesSave = (params) => {
  return axios({
    url: '/sales/save',
    data: params,
    method: 'post'
  })
}

//  销售 删除
export const salesDel = (params) => {
  return axios({
    url: `/sales/delete/${params.id}`,
    data: params,
    method: 'post'
  })
}

// 销售 统计
export const salesCount = (params) => {
  return axios({
    url: `/sales/queryCount`,
    data: params,
    method: 'post'
  })
}
// 车架号
export const supperCodeByVin = (params) => {
  return axios({
    url: `/vinIdentify/queryPartCodeByVin/${params.vin}`,
    method: 'get'
  })
}
// 销售 详情  打印
export const salesDetailPrint = params => {
  const data = {
    url: `/sales/print/${params.sn}/${params.type}`,
    method: 'get'
  }
  // 喷墨打印
  if (params.type == 'INK') {
    data.responseType = 'blob'
  }
  return axios.request(data)
}
// 销售 详情  导出
export const salesDetailExport = params => {
  return axios.request({
    url: `/sales/excel/${params.sn}`,
    method: 'get',
    responseType: 'blob'
  })
}
// 销售 列表  导出
export const salesExport = params => {
  return axios.request({
    url: `/sales/exportWithDetail`,
    data: params,
    method: 'post',
    responseType: 'blob'
  })
}
// 车架号  识别图片内容
export const vinCodeParse = params => {
  return axios.request({
    url: `/vinIdentify/ocr`,
    method: 'post',
    data: params,
    responseType: 'blob'
  })
}
