import { request } from '@/api/_service'

const BASE = 'planning_production/production_batch_management/batch/'

function apiParams (method, data = {}) {
  return {
    method: `planning_production_production_batch_management_batch_${method}`,
    platform: 'background',
    ...data
  }
}

export function getBatchAll (data) {
  return request({
    url: BASE + 'all',
    method: 'get',
    params: apiParams('all', data)
  })
}

export function getBatchList (data) {
  return request({
    url: BASE + 'list',
    method: 'get',
    params: apiParams('list', data)
  })
}

export function createBatch (data) {
  return request({
    url: BASE + 'create',
    method: 'post',
    data: apiParams('create', data)
  })
}

export function editBatch (data) {
  return request({
    url: BASE + 'edit',
    method: 'put',
    data: apiParams('edit', data)
  })
}

export function deleteBatch (data) {
  return request({
    url: BASE + 'delete',
    method: 'delete',
    data: apiParams('delete', data)
  })
}

export function getProcessBatch (data) {
  return request({
    url: BASE + 'getProcessBatch',
    method: 'post',
    data: apiParams('getProcessBatch', data)
  })
}
