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

const BASE = 'production_configuration/technology_model/technology_flow_process/'

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

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

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

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

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

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

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

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

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

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

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

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

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

export function getTemperatureTemplate (data) {
  return request({
    url: BASE + 'get_temperature_template',
    method: 'post',
    responseType: 'blob',
    data: apiParams('get_temperature_template', data)
  })
}

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

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