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

//  产品 列表  分页
export const productList = (params) => {
  const url = `/product/queryPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers:{
        'module': encodeURIComponent('列表查询')
    }
  })
}
// 产品上线信息列表
export const queryOnlinePageList = (params) => {
  const url = `/productLog/queryOnlinePage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers:{
        'module': encodeURIComponent('列表查询')
    }
  })
}
// 产品上线信息导出
export const productLogExportExcel = (params) => {
  return axios({
    url: '/productLog/exportExcel',
    data: params,
    method: 'post',
    responseType: 'blob',
    headers:{
        'module': encodeURIComponent('导出')
    }
  })
}

//  产品 列表 已定过价的 分页
export const productPricedList = (params) => {
  const url = `/product/queryPricedPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers:{
        'module': encodeURIComponent('定过价的产品列表')
    }
  })
}
// 定价批量审核
export const batchAuditPrice = (params) => {
  const url = `/product/pricing/batchAudit`
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers:{
        'module': encodeURIComponent('批量审核')
    }
  })
}
// 导出产品定价
export const productExportPricing = (params) => {
  return axios({
    url: '/product/pricing/exportExcel',
    data: params,
    method: 'post',
    responseType: 'blob',
    headers:{
        'module': encodeURIComponent('导出')
    }
  })
}
// 产品定价 下载模板
export const productPriceTplDownload = params => {
  return axios.request({
    url: `/product/productPrice/importTemplate`,
    method: 'post',
    responseType: 'blob',
  })
}
// 产品定价 入库导入数据
export const productPriceInsertImport = params => {
  return axios({
    url: '/product/productPrice/insertImport',
    data: params,
    method: 'post',
    headers:{
        'module': encodeURIComponent('入库导入')
    }
  })
}
// 产品定价  批量插入
export const productPriceImport = params => {
  return axios({
    url: '/product/productPrice/import',
    data: params,
    method: 'post',
    headers:{
        'module': encodeURIComponent('导入产品')
    }
  })
}
//  产品定价 导入产品 导出错误项
export const productPriceFailExcel = (params) => {
  const url = `/product/productPrice/exportImportError`
  return axios.request({
    url: url,
    method: 'post',
    data: params,
    responseType: 'blob',
    headers:{
        'module': encodeURIComponent('导出错误项')
    }
  })
}

//  产品 保存
export const productSave = (params) => {
  return axios({
    url: '/product/save',
    data: params,
    method: 'post',
    headers:{
        'module': encodeURIComponent('新增/编辑')
    }
  })
}
//  产品 删除
export const productDel = (params) => {
  return axios({
    url: `/product/delete/${params.sn}`,
    method: 'get',
    headers:{
        'module': encodeURIComponent('删除')
    }
  })
}
//  产品 导出
export const productExport = (params) => {
  return axios({
    url: '/product/exportExcel',
    data: params,
    method: 'post',
    responseType: 'blob',
    headers:{
        'module': encodeURIComponent('导出')
    }
  })
}
//  产品 详情  根据sn查询
export const productSnDetail = (params) => {
  return axios({
    url: `/product/findBySn/${params.sn}`,
    method: 'get',
    headers:{
        'module': encodeURIComponent('详情')
    }
  })
}
//  产品 审核
export const productAudit = (params) => {
  return axios({
    url: `/product/audit/${params.sn}`,
    method: 'get',
    headers:{
        'module': encodeURIComponent('审核')
    }
  })
}
//  产品 批量审核
export const productBatchAudit = (params) => {
  return axios({
    url: '/product/batchAudit',
    data: params,
    method: 'post',
    headers:{
        'module': encodeURIComponent('批量审核')
    }
  })
}
//  产品 上线
export const productOnline = (params) => {
  return axios({
    url: `/product/online/${params.sn}`,
    method: 'get',
    headers:{
        'module': encodeURIComponent('上线')
    }
  })
}
//  产品 下线
export const productOffline = (params) => {
  return axios({
    url: `/product/offline`,
    data: params,
    method: 'post',
    headers:{
        'module': encodeURIComponent('下线')
    }
  })
}
//  产品 批量上线
export const productBatchOnline = (params) => {
  return axios({
    url: '/product/batchOnline',
    data: params,
    method: 'post',
    headers:{
        'module': encodeURIComponent('批量上线')
    }
  })
}

//  产品  定价  列表  分页
export const productPricingList = (params) => {
  const url = `/product/pricing/queryPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers:{
        'module': encodeURIComponent('列表查询')
    }
  })
}
//  产品  定价 详情  根据sn查询
export const productPricingSnDetail = (params) => {
  return axios({
    url: `/product/pricing/getPricingInfo/${params.sn}`,
    method: 'get'
  })
}
//  产品  定价 编辑
export const productPricingSave = (params) => {
  return axios({
    url: '/product/pricing/save',
    data: params,
    method: 'post',
    headers:{
        'module': encodeURIComponent('编辑')
    }
  })
}
//  产品  定价 审核
export const productPricingAudit = (params) => {
  return axios({
    url: '/product/pricing/audit',
    data: params,
    method: 'post',
    headers:{
        'module': encodeURIComponent('审核')
    }
  })
}

// 产品上线、下线分页接口
export const productLogList = (params) => {
  const url = `/productLog/queryPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers:{
        'module': encodeURIComponent('列表查询')
    }
  })
}
// 产品上线、下线审核
export const productLogAudit = (params) => {
  return axios({
    url: `/productLog/audit`,
    data: params,
    method: 'post',
    headers:{
        'module': encodeURIComponent('审核')
    }
  })
}
// 批量上线、下线审核
export const productLogAuditBatch = (params) => {
  return axios({
    url: `/productLog/auditBatch`,
    data: params,
    method: 'post',
    headers:{
        'module': encodeURIComponent('批量审核')
    }
  })
}

//  产品  上线审核  列表  分页 （已废弃）
export const productOnlineList = (params) => {
  const url = `/product/online/queryPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post'
  })
}
//  产品 上线审核  审核（已废弃）
export const productOnlineAudit = (params) => {
  return axios({
    url: `/product/auditOnline/${params.sn}`,
    method: 'get'
  })
}
//  产品 批量上线审核（已废弃）
export const productBatchOnlineAudit = (params) => {
  return axios({
    url: '/product/batchAuditOnline',
    data: params,
    method: 'post'
  })
}

//  产品  下线审核  列表  分页 （已废弃）
export const productOfflineList = (params) => {
  const url = `/product/offline/queryPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post'
  })
}
//  产品 下线审核  审核（已废弃）
export const productOfflineAudit = (params) => {
  return axios({
    url: `/product/auditOffline/${params.sn}`,
    method: 'get'
  })
}
//  产品 批量下线审核（已废弃）
export const productBatchOfflineAudit = (params) => {
  return axios({
    url: '/product/batchAuditOffline',
    data: params,
    method: 'post'
  })
}

//  产品  价格变更记录  列表  分页
export const productPriceChangeList = (params) => {
  const url = `/product/priceChange/queryPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers:{
        'module': encodeURIComponent('列表查询')
    }
  })
}
//  价格变更记录 导出
export const productPriceChangeExport = (params) => {
  return axios({
    url: '/product/priceChange/exportExcel',
    data: params,
    method: 'post',
    responseType: 'blob',
    headers:{
        'module': encodeURIComponent('导出')
    }
  })
}
//  产品  级别 列表  分页
export const productLevelList = (params) => {
  const url = `/product/level/queryPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers:{
        'module': encodeURIComponent('列表查询')
    }
  })
}
//  产品  级别 保存
export const productLevelSave = (params) => {
  return axios({
    url: '/product/saveProductLevel',
    data: params,
    method: 'post',
    headers:{
        'module': encodeURIComponent('编辑')
    }
  })
}
//  价格查询 列表  分页
export const productPriceList = (params) => {
  const url = `/product/price/queryPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers:{
        'module': encodeURIComponent('列表查询')
    }
  })
}
//  产品 获取价格
export const productPriceInfo = (params) => {
  return axios({
    url: `/product/getProductPriceInfo/${params.sn}`,
    method: 'get',
    headers:{
        'module': encodeURIComponent('获取价格')
    }
  })
}
// 查询最近上下线产品
export const queryNewProductPage = (params) => {
  const url = `/product/queryNewProductPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers:{
        'module': encodeURIComponent(params.onlineFalg==0?'查询最近下线产品':'查询最近上线产品')
    }
  })
}

// 导出产品及货位信息
export const stackPlaceExport = (params) => {
  return axios({
    url: '/product/stackPlace/export',
    data: params,
    method: 'post',
    responseType: 'blob',
    headers:{
        'module': encodeURIComponent('导出')
    }
  })
}

// 导入产品货位-导出错误
export const stackPlaceExportError = (params) => {
  return axios({
    url: '/product/stackPlace/exportError',
    data: params,
    method: 'post',
    responseType: 'blob',
    headers:{
        'module': encodeURIComponent('导出错误项')
    }
  })
}

// 导入产品货位
export const stackPlaceImport = (params) => {
  return axios({
    url: '/product/stackPlace/import',
    data: params,
    method: 'post'
  })
}
// 下载导入模板
export const stackPlaceImportTemplate = (params) => {
  return axios({
    url: '/product/stackPlace/importTemplate',
    data: params,
    method: 'post',
    responseType: 'blob'
  })
}
// 导入产品货位-入库数据
export const stackPlaceInsertImport = (params) => {
  return axios({
    url: '/product/stackPlace/insertImport',
    data: params,
    method: 'post',
    headers:{
        'module': encodeURIComponent('导入产品货位')
    }
  })
}
// 查询产品货位历史变更记录
export const stackPlaceListHistory = (params) => {
  return axios({
    url: '/product/stackPlace/listHistory',
    data: params,
    method: 'post',
    headers:{
        'module': encodeURIComponent('变更记录')
    }
  })
}
// 分页查询产品及货位信息
export const queryStackPlaceQueryPage = (params) => {
  const url = `/product/stackPlace/queryPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers:{
        'module': encodeURIComponent('列表查询')
    }
  })
}
// 保存产品货位信息
export const stackPlaceSave = (params) => {
  return axios({
    url: '/product/stackPlace/save',
    data: params,
    method: 'post',
    headers:{
        'module': encodeURIComponent(params.id?'编辑':'新增')
    }
  })
}

// 批量导入产品
export const batchImportProduct = (params) => {
  return axios({
    url: '/product/importProduct',
    data: params,
    method: 'post',
  })
}
// 导出错误项产品
export const exportErrorProduct = (params) => {
  return axios({
    url: '/product/exportErrorProduct',
    data: params,
    method: 'post',
    responseType: 'blob',
    headers:{
        'module': encodeURIComponent('导出错误项产品')
    }
  })
}

// 批量保存产品
export const saveBatchImportProduct = (params) => {
  return axios({
    url: '/product/saveBatchImportProduct',
    data: params,
    method: 'post',
    headers:{
        'module': encodeURIComponent('批量导入')
    }
  })
}

// 批量导入上线产品
export const batchImportOnlineProduct = (params) => {
  return axios({
    url: '/product/importOnline',
    data: params,
    method: 'post',
  })
}

// 导出错误项上线产品
export const exportErrorOnlineProduct = (params) => {
  return axios({
    url: '/product/importOnlineError',
    data: params,
    method: 'post',
    responseType: 'blob',
    headers:{
        'module': encodeURIComponent('导出错误项上线产品')
    }
  })
}
// 批量保存上线产品
export const saveBatchImportOnlineProduct = (params) => {
  return axios({
    url: '/product/onlineBatch',
    data: params,
    method: 'post',
    headers:{
        'module': encodeURIComponent('批量导入上线产品')
    }
  })
}

// 价格变更状态
export const priceChangeEnabled = (params) => {
  return axios({
    url: '/product/priceChange/enabled',
    data: params,
    method: 'post',
    headers:{
        'module': encodeURIComponent('启用/禁用')
    }
  })
}

/*
* 批量导入下线产品
*/
// 批量导入下线产品
export const offlineImport = (params) => {
  return axios({
    url: '/product/offline/import',
    data: params,
    method: 'post'
  })
}
// 导出错误项产品
export const exportErrorOffline = (params) => {
  return axios({
    url: '/product/offline/exportError',
    data: params,
    method: 'post',
    responseType: 'blob',
    headers:{
        'module': encodeURIComponent('导出错误项')
    }
  })
}

// 批量保存产品
export const importSaveBatch = (params) => {
  return axios({
    url: '/product/offline/importSaveBatch',
    data: params,
    method: 'post',
    headers:{
        'module': encodeURIComponent('批量导入下线产品')
    }
  })
}

// 产品状态信息
export const queryOnlinePage = (params) => {
  const url = `/product/queryOnlinePage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers:{
        'module': encodeURIComponent('列表查询')
    }
  })
}

// 产品状态信息 导出
export const excelOnlineList = (params) => {
  return axios({
    url: '/product/excelOnlineList',
    data: params,
    method: 'post',
    responseType: 'blob',
    headers:{
        'module': encodeURIComponent('导出')
    }
  })
}

// 显示/隐藏
export const updateShowFlag = (params) => {
  return axios({
    url: '/productLog/updateShowFlag',
    data: params,
    method: 'post',
    headers:{
        'module': encodeURIComponent('显示/隐藏')
    }
  })
}
// 修改停产状态
export const updateHaltProdFlag = (params) => {
  return axios({
    url: '/product/updateHaltProdFlag',
    data: params,
    method: 'post',
    headers:{
        'module': encodeURIComponent('启用/停产')
    }
  })
}
