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


const apiPrefix = '/api/cms/sku-brand/';

export function getTableData(query: any) {
  return request({
    url: '/api/cms/sku/',
    method: 'GET',
    params: query
  });
}

export function createObj (body: any) {
  return request({
    url: '/api/cms/sku/',
    method: 'post',
    data: body
  })
}

export function PartialUpdateObj (id: number, body: any) {
  return request({
    url: '/api/cms/sku/' + id + '/',
    method: 'put',
    data: body,
    params: {
      partial: true
    }
  })
}

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

export function getKindOptions() {
  return request({
    url: '/api/cms/sku_kind/dictionary/',
    method: 'GET',
  });
}

export function deleteRow(query: any) {
  return request({
    url: '/api/cms/sku/' + query + '/',
    method: 'DELETE',
    params: query
  });
}

export function postRelease(body: any) {
  return request({
    url: '/api/cms/sku/batch_update/',
    method: 'PUT',
    data: body
  });
}

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

export function createAttr(data:any) {
  return request({
    url: apiPrefix,
    method: 'post',
    data: data
  })
}

export function releaseSku(body: any){
  return request({
    url: '/api/cms/sku/' + `${body.id}/` ,
    method: 'PUT',
    params: { partial: 1 },
    data: { status: body.status }
  });
}

export function getSkuDetail(query: any) {
  return request({
		url: '/api/cms/sku/selection/',
		method: 'GET',
    params: query
  });
}

export function getSkuDetailByPower(query: any) {
  return request({
		url: '/api/cms/sku_attr/',
		method: 'GET',
		params: query,
	});
}

export function getSkuDetailByKind(query: any) {
  return request({
		url: '/api/cms/sku_kind/'+`${query}/` ,
		method: 'GET',
		// params: query,
	});
}

export function getBrandSelect() {
  return request({
    url:'/api/cms/sku-brand/select/',
    method:'get',
  })
}

export function GetDictionary (query: any) {
  return request({
    url: '/api/cms/sku_kind/dictionary/',
    method: 'get',
    params: { ...query }
  })
}

