import { request } from '/@/utils/service';


const apiPrefix = '/api/choice/competitor_monitor/';

export function getTableData(query: any) {
  return request({
    url: apiPrefix,
    method: 'GET',
    params: query
  });
}

export function createCompetitorMonitor(body: any) {
  return request({
    url: apiPrefix,
    method: 'POST',
    data: body
  });
}

export function getGroupOptions(query: any) {
  return request({
    url: '/api/choice/goods/tags/',
    method: 'GET',
    params: query
  });
}

export function getBrandsOptions(query: any) {
  return request({
    url: '/api/choice/goods/brands/',
    method: 'GET',
    params: query
  });
}

export function getShopsOptions(query: any) {
  return request({
    url: '/api/choice/marketplace_shops/select/',
    method: 'GET',
    params: query
  });
}

export function updateRow(body: any) {
  return request({
    url: apiPrefix + `${body.id}/` ,
    method: 'PUT',
    params: { partial: 1 },
    data: body
  });
}

export function deleteRow(body: any) {
  return request({
    url: apiPrefix + `${body.id}/` ,
    method: 'DELETE',
    data: body
  });
}

export function batchDeleteRow(body: any) {
  return request({
    url: apiPrefix + 'multiple_delete/',
    method: 'DELETE',
    data: body
  });
}

// 导入
export function upload(body: any){
  return request({
    url: apiPrefix +'import_data/',
    method: 'POST',
    data: body,
  });
}

// 导出
export function exportData(query: any) {
  return request({
    url: apiPrefix + 'export_data/',
    method: 'GET',
    params: query,
    responseType: 'blob'
  });
}
