import request from '@/utils/request'

// 获取流程引擎列表
export function FlowEngineList(data) {
  return request({
    url: `/visual-api/paas/workflow/Engine/FlowEngine`,
    method: 'get',
    data
  })
}
// 获取流程引擎信息
export function FlowEngineInfo(id) {
  return request({
    url: `/flow-api/paas/workflow/Engine/FlowEngine/${id}`,
    method: 'get'
  })
}
// 删除流程引擎
export function Delete(id) {
  return request({
    url: `/visual-api/paas/workflow/Engine/FlowEngine/${id}`,
    method: 'DELETE'
  })
}
// 新建流程引擎
export function Create(data) {
  return request({
    url: `/flow-api/paas/workflow/Engine/FlowEngine`,
    method: 'post',
    data
  })
}
//  更新流程引擎
export function Update(data) {
  return request({
    url: `/flow-api/paas/workflow/Engine/FlowEngine/${data.id}`,
    method: 'PUT',
    data
  })
}
// 复制流程表单
export function Copy(id) {
  return request({
    url: `/visual-api/paas/workflow/Engine/FlowEngine/${id}/Actions/Copy`,
    method: 'post'
  })
}
// 导出流程表单
export function exportData(id) {
  return request({
    url: `/api/workflow/Engine/FlowEngine/${id}/Actions/ExportData`,
    method: 'GET'
  })
}
// 发布流程引擎
export function Release(id) {
  return request({
    url: `/api/workflow/Engine/FlowEngine/Release/${id}`,
    method: 'post'
  })
}
// 停止流程引擎
export function Stop(id) {
  return request({
    url: `/api/workflow/Engine/FlowEngine/Stop/${id}`,
    method: 'post'
  })
}
// 列表ListAll
export function FlowEngineListAll() {
  return request({
    url: `/visual-api/paas/workflow/Engine/FlowEngine/ListAll`,
    method: 'get'
  })
}
// 流程引擎下拉框
export function FlowEngineSelector(type) {
  return request({
    url: `/api/workflow/Engine/FlowEngine/Selector`,
    method: 'get',
    data: { type }
  })
}
// 流程表单主表属性
export function getFormDataFields(id) {
  return request({
    url: `/api/workflow/Engine/FlowEngine/${id}/FormDataFields`,
    method: 'get'
  })
}
// 流程表单数据
export function FieldDataSelect(id) {
  return request({
    url: `/api/workflow/Engine/FlowEngine/${id}/FieldDataSelect`,
    method: 'get'
  })
}
// 获取流程表单详情
export function getFlowTaskData(flowId, id) {
  return request({
    url: `/api/workflow/Engine/FlowTask/${flowId}/${id}`,
    method: 'get'
  })
}

export function reportdatasourceList() {
  return request({
    url: '/bi-api/report/reportdatasource/list',
    method: 'get'
  })
}
// 发布流程引擎
export function temporarySubmit(data) {
  return request({
    url: '/bi-api/cube/static-data/temporary/submit',
    method: 'post',
    data
  })
}
export const cubeList = (params) => {
  return request({
    url: '/bi-api/cube/data/list',
    method: 'get',
    params
  })
}
export const categoryList = (params) => {
  return request({
    url: '/bi-api/cube/workspace/list',
    method: 'get',
    params
  })
}

export const cubeFieldList = (params) => {
  return request({
    url: '/bi-api/cube/tableColumn/list',
    method: 'get',
    params
  })
}
export const listViewsByDataSource = (params) => {
  return request({
    url: '/bi-api/report/baseInfo/listViewsByDataSource',
    method: 'get',
    params
  })
}
export const tableFieldList = (params) => {
  return request({
    url: '/bi-api/cube/tableColumn/listByTableName',
    method: 'get',
    params
  })
}
// 根据表名创建数据集
export function createCubeByTable(data) {
  return request({
    url: '/bi-api/cube/data/createCubeByTable',
    method: 'post',
    headers: {
      'content-type': 'application/x-www-form-urlencoded;charset=UTF-8'
    },
    data
  })
}
// 批量获取数据集信息
export function cubeFieldListBatch(data) {
  return request({
    url: '/bi-api/cube/tableColumn/list/batch',
    method: 'post',
    data
  })
}

export const cubeFieldOption = (params) => {
  return request({
    url: '/visual-api/paas/visualdev/Base/fieldOption',
    method: 'get',
    params
  })
}
// 获取分类列表
export const getFlowCateList = (data) => {
  return request({
    url: '/flow-api/flow/cate/list',
    method: 'get',
    data
  })
}
