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

//  供应商 列表  有分页
export const supplierList = (params) => {
  const url = `/supplier/queryPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers:{
          'module': encodeURIComponent('列表查询')
        }
  })
}
// 供应商成本变更记录
export const supplierProductCostLogList = (params) => {
  const url = `/supplierProductCostLog/queryPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers:{
          'module': encodeURIComponent('列表查询')
        }
  })
}
// 成本变更导出明细
export const supplierProductCostLogExport = params => {
  return axios.request({
    url: `/supplierProductCostLog/export`,
    method: 'post',
    data: params,
    responseType: 'blob',
    headers:{
          'module': encodeURIComponent('导出')
        }
  })
}
// 供应商 列表 有权限
export const supplierAuthAllList = (params) => {
  return axios({
    url: '/bizuser/queryAuthSupplier',
    method: 'get'
  })
}
//  供应商 列表  无分页
export const supplierAllList = (params) => {
  return axios({
    url: '/supplier/queryAll',
    method: 'get'
  })
}
//  供应商 详情
export const supplierDetail = (params) => {
  return axios({
    url: `/supplier/findBySn/${params.sn}`,
    method: 'get'
  })
}
//  供应商 保存
export const supplierSave = (params) => {
  return axios({
    url: '/supplier/save',
    data: params,
    method: 'post',
    headers:{
          'module': encodeURIComponent('新增/编辑')
        }
  })
}

// 启用禁用
export const updateEnableStatus = (params) => {
  return axios({
    url: `/supplier/enable/${params.sn}/${params.flag}`,
    data: params,
    method: 'post',
    headers:{
          'module': encodeURIComponent('启用禁用')
        }
  })
}

// 分页查询供应商产品列表
export const supplierProductList = (params) => {
  const url = `/supplierProduct/queryPage/${params.pageNo}/${params.pageSize}`
  delete params.pageNo
  delete params.pageSize
  return axios({
    url: url,
    data: params,
    method: 'post',
    headers:{
          'module': encodeURIComponent('列表查询')
        }
  })
}

// 设置成本价
export const settingCost = (params) => {
  return axios({
    url: `/supplierProduct/settingCost`,
    data: params,
    method: 'post',
    headers:{
          'module': encodeURIComponent('设置成本价')
        }
  })
}

// 删除产品信息
export const deleteProduct = (params) => {
  return axios({
    url: `/supplierProduct/deleteProduct/${params.sn}`,
    method: 'get',
    headers:{
          'module': encodeURIComponent('删除产品')
        }
  })
}

// 添加产品信息
export const addProduct = (params) => {
  return axios({
    url: `/supplierProduct/addProduct`,
    data: params,
    method: 'post',
    headers:{
          'module': encodeURIComponent('增加产品')
        }
  })
}
// 查询供应商产品sn集合
export const supplierProductSnList = (params) => {
  return axios({
    url: `/supplierProduct/queryProductSnList/${params.sn}`,
    method: 'get'
  })
}
// 供应商关联产品 下载模板
export const supplierProductDownload = params => {
  return axios.request({
    url: `/supplierProduct/downloadExcel`,
    method: 'post',
    responseType: 'blob',
    headers:{
          'module': encodeURIComponent('下载模板')
        }
  })
}
// 供应商关联产品 下载模板
export const supplierProductNewDownloadExcel = params => {
  return axios.request({
    url: `/supplierProduct/newDownloadExcel`,
    method: 'post',
    responseType: 'blob',
    headers:{
          'module': encodeURIComponent('下载模板')
        }
  })
}
// 设置成本导出明细
export const supplierProductExportDetail = params => {
  return axios.request({
    url: `/supplierProduct/export`,
    method: 'post',
    data: params,
    responseType: 'blob',
    headers:{
          'module': encodeURIComponent('导出明细')
        }
  })
}
// 审核成本价
export const supplierProductUpdateAuditState = params => {
  return axios.request({
    url: `/supplierProduct/updateAuditState`,
    method: 'post',
    data: params,
    headers:{
          'module': encodeURIComponent(params.supplierProductSnList.length==1 ? '审核' : '批量审核')
        }
  })
}
// 供应商关联产品  解析导入的文件
export const supplierProductParseProducts = params => {
  return axios({
    url: '/supplierProduct/parseProducts',
    data: params,
    method: 'post'
  })
}
// 供应商关联产品  解析导入的文件
export const supplierProductParseNewProducts = params => {
  return axios({
    url: '/supplierProduct/newParseProducts',
    data: params,
    method: 'post'
  })
}
// 供应商关联产品  批量插入
export const supplierProductBatchInsert = params => {
  return axios({
    url: '/supplierProduct/batchInsert',
    data: params,
    method: 'post',
    headers:{
        'module': encodeURIComponent('导入产品')
    }
  })
}
export const supplierProductNewBatchInsert = params => {
  return axios({
    url: '/supplierProduct/newBatchInsert',
    data: params,
    method: 'post',
    headers:{
        'module': encodeURIComponent('批量导入产品')
    }
  })
}
//  供应商关联产品 导入产品  导出错误项
export const supplierProductailExcel = (params) => {
  return axios({
    url: '/supplierProduct/downloadFailExcel',
    data: params,
    method: 'post',
    responseType: 'blob',
    headers:{
        'module': encodeURIComponent('导出错误项')
    }
  })
}
export const supplierProductailNewExcel = (params) => {
  return axios({
    url: '/supplierProduct/newDownloadFailExcel',
    data: params,
    method: 'post',
    responseType: 'blob',
    headers:{
        'module': encodeURIComponent('导出错误项')
    }
  })
}
