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


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

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

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

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

export function getGroupOptions() {
  return request({
    url: apiPrefix + 'tags/',
    method: 'GET'
  });
}

export function getBrandsOptions() {
  return request({
    url: apiPrefix + 'brands/',
  });
}

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

export function getStaffsOptions(query: any) {
  return request({
    url: '/api/system/user/select/',
    params: query,
    method: 'GET'
  })
}

export function getExistingStaffs(query: any) {
  return request({
    url: apiPrefix + 'alarm-manage/',
    params: query,
    method: 'GET'
  })
}

export function postMonitor(body: any) {
  return request({
    url: apiPrefix + 'monitor/',
    data: body,
    method: 'POST'
  })
}

export function postStaffs(body: any) {
  return request({
    url: apiPrefix + 'alarm-manage/',
    data: body,
    method: 'post'
  })
}

export function uploadFile(body: any){
  return request({
    url: 'api/system/file/',
    method: 'POST',
    data: body,
    headers: { 'Content-Type':'multipart/form-data' },
  });
}

// 商品变更通知导入
export function uploadChangeNotice(body: any){
  return request({
    url: apiPrefix +'alarm/import_data/',
    method: 'POST',
    data: body,
  });
}

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

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

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

// 同步群消息
export function alarmMessage(body: any){
  return request({
    url: '/api/choice/goods/sku-alarm/',
    method: 'POST',
    data: body,
  });
}
