import request from '@/utils/request'

// 创建采收批次
export function createHarvestBatch(data) {
  return request({
    url: '/product/harvest-batch/create',
    method: 'post',
    data: data
  })
}

// 更新采收批次
export function updateHarvestBatch(data) {
  return request({
    url: '/product/harvest-batch/update',
    method: 'put',
    data: data
  })
}

// 删除采收批次
export function deleteHarvestBatch(id) {
  return request({
    url: '/product/harvest-batch/delete?id=' + id,
    method: 'delete'
  })
}

// 批量删除采收批次
export function deleteHarvestBatchs(query) {
  return request({
    url: '/product/harvest-batch/deleteBatch',
    method: 'delete',
    params: query
  })
}

// 获得采收批次
export function getHarvestBatch(id) {
  return request({
    url: '/product/harvest-batch/get?id=' + id,
    method: 'get'
  })
}

// 获得采收批次分页
export function getHarvestBatchPage(query) {
  return request({
    url: '/product/harvest-batch/page',
    method: 'get',
    params: query
  })
}

export function getAllBatchCode() {
  return request({
    url: '/product/harvest-batch/getAllBatchCode',
    method: 'get',
  })
}

// 导出采收批次 Excel
export function exportHarvestBatchExcel(query) {
  return request({
    url: '/product/harvest-batch/export-excel',
    method: 'get',
    params: query,
    responseType: 'blob'
  })
}

// 获得采收批次编号列表
export function getHarverstBatchIdList(query) {
  return request({
    url: '/product/harvest-batch/getHarverstBatchIdList',
    method: 'get',
    params: query,
  })
}

// 获得商品信息配置 - 溯源环节相关
export function getGoodsConfig(query) {
  return request({
    url: '/product/harvest-batch/getGoodsConfig',
    method: 'get',
    params: query,
  })
}

// 创建商品信息配置 - 溯源环节相关
export function createGoodsConfig(data) {
  return request({
    url: '/product/harvest-batch/createGoodsConfig',
    method: 'post',
    data,
  })
}

// 更新商品信息配置 - 溯源环节相关
export function updateGoodsConfig(data) {
  return request({
    url: '/product/harvest-batch/updateGoodsConfig',
    method: 'put',
    data,
  })
}

// 创建环节信息配置 - 溯源环节相关
export function createLinkConfig(data) {
  return request({
    url: '/product/harvest-batch/createLinkConfig',
    method: 'post',
    data,
  })
}

// 获得环节信息配置 - 溯源环节相关
export function getLinkConfig(query) {
  return request({
    url: '/product/harvest-batch/getLinkConfig',
    method: 'get',
    params: query,
  })
}

// 更新环节信息配置 - 溯源环节相关
export function updateLinkConfig(data) {
  return request({
    url: '/product/harvest-batch/updateLinkConfig',
    method: 'put',
    data,
  })
}

// 获取小程序显示的预览数据
export function previewLinkConfig(params) {
  return request({
    url: '/product/harvest-batch/preview',
    method: 'get',
    params,
  })
}

// 冻结
export function getHarverstFreeze(id) {
  return request({
    url: '/product/harvest-batch/freeze?id='+id,
    method: 'put',
  })
}

// 激活
export function getHarverstActive(id) {
  return request({
    url: '/product/harvest-batch/active?id='+id,
    method: 'put',
  })
}

// 根据入库批次获取时间
export function getHarvestBatchByHarvesId(id) {
  return request({
    url: '/product/harvest-batch/getHarvestBatchByHarvesId?harvestBatchId='+id,
    method: 'get',
  })
}

export function getHarvestBatchConfig(id, languageTypeId) {
  return request({
    url: '/product/harvest-batch/getHarvestBatchConfig?id=' + id + '&languageTypeId=' + languageTypeId,
    method: 'get',
  })
}

// 更新采收批次配置
export function updateHarvestBatchConfig(data) {
  return request({
    url: '/product/harvest-batch/updateHarvestBatchConfig',
    method: 'put',
    data,
  })
}

export function initConfig() {
  return request({
    url: '/product/harvest-batch/initHarvestBatchConfig',
    method: 'post',
  });
}
