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

// 获取详细列表
export const getCateInfo = (params) => {
  return request({
    url: api + '/paas/visualdev/Base/page',
    method: 'get',
    params
  })
}

// 获取分类列表
export const getCateList = (data) => {
  return request({
    url: '/visual-api/paas/visualdev/cate/list',
    method: 'get',
    data
  })
}
// 获取功能列表
export function getVisualDevList(data) {
  return request({
    url: '/visual-api/paas/visualdev/Base',
    method: 'get',
    data
  })
}
// 获取功能信息
export function getVisualDevInfo(id) {
  return request({
    url: `/visual-api/paas/visualdev/Base/v3/${id}`,
    method: 'get'
  })
}

// 删除功能
export function Delete(id) {
  return request({
    url: `/visual-api/paas/visualdev/Base/${id}`,
    method: 'DELETE'
  })
}
// 修改功能
export function Update(data) {
  return request({
    url: '/visual-api/paas/visualdev/Base/v3/update',
    method: 'post',
    data
  })
}
// 新建功能
export function Create(data) {
  return request({
    url: '/visual-api/paas/visualdev/Base/v3',
    method: 'post',
    data
  })
}
// 零代码新建功能
export function NOCreate(data) {
  return request({
    url: '/nocode-api/paas/visualdev/Base',
    method: 'post',
    data
  })
}
// 新建流水号重置功能
export function CreateSerialnumber(data) {
  return request({
    url: '/visual-api/paas/visualdev/Base/serialnumber/save',
    method: 'post',
    data
  })
}
// 复制功能
export function Copy(id) {
  return request({
    url: `/visual-api/paas/visualdev/Base/${id}/Actions/Copy`,
    method: 'POST'
  })
}
// 获取模块命名
export function getAreasName() {
  return request({
    url: `/api/visualdev/Generater/AreasName`,
    method: 'get'
  })
}
// 代码下载
export function DownloadCode(id, data) {
  return request({
    url: `/api/visualdev/Generater/${id}/Actions/DownloadCode`,
    method: 'POST',
    data
  })
}
// 代码预览
export function CodePreview(id, data) {
  return request({
    url: `/api/visualdev/Generater/${id}/Actions/CodePreview`,
    method: 'POST',
    data
  })
}
// 无表
// 获取被引用关联表单接口
export function getAssociatedFormInterfaces(modelId) {
  return request({
    url: `/visual-api/paas/visualdev/Base/ignoringReferencedAssociatedFormInterfaces/${modelId}`,
    method: 'get'
  })
}
// 获取列表表单配置JSON
export function getConfigData(modelId) {
  return request({
    url: `/visual-api/paas/visualdev/OnlineDev/${modelId}/Config`,
    method: 'get'
  })
}
// 获取子表信息
export function getChildrenConfigData(modelId, cubeId) {
  return request({
    url: `/visual-api/paas/visualdev/OnlineDev/${modelId}/${cubeId}/${2}/Config`,
    method: 'get'
  })
}
// 获取列表表单配置JSON 零代码
export function NOgetConfigData(modelId) {
  return request({
    url: `/nocode-api/paas/visualdev/OnlineDev/${modelId}/Config`,
    method: 'get'
  })
}
// 获取列表配置JSON
export function getColumnData(modelId) {
  return request({
    url: `/visual-api/paas/visualdev/OnlineDev/${modelId}/ColumnData`,
    method: 'get'
  })
}
// 获取表单配置JSON
export function getFormData(modelId) {
  return request({
    url: `/visual-api/paas/visualdev/OnlineDev/${modelId}/FormData`,
    method: 'get'
  })
}
// 数据预览
export function getBrowserData(modelId, data) {
  return request({
    url: `/visual-api/paas/visualdev/data/Base/wherein/browser`,
    method: 'post',
    data
  })
}
// 获取数据集数据
export function getChildrenBrowserData(modelId, data) {
  return request({
    url: `/bi-api/cube/browser/${modelId}`,
    method: 'post',
    data
  })
}
//零代码数据预览
export function NOgetBrowserData(modelId, data) {
  return request({
    url: `/nocode-api/paas/visualdev/data/Base/browser`,
    method: 'post',
    data
  })
}
// 获取数据列表
export function getModelList(modelId, data) {
  return request({
    url: `/visual-api/paas/visualdev/OnlineDev/${modelId}/List`,
    method: 'post',
    data
  })
}
// 添加数据
export function createModel(modelId, data) {
  return request({
    url: `/visual-api/paas/visualdev/OnlineDev/v2/${modelId}`,
    method: 'POST',
    data
  })
}
// 添加数据
export function NewCreateModel(modelId, data) {
  return request({
    url: `/visual-api/paas/visualdev/data/Base/v3/${modelId}`,
    method: 'POST',
    data
  })
}
// 添加数据
export function NOcreateModel(modelId, data) {
  return request({
    url: `/nocode-api/paas/visualdev/OnlineDev/v2/${modelId}`,
    method: 'POST',
    data
  })
}
// 修改数据
export function updateModel(modelId, data, id) {
  return request({
    url: `/visual-api/paas/visualdev/OnlineDev/v2/${modelId}/${id}`,
    method: 'PUT',
    data
  })
}
export function NewupdateModel(modelId, data, id, cubeId, type) {
  return request({
    url: `/visual-api/paas/visualdev/data/Base/v3/${modelId}/${id}/${cubeId}/${type}`,
    method: 'PUT',
    data
  })
}
// 主表编辑子表新增
export function NewListupdateModel(modelId, data, id, cubeId) {
  return request({
    url: `/visual-api/paas/visualdev/data/Base/v3/primary/${modelId}/${id}/${cubeId}`,
    method: 'PUT',
    data
  })
}
export function NewAddModel(modelId, data, id, dbLink) {
  return request({
    url: `/visual-api/paas/visualdev/data/Base/v3/${modelId}/${dbLink}`,
    method: 'post',
    data
  })
}
// 修改数据
export function batchUpdateModel(modelId, data) {
  return request({
    url: `/visual-api/paas/visualdev/OnlineDev/batchUpdate/${modelId}`,
    method: 'post',
    data
  })
}
// 获取数据信息
export function getModelInfo(modelId, id) {
  return request({
    url: `/visual-api/paas/visualdev/OnlineDev/${modelId}/${id}`,
    method: 'GET'
  })
}
// 获取数据详情
export function getDataChange(modelId, id) {
  return request({
    url: `/visual-api/paas/visualdev/OnlineDev/${modelId}/${id}/DataChange`,
    method: 'GET'
  })
}
// 获取表单主表属性列表
export function getFormDataFields(modelId) {
  return request({
    url: `/visual-api/paas/visualdev/Base/${modelId}/FormDataFields`,
    method: 'GET'
  })
}
// 获取表单主表属性下拉框
export function getFieldDataSelect(modelId, data) {
  return request({
    url: `/visual-api/paas/visualdev/Base/${modelId}/FieldDataSelect`,
    method: 'GET',
    data
  })
}
// 删除数据
export function deteleModel(modelId, id, data) {
  return request({
    url: `/visual-api/paas/visualdev/OnlineDev/${modelId}/${id}`,
    method: 'DELETE',
    headers: {
      'content-type': 'application/x-www-form-urlencoded;charset=UTF-8'
    },
    data
  })
}
// 删除子表数据
export function deteleChildrenModel(modelId, id, data, cubeId) {
  return request({
    url: `/visual-api/paas/visualdev/OnlineDev/${modelId}/${cubeId}/${id}`,
    method: 'DELETE',
    headers: {
      'content-type': 'application/x-www-form-urlencoded;charset=UTF-8'
    },
    data
  })
}
// 批量删除数据
export function batchDelete(modelId, ids, dataJson) {
  return request({
    url: `/visual-api/paas/visualdev/OnlineDev/batchDelete/${modelId}`,
    method: 'post',
    data: { ids, dataJson, columnDict }
  })
}
// 导出
export function exportModel(data) {
  return request({
    url: '/visual-api/paas/visualdev/OnlineDev/export',
    method: 'POST',
    data
  })
}

// 新版导出
export function exportBaseModel(data) {
  return request({
    url: '/visual-api/paas/visualdev/data/Base/export',
    method: 'POST',
    data
  })
}

// 导出列表
export const exportModelList = (params) => {
  return request({
    url: '/visual-api/paas/visualdev/data/export/list',
    method: 'get',
    params
  })
}
// 导出列表 下载
export function exportModelListDownload(data) {
  return request({
    url: '/visual-api/paas/visualdev/data/export/download',
    method: 'POST',
    headers: {
      'content-type': 'application/x-www-form-urlencoded;charset=UTF-8'
    },
    responseType: 'blob',
    data
  })
}
// 导入列表
export const importModelList = (params) => {
  return request({
    url: '/visual-api/paas/visualdev/data/import/list',
    method: 'get',
    params
  })
}
// 导入列表
export const importModelRevoke = (params) => {
  return request({
    url: '/visual-api/paas/visualdev/data/import/revoke',
    method: 'get',
    params
  })
}
// 导出列表 下载
export function importModelListDownload(data) {
  return request({
    url: '/visual-api/paas/visualdev/data/import/download',
    method: 'POST',
    headers: {
      'content-type': 'application/x-www-form-urlencoded;charset=UTF-8'
    },
    responseType: 'blob',
    data
  })
}
// 回收站
export const recycleModelList = (params) => {
  return request({
    url: '/visual-api/paas/visualdev/data/recycle/list',
    method: 'get',
    params
  })
}
// 回收站 数据恢复
export function recycleModelrecovery(data) {
  return request({
    url: '/visual-api/paas/visualdev/data/recycle/recovery',
    method: 'POST',
    data
  })
}
// 回收站 彻底删除
export function recycleModelDelete(data) {
  return request({
    url: '/visual-api/paas/visualdev/data/recycle/delete/completely',
    method: 'POST',
    data
  })
}
// 批量导入
export function uploadModel(data) {
  return request({
    url: `/visual-api/paas/visualdev/OnlineDev/createBatch`,
    method: 'POST',
    data
  })
}
// 下载模板
export function getTemplate(modelId) {
  return request({
    url: `/visual-api/paas/visualdev/OnlineDev/${modelId}/Template`,
    method: 'GET'
  })
}
// 获取功能下拉框列表
export function getFeatureSelector(data) {
  return request({
    url: '/visual-api/paas/visualdev/Base/Selector',
    method: 'GET',
    data
  })
}
// App预览(后台APP表单设计)
export function Preview(data) {
  return request({
    url: `/visual-api/paas/visualdev/OnlineDev/App/Preview`,
    method: 'post',
    data: { data }
  })
}
// 导出模板
export function exportData(modelId) {
  return request({
    url: `/visual-api/paas/visualdev/OnlineDev/${modelId}/Actions/ExportData`,
    method: 'post'
  })
}
// 导出App
export function exportAppData(modelId) {
  return request({
    url: `/visual-api/paas/visualdev/OnlineDev/App/${modelId}/Actions/ExportData`,
    method: 'post'
  })
}
// 列表查询按钮权限
export function getModePerm(modelId) {
  return request({
    url: `/visual-api/paas/visualdev/OnlineDev/getPerm/${modelId}`,
    method: 'post'
  })
}

// 列表查询按钮权限新
export function getModePermV2(modelId) {
  return request({
    url: `/visual-api/paas/visualdev/OnlineDev/getPerm/v2/${modelId}`,
    method: 'post'
  })
}

export function getPrecondition(modelId, data) {
  return request({
    url: `/visual-api/paas/visualdev/customButton/precondition/${modelId}`,
    method: 'post',
    data
  })
}

// 列表查询按钮权限
export const getListDatalog = (params) => {
  return request({
    url: '/visual-api/paas/visualdev/datalog/all',
    method: 'get',
    params
  })
}
// 获取上传文件表头
export function getReadExcelHeader(data) {
  return request({
    url: '/visual-api/paas/visualdev/OnlineDev/readExcelHeader',
    method: 'POST',
    data
  })
}
export const customEventList = (modelId, params) => {
  return request({
    url: '/visual-api/paas/visualdev/customEvent/page/' + modelId,
    method: 'get',
    params
  })
}
// 新增自定义事件
export function addCustomEvent(modelId, data) {
  return request({
    url: '/visual-api/paas/visualdev/customEvent/' + modelId,
    method: 'POST',
    data
  })
}
// 删除自定义事件
export function deleteCustomEvent(data) {
  return request({
    url: '/visual-api/paas/visualdev/customEvent/delete',
    method: 'POST',
    headers: {
      'content-type': 'application/x-www-form-urlencoded;charset=UTF-8'
    },
    data
  })
}
// 添加页签
export function addCustomTab(modelId, data) {
  return request({
    url: '/visual-api/paas/visualdev/tab/' + modelId,
    method: 'POST',
    data
  })
}
// 页签分页查询
export const customTabList = (modelId, params) => {
  return request({
    url: '/visual-api/paas/visualdev/tab/page/' + modelId,
    method: 'get',
    params
  })
}
// 删除页签
export function deleteCustomTab(data) {
  return request({
    url: '/visual-api/paas/visualdev/tab/delete',
    method: 'POST',
    headers: {
      'content-type': 'application/x-www-form-urlencoded;charset=UTF-8'
    },
    data
  })
}
// 查询事件日志
export function getEventLog(data) {
  return request({
    url: '/visual-api/paas/visualdev/customEvent/eventLog/page',
    method: 'POST',
    data
  })
}
// 获取自定义按钮
export function getCustomButton(modelId) {
  return request({
    url: `/visual-api/paas/visualdev/customButton/page/${modelId}?size=50`,
    method: 'GET'
  })
}

// 新增自定义按钮
export function addCustomButton(modelId, data) {
  return request({
    url: '/visual-api/paas/visualdev/customButton/' + modelId,
    method: 'POST',
    data
  })
}

// 删除自定义按钮
export function deleteCustomButton(modelId, id) {
  return request({
    url: `/visual-api/paas/visualdev/customButton/delete/${modelId}?id=${id}`,
    method: 'POST',
    data: {
      id
    }
  })
}

// 执行自定义按钮
export function executeCustomButton(data) {
  return request({
    url: `/visual-api/paas/visualdev/customButton/execute`,
    method: 'POST',
    data
  })
}

// 批量执行自定义按钮
export function executeBatchCustomButton(data) {
  return request({
    url: `/visual-api/paas/visualdev/customButton/batch/execute`,
    method: 'POST',
    data
  })
}

// 获取自定义按钮
export function getResetSerialnumber(modelId) {
  return request({
    url: `/visual-api/paas/visualdev/Base/getResetSerialnumber/${modelId}`,
    method: 'GET'
  })
}
// 获取自定义按钮
export function fieldCompare(cubeId) {
  return request({
    url: `/visual-api/paas/visualdev/Base/fieldCompare/${cubeId}`,
    method: 'GET'
  })
}
