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

const BASE = 'production_configuration/product_model/product_ng_info/'

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

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

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

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

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

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

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

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

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