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

const BASE = 'production_configuration/device_model/device_management/'

function params (method, data = {}) { return { method, platform: 'background', ...data } }

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

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

export function createItem (data) {
  return request({ url: BASE + 'create', method: 'post', data: params('production_configuration_device_model_device_management_create', data) })
}

export function editItem (data) {
  return request({ url: BASE + 'edit', method: 'put', data: params('production_configuration_device_model_device_management_edit', data) })
}

export function deleteItem (data) {
  return request({ url: BASE + 'delete', method: 'delete', data: params('production_configuration_device_model_device_management_delete', data) })
}

export function batchDeleteItems (data) {
  return request({ url: BASE + 'batch_delete', method: 'delete', data: params('production_configuration_device_model_device_management_batch_delete', data) })
}

export function getImportTemplate (data) {
  return request({
    url: BASE + 'get_import_template',
    method: 'post',
    responseType: 'blob',
    data: params('production_configuration_device_model_device_management_get_import_template', data)
  })
}

export function importData (data) {
  return request({
    url: BASE + 'device_data_import',
    method: 'post',
    data: params('production_configuration_device_model_device_management_device_data_import', data)
  })
}

export function createExportTask (data) {
  return request({ url: BASE + 'device_data_export_task', method: 'post', data: params('production_configuration_device_model_device_management_device_export_task', data) })
}
