import request from '@/utils/request'
const api = '/bi-api'
const flowapi = '/visual-api'

export const tableFileUpload = (data) =>
  request({
    url: api + '/cube/file/uploadToDs',
    method: 'post',
    data,
    headers: { 'Content-Type': 'multipart/form-data' }
  })
export const tableFileList = (params) => request({ url: api + '/cube/tableFile/list', method: 'get', params })

export const tableFieldList = (params) =>
  request({
    url: api + '/cube/tableColumn/listByTableName',
    method: 'get',
    params
  })

export const tableFunctionList = (params) => request({ url: api + '/cube/function/list', method: 'get', params })
export const jstableFunctionList = (params) => request({ url: flowapi + '/paas/visualdev/function/list', method: 'get', params })

export const cubePreview = (data) => {
  return request.post(api + '/cube/data/preview', data, {
    headers: { 'Content-Type': 'application/base64;charset=UTF-8' }
  })
  // console.log(data)
  // return request({
  //   url: api + '/cube/data/preview',
  //   method: 'post',
  //   data,
  //   headers: {"Content-Type": "application/json;charset=UTF-8"}
  // });
}

// export const cubePreview = data => request({url: api + '/cube/data/preview', method: 'post', data});
export const cubeSave = (data) => {
  return request({
    url: api + '/cube/data/saveOrUpdate',
    method: 'post',
    data,
    headers: { 'Content-Type': 'application/json;charset=UTF-8' }
  })
}

export const cubeList = (params) => request({ url: api + '/cube/data/list', method: 'get', params })

export const cubeDetail = (params) => request({ url: api + '/cube/data/info', method: 'get', params })

export const funcAttrList = (params) => request.get(api + '/cube/function/funcAttrList', { params })
export const jsfuncAttrList = (params) => request.get(flowapi + '/paas/visualdev/function/funcAttrList', { params })

export const cubeFieldList = (params) => request({ url: api + '/cube/tableColumn/list', method: 'get', params })

export const categoryList = (params) => request({ url: api + '/cube/workspace/list', method: 'get', params })

export const globalCategoryList = (params) => request.get(api + '/cube/globalParamType/page', { params })

export const paramList = (params) => request.get(api + '/cube/globalParam/page', { params })

export const categorySave = (data) => request({ url: api + '/cube/workspace/saveOrUpdate', method: 'post', data })

export const categoryDel = (params) => request.post(api + '/cube/workspace/delete', {}, { params })

export const cubeFieldDel = (params) => request.post(api + '/cube/tableColumn/delete', {}, { params })

export const bloodRelation = (params) => request({ url: api + '/visual/bloodRelation/tree', params })

export const cubePremSave = (data) =>
  request.post(api + '/cubeDataPerm/submit', data, {
    headers: { 'Content-Type': 'application/base64;charset=UTF-8' }
  })

export const cubePremSDel = (params) => request.post(api + '/cubeDataPerm/delete', {}, { params })
//删除按钮权限
export const cubeBtnPremSDel = (params) => request.post('/visual-api/paas/visualdev/dataPerm/delete', {}, { params })

export const flowList = (params) => request.get('/flow-api' + '/flow/cate/flowList', { params })

export const cubePremList = (params) => request.get(api + '/cubeDataPerm/list', { params })

export const checkHavePoly = (data) =>
  request.post(api + '/cube/tableColumn/checkAggregation', data, {
    headers: { 'Content-Type': 'application/base64;charset=UTF-8' }
  })
export const tempList = (params) => request.get('/api/blade-system/sms/page', { params })

export const viewList = (params) => request.get(api + '/cube/sqlview/list', { params })
