fix : 简化模板
This commit is contained in:
@@ -1,6 +1,4 @@
|
|||||||
# Ե<EFBFBD><EFBFBD>/FateVerse
|
# SmartOpsWeb
|
||||||
|
|
||||||
Ե<EFBFBD><EFBFBD><EFBFBD><EFBFBD>̨<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><EFBFBD>ڽ<EFBFBD>ɫ<EFBFBD><EFBFBD>Ȩ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ, <20><><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD>õĹ<C3B5><C4B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>; <20><><EFBFBD>ڿ<EFBFBD><DABF><EFBFBD><EFBFBD>߶<EFBFBD><DFB6><EFBFBD>, <20><><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD><D7BF>ٿ<EFBFBD><D9BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
||||||
|
|
||||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ջ[vue@3](https://cn.vuejs.org/);[vue-router@4](https://router.vuejs.org/zh/);
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ջ[vue@3](https://cn.vuejs.org/);[vue-router@4](https://router.vuejs.org/zh/);
|
||||||
[pinia@2](https://pinia.vuejs.org/zh/);[element-plus](https://element-plus.org/zh-CN/);[vite@4](https://cn.vitejs.dev/)
|
[pinia@2](https://pinia.vuejs.org/zh/);[element-plus](https://element-plus.org/zh-CN/);[vite@4](https://cn.vitejs.dev/)
|
||||||
|
|||||||
1
components.d.ts
vendored
1
components.d.ts
vendored
@@ -86,7 +86,6 @@ declare module '@vue/runtime-core' {
|
|||||||
SvgIcon: typeof import('./src/components/svgIcon/index.vue')['default']
|
SvgIcon: typeof import('./src/components/svgIcon/index.vue')['default']
|
||||||
Tag: typeof import('./src/components/Tag.vue')['default']
|
Tag: typeof import('./src/components/Tag.vue')['default']
|
||||||
TheWelcome: typeof import('./src/components/TheWelcome.vue')['default']
|
TheWelcome: typeof import('./src/components/TheWelcome.vue')['default']
|
||||||
Tinymce: typeof import('./src/components/Tinymce.vue')['default']
|
|
||||||
WelcomeItem: typeof import('./src/components/WelcomeItem.vue')['default']
|
WelcomeItem: typeof import('./src/components/WelcomeItem.vue')['default']
|
||||||
}
|
}
|
||||||
export interface ComponentCustomProperties {
|
export interface ComponentCustomProperties {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<link rel="icon" href="/favicon.ico">
|
<link rel="icon" href="/favicon.ico">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>FateVerse</title>
|
<title>SmartOpsWeb</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
|
|||||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,11 +1,11 @@
|
|||||||
{
|
{
|
||||||
"name": "fateverse",
|
"name": "smartOpsWeb",
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "fateverse",
|
"name": "smartOpsWeb",
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@antv/g6": "^3.5.7",
|
"@antv/g6": "^3.5.7",
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "fateverse",
|
"name": "smartOpsWeb",
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
@@ -1,105 +0,0 @@
|
|||||||
import request from "@/utils/request.js";
|
|
||||||
import { method } from "lodash";
|
|
||||||
|
|
||||||
// 请求数据源适配器list
|
|
||||||
export const getDataAdapterList = (params) => {
|
|
||||||
return request({
|
|
||||||
url: "/custom/query/query/adapter",
|
|
||||||
method: "get",
|
|
||||||
params,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
//获取到option列表
|
|
||||||
export const getDataAdapterOpt = () => {
|
|
||||||
return request({
|
|
||||||
url: "/custom/query/query/adapter/option",
|
|
||||||
method: "get",
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// 获取数据源适配器详情
|
|
||||||
export const getDataAdapterDetails = (dataAdapterId) => {
|
|
||||||
return request({
|
|
||||||
url: "/custom/query/query/adapter/" + dataAdapterId,
|
|
||||||
method: "get",
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// 新增数据源适配器
|
|
||||||
export const addDataAdapter = (data) => {
|
|
||||||
return request({
|
|
||||||
url: "/custom/query/query/adapter",
|
|
||||||
method: "post",
|
|
||||||
data,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
//模拟执行适配器函数
|
|
||||||
export const executeAdapterMockData = (data) => {
|
|
||||||
return request({
|
|
||||||
url: "/custom/query/query/adapter/mock/execute",
|
|
||||||
method: "post",
|
|
||||||
data,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// 修改数据源适配器
|
|
||||||
export const editDataAdapter = (data) => {
|
|
||||||
return request({
|
|
||||||
url: "/custom/query/query/adapter",
|
|
||||||
method: "put",
|
|
||||||
data,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// 删除数据源适配器
|
|
||||||
export const delDataAdapter = (dataAdapterId) => {
|
|
||||||
return request({
|
|
||||||
url: "/custom/query/query/adapter/" + dataAdapterId,
|
|
||||||
method: "delete",
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// 获取查询mock数据
|
|
||||||
export const getMockData = (data) => {
|
|
||||||
return request({
|
|
||||||
url: "/custom/query/portal/mock/data",
|
|
||||||
method: "post",
|
|
||||||
data,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// 获取查询条件
|
|
||||||
export const getMapFields = (queryId) => {
|
|
||||||
return request({
|
|
||||||
url: "/custom/query/tool/con/" + queryId,
|
|
||||||
method: "get",
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// 获取专用适配器详情
|
|
||||||
export const getSpecialDetail = (portalId) => {
|
|
||||||
return request({
|
|
||||||
url: "/custom/query/portal/detail/" + portalId,
|
|
||||||
method: "get",
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// 模拟执行代码
|
|
||||||
export const executeCode = (data) => {
|
|
||||||
return request({
|
|
||||||
url: "/custom/query/portal/mock/execute",
|
|
||||||
method: "post",
|
|
||||||
data,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// 保存代码
|
|
||||||
export const savaCode = (data) => {
|
|
||||||
return request({
|
|
||||||
url: "/custom/query/portal/save/code",
|
|
||||||
method: "post",
|
|
||||||
data,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
import request from '@/utils/request.js'
|
|
||||||
|
|
||||||
// 请求数据源管理list
|
|
||||||
export const getDataSourceManageList = (params) => {
|
|
||||||
return request({
|
|
||||||
url: '/custom/query/datasource',
|
|
||||||
method: 'get',
|
|
||||||
params
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
//获取到option列表
|
|
||||||
export const getDataSourceManageOpt = () => {
|
|
||||||
return request({
|
|
||||||
url: '/custom/query/datasource/option',
|
|
||||||
method: 'get',
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取数据源管理详情
|
|
||||||
export const getDataSourceManageDetails = (queryDataSourceId) => {
|
|
||||||
return request({
|
|
||||||
url: '/custom/query/datasource/' + queryDataSourceId,
|
|
||||||
method: 'get'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
// 获取数据源管理详情
|
|
||||||
export const getDataSourceType = () => {
|
|
||||||
return request({
|
|
||||||
url: '/custom/query/datasource/option/type',
|
|
||||||
method: 'get'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
// 获取校验规则option
|
|
||||||
export const getDataSourceOption = () => {
|
|
||||||
return request({
|
|
||||||
url: '/custom/query/datasource/option',
|
|
||||||
method: 'get'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
// 新增数据源管理
|
|
||||||
export const addDataSourceManage = (data) => {
|
|
||||||
return request({
|
|
||||||
url: '/custom/query/datasource',
|
|
||||||
method: 'post',
|
|
||||||
data
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 修改数据源管理
|
|
||||||
export const editDataSourceManage = (data) => {
|
|
||||||
return request({
|
|
||||||
url: '/custom/query/datasource',
|
|
||||||
method: 'put',
|
|
||||||
data
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 删除数据源管理
|
|
||||||
export const delDataSourceManage =(queryDataSourceId) => {
|
|
||||||
return request({
|
|
||||||
url: '/custom/query/datasource/' + queryDataSourceId,
|
|
||||||
method: 'delete'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
import request from '@/utils/request.js'
|
|
||||||
|
|
||||||
export const getEchartsList = (params) => {
|
|
||||||
return request({
|
|
||||||
url: '/custom/query/echarts',
|
|
||||||
method: 'get',
|
|
||||||
params
|
|
||||||
})
|
|
||||||
}
|
|
||||||
export const getEchartsDetails = (echartsId) => {
|
|
||||||
return request({
|
|
||||||
url: '/custom/query/echarts/' + echartsId,
|
|
||||||
method: 'get'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export const addEcharts = (data) => {
|
|
||||||
return request({
|
|
||||||
url: '/custom/query/echarts',
|
|
||||||
method: 'post',
|
|
||||||
data
|
|
||||||
})
|
|
||||||
}
|
|
||||||
export const editEcharts = (data) => {
|
|
||||||
return request({
|
|
||||||
url: '/custom/query/echarts',
|
|
||||||
method: 'put',
|
|
||||||
data
|
|
||||||
})
|
|
||||||
}
|
|
||||||
export const delEcharts=(echartsIdList) => {
|
|
||||||
return request({
|
|
||||||
url: '/custom/query/echarts/' + echartsIdList,
|
|
||||||
method: 'delete'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@@ -1,77 +0,0 @@
|
|||||||
import request from "@/utils/request.js";
|
|
||||||
|
|
||||||
export const getPortalList = (params) => {
|
|
||||||
return request({
|
|
||||||
url: "/custom/query/portal",
|
|
||||||
method: "get",
|
|
||||||
params,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// 自定义查询结果列表
|
|
||||||
export const getQueryList = (type) => {
|
|
||||||
return request({
|
|
||||||
url: "/custom/query/tool/option/" + type,
|
|
||||||
method: "get",
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// 适配器列表
|
|
||||||
export const getAdapterList = (params) => {
|
|
||||||
return request({
|
|
||||||
url: "/custom/query/query/adapter",
|
|
||||||
method: "get",
|
|
||||||
params,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// 参数映射字段
|
|
||||||
export const getMapFields = (queryId) => {
|
|
||||||
return request({
|
|
||||||
url: "/custom/query/tool/con/" + queryId,
|
|
||||||
method: "get",
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// 新增接口
|
|
||||||
export const addPortal = (data) => {
|
|
||||||
return request({
|
|
||||||
url: "/custom/query/portal",
|
|
||||||
method: "post",
|
|
||||||
data,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// 获取接口详情
|
|
||||||
export const getPortalDetail = (portalId) => {
|
|
||||||
return request({
|
|
||||||
url: "/custom/query/portal/" + portalId,
|
|
||||||
method: "get",
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// 修改接口
|
|
||||||
export const updatePortal = (data) => {
|
|
||||||
return request({
|
|
||||||
url: "/custom/query/portal",
|
|
||||||
method: "put",
|
|
||||||
data,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// 删除接口
|
|
||||||
export const deletePortal = (portalId) => {
|
|
||||||
return request({
|
|
||||||
url: "/custom/query/portal/" + portalId,
|
|
||||||
method: "delete",
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// 发布列表接口
|
|
||||||
export const publishPortal = (data) => {
|
|
||||||
return request({
|
|
||||||
url: "/custom/query/portal/list/publish",
|
|
||||||
method: "post",
|
|
||||||
data,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
import request from '@/utils/request.js'
|
|
||||||
|
|
||||||
// 获取查询页面信息
|
|
||||||
export const getPageInfo = (queryId, params) => {
|
|
||||||
return request({
|
|
||||||
url: '/custom/query/page/' + queryId,
|
|
||||||
method: 'get',
|
|
||||||
params: params
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取到页面数据
|
|
||||||
export const getPageData = (params, data) => {
|
|
||||||
return request({
|
|
||||||
url: '/custom/query/page/data',
|
|
||||||
method: 'post',
|
|
||||||
params: params,
|
|
||||||
data: data
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
import request from '@/utils/request.js'
|
|
||||||
|
|
||||||
export const getSqlInfo = (queryId) => {
|
|
||||||
return request({
|
|
||||||
url: '/custom/query/sql/search/' + queryId,
|
|
||||||
method: 'get'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export const previewSql= (data,pageInfo) => {
|
|
||||||
return request({
|
|
||||||
url:'/custom/query/sql/search/preview' ,
|
|
||||||
method: 'put',
|
|
||||||
data,
|
|
||||||
params:pageInfo
|
|
||||||
})
|
|
||||||
}
|
|
||||||
export const saveSqlQueryParams = (data) => {
|
|
||||||
return request({
|
|
||||||
url: '/custom/query/sql/search',
|
|
||||||
method: 'post',
|
|
||||||
data
|
|
||||||
})
|
|
||||||
}
|
|
||||||
export const sqlToLine = (data) => {
|
|
||||||
return request({
|
|
||||||
url: '/custom/query/sql/search/publish',
|
|
||||||
method: 'post',
|
|
||||||
data
|
|
||||||
})
|
|
||||||
}
|
|
||||||
export const sqlDownLine = (queryId) => {
|
|
||||||
return request({
|
|
||||||
url: '/custom/query/sql/search/cancel/'+queryId,
|
|
||||||
method: 'put'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
import request from '@/utils/request.js'
|
|
||||||
|
|
||||||
// 获取Sql List
|
|
||||||
export const getSqlList = (params) => {
|
|
||||||
return request({
|
|
||||||
url: '/custom/query/sql/uni',
|
|
||||||
method: 'get',
|
|
||||||
params
|
|
||||||
})
|
|
||||||
}
|
|
||||||
// 获取Sql详情
|
|
||||||
export const getSqlDetails = (sqlId) => {
|
|
||||||
return request({
|
|
||||||
url: '/custom/query/sql/uni/' + sqlId,
|
|
||||||
method: 'get'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
// 新增Sql
|
|
||||||
export const addSql = (data) => {
|
|
||||||
return request({
|
|
||||||
url: '/custom/query/sql/uni',
|
|
||||||
method: 'post',
|
|
||||||
data
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 修改Sql
|
|
||||||
export const editSql = (data) => {
|
|
||||||
return request({
|
|
||||||
url: '/custom/query/sql/uni',
|
|
||||||
method: 'put',
|
|
||||||
data
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 删除Sql
|
|
||||||
export const delSql =(idList) => {
|
|
||||||
return request({
|
|
||||||
url: '/custom/query/sql/uni/' + idList,
|
|
||||||
method: 'delete'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@@ -1,70 +0,0 @@
|
|||||||
import request from '@/utils/request.js'
|
|
||||||
|
|
||||||
//获取表格维护列表
|
|
||||||
export const getTableInfo = (params) => {
|
|
||||||
return request({
|
|
||||||
url: '/custom/query/table',
|
|
||||||
method: 'get',
|
|
||||||
params
|
|
||||||
})
|
|
||||||
}
|
|
||||||
export const getDynamicTableList = (params) => {
|
|
||||||
return request({
|
|
||||||
url: '/custom/query/dynamic/table',
|
|
||||||
method: 'get',
|
|
||||||
params
|
|
||||||
})
|
|
||||||
}
|
|
||||||
//根据数据源获取到表格option信息
|
|
||||||
export const getAssociationTableOption = (datasourceId) => {
|
|
||||||
return request({
|
|
||||||
url: '/custom/query/table/option/' + datasourceId,
|
|
||||||
method: 'get'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
//获取表格字段option信息
|
|
||||||
export const getAssociationFieldOption = (tableId) => {
|
|
||||||
return request({
|
|
||||||
url: '/custom/query/table/column/option/' + tableId,
|
|
||||||
method: 'get'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
// 获取详细信息
|
|
||||||
export const getTableDetails = (tableId) => {
|
|
||||||
return request({
|
|
||||||
url: '/custom/query/table/' + tableId,
|
|
||||||
method: 'get'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
// 导入表信息
|
|
||||||
export const addTableInfo= (data) => {
|
|
||||||
return request({
|
|
||||||
url: '/custom/query/table/import',
|
|
||||||
method: 'post',
|
|
||||||
data
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 修改自定义查询表格维护
|
|
||||||
export const editTable = (data) => {
|
|
||||||
return request({
|
|
||||||
url: '/custom/query/table',
|
|
||||||
method: 'put',
|
|
||||||
data
|
|
||||||
})
|
|
||||||
}
|
|
||||||
// 同步数据库
|
|
||||||
export const syncDatabase = (tableId) => {
|
|
||||||
return request({
|
|
||||||
url: '/custom/query/table/sync/'+ tableId,
|
|
||||||
method: 'put'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 删除自定义查询表格维护
|
|
||||||
export const delTable=(tableId) => {
|
|
||||||
return request({
|
|
||||||
url: '/custom/query/table/' + tableId,
|
|
||||||
method: 'delete'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
import request from '@/utils/request.js'
|
|
||||||
|
|
||||||
// 获取topo拖拽数据信息
|
|
||||||
export const getTopoDragInfo = (queryId) => {
|
|
||||||
return request({
|
|
||||||
url: '/custom/query/topo/search/' + queryId,
|
|
||||||
method: 'get'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
export const saveTopo = (data) => {
|
|
||||||
return request({
|
|
||||||
url: '/custom/query/topo/search',
|
|
||||||
method: 'post',
|
|
||||||
data
|
|
||||||
})
|
|
||||||
}
|
|
||||||
export const previewTopo = (data,pageInfo) => {
|
|
||||||
return request({
|
|
||||||
url: '/custom/query/topo/search/preview',
|
|
||||||
method: 'post',
|
|
||||||
data,
|
|
||||||
params:pageInfo,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
export const previewTopologyData = (data,pageInfo) => {
|
|
||||||
return request({
|
|
||||||
url: '/custom/query/topo/search/preview/data',
|
|
||||||
method: 'post',
|
|
||||||
data,
|
|
||||||
params:pageInfo,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export const topoToLine = (data) => {
|
|
||||||
return request({
|
|
||||||
url: '/custom/query/topo/search/publish',
|
|
||||||
method: 'post',
|
|
||||||
data
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export const topoDownLine = (queryId) => {
|
|
||||||
return request({
|
|
||||||
url: '/custom/query/topo/search/cancel/'+queryId,
|
|
||||||
method: 'put'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
import request from '@/utils/request.js'
|
|
||||||
|
|
||||||
// 获取topoList
|
|
||||||
export const getTopoList = (params) => {
|
|
||||||
return request({
|
|
||||||
url: '/custom/query/topo/uni',
|
|
||||||
method: 'get',
|
|
||||||
params
|
|
||||||
})
|
|
||||||
}
|
|
||||||
// 获取topo详情
|
|
||||||
export const getTopoDetails = (topoId) => {
|
|
||||||
return request({
|
|
||||||
url: '/custom/query/topo/uni/' + topoId,
|
|
||||||
method: 'get'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
// 新增topo
|
|
||||||
export const addTopo = (data) => {
|
|
||||||
return request({
|
|
||||||
url: '/custom/query/topo/uni',
|
|
||||||
method: 'post',
|
|
||||||
data
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 修改topo
|
|
||||||
export const editTopo = (data) => {
|
|
||||||
return request({
|
|
||||||
url: '/custom/query/topo/uni',
|
|
||||||
method: 'put',
|
|
||||||
data
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 删除topo
|
|
||||||
export const delTopo =(idList) => {
|
|
||||||
return request({
|
|
||||||
url: '/custom/query/topo/uni/' + idList,
|
|
||||||
method: 'delete'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
import request from '@/utils/request.js'
|
|
||||||
|
|
||||||
// 获取list
|
|
||||||
export const getIPBlackList = (params) => {
|
|
||||||
return request({
|
|
||||||
url: '/ip/back',
|
|
||||||
method: 'get',
|
|
||||||
params
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 新增
|
|
||||||
export const addIPBlack = (data) => {
|
|
||||||
return request({
|
|
||||||
url: '/ip/back',
|
|
||||||
method: 'post',
|
|
||||||
data
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 修改
|
|
||||||
export const editIPBlack = (data) => {
|
|
||||||
return request({
|
|
||||||
url: '/ip/back',
|
|
||||||
method: 'put',
|
|
||||||
data
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 删除
|
|
||||||
export const delIPBlack = (ids) => {
|
|
||||||
return request({
|
|
||||||
url: '/ip/back/'+ids,
|
|
||||||
method: 'delete'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 详情
|
|
||||||
export const getIPBlackDetail = (id) => {
|
|
||||||
return request({
|
|
||||||
url: '/ip/back/'+id,
|
|
||||||
method: 'get'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
import request from "@/utils/request.js";
|
|
||||||
|
|
||||||
//查询登录日志
|
|
||||||
export const getLoginLogList = (params) => {
|
|
||||||
return request({
|
|
||||||
url: "/log/login-info/list",
|
|
||||||
method: "get",
|
|
||||||
params
|
|
||||||
});
|
|
||||||
};
|
|
||||||
//查询登录日志详情
|
|
||||||
export const getLoginLogDetail = (infoId) => {
|
|
||||||
return request({
|
|
||||||
url: `/log/login-info/${infoId}`,
|
|
||||||
method: "get"
|
|
||||||
});
|
|
||||||
};
|
|
||||||
//删除登录日志
|
|
||||||
export const deleteLoginLog = (infoIds) => {
|
|
||||||
return request({
|
|
||||||
url: `/log/login-info/${infoIds}`,
|
|
||||||
method: "delete"
|
|
||||||
});
|
|
||||||
};
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
import request from "@/utils/request.js";
|
|
||||||
|
|
||||||
//查询操作日志
|
|
||||||
export const getOperateLog = (params) => {
|
|
||||||
return request({
|
|
||||||
url: "/log/log/list",
|
|
||||||
method: "get",
|
|
||||||
params
|
|
||||||
});
|
|
||||||
};
|
|
||||||
//查询操作日志详情
|
|
||||||
export const getOperateLogDetail = (operId) => {
|
|
||||||
return request({
|
|
||||||
url: `/log/log/${operId}`,
|
|
||||||
method: "get"
|
|
||||||
});
|
|
||||||
};
|
|
||||||
//删除操作日志
|
|
||||||
export const deleteOperateLog = (operIds) => {
|
|
||||||
return request({
|
|
||||||
url: `/log/log/${operIds}`,
|
|
||||||
method: "delete"
|
|
||||||
});
|
|
||||||
};
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
import request from "@/utils/request.js";
|
|
||||||
//查询在线用户
|
|
||||||
export const getOnlineList = (params) => {
|
|
||||||
return request({
|
|
||||||
url: "/online/user",
|
|
||||||
method: "get",
|
|
||||||
params
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
//强制退出用户
|
|
||||||
export const deleteOnlineUser= (tokenId) => {
|
|
||||||
return request({
|
|
||||||
url: '/online/user/'+tokenId,
|
|
||||||
method: "delete"
|
|
||||||
});
|
|
||||||
};
|
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
import request from '@/utils/request.js'
|
|
||||||
|
|
||||||
export const getTableList = (params) => {
|
|
||||||
return request({
|
|
||||||
url: '/code-gen/table',
|
|
||||||
method: 'get',
|
|
||||||
params
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export const getDynamicTable = (params) => {
|
|
||||||
return request({
|
|
||||||
url: '/code-gen/dynamic-table',
|
|
||||||
method: 'get',
|
|
||||||
params
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export const getTableDetail = (tableId) => {
|
|
||||||
return request({
|
|
||||||
url: `/code-gen/table/${tableId}`,
|
|
||||||
method: 'get',
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export const previewCode = (tableId) => {
|
|
||||||
return request({
|
|
||||||
url: `/code-gen/table/preview/${tableId}`,
|
|
||||||
method: 'get',
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export const deleteMoreTable = (params) => {
|
|
||||||
return request({
|
|
||||||
url: '/code-gen/table',
|
|
||||||
method: 'delete',
|
|
||||||
params
|
|
||||||
})
|
|
||||||
}
|
|
||||||
export const deleteTable = (tableId) => {
|
|
||||||
return request({
|
|
||||||
url: `/code-gen/table/${tableId}`,
|
|
||||||
method: 'delete',
|
|
||||||
})
|
|
||||||
}
|
|
||||||
export const importTable = (data) => {
|
|
||||||
return request({
|
|
||||||
url: "/code-gen/table/import-table",
|
|
||||||
method: 'post',
|
|
||||||
data
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export const editCodeGen = (data) => {
|
|
||||||
return request({
|
|
||||||
url: '/code-gen/table',
|
|
||||||
method: 'put',
|
|
||||||
data
|
|
||||||
})
|
|
||||||
}
|
|
||||||
export const syncDatabase = (tableId) => {
|
|
||||||
return request({
|
|
||||||
url: '/code-gen/table/sync/'+tableId,
|
|
||||||
method: 'put'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,54 +0,0 @@
|
|||||||
import request from '@/utils/request.js'
|
|
||||||
|
|
||||||
|
|
||||||
export const getDataSourceList = (params) => {
|
|
||||||
return request({
|
|
||||||
url: '/code-gen/data-source',
|
|
||||||
method: 'get',
|
|
||||||
params
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export const getDataSourceOption = () => {
|
|
||||||
return request({
|
|
||||||
url: '/code-gen/data-source/option',
|
|
||||||
method: 'get'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export const getDataSourceOptionType=()=>{
|
|
||||||
return request({
|
|
||||||
url:'/code-gen/data-source/option/type',
|
|
||||||
method:'get'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export const getDataSource = (dsId) => {
|
|
||||||
return request({
|
|
||||||
url: `/code-gen/data-source/${dsId}`,
|
|
||||||
method: 'get'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export const addDataSource = (data) => {
|
|
||||||
return request({
|
|
||||||
url: '/code-gen/data-source',
|
|
||||||
method: 'post',
|
|
||||||
data
|
|
||||||
})
|
|
||||||
}
|
|
||||||
export const editDataSource = (data) => {
|
|
||||||
return request({
|
|
||||||
url: '/code-gen/data-source',
|
|
||||||
method: 'put',
|
|
||||||
data
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export const deleteDataSource = (dsId) => {
|
|
||||||
return request({
|
|
||||||
url: `/code-gen/data-source/${dsId}`,
|
|
||||||
method: 'delete'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
import request from '@/utils/request.js'
|
|
||||||
|
|
||||||
// 请求校验规则表list
|
|
||||||
export const getRegularList = (params) => {
|
|
||||||
return request({
|
|
||||||
url: '/code-gen/rapid/regular',
|
|
||||||
method: 'get',
|
|
||||||
params
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取校验规则表详情
|
|
||||||
export const getRegularDetails = (regularId) => {
|
|
||||||
return request({
|
|
||||||
url: '/code-gen/rapid/regular/' + regularId,
|
|
||||||
method: 'get'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取校验规则选项列表
|
|
||||||
export const getRegularOpt = (regularId) => {
|
|
||||||
return request({
|
|
||||||
url: '/code-gen/rapid/regular/option',
|
|
||||||
method: 'get'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 新增校验规则表
|
|
||||||
export const addRegular = (data) => {
|
|
||||||
return request({
|
|
||||||
url: '/code-gen/rapid/regular',
|
|
||||||
method: 'post',
|
|
||||||
data
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 修改校验规则表
|
|
||||||
export const editRegular = (data) => {
|
|
||||||
return request({
|
|
||||||
url: '/code-gen/rapid/regular',
|
|
||||||
method: 'put',
|
|
||||||
data
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 删除校验规则表
|
|
||||||
export const delRegular =(regularId) => {
|
|
||||||
return request({
|
|
||||||
url: '/code-gen/rapid/regular/' + regularId,
|
|
||||||
method: 'delete'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
import request from '@/utils/request.js'
|
|
||||||
|
|
||||||
// 请求字典类型表list
|
|
||||||
export const getDictDataList = (params) => {
|
|
||||||
return request({
|
|
||||||
url: '/dict/data',
|
|
||||||
method: 'get',
|
|
||||||
params
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取字典数据表详情
|
|
||||||
export const getDictDataDetails = (dictCode) => {
|
|
||||||
return request({
|
|
||||||
url: '/dict/data/' + dictCode,
|
|
||||||
method: 'get'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 新增字典数据表
|
|
||||||
export const addDictData = (data) => {
|
|
||||||
return request({
|
|
||||||
url: '/dict/data',
|
|
||||||
method: 'post',
|
|
||||||
data
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 修改字典类型表
|
|
||||||
export const editDictData = (data) => {
|
|
||||||
return request({
|
|
||||||
url: '/dict/data',
|
|
||||||
method: 'put',
|
|
||||||
data
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 删除字典类型表
|
|
||||||
export const delDictData = (dictCode) => {
|
|
||||||
return request({
|
|
||||||
url: `/dict/data/${dictCode}`,
|
|
||||||
method: 'delete'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
import request from '@/utils/request.js'
|
|
||||||
|
|
||||||
export const getDictOption = () => {
|
|
||||||
return request({
|
|
||||||
url: '/dict/type/option',
|
|
||||||
method: 'get'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 请求字典类型表list
|
|
||||||
export const getDictTypeList = (params) => {
|
|
||||||
return request({
|
|
||||||
url: '/dict/type',
|
|
||||||
method: 'get',
|
|
||||||
params
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取字典类型表详情
|
|
||||||
export const getDictTypeDetails = (dictTypeId) => {
|
|
||||||
return request({
|
|
||||||
url: '/dict/type/' + dictTypeId,
|
|
||||||
method: 'get'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 新增字典类型表
|
|
||||||
export const addDictType = (data) => {
|
|
||||||
return request({
|
|
||||||
url: '/dict/type',
|
|
||||||
method: 'post',
|
|
||||||
data
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 修改字典类型表
|
|
||||||
export const editDictType = (data) => {
|
|
||||||
return request({
|
|
||||||
url: '/dict/type',
|
|
||||||
method: 'put',
|
|
||||||
data
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 删除字典类型表
|
|
||||||
export const delDictType =(dictTypeId) => {
|
|
||||||
return request({
|
|
||||||
url: '/dict/type/' + dictTypeId,
|
|
||||||
method: 'delete'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
import request from '@/utils/request.js'
|
|
||||||
|
|
||||||
export const getMappingList = (params) => {
|
|
||||||
return request({
|
|
||||||
url: '/mapping/switch',
|
|
||||||
method: 'get',
|
|
||||||
params
|
|
||||||
})
|
|
||||||
}
|
|
||||||
export const editMappingSwitch = (data) => {
|
|
||||||
return request({
|
|
||||||
url: '/mapping/switch',
|
|
||||||
method: 'put',
|
|
||||||
data
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@@ -1,62 +0,0 @@
|
|||||||
import request from '@/utils/request.js'
|
|
||||||
|
|
||||||
export function getProcessDefinitionList(param) {
|
|
||||||
return request({
|
|
||||||
url: "/workflow/process/definition",
|
|
||||||
method: "get",
|
|
||||||
params: param
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getProcessDefinitionInfo(deploymentId) {
|
|
||||||
return request({
|
|
||||||
url: "/workflow/process/definition/" + deploymentId,
|
|
||||||
method: "get",
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getInitiateInfo(processDefinitionKey) {
|
|
||||||
return request({
|
|
||||||
url: "/workflow/process/definition/key/" + processDefinitionKey,
|
|
||||||
method: "get",
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export function getHistoryVersion(processDefinitionKey) {
|
|
||||||
return request({
|
|
||||||
url: "/workflow/process/definition/history/" + processDefinitionKey,
|
|
||||||
method: "get",
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export function deleteHistoryVersion(deploymentId) {
|
|
||||||
return request({
|
|
||||||
url: "/workflow/process/definition/" + deploymentId,
|
|
||||||
method: "delete",
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export function suspendProcessDefinition(processDefinitionId) {
|
|
||||||
return request({
|
|
||||||
url: "/workflow/process/definition/suspend",
|
|
||||||
method: "put",
|
|
||||||
data: processDefinitionId
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export function activateProcessDefinition(processDefinitionId) {
|
|
||||||
return request({
|
|
||||||
url: "/workflow/process/definition/activate",
|
|
||||||
method: "put",
|
|
||||||
data: processDefinitionId
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export function addProcessDefinition(param) {
|
|
||||||
return request({
|
|
||||||
url: "/workflow/process/definition",
|
|
||||||
method: "post",
|
|
||||||
data: param
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
import request from '@/utils/request.js'
|
|
||||||
|
|
||||||
export function deleteFile(fileId) {
|
|
||||||
// 删除文件
|
|
||||||
return request({
|
|
||||||
url: '/workflow/process/file/' + fileId,
|
|
||||||
method: 'delete',
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
import request from '@/utils/request.js'
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 开始实例流程
|
|
||||||
* @param param
|
|
||||||
* @returns {*}
|
|
||||||
*/
|
|
||||||
export function startProcessInstance(param) {
|
|
||||||
return request({
|
|
||||||
url: "/workflow/process/instance/start",
|
|
||||||
method: "post",
|
|
||||||
data: param
|
|
||||||
})
|
|
||||||
}
|
|
||||||
export function restartProcessInstance(param) {
|
|
||||||
return request({
|
|
||||||
url: "/workflow/process/instance/restart",
|
|
||||||
method: "post",
|
|
||||||
data: param
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getAboutInstanceList(param) {
|
|
||||||
return request({
|
|
||||||
url: "/workflow/process/instance/about",
|
|
||||||
method: "get",
|
|
||||||
params: param
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getInitiatedInstanceList(param) {
|
|
||||||
return request({
|
|
||||||
url: "/workflow/process/instance/self",
|
|
||||||
method: "get",
|
|
||||||
params: param
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getInitiatedInstanceInfo(processInstanceId) {
|
|
||||||
return request({
|
|
||||||
url: "/workflow/process/instance/info/"+processInstanceId,
|
|
||||||
method: "get",
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export function getInitiatedInstanceReInfo(instanceId) {
|
|
||||||
return request({
|
|
||||||
url: "/workflow/process/instance/re/info/"+instanceId,
|
|
||||||
method: "get",
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
import request from '@/utils/request.js'
|
|
||||||
|
|
||||||
// 请求系统内置监听器list
|
|
||||||
export const getProcessListenerList = (params) => {
|
|
||||||
return request({
|
|
||||||
url: '/workflow/process/listener',
|
|
||||||
method: 'get',
|
|
||||||
params
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
//获取到option列表
|
|
||||||
|
|
||||||
// 获取系统内置监听器详情
|
|
||||||
export const getProcessListenerDetails = (processListenerId) => {
|
|
||||||
return request({
|
|
||||||
url: '/workflow/process/listener/' + processListenerId,
|
|
||||||
method: 'get'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 新增系统内置监听器
|
|
||||||
export const addProcessListener = (data) => {
|
|
||||||
return request({
|
|
||||||
url: '/workflow/process/listener',
|
|
||||||
method: 'post',
|
|
||||||
data
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 修改系统内置监听器
|
|
||||||
export const editProcessListener = (data) => {
|
|
||||||
return request({
|
|
||||||
url: '/workflow/process/listener',
|
|
||||||
method: 'put',
|
|
||||||
data
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 删除系统内置监听器
|
|
||||||
export const delProcessListener =(processListenerId) => {
|
|
||||||
return request({
|
|
||||||
url: '/workflow/process/listener/' + processListenerId,
|
|
||||||
method: 'delete'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
import request from '@/utils/request.js'
|
|
||||||
|
|
||||||
export function getTaskList() {
|
|
||||||
return request({
|
|
||||||
url: "/workflow/process/task",
|
|
||||||
method: "get",
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getTaskInfo(taskId) {
|
|
||||||
return request({
|
|
||||||
url: "/workflow/process/task/"+taskId,
|
|
||||||
method: "get",
|
|
||||||
})
|
|
||||||
}
|
|
||||||
export function completeTask(params) {
|
|
||||||
return request({
|
|
||||||
url: "/workflow/process/task/complete",
|
|
||||||
method: "put",
|
|
||||||
data: params
|
|
||||||
})
|
|
||||||
}
|
|
||||||
export function refuseTask(params) {
|
|
||||||
return request({
|
|
||||||
url: "/workflow/process/task/refuse",
|
|
||||||
method: "put",
|
|
||||||
data: params
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export function rollBackTask(params) {
|
|
||||||
return request({
|
|
||||||
url: "/workflow/process/task/rollback",
|
|
||||||
method: "put",
|
|
||||||
data: params
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export function addComment(params) {
|
|
||||||
return request({
|
|
||||||
url: "/workflow/process/task/comment",
|
|
||||||
method: "post",
|
|
||||||
data: params
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
import request from '@/utils/request.js'
|
|
||||||
|
|
||||||
//根据角色或者部门获取到对应的数据
|
|
||||||
export function getUserTree(type,chooseId){
|
|
||||||
return request({
|
|
||||||
url:`/user/choose/${type}/${chooseId}`,
|
|
||||||
method:'get'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// 查询系统角色
|
|
||||||
export function getRole() {
|
|
||||||
return request({
|
|
||||||
url: 'admin/role/option',
|
|
||||||
method: 'get'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
//获取采取树形控件的部门option
|
|
||||||
export function getDepartmentTree() {
|
|
||||||
return request({
|
|
||||||
url: 'admin/dept/option',
|
|
||||||
method: 'get'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@@ -1,185 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="tinymce-boxz">
|
|
||||||
<Editor v-model="content" :init="init"/>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import tinymce from 'tinymce'
|
|
||||||
import Editor from "@tinymce/tinymce-vue";
|
|
||||||
import {defineProps} from "vue";
|
|
||||||
import {ElMessage} from "element-plus";
|
|
||||||
import {getToken} from '@/utils/auth'
|
|
||||||
import axios from "axios";
|
|
||||||
|
|
||||||
import 'tinymce/themes/silver'
|
|
||||||
import 'tinymce/icons/default/icons'
|
|
||||||
import 'tinymce/plugins/preview'
|
|
||||||
import 'tinymce/plugins/searchreplace'
|
|
||||||
import 'tinymce/plugins/autolink'
|
|
||||||
import 'tinymce/plugins/directionality'
|
|
||||||
import 'tinymce/plugins/visualblocks'
|
|
||||||
import 'tinymce/plugins/visualchars'
|
|
||||||
import 'tinymce/plugins/advlist'
|
|
||||||
import 'tinymce/plugins/fullscreen'
|
|
||||||
import 'tinymce/plugins/image'
|
|
||||||
import 'tinymce/plugins/link'
|
|
||||||
import 'tinymce/plugins/media'
|
|
||||||
import 'tinymce/plugins/template'
|
|
||||||
import 'tinymce/plugins/code'
|
|
||||||
import 'tinymce/plugins/codesample'
|
|
||||||
import 'tinymce/plugins/table'
|
|
||||||
import 'tinymce/plugins/pagebreak'
|
|
||||||
import 'tinymce/plugins/nonbreaking'
|
|
||||||
import 'tinymce/plugins/anchor'
|
|
||||||
import 'tinymce/plugins/insertdatetime'
|
|
||||||
import 'tinymce/plugins/lists'
|
|
||||||
import 'tinymce/plugins/wordcount'
|
|
||||||
import 'tinymce/plugins/autosave'
|
|
||||||
|
|
||||||
const emit = defineEmits(['update:value'])
|
|
||||||
const props = defineProps({
|
|
||||||
//默认值
|
|
||||||
value: {
|
|
||||||
type: String,
|
|
||||||
default: "",
|
|
||||||
},
|
|
||||||
imageUrl: {
|
|
||||||
type: String,
|
|
||||||
default: "",
|
|
||||||
},
|
|
||||||
fileUrl: {
|
|
||||||
type: String,
|
|
||||||
default: "",
|
|
||||||
},
|
|
||||||
plugins: {
|
|
||||||
type: [String, Array],
|
|
||||||
default:
|
|
||||||
"preview searchreplace autolink directionality visualblocks visualchars fullscreen image link media template code codesample table pagebreak nonbreaking anchor insertdatetime advlist lists wordcount autosave",
|
|
||||||
},
|
|
||||||
toolbar: {
|
|
||||||
type: [String, Array],
|
|
||||||
default: [
|
|
||||||
"fullscreen undo redo restoredraft | cut copy paste pastetext | forecolor backcolor bold italic underline strikethrough link anchor | alignleft aligncenter alignright alignjustify outdent indent | bullist numlist | blockquote subscript superscript removeformat ",
|
|
||||||
"styleselect formatselect fontselect fontsizeselect | table image axupimgs media pagebreak insertdatetime selectall visualblocks searchreplace | code preview | indent2em lineheight formatpainter",
|
|
||||||
],
|
|
||||||
},
|
|
||||||
fontFormats: {
|
|
||||||
type: [String, Array],
|
|
||||||
default: "微软雅黑=Microsoft YaHei,Helvetica Neue,PingFang SC,sans-serif;苹果苹方=PingFang SC,Microsoft YaHei,sans-serif;宋体=simsun,serif;仿宋体=FangSong,serif;黑体=SimHei,sans-serif;Arial=arial,helvetica,sans-serif;Arial Black=arial black,avant garde;Book Antiqua=book antiqua,palatino;"
|
|
||||||
}
|
|
||||||
})
|
|
||||||
const content = ref(props.value);
|
|
||||||
const imgUrl = ref();
|
|
||||||
// const apiKey = reactive("v4zo4n22oanvco29ws5drh0pecuf3gh53clx53cccj3grjwg");
|
|
||||||
const init = reactive({
|
|
||||||
language_url: '/langs/zh_CN.js', //汉化路径是自定义的
|
|
||||||
skin_url: '/skins/ui/oxide', //皮肤
|
|
||||||
content_css: '/skins/content/default/content.css',
|
|
||||||
language: 'zh_CN',
|
|
||||||
placeholder: "在这里输入文字", //textarea中的提示信息
|
|
||||||
min_width: 320,
|
|
||||||
min_height: 220,
|
|
||||||
height: 500, //注:引入autoresize插件时,此属性失效
|
|
||||||
resize: "both", //编辑器宽高是否可变,false-否,true-高可变,'both'-宽高均可,注意引号
|
|
||||||
promotion: false,
|
|
||||||
branding: false, //tiny技术支持信息是否显示
|
|
||||||
// statusbar: false, //最下方的元素路径和字数统计那一栏是否显示
|
|
||||||
// elementpath: false, //元素路径是否显示
|
|
||||||
font_formats: props.fontFormats, //字体样式
|
|
||||||
plugins: props.plugins, //插件配置 axupimgs indent2em
|
|
||||||
toolbar: props.toolbar, //工具栏配置,设为false则隐藏
|
|
||||||
// menubar: "file edit my1", //菜单栏配置,设为false则隐藏,不配置则默认显示全部菜单,也可自定义配置--查看 http://tinymce.ax-z.cn/configure/editor-appearance.php --搜索“自定义菜单”
|
|
||||||
// images_upload_url: '/apib/api-upload/uploadimg', //后端处理程序的url,建议直接自定义上传函数image_upload_handler,这个就可以不用了
|
|
||||||
// images_upload_base_path: '/demo', //相对基本路径--关于图片上传建议查看--http://tinymce.ax-z.cn/general/upload-images.php
|
|
||||||
paste_data_images: true, //图片是否可粘贴
|
|
||||||
file_picker_types: "file image media", //file image media分别对应三个类型文件的上传:link插件,image和axupimgs插件,media插件。想屏蔽某个插件的上传就去掉对应的参数
|
|
||||||
// 文件上传处理函数
|
|
||||||
setup: function (editor) {
|
|
||||||
editor.on('change', function (e) {
|
|
||||||
tinymce.activeEditor.save();//执行自动保存
|
|
||||||
});
|
|
||||||
},
|
|
||||||
//此处为图片上传处理函数
|
|
||||||
images_upload_handler: (blobInfo, success) => {
|
|
||||||
// new Promise((resolve, reject) => {
|
|
||||||
let formData = new FormData()
|
|
||||||
formData.append('file', blobInfo.blob())
|
|
||||||
//上传图片接口 上传成功后返回图片地址,用于显示在富文本中
|
|
||||||
uploadFile(formData, props.imageUrl, success)
|
|
||||||
// }),
|
|
||||||
},
|
|
||||||
file_picker_callback: (callback, value, meta) => {
|
|
||||||
// console.log('callback, value, meta',callback, value, meta)
|
|
||||||
// 使用案例http://tinymce.ax-z.cn/general/upload-images.php
|
|
||||||
// meta.filetype //根据这个判断点击的是什么file image media
|
|
||||||
let filetype; //限制文件的上传类型,需要什么就添加什么的后缀
|
|
||||||
if (meta.filetype == "image") {
|
|
||||||
filetype = ".jpg, .jpeg, .png, .gif, .ico, .svg";
|
|
||||||
} else if (meta.filetype == "media") {
|
|
||||||
filetype = ".mp3, .mp4, .avi, .mov";
|
|
||||||
} else {
|
|
||||||
filetype =
|
|
||||||
".pdf, .txt, .zip, .rar, .7z, .doc, .docx, .xls, .xlsx, .ppt, .pptx, .mp3, .mp4, .jpg, .jpeg, .png, .gif, .ico, .svg";
|
|
||||||
}
|
|
||||||
let inputElem = document.createElement("input"); //创建文件选择
|
|
||||||
inputElem.setAttribute("type", "file");
|
|
||||||
inputElem.setAttribute("accept", filetype);
|
|
||||||
inputElem.click();
|
|
||||||
inputElem.onchange = () => {
|
|
||||||
let file = inputElem.files[0]; //获取文件信息
|
|
||||||
let reader = new FileReader();
|
|
||||||
reader.readAsDataURL(file);
|
|
||||||
reader.onload = function () {
|
|
||||||
let id = "blobid" + new Date().getTime();
|
|
||||||
let blobCache = tinymce.activeEditor.editorUpload.blobCache;
|
|
||||||
let base64 = reader.result.split(",")[1];
|
|
||||||
let blobInfo = blobCache.create(id, file, base64);
|
|
||||||
blobCache.add(blobInfo);
|
|
||||||
callback(blobInfo.blobUri(), {alt: file.name});
|
|
||||||
};
|
|
||||||
};
|
|
||||||
},
|
|
||||||
});
|
|
||||||
//内容有变化,就更新内容,将值返回给父组件
|
|
||||||
watch(() => {
|
|
||||||
emit("update:value", content.value);
|
|
||||||
});
|
|
||||||
const uploadFile = (formData, url,success) => {
|
|
||||||
axios.post(
|
|
||||||
import.meta.env.VITE_BASE_URL + url,
|
|
||||||
formData,
|
|
||||||
{
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'multipart/form-data',
|
|
||||||
Authorization: getToken()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
).then(res => {
|
|
||||||
// if (res.status !== 200) {
|
|
||||||
// ElMessage.error("上传失败!")
|
|
||||||
// }
|
|
||||||
let data = res.data
|
|
||||||
if (data.code !== 1000) {
|
|
||||||
ElMessage.error(data.msg)
|
|
||||||
}else {
|
|
||||||
success(data.data.url)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
<style scoped>
|
|
||||||
.tinymce-boxz > textarea {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<style>
|
|
||||||
/* 隐藏apikey没有绑定当前域名的提示 */
|
|
||||||
.tox-notifications-container .tox-notification--warning {
|
|
||||||
display: none !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.tox.tox-tinymce {
|
|
||||||
max-width: 100%;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,69 +0,0 @@
|
|||||||
<template>
|
|
||||||
<codemirror
|
|
||||||
v-model="javaCode"
|
|
||||||
:placeholder="editorPlaceholder"
|
|
||||||
:style="{ height: editorHeight+'px' }"
|
|
||||||
:autofocus="true"
|
|
||||||
:indent-with-tab="true"
|
|
||||||
:tabSize="tabSize"
|
|
||||||
:extensions="extensions"
|
|
||||||
:scrollbarStyle="null"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import {Codemirror} from "vue-codemirror";
|
|
||||||
import {java, javaLanguage} from "@codemirror/lang-java";
|
|
||||||
|
|
||||||
const emit = defineEmits()
|
|
||||||
const props = defineProps({
|
|
||||||
value: {
|
|
||||||
type: String,
|
|
||||||
default: "",
|
|
||||||
},
|
|
||||||
editorPlaceholder: {
|
|
||||||
type: String,
|
|
||||||
default: "请输入代码",
|
|
||||||
},
|
|
||||||
editorHeight: {
|
|
||||||
type: String,
|
|
||||||
default: "300",
|
|
||||||
},
|
|
||||||
tabSize: {
|
|
||||||
type: Number,
|
|
||||||
default: 2,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
const _value = computed({
|
|
||||||
get() {
|
|
||||||
return props.value || ""
|
|
||||||
},
|
|
||||||
set(value) {
|
|
||||||
emit('update:value', value)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
const javaCode = ref();
|
|
||||||
const customJavaCodeTips = (context) => {
|
|
||||||
let word = context.matchBefore(/\w*/)
|
|
||||||
if (word.from == word.to && !context.explicit) return null;
|
|
||||||
return {
|
|
||||||
from: word.from?word.from:context.pos,
|
|
||||||
options: [
|
|
||||||
{label: "function", type: "keyword",apply:"function name(params) {\n\t\n}",detail: "definition"},
|
|
||||||
// {label: "hello", type: "variable", info: "(World)"},
|
|
||||||
{label: "fori", type: "keyword",apply:"for (let i = 0; i < list.length; i++) {\n\n}", detail: "loop"},
|
|
||||||
{label: "for", type: "keyword",apply:"for (let name of list) {\n\n}", detail: "of loop"},
|
|
||||||
{label: "psf", type: "keyword",apply:"public static final ", detail: "public static final"},
|
|
||||||
{label: "psv", type: "keyword",apply:"public static void name(){\n\n}", detail: "public static void"},
|
|
||||||
{label: "psfi", type: "keyword",apply:"public static final int ", detail: "public static final int"},
|
|
||||||
{label: "psfs", type: "keyword",apply:"public static final String ", detail: "public static final String"},
|
|
||||||
{label: "psvm", type: "keyword", apply: "public static void main(String[] args){\n\t\n}", detail: "main() 方法声明"}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const javaSnippets = javaLanguage.data.of({
|
|
||||||
autocomplete: customJavaCodeTips,
|
|
||||||
})
|
|
||||||
const extensions = ref([java(), javaSnippets]);
|
|
||||||
</script>
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
<template>
|
|
||||||
<codemirror
|
|
||||||
v-model="jsCode"
|
|
||||||
:placeholder="editorPlaceholder"
|
|
||||||
:style="{ height: editorHeight+'px' }"
|
|
||||||
:autofocus="true"
|
|
||||||
:indent-with-tab="true"
|
|
||||||
:tabSize="tabSize"
|
|
||||||
:extensions="extensions"
|
|
||||||
:scrollbarStyle="null"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import {Codemirror} from "vue-codemirror";
|
|
||||||
import {javascript} from "@codemirror/lang-javascript";
|
|
||||||
import {defineEmits, ref, defineProps, computed} from "vue";
|
|
||||||
|
|
||||||
const emit = defineEmits()
|
|
||||||
const props = defineProps({
|
|
||||||
value: {
|
|
||||||
type: String,
|
|
||||||
default: "",
|
|
||||||
},
|
|
||||||
editorPlaceholder: {
|
|
||||||
type: String,
|
|
||||||
default: "请输入代码",
|
|
||||||
},
|
|
||||||
editorHeight: {
|
|
||||||
type: String,
|
|
||||||
default: "300",
|
|
||||||
},
|
|
||||||
tabSize: {
|
|
||||||
type: Number,
|
|
||||||
default: 2,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
const _value = computed({
|
|
||||||
get() {
|
|
||||||
return props.value || ""
|
|
||||||
},
|
|
||||||
set(value) {
|
|
||||||
emit('update:value', value)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
const jsCode = ref();
|
|
||||||
const extensions = ref([javascript()]);
|
|
||||||
</script>
|
|
||||||
@@ -1,83 +0,0 @@
|
|||||||
<template>
|
|
||||||
<codemirror
|
|
||||||
v-model="sqlCode"
|
|
||||||
:placeholder="editorPlaceholder"
|
|
||||||
:style="{ height: editorHeight+'px' }"
|
|
||||||
:autofocus="true"
|
|
||||||
:indent-with-tab="true"
|
|
||||||
:tabSize="tabSize"
|
|
||||||
:extensions="extensions"
|
|
||||||
:scrollbarStyle="null"
|
|
||||||
@change="emit('change',$event)"
|
|
||||||
/>
|
|
||||||
<!-- <div class="sql-format">-->
|
|
||||||
<!-- <span @click="formatSql">格式化SQL</span>-->
|
|
||||||
<!-- <span @click="clearVal">一键清空</span>-->
|
|
||||||
<!-- </div>-->
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import {Codemirror} from "vue-codemirror";
|
|
||||||
import {sql} from '@codemirror/lang-sql';
|
|
||||||
import {defineEmits, ref, defineProps, computed} from "vue";
|
|
||||||
import * as sqlFormatter from "sql-formatter";
|
|
||||||
|
|
||||||
const emit = defineEmits()
|
|
||||||
const props = defineProps({
|
|
||||||
value: {
|
|
||||||
type: String,
|
|
||||||
default: "",
|
|
||||||
},
|
|
||||||
editorPlaceholder: {
|
|
||||||
type: String,
|
|
||||||
default: "请输入代码",
|
|
||||||
},
|
|
||||||
editorHeight: {
|
|
||||||
type: String,
|
|
||||||
default: "300",
|
|
||||||
},
|
|
||||||
tabSize: {
|
|
||||||
type: Number,
|
|
||||||
default: 2,
|
|
||||||
}
|
|
||||||
})
|
|
||||||
const _value = computed({
|
|
||||||
get() {
|
|
||||||
return props.value || ""
|
|
||||||
},
|
|
||||||
set(value) {
|
|
||||||
emit('update:modelValue', value)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const sqlCode = ref(_value);
|
|
||||||
const extensions = ref([sql()]);
|
|
||||||
//代码格式化
|
|
||||||
const formatSql = () => {
|
|
||||||
sqlCode.value=sqlFormatter.format(sqlCode.value)
|
|
||||||
}
|
|
||||||
// 清除值
|
|
||||||
const clearVal = () => {
|
|
||||||
sqlCode.value=''
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
<style scoped lang="scss">
|
|
||||||
.sql-format {
|
|
||||||
background-color: #f7f7f7;
|
|
||||||
text-align: right;
|
|
||||||
color: #2a99ff;
|
|
||||||
padding: 10px;
|
|
||||||
|
|
||||||
span:hover {
|
|
||||||
cursor: pointer;
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
|
||||||
|
|
||||||
> span:first-child {
|
|
||||||
margin-right: 10px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
::v-deep .cm-line{
|
|
||||||
font-size: 16px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="logo" ref="logo">
|
<div class="logo" ref="logo">
|
||||||
<span v-if="!siderbarStore.isCollapse">FateVerse</span>
|
<span v-if="!siderbarStore.isCollapse">智能语音服务</span>
|
||||||
</div>
|
</div>
|
||||||
<el-scrollbar :height="`calc(100vh - ${logoHeight}px)`" style="background-color: #ffffff">
|
<el-scrollbar :height="`calc(100vh - ${logoHeight}px)`" style="background-color: #ffffff">
|
||||||
<el-menu
|
<el-menu
|
||||||
|
|||||||
@@ -175,36 +175,36 @@ const router = createRouter({
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
router.beforeEach(async (to, form, next) => {
|
// router.beforeEach(async (to, form, next) => {
|
||||||
const permisstionStore = usePermisstionStroe();
|
// const permisstionStore = usePermisstionStroe();
|
||||||
const authStore = useAuthStore();
|
// const authStore = useAuthStore();
|
||||||
NProgress.start();
|
// NProgress.start();
|
||||||
if (!getToken()) {
|
// if (!getToken()) {
|
||||||
if (to.path === "/login" || to.path === "/forbidden") {
|
// if (to.path === "/login" || to.path === "/forbidden") {
|
||||||
next();
|
// next();
|
||||||
NProgress.done();
|
// NProgress.done();
|
||||||
} else {
|
// } else {
|
||||||
next({ path: "/login" });
|
// next({ path: "/login" });
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
if (to.path === "/login") {
|
// if (to.path === "/login") {
|
||||||
next("/");
|
// next("/");
|
||||||
NProgress.done();
|
// NProgress.done();
|
||||||
} else {
|
// } else {
|
||||||
permisstionStore.setIsLoadRoutes(true);
|
// permisstionStore.setIsLoadRoutes(true);
|
||||||
if (
|
// if (
|
||||||
permisstionStore.isLoadRoutes &&
|
// permisstionStore.isLoadRoutes &&
|
||||||
permisstionStore.asyncRouters.length == 0
|
// permisstionStore.asyncRouters.length == 0
|
||||||
) {
|
// ) {
|
||||||
await permisstionStore.setAsyncRouters();
|
// await permisstionStore.setAsyncRouters();
|
||||||
await authStore.setUserInfo();
|
// await authStore.setUserInfo();
|
||||||
next({ ...to, replace: true });
|
// next({ ...to, replace: true });
|
||||||
} else {
|
// } else {
|
||||||
next();
|
// next();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
|
|
||||||
router.afterEach(() => {
|
router.afterEach(() => {
|
||||||
NProgress.done();
|
NProgress.done();
|
||||||
|
|||||||
@@ -1,293 +0,0 @@
|
|||||||
<template>
|
|
||||||
<el-steps
|
|
||||||
v-if="!isSpecial"
|
|
||||||
style="max-width: 2000px; margin-top: 5px"
|
|
||||||
:active="4"
|
|
||||||
simple
|
|
||||||
align-center
|
|
||||||
>
|
|
||||||
<el-step title="查看数据源" />
|
|
||||||
<el-step title="输入模拟数据作为入参" />
|
|
||||||
<el-step title="执行代码" />
|
|
||||||
<el-step title="下方查看结果" />
|
|
||||||
</el-steps>
|
|
||||||
<el-form ref="queryForm" class="query-form" :model="queryParams">
|
|
||||||
<el-row :gutter="20">
|
|
||||||
<el-col :span="16">
|
|
||||||
<div class="code-editor">
|
|
||||||
<java-code-edit
|
|
||||||
v-if="codeType !== 'JAVA_SCRIPT'"
|
|
||||||
v-model="codeData"
|
|
||||||
:editor-placeholder="'请输入Java代码'"
|
|
||||||
:editor-height="500"
|
|
||||||
:tab-size="2"
|
|
||||||
/>
|
|
||||||
<js-code-edit
|
|
||||||
v-else
|
|
||||||
v-model="codeData"
|
|
||||||
:editor-placeholder="'请输入JavaScript代码'"
|
|
||||||
:editor-height="500"
|
|
||||||
:tab-size="2"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="8">
|
|
||||||
<el-row>
|
|
||||||
<el-col :span="12" v-for="(item, index) in mappings">
|
|
||||||
<el-form-item :label="item.mappingValue + ':'" prop="mappingKey">
|
|
||||||
<el-input
|
|
||||||
placeholder="请输入查询参数"
|
|
||||||
v-model="mappings[index].userInput"
|
|
||||||
></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
|
|
||||||
<el-form-item
|
|
||||||
label="查询结果:"
|
|
||||||
prop="operParam"
|
|
||||||
class="json-viewer-father"
|
|
||||||
v-if="isSpecial"
|
|
||||||
>
|
|
||||||
<span
|
|
||||||
class="expand"
|
|
||||||
@click="
|
|
||||||
isExpandVisible = true;
|
|
||||||
expandData = mockData;
|
|
||||||
"
|
|
||||||
v-if="isExpandBtnVisible"
|
|
||||||
>展开</span
|
|
||||||
>
|
|
||||||
<div class="json-viewer">
|
|
||||||
<json-viewer
|
|
||||||
:value="mockData"
|
|
||||||
:expand-depth="100"
|
|
||||||
style="width: 100%; height: 300px"
|
|
||||||
></json-viewer>
|
|
||||||
</div>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item prop="mockData" v-if="!isSpecial">
|
|
||||||
<el-input
|
|
||||||
v-model="queryParams.mockData"
|
|
||||||
placeholder="请输入模拟数据源"
|
|
||||||
:rows="20"
|
|
||||||
type="textarea"
|
|
||||||
clearable
|
|
||||||
>
|
|
||||||
</el-input>
|
|
||||||
</el-form-item>
|
|
||||||
<el-button type="primary" @click="handleSave">保存代码</el-button>
|
|
||||||
<el-button type="primary" @click="handleExecute">模拟执行</el-button>
|
|
||||||
<el-button type="primary" @click="handleSourceData" v-if="!isSpecial"
|
|
||||||
>查看数据源</el-button
|
|
||||||
>
|
|
||||||
<el-button type="primary" @click="handleSourceData" v-if="isSpecial"
|
|
||||||
>查询数据源</el-button
|
|
||||||
>
|
|
||||||
</el-col>
|
|
||||||
<el-col class="preview-bottom">
|
|
||||||
<el-row>
|
|
||||||
<el-col :span="16">
|
|
||||||
输出:
|
|
||||||
<span
|
|
||||||
style="color: #49c4ff; cursor: pointer"
|
|
||||||
@click="
|
|
||||||
isExpandVisible = true;
|
|
||||||
expandData = resPreviewData;
|
|
||||||
"
|
|
||||||
>展开</span
|
|
||||||
>
|
|
||||||
<json-viewer
|
|
||||||
class="bottom-printf"
|
|
||||||
:value="resPreviewData"
|
|
||||||
:expand-depth="105"
|
|
||||||
copyable
|
|
||||||
sort
|
|
||||||
></json-viewer>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="8">
|
|
||||||
控制台:
|
|
||||||
<el-input
|
|
||||||
v-model="errorPreviewData"
|
|
||||||
:rows="10"
|
|
||||||
style="color: red"
|
|
||||||
disabled
|
|
||||||
type="textarea"
|
|
||||||
clearable
|
|
||||||
>
|
|
||||||
</el-input>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
</el-form>
|
|
||||||
<el-dialog title="数据展开" v-model="isExpandVisible">
|
|
||||||
<json-viewer
|
|
||||||
:value="expandData"
|
|
||||||
:expand-depth="100"
|
|
||||||
style="width: 100%"
|
|
||||||
></json-viewer
|
|
||||||
></el-dialog>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
/**
|
|
||||||
* @author: JimTT
|
|
||||||
* @description: 适配器设计
|
|
||||||
*/
|
|
||||||
|
|
||||||
import JsonViewer from "vue-json-viewer";
|
|
||||||
import JavaCodeEdit from "@/components/codeEdit/JavaCodeEdit.vue";
|
|
||||||
import JsCodeEdit from "@/components/codeEdit/JsCodeEdit.vue";
|
|
||||||
import { ElMessage } from "element-plus";
|
|
||||||
import {
|
|
||||||
getMockData,
|
|
||||||
getSpecialDetail,
|
|
||||||
executeCode,
|
|
||||||
savaCode,
|
|
||||||
} from "@/api/custom-query/adapter";
|
|
||||||
import { useRouter } from "vue-router";
|
|
||||||
|
|
||||||
const isExpandBtnVisible = ref(false);
|
|
||||||
const isExpandVisible = ref(false);
|
|
||||||
const unencryptedPortalId = ref(null);
|
|
||||||
const mockData = ref();
|
|
||||||
const codeData = ref(null);
|
|
||||||
const resPreviewData = ref();
|
|
||||||
const errorPreviewData = ref();
|
|
||||||
const expandData = ref(null);
|
|
||||||
const router = useRouter();
|
|
||||||
const isSpecial = router.currentRoute.value.query.special;
|
|
||||||
const portalId = router.currentRoute.value.query.portalId;
|
|
||||||
const queryParams = ref({});
|
|
||||||
const mappings = ref([]);
|
|
||||||
const codeType = ref(null);
|
|
||||||
|
|
||||||
// 获取专用适配器详情
|
|
||||||
const getSpecialDetails = async () => {
|
|
||||||
const { code, data } = await getSpecialDetail(portalId);
|
|
||||||
if (code === 1000) {
|
|
||||||
mappings.value = data.mappings;
|
|
||||||
unencryptedPortalId.value = data.portalId;
|
|
||||||
codeData.value = data.dataAdapter.code;
|
|
||||||
codeType.value = data.dataAdapter.type;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
getSpecialDetails();
|
|
||||||
|
|
||||||
// 保存
|
|
||||||
const handleSave = async () => {
|
|
||||||
try {
|
|
||||||
const { code } = await savaCode({
|
|
||||||
code: codeData.value,
|
|
||||||
portalId: unencryptedPortalId.value,
|
|
||||||
});
|
|
||||||
if (code === 1000) {
|
|
||||||
ElMessage.success("保存成功");
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
console.log(err);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// 执行
|
|
||||||
const handleExecute = async () => {
|
|
||||||
let params = [];
|
|
||||||
mappings.value.forEach((item) => {
|
|
||||||
params.push({
|
|
||||||
key: item.mappingKey,
|
|
||||||
value: item.userInput,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
let mockParams = {
|
|
||||||
code: codeData.value,
|
|
||||||
params,
|
|
||||||
portalId: unencryptedPortalId.value,
|
|
||||||
};
|
|
||||||
|
|
||||||
try {
|
|
||||||
const { code, data } = await executeCode(mockParams);
|
|
||||||
if (code === 1000) {
|
|
||||||
if (data.success) {
|
|
||||||
resPreviewData.value = data.result;
|
|
||||||
errorPreviewData.value = data.console;
|
|
||||||
} else {
|
|
||||||
errorPreviewData.value = data.console;
|
|
||||||
resPreviewData.value = data.result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
console.log(err);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// 查看资源
|
|
||||||
const handleSourceData = async () => {
|
|
||||||
let params = [];
|
|
||||||
mappings.value.forEach((item) => {
|
|
||||||
params.push({
|
|
||||||
key: item.mappingKey,
|
|
||||||
value: item.userInput,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
const res = await getMockData({
|
|
||||||
params,
|
|
||||||
portalId: unencryptedPortalId.value,
|
|
||||||
});
|
|
||||||
if (res.code === 1000) {
|
|
||||||
isExpandBtnVisible.value = true;
|
|
||||||
mockData.value = res.data;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped lang="scss">
|
|
||||||
.data-preview {
|
|
||||||
width: 98%;
|
|
||||||
margin: 10px auto;
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
.copy {
|
|
||||||
color: #418dff;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.preview-bottom {
|
|
||||||
max-height: 255px;
|
|
||||||
.bottom-preview {
|
|
||||||
max-height: 255px;
|
|
||||||
}
|
|
||||||
.bottom-printf {
|
|
||||||
max-height: 255px;
|
|
||||||
overflow-y: auto;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.json-viewer-father {
|
|
||||||
position: relative;
|
|
||||||
|
|
||||||
.json-viewer {
|
|
||||||
height: 305px;
|
|
||||||
overflow: auto;
|
|
||||||
}
|
|
||||||
.expand {
|
|
||||||
display: block;
|
|
||||||
position: absolute;
|
|
||||||
color: #49c4ff;
|
|
||||||
top: 270px;
|
|
||||||
left: -50px;
|
|
||||||
z-index: 999;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
::v-deep .v-codemirror .cm-focused {
|
|
||||||
outline: none;
|
|
||||||
}
|
|
||||||
::v-deep .jv-container.jv-light .jv-item.jv-undefined {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
::v-deep .el-textarea.is-disabled .el-textarea__inner {
|
|
||||||
color: red;
|
|
||||||
background-color: #fff;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,393 +0,0 @@
|
|||||||
<template>
|
|
||||||
<el-form :model="queryParams" inline class="query-form" ref="queryForm">
|
|
||||||
<el-form-item label="适配器名称" prop="adapterName">
|
|
||||||
<el-input
|
|
||||||
v-model="queryParams.adapterName"
|
|
||||||
placeholder="请输适配器名称"
|
|
||||||
></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="适配器来源" prop="source">
|
|
||||||
<el-select
|
|
||||||
v-model="queryParams.source"
|
|
||||||
placeholder="请选择适配器来源"
|
|
||||||
clearable
|
|
||||||
filterable
|
|
||||||
>
|
|
||||||
<el-option
|
|
||||||
v-for="item in cacheStore.getDict('data_adapter_source')"
|
|
||||||
:key="item.value"
|
|
||||||
:label="item.label"
|
|
||||||
:value="item.value"
|
|
||||||
/>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="代码类型" prop="type">
|
|
||||||
<el-select
|
|
||||||
v-model="queryParams.type"
|
|
||||||
placeholder="请选择数据适配器代码类型"
|
|
||||||
clearable
|
|
||||||
filterable
|
|
||||||
>
|
|
||||||
<el-option
|
|
||||||
v-for="item in cacheStore.getDict('data_adapter_type')"
|
|
||||||
:key="item.value"
|
|
||||||
:label="item.label"
|
|
||||||
:value="item.value"
|
|
||||||
/>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item>
|
|
||||||
<el-button type="primary" @click="getList" :icon="Search">搜索</el-button>
|
|
||||||
<el-button @click="handleReset" :icon="Refresh">重置</el-button>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
<div class="query-btn">
|
|
||||||
<el-button
|
|
||||||
type="primary"
|
|
||||||
v-perm="['query:adapter:add']"
|
|
||||||
@click="handleAdd"
|
|
||||||
:icon="Plus"
|
|
||||||
plain
|
|
||||||
>新增</el-button
|
|
||||||
>
|
|
||||||
<el-button
|
|
||||||
type="danger"
|
|
||||||
:icon="Delete"
|
|
||||||
v-perm="['query:adapter:del']"
|
|
||||||
@click="handleMoreDelete(adapterIds)"
|
|
||||||
:disabled="disabled"
|
|
||||||
plain
|
|
||||||
>删除
|
|
||||||
</el-button>
|
|
||||||
<el-button
|
|
||||||
type="warning"
|
|
||||||
v-perm="['query:adapter:export']"
|
|
||||||
@click="handleExport"
|
|
||||||
:icon="Download"
|
|
||||||
plain
|
|
||||||
>导出
|
|
||||||
</el-button>
|
|
||||||
</div>
|
|
||||||
<div class="table">
|
|
||||||
<el-table
|
|
||||||
:data="list"
|
|
||||||
row-key="adapterId"
|
|
||||||
:lazy="true"
|
|
||||||
ref="singleTable"
|
|
||||||
v-loading="loading"
|
|
||||||
v-tabh
|
|
||||||
>
|
|
||||||
<el-table-column type="selection" width="55" />
|
|
||||||
<el-table-column label="序号" type="index" width="60" />
|
|
||||||
<el-table-column prop="adapterName" label="适配器名称" align="center" />
|
|
||||||
<el-table-column prop="type" label="代码类型" align="center">
|
|
||||||
<template #default="scope">
|
|
||||||
<tag dict-type="data_adapter_type" :value="scope.row.type" />
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column prop="source" label="适配器来源" align="center">
|
|
||||||
<template #default="scope">
|
|
||||||
<tag dict-type="data_adapter_source" :value="scope.row.source" />
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="操作" align="center">
|
|
||||||
<template #default="scope">
|
|
||||||
<el-button
|
|
||||||
type="primary"
|
|
||||||
size="mini"
|
|
||||||
v-perm="['query:adapter:edit']"
|
|
||||||
@click="handleEdit(scope.row.adapterId)"
|
|
||||||
link
|
|
||||||
>编辑
|
|
||||||
</el-button>
|
|
||||||
<el-button
|
|
||||||
type="primary"
|
|
||||||
size="mini"
|
|
||||||
@click="handleDesign(scope.row)"
|
|
||||||
link
|
|
||||||
>设计
|
|
||||||
</el-button>
|
|
||||||
<popover-delete
|
|
||||||
:name="scope.row.adapterName"
|
|
||||||
:type="'适配器'"
|
|
||||||
:perm="['query:adapter:del']"
|
|
||||||
@delete="handleDelete(scope.row.adapterId)"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
|
||||||
</div>
|
|
||||||
<paging
|
|
||||||
:current-page="pageInfo.pageNum"
|
|
||||||
:page-size="pageInfo.pageSize"
|
|
||||||
:page-sizes="[10, 20, 30, 40, 50]"
|
|
||||||
:total="total"
|
|
||||||
@changeSize="handleSizeChange"
|
|
||||||
@goPage="handleCurrentChange"
|
|
||||||
/>
|
|
||||||
<el-dialog v-model="isVisited" :title="title" width="700px">
|
|
||||||
<el-form :model="form" ref="formInstance" class="dialog-form">
|
|
||||||
<el-row>
|
|
||||||
<el-col :span="24">
|
|
||||||
<el-form-item label="适配器名称" prop="adapterName">
|
|
||||||
<el-input
|
|
||||||
v-model="form.adapterName"
|
|
||||||
placeholder="请输入适配器名称"
|
|
||||||
></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="24">
|
|
||||||
<el-form-item label="数据适配器代码类型" prop="type">
|
|
||||||
<el-select
|
|
||||||
v-model="form.type"
|
|
||||||
placeholder="请选择数据适配器代码类型"
|
|
||||||
clearable
|
|
||||||
filterable
|
|
||||||
>
|
|
||||||
<el-option
|
|
||||||
v-for="item in cacheStore.getDict('data_adapter_type')"
|
|
||||||
:key="item.value"
|
|
||||||
:label="item.label"
|
|
||||||
:value="item.value"
|
|
||||||
/>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="24">
|
|
||||||
<el-form-item label="适配器来源" prop="source">
|
|
||||||
<el-select
|
|
||||||
v-model="form.source"
|
|
||||||
placeholder="请选择适配器来源"
|
|
||||||
clearable
|
|
||||||
filterable
|
|
||||||
>
|
|
||||||
<el-option
|
|
||||||
v-for="item in cacheStore.getDict('data_adapter_source')"
|
|
||||||
:key="item.value"
|
|
||||||
:label="item.label"
|
|
||||||
:value="item.value"
|
|
||||||
/>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="11"> </el-col>
|
|
||||||
</el-row>
|
|
||||||
</el-form>
|
|
||||||
<template #footer>
|
|
||||||
<span>
|
|
||||||
<el-button @click="handleCancel">取消</el-button>
|
|
||||||
<el-button type="primary" @click="handleSubmit(formInstance)"
|
|
||||||
>确定</el-button
|
|
||||||
>
|
|
||||||
</span>
|
|
||||||
</template>
|
|
||||||
</el-dialog>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import {
|
|
||||||
getDataAdapterList,
|
|
||||||
getDataAdapterDetails,
|
|
||||||
addDataAdapter,
|
|
||||||
editDataAdapter,
|
|
||||||
delDataAdapter,
|
|
||||||
} from "@/api/custom-query/adapter";
|
|
||||||
import {
|
|
||||||
Search,
|
|
||||||
Refresh,
|
|
||||||
Delete,
|
|
||||||
Plus,
|
|
||||||
Edit,
|
|
||||||
Download,
|
|
||||||
} from "@element-plus/icons-vue";
|
|
||||||
import { ElMessage, ElMessageBox } from "element-plus";
|
|
||||||
import Paging from "@/components/pagination/index.vue";
|
|
||||||
import { useCacheStore } from "@/stores/cache";
|
|
||||||
import { useRouter } from "vue-router";
|
|
||||||
import Tag from "@/components/Tag.vue";
|
|
||||||
|
|
||||||
const router = useRouter();
|
|
||||||
const cacheStore = useCacheStore();
|
|
||||||
const queryParams = reactive({
|
|
||||||
adapterName: "",
|
|
||||||
source: "",
|
|
||||||
type: "",
|
|
||||||
});
|
|
||||||
|
|
||||||
const pageInfo = reactive({
|
|
||||||
pageNum: 1,
|
|
||||||
pageSize: 10,
|
|
||||||
});
|
|
||||||
const list = ref([]);
|
|
||||||
const queryForm = ref([]);
|
|
||||||
const loading = ref(true);
|
|
||||||
const disabled = ref(true);
|
|
||||||
const total = ref();
|
|
||||||
const title = ref("");
|
|
||||||
const isVisited = ref(false);
|
|
||||||
const form = ref();
|
|
||||||
const formInstance = ref();
|
|
||||||
const adapterIds = ref([]);
|
|
||||||
const adapterNameList = ref([]);
|
|
||||||
|
|
||||||
//获取数据
|
|
||||||
const getList = async () => {
|
|
||||||
let params = {
|
|
||||||
...queryParams,
|
|
||||||
...pageInfo,
|
|
||||||
};
|
|
||||||
loading.value = true;
|
|
||||||
getDataAdapterList(params).then((res) => {
|
|
||||||
if (res.code === 1000) {
|
|
||||||
list.value = res.data.rows;
|
|
||||||
total.value = res.data.total;
|
|
||||||
loading.value = false;
|
|
||||||
} else {
|
|
||||||
ElMessage.error(res.msg);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
//重置from表单
|
|
||||||
const restFrom = () => {
|
|
||||||
form.value = {
|
|
||||||
adapterName: null,
|
|
||||||
source: "CUSTOM",
|
|
||||||
type: null,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
//添加
|
|
||||||
const handleAdd = async () => {
|
|
||||||
restFrom();
|
|
||||||
title.value = "新增数据源适配器";
|
|
||||||
isVisited.value = true;
|
|
||||||
nextTick(() => {
|
|
||||||
// 清空校验
|
|
||||||
formInstance.value.clearValidate();
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
//修改
|
|
||||||
const handleEdit = async (id) => {
|
|
||||||
restFrom();
|
|
||||||
getDataAdapterDetails(id).then((res) => {
|
|
||||||
if (res.code === 1000) {
|
|
||||||
form.value = res.data;
|
|
||||||
title.value = "编辑数据源适配器";
|
|
||||||
isVisited.value = true;
|
|
||||||
nextTick(() => {
|
|
||||||
// 清空校验
|
|
||||||
formInstance.value.clearValidate();
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
ElMessage.error(res.msg);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
//设计
|
|
||||||
const handleDesign = (row) => {
|
|
||||||
router.push({ path: `/custom/query/data/adapter/design/${row.adapterId}` });
|
|
||||||
};
|
|
||||||
|
|
||||||
//删除
|
|
||||||
const handleDelete = async (adapterId) => {
|
|
||||||
delDataAdapter(adapterId).then((res) => {
|
|
||||||
if (res.code === 1000) {
|
|
||||||
ElMessage.success(res.msg);
|
|
||||||
getList();
|
|
||||||
} else {
|
|
||||||
ElMessage.error(res.msg);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
//多删
|
|
||||||
const handleMoreDelete = (adapterIds) => {
|
|
||||||
ElMessageBox.confirm(
|
|
||||||
`确认删除名称为${adapterNameList.value}的适配器吗?`,
|
|
||||||
"系统提示",
|
|
||||||
{
|
|
||||||
confirmButtonText: "确定",
|
|
||||||
cancelButtonText: "取消",
|
|
||||||
type: "warning",
|
|
||||||
}
|
|
||||||
).then(() => {
|
|
||||||
handleDelete(adapterIds);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
//勾选table数据行事件
|
|
||||||
// const handleSelect = async (selection) => {
|
|
||||||
// if (selection.length !== 0) {
|
|
||||||
// disabled.value = false;
|
|
||||||
// adapterIds.value = selection.map((item) => item.adapterId).join();
|
|
||||||
// adapterNameList.value = selection.map((item) => item.adapterName).join();
|
|
||||||
// } else {
|
|
||||||
// disabled.value = true;
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
|
|
||||||
//取消
|
|
||||||
const handleCancel = () => {
|
|
||||||
restFrom();
|
|
||||||
isVisited.value = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
//提交
|
|
||||||
const handleSubmit = async (instance) => {
|
|
||||||
if (!instance) return;
|
|
||||||
instance.validate(async (valid) => {
|
|
||||||
if (!valid) return;
|
|
||||||
if (title.value === "新增数据源适配器") {
|
|
||||||
addDataAdapter(form.value).then((res) => {
|
|
||||||
if (res.code === 1000) {
|
|
||||||
ElMessage.success(res.msg);
|
|
||||||
getList();
|
|
||||||
isVisited.value = false;
|
|
||||||
} else {
|
|
||||||
ElMessage.error(res.msg);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
editDataAdapter(form.value).then((res) => {
|
|
||||||
if (res.code === 1000) {
|
|
||||||
ElMessage.success(res.msg);
|
|
||||||
getList();
|
|
||||||
isVisited.value = false;
|
|
||||||
} else {
|
|
||||||
ElMessage.error(res.msg);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
//切换每页显示条数
|
|
||||||
const handleSizeChange = async (val) => {
|
|
||||||
pageInfo.pageSize = val;
|
|
||||||
await getList();
|
|
||||||
};
|
|
||||||
|
|
||||||
//重置搜索
|
|
||||||
const handleReset = () => {
|
|
||||||
console.log("重置~~");
|
|
||||||
};
|
|
||||||
|
|
||||||
// 导出
|
|
||||||
const handleExport = () => {
|
|
||||||
console.log("导出~~");
|
|
||||||
};
|
|
||||||
|
|
||||||
//点击页码进行分页功能
|
|
||||||
const handleCurrentChange = async (val) => {
|
|
||||||
pageInfo.pageNum = val;
|
|
||||||
await getList();
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
getList();
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped></style>
|
|
||||||
@@ -1,392 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div>
|
|
||||||
<el-form :model="queryParams" inline class="query-form" ref="queryForm">
|
|
||||||
<el-form-item label="数据模型名称" prop="dsName">
|
|
||||||
<el-input v-model="queryParams.dsName" placeholder="请输入数据模型名称" clearable></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="数据库名称" prop="dbName">
|
|
||||||
<el-input v-model="queryParams.dbName" placeholder="请输入数据库名称" clearable></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="配置类型" prop="configType">
|
|
||||||
<el-select v-model="queryParams.configType" placeholder="请选择配置类型" clearable filterable>
|
|
||||||
<el-option label="主机" value="1"/>
|
|
||||||
<el-option label="JDBC" value="2"/>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item>
|
|
||||||
<el-button type="primary" @click="handleSearch" :icon="Search">搜索</el-button>
|
|
||||||
<el-button @click="handleReset" :icon="Refresh">重置</el-button>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
<div class="query-btn">
|
|
||||||
<el-button type="primary" v-perm="['query:source:add']" @click="handleAdd" :icon="Plus" plain>新增</el-button>
|
|
||||||
<el-button type="danger" :icon="Delete" v-perm="['query:source:del']"
|
|
||||||
@click="handleMoreDelete(sourceId,sourceName)" :disabled="disabled" plain>删除
|
|
||||||
</el-button>
|
|
||||||
<el-button type="warning" v-perm="['query:source:export']" @click="handleExport" :icon="Download" plain>导出
|
|
||||||
</el-button>
|
|
||||||
</div>
|
|
||||||
<div class="table">
|
|
||||||
<el-table
|
|
||||||
:data="list"
|
|
||||||
row-key="id"
|
|
||||||
:lazy="true"
|
|
||||||
ref="singleTable"
|
|
||||||
v-loading="loading"
|
|
||||||
@select="handleSelect"
|
|
||||||
v-tabh
|
|
||||||
>
|
|
||||||
<el-table-column type="selection" width="55"/>
|
|
||||||
<el-table-column label="序号" type="index" width="60" align="center"/>
|
|
||||||
<el-table-column prop="dsName" label="数据模型名称" align="center"/>
|
|
||||||
<el-table-column prop="dbName" label="数据库名称" align="center"/>
|
|
||||||
<el-table-column prop="username" label="数据模型用户名" align="center"/>
|
|
||||||
<el-table-column prop="type" label="数据模型类型" align="center"/>
|
|
||||||
<el-table-column prop="confType" label="数据模型配置类型" align="center">
|
|
||||||
<template #default="scope">
|
|
||||||
<tag dict-type="data_source_config" :value="scope.row.configType"/>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column prop="url" label="数据模型连接地址" align="center">
|
|
||||||
<template #default="scope">
|
|
||||||
<div class="formatterUrl">{{ scope.row.url }}</div>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="操作" align="center">
|
|
||||||
<template #default="scope">
|
|
||||||
<el-button type="primary" size="mini" v-perm="['query:source:edit']"
|
|
||||||
@click="handleEdit(scope.row.id)" link>编辑
|
|
||||||
</el-button>
|
|
||||||
<popover-delete :name="scope.row.dsName" :type="'数据模型'" :perm="['query:source:del']"
|
|
||||||
@delete="handleDelete(scope.row.id)"/>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
|
||||||
</div>
|
|
||||||
<paging :current-page="pageInfo.pageNum" :page-size="pageInfo.pageSize" :page-sizes="[10, 20, 30, 40,50]"
|
|
||||||
:total="total" @changeSize="handleSizeChange" @goPage="handleCurrentChange"/>
|
|
||||||
<el-dialog v-model="isVisited" :title="title" width="900px">
|
|
||||||
<el-form :model="form" ref="formInstance" :rules="formRules" class="dialog-form" :validate-on-rule-change="false">
|
|
||||||
<el-row>
|
|
||||||
<el-col :span="11">
|
|
||||||
<el-form-item label="数据模型名称" prop="dsName">
|
|
||||||
<el-input v-model="form.dsName" placeholder="请输入数据模型名称"></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="11" :offset="2">
|
|
||||||
<el-form-item label="数据模型用户名" prop="username">
|
|
||||||
<el-input v-model="form.username" placeholder="请输入数据模型用户名"></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="11">
|
|
||||||
<el-form-item label="数据模型密码" prop="password">
|
|
||||||
<el-input v-model="form.password" placeholder="请输入数据模型密码"></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="11" :offset="2">
|
|
||||||
<el-form-item label="数据模型类型" prop="type">
|
|
||||||
<el-select v-model="form.type" placeholder="请选择数据模型类型" filterable @change="handleTypeChange(form.type)">
|
|
||||||
<el-option
|
|
||||||
v-for="typeItem in typeList"
|
|
||||||
:key="typeItem.value"
|
|
||||||
:label="typeItem.label"
|
|
||||||
:value="typeItem.value"
|
|
||||||
/>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="11">
|
|
||||||
<el-form-item label="配置类型" prop="configType">
|
|
||||||
<el-radio-group v-model="form.configType">
|
|
||||||
<el-radio border :label="1">主机</el-radio>
|
|
||||||
<el-radio border :label="2">JDBC</el-radio>
|
|
||||||
</el-radio-group>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="11" :offset="2" v-if="form.configType === 1">
|
|
||||||
<el-form-item label="数据模型端口" prop="port">
|
|
||||||
<el-input-number v-model="form.port"></el-input-number>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="11" v-if="form.configType === 1">
|
|
||||||
<el-form-item label="数据模型服务地址" prop="host">
|
|
||||||
<el-input v-model="form.host" placeholder="请输入数据模型服务地址"></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="11" :offset="2">
|
|
||||||
<el-form-item label="数据库名称" prop="dbName" v-if="form.configType === 1">
|
|
||||||
<el-input v-model="form.dbName" placeholder="请输入数据库名称"></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="24" v-if="form.configType === 2">
|
|
||||||
<el-form-item label="数据模型连接地址" prop="url">
|
|
||||||
<el-input v-model="form.url" :rows="4"
|
|
||||||
type="textarea" placeholder="请输入数据模型连接地址"></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="24" v-if="form.configType === 1">
|
|
||||||
<el-form-item label="配置参数" prop="args">
|
|
||||||
<el-input v-model="form.args" :rows="4"
|
|
||||||
type="textarea" placeholder="请输入配置参数"></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="24">
|
|
||||||
<el-form-item label="服务名称" prop="params.serviceName" v-if="form.type === 'ORACLE' && form.configType===1">
|
|
||||||
<el-input v-model="form.params.serviceName" placeholder="请输入服务名称"></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="24">
|
|
||||||
<el-form-item label="命名空间" prop="params.namespace" v-if="form.type === 'POSTGRES' && form.configType===1">
|
|
||||||
<el-input v-model="form.params.namespace" placeholder="请输入命名空间"></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
</el-form>
|
|
||||||
<template #footer>
|
|
||||||
<el-button @click="handleCancel">取消</el-button>
|
|
||||||
<el-button type="primary" @click="handleSubmit(formInstance)">确定</el-button>
|
|
||||||
</template>
|
|
||||||
</el-dialog>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import {
|
|
||||||
getDataSourceManageList,
|
|
||||||
getDataSourceManageDetails,
|
|
||||||
addDataSourceManage,
|
|
||||||
editDataSourceManage,
|
|
||||||
delDataSourceManage,
|
|
||||||
getDataSourceType
|
|
||||||
} from "@/api/custom-query/datamodel";
|
|
||||||
import {Search, Refresh, Delete, Plus, Edit, Download} from '@element-plus/icons-vue'
|
|
||||||
import {ElMessage, ElMessageBox} from "element-plus";
|
|
||||||
import {downLoadExcel} from "@/utils/downloadZip";
|
|
||||||
import Paging from "@/components/pagination/index.vue";
|
|
||||||
|
|
||||||
//查询参数
|
|
||||||
const queryParams = reactive({
|
|
||||||
dsName: '',
|
|
||||||
dbName: '',
|
|
||||||
type: '',
|
|
||||||
})
|
|
||||||
//页面信息
|
|
||||||
const pageInfo = reactive({
|
|
||||||
pageNum: 1,
|
|
||||||
pageSize: 10,
|
|
||||||
})
|
|
||||||
const disabled = ref(true)
|
|
||||||
const typeList = ref([])
|
|
||||||
const list = ref([])
|
|
||||||
const queryForm = ref([])
|
|
||||||
const loading = ref(true)
|
|
||||||
const total = ref()
|
|
||||||
const sourceId = ref()
|
|
||||||
const sourceName = ref()
|
|
||||||
const singleTable = ref()
|
|
||||||
const title = ref('')
|
|
||||||
const isVisited = ref(false)
|
|
||||||
const form = ref()
|
|
||||||
const formInstance = ref()
|
|
||||||
const formRules = ref({
|
|
||||||
dsName: [{required: true, message: '请输入数据模型名称', trigger: 'blur'}],
|
|
||||||
username: [{required: true, message: '请输入数据模型用户名', trigger: 'blur'}],
|
|
||||||
password: [{required: true, message: '请输入数据模型密码', trigger: 'blur'}],
|
|
||||||
type: [{required: true, message: '请选择数据模型类型', trigger: 'blur'}],
|
|
||||||
configType: [{required: true, message: '请选择配置类型', trigger: 'blur'}],
|
|
||||||
port: [{required: true, message: '请输入数据模型端口', trigger: 'blur'}],
|
|
||||||
host: [{required: true, message: '请输入数据模型服务地址', trigger: 'blur'}],
|
|
||||||
dbName: [{required: true, message: '请输入数据库名称', trigger: 'blur'}],
|
|
||||||
url: [{required: true, message: '请输入数据模型连接地址', trigger: 'blur'}],
|
|
||||||
params: {
|
|
||||||
serviceName: [{required: true, message: '请输入服务名称', trigger: 'blur'}],
|
|
||||||
namespace: [{required: true, message: '请输入命名空间', trigger: 'blur'}]
|
|
||||||
}
|
|
||||||
})
|
|
||||||
const getTypeOption = () => {
|
|
||||||
getDataSourceType().then(res => {
|
|
||||||
typeList.value = res.data
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleTypeChange = (type) => {
|
|
||||||
if (form.value.configType !== 1) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (type === 'ORACLE') {
|
|
||||||
form.value.params = {
|
|
||||||
serviceName: ''
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (type === 'POSTGRES') {
|
|
||||||
form.value.params = {
|
|
||||||
namespace: ''
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//搜索功能
|
|
||||||
const handleSearch = () => {
|
|
||||||
getList()
|
|
||||||
}
|
|
||||||
//重置搜索
|
|
||||||
const handleReset = () => {
|
|
||||||
queryForm.value.resetFields()
|
|
||||||
getList()
|
|
||||||
}
|
|
||||||
//获取数据
|
|
||||||
const getList = async () => {
|
|
||||||
let params = {
|
|
||||||
...queryParams,
|
|
||||||
...pageInfo
|
|
||||||
}
|
|
||||||
loading.value = true
|
|
||||||
getDataSourceManageList(params).then(res => {
|
|
||||||
if (res.code === 1000) {
|
|
||||||
list.value = res.data.rows
|
|
||||||
total.value = res.data.total
|
|
||||||
loading.value = false
|
|
||||||
} else {
|
|
||||||
ElMessage.error(res.msg)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
//重置from表单
|
|
||||||
const restFrom = () => {
|
|
||||||
form.value = {
|
|
||||||
dsName: null,
|
|
||||||
username: null,
|
|
||||||
password: null,
|
|
||||||
host: null,
|
|
||||||
port: 0,
|
|
||||||
type: null,
|
|
||||||
dbName: null,
|
|
||||||
configType: 1,
|
|
||||||
url: null,
|
|
||||||
args: null,
|
|
||||||
params: {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//取消
|
|
||||||
const handleCancel = () => {
|
|
||||||
restFrom()
|
|
||||||
isVisited.value = false
|
|
||||||
}
|
|
||||||
//提交
|
|
||||||
const handleSubmit = async (instance) => {
|
|
||||||
if (!instance) return
|
|
||||||
instance.validate(async (valid) => {
|
|
||||||
if (!valid) return
|
|
||||||
if (title.value === '新增数据模型管理') {
|
|
||||||
addDataSourceManage(form.value).then(res => {
|
|
||||||
if (res.code === 1000) {
|
|
||||||
ElMessage.success(res.msg)
|
|
||||||
getList()
|
|
||||||
isVisited.value = false
|
|
||||||
} else {
|
|
||||||
ElMessage.error(res.msg)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
editDataSourceManage(form.value).then(res => {
|
|
||||||
if (res.code === 1000) {
|
|
||||||
ElMessage.success(res.msg)
|
|
||||||
getList()
|
|
||||||
isVisited.value = false
|
|
||||||
} else {
|
|
||||||
ElMessage.error(res.msg)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
//添加
|
|
||||||
const handleAdd = async () => {
|
|
||||||
formRules.value.password[0].required = true
|
|
||||||
restFrom()
|
|
||||||
title.value = "新增数据模型管理"
|
|
||||||
isVisited.value = true
|
|
||||||
nextTick(() => {
|
|
||||||
// 清空校验
|
|
||||||
formInstance.value.clearValidate()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
//修改
|
|
||||||
const handleEdit = async (id) => {
|
|
||||||
restFrom()
|
|
||||||
getDataSourceManageDetails(id).then(res => {
|
|
||||||
if (res.code === 1000) {
|
|
||||||
console.log('res', res.data)
|
|
||||||
formRules.value.password[0].required = false
|
|
||||||
form.value = res.data
|
|
||||||
title.value = "编辑数据模型管理"
|
|
||||||
isVisited.value = true
|
|
||||||
nextTick(() => {
|
|
||||||
// 清空校验
|
|
||||||
formInstance.value.clearValidate()
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
ElMessage.error(res.msg)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
//导出excel
|
|
||||||
const handleExport = () => {
|
|
||||||
downLoadExcel('/query/query/source/export', {...queryParams})
|
|
||||||
}
|
|
||||||
|
|
||||||
//勾选table数据行的 Checkbox
|
|
||||||
const handleSelect = async (selection) => {
|
|
||||||
if (selection.length !== 0) {
|
|
||||||
disabled.value = false
|
|
||||||
sourceId.value = selection.map(item => item.id).join()
|
|
||||||
sourceName.value = selection.map(item => item.dsName).join()
|
|
||||||
} else {
|
|
||||||
disabled.value = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//切换每页显示条数
|
|
||||||
const handleSizeChange = async (val) => {
|
|
||||||
pageInfo.pageSize = val
|
|
||||||
await getList()
|
|
||||||
}
|
|
||||||
|
|
||||||
//点击页码进行分页功能
|
|
||||||
const handleCurrentChange = async (val) => {
|
|
||||||
pageInfo.pageNum = val
|
|
||||||
await getList()
|
|
||||||
}
|
|
||||||
//删除
|
|
||||||
const handleDelete = async (id) => {
|
|
||||||
delDataSourceManage(id).then(res => {
|
|
||||||
if (res.code === 1000) {
|
|
||||||
ElMessage.success(res.msg)
|
|
||||||
getList()
|
|
||||||
} else {
|
|
||||||
ElMessage.error(res.msg)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
//多删
|
|
||||||
const handleMoreDelete = (sourceId, sourceName) => {
|
|
||||||
ElMessageBox.confirm(`确认删除名称为${sourceName}的数据模型吗?`, '系统提示', {
|
|
||||||
confirmButtonText: '确定',
|
|
||||||
cancelButtonText: '取消',
|
|
||||||
type: 'warning'
|
|
||||||
}).then(() => {
|
|
||||||
handleDelete(sourceId)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
getTypeOption()
|
|
||||||
getList()
|
|
||||||
</script>
|
|
||||||
<style scoped>
|
|
||||||
.formatterUrl {
|
|
||||||
display: -webkit-box;
|
|
||||||
-webkit-box-orient: vertical;
|
|
||||||
-webkit-line-clamp: 2;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,233 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div>
|
|
||||||
<EchartsEditor :info="initInfo" :line-data="lineChartsItem" :bar-data="barChartsItem" :pie-data="pieChartsItem"
|
|
||||||
:radar-data="radarChartsItem" :radar-indicator="indicator" @getFinalInfo="getFinalInfo"/>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import EchartsEditor from "./components/EchartsEditor.vue";
|
|
||||||
//入参
|
|
||||||
const lineChartsItem = ref([
|
|
||||||
{
|
|
||||||
id: 1,
|
|
||||||
unit: '年份',
|
|
||||||
type: '',
|
|
||||||
dataType: 'key',
|
|
||||||
color: '',
|
|
||||||
label: '年份',
|
|
||||||
symbol: "",
|
|
||||||
symbolSize: 0,
|
|
||||||
showSymbol: false,
|
|
||||||
lineStyle: {
|
|
||||||
shadowColor: '',//阴影颜色
|
|
||||||
shadowBlur: 0,//图形阴影的模糊大小
|
|
||||||
opacity: 1
|
|
||||||
},
|
|
||||||
data: ['2013', '2014', '2015', '2016', '2017', '2018']
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 2,
|
|
||||||
unit: '年销量',
|
|
||||||
type: 'line',
|
|
||||||
dataType: 'value',
|
|
||||||
color: '#9a60b4',//图形颜色
|
|
||||||
label: '华北',
|
|
||||||
symbol: "triangle",//标记的图形circle:圆形,rect:矩形,triangle:三角形,diamond:钻石形,roundRect:圆角矩形,pin:圆钉形,arrow:箭头形,none:不显示标记
|
|
||||||
symbolSize: 8,//标记的大小
|
|
||||||
showSymbol: true,//是否显示标记,如果 false 则只有在 tooltip hover 的时候显示。
|
|
||||||
lineStyle: {
|
|
||||||
shadowColor: '',//阴影颜色
|
|
||||||
shadowBlur: 0,//图形阴影的模糊大小
|
|
||||||
opacity: 1//图形透明度
|
|
||||||
},
|
|
||||||
data: [40, 80, 20, 120, 140, 50]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 3,
|
|
||||||
unit: '年销量',
|
|
||||||
type: 'line',
|
|
||||||
dataType: 'value',
|
|
||||||
color: '#3ba272',
|
|
||||||
label: '华东',
|
|
||||||
symbol: "circle",
|
|
||||||
symbolSize: 8,
|
|
||||||
showSymbol: true,
|
|
||||||
lineStyle: {
|
|
||||||
shadowColor: '',//阴影颜色
|
|
||||||
shadowBlur: 0,//图形阴影的模糊大小
|
|
||||||
opacity: 1
|
|
||||||
},
|
|
||||||
data: [140, 180, 120, 40, 50, 150]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 4,
|
|
||||||
unit: '年销量',
|
|
||||||
type: 'line',
|
|
||||||
dataType: 'value',
|
|
||||||
color: '#5470c6',
|
|
||||||
label: '华南',
|
|
||||||
symbol: "rect",
|
|
||||||
symbolSize: 8,
|
|
||||||
showSymbol: true,
|
|
||||||
lineStyle: {
|
|
||||||
shadowColor: '',//阴影颜色
|
|
||||||
shadowBlur: 0,//图形阴影的模糊大小
|
|
||||||
opacity: 1
|
|
||||||
},
|
|
||||||
data: [110, 143, 68, 90, 120, 130]
|
|
||||||
}
|
|
||||||
])
|
|
||||||
const barChartsItem = ref([
|
|
||||||
{
|
|
||||||
id: 1,
|
|
||||||
unit: '年份',
|
|
||||||
type: '',
|
|
||||||
dataType: 'key',
|
|
||||||
color: '',
|
|
||||||
label: '年份',
|
|
||||||
showBackground: false,
|
|
||||||
backgroundStyle: {
|
|
||||||
color: '',
|
|
||||||
borderWidth: 0,
|
|
||||||
borderColor: '',
|
|
||||||
borderType: 'solid',
|
|
||||||
},
|
|
||||||
data: ['2013', '2014', '2015', '2016', '2017', '2018']
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 2,
|
|
||||||
unit: '销售金额',
|
|
||||||
type: 'bar',
|
|
||||||
dataType: 'value',
|
|
||||||
color: '#9a60b4',//图形颜色
|
|
||||||
label: '王五',
|
|
||||||
showBackground: true,//是否显示柱条的背景色
|
|
||||||
backgroundStyle: {
|
|
||||||
color: '#e5e2e2',//柱条的颜色
|
|
||||||
borderWidth: 0,//柱条的描边宽度,默认不描边。
|
|
||||||
borderColor: '#000',//柱条的描边颜色
|
|
||||||
borderType: 'dotted',//柱条的描边类型,默认为实线,支持 'dashed', 'dotted'
|
|
||||||
},
|
|
||||||
data: [40, 80, 20, 120, 140, 50]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 3,
|
|
||||||
unit: '销售金额',
|
|
||||||
type: 'bar',
|
|
||||||
dataType: 'value',
|
|
||||||
color: '#3ba272',
|
|
||||||
label: '李四',
|
|
||||||
showBackground: true,
|
|
||||||
backgroundStyle: {
|
|
||||||
color: '#e5e2e2',
|
|
||||||
borderWidth: 0,
|
|
||||||
borderColor: '#000',
|
|
||||||
borderType: 'dashed',
|
|
||||||
},
|
|
||||||
data: [140, 180, 120, 40, 50, 150]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 4,
|
|
||||||
unit: '销售金额',
|
|
||||||
type: 'bar',
|
|
||||||
dataType: 'value',
|
|
||||||
color: '#2644a4',
|
|
||||||
label: '张三',
|
|
||||||
showBackground: true,
|
|
||||||
backgroundStyle: {
|
|
||||||
color: '#e5e2e2',
|
|
||||||
borderWidth: 0,
|
|
||||||
borderColor: '#000',
|
|
||||||
borderType: 'solid',
|
|
||||||
},
|
|
||||||
data: [110, 143, 68, 90, 120, 130]
|
|
||||||
}
|
|
||||||
])
|
|
||||||
const pieChartsItem = ref([
|
|
||||||
{id: 1, label: '京东', dataType: 'value', value: 335},
|
|
||||||
{id: 2, label: '菜鸟', dataType: 'value', value: 310},
|
|
||||||
{id: 3, label: '总部', dataType: 'value', value: 234},
|
|
||||||
{id: 4, label: '小电商', dataType: 'value', value: 135},
|
|
||||||
])
|
|
||||||
const radarChartsItem = ref([
|
|
||||||
{label: 'Allocated Budget', dataType: 'value', data: [4200, 3000, 20000, 35000, 50000, 18000]},
|
|
||||||
{label: 'Actual Spending', dataType: 'value', data: [5000, 14000, 28000, 26000, 42000, 21000]},
|
|
||||||
])
|
|
||||||
//定义好echarts的配置数据
|
|
||||||
let initInfo = reactive({
|
|
||||||
xValueAxis: [],
|
|
||||||
yValueAxis: [],
|
|
||||||
//echarts配置数据
|
|
||||||
echartsOptions: {
|
|
||||||
//图例
|
|
||||||
legend: {
|
|
||||||
data: [],
|
|
||||||
selected: {},
|
|
||||||
selectedMode: false
|
|
||||||
},
|
|
||||||
//离容器四侧的距离
|
|
||||||
grid: {
|
|
||||||
left: 40, // 左边距
|
|
||||||
right: 60, // 右边距
|
|
||||||
top: 40, // 顶边距
|
|
||||||
bottom: 20, // 底边距
|
|
||||||
// containLabel: true,
|
|
||||||
},
|
|
||||||
//提示框组件
|
|
||||||
tooltip: {
|
|
||||||
show: true,
|
|
||||||
trigger: 'axis'
|
|
||||||
},
|
|
||||||
//工具栏
|
|
||||||
// toolbox: {
|
|
||||||
// feature: {
|
|
||||||
// //重置按钮显示
|
|
||||||
// restore: {
|
|
||||||
// show: true,
|
|
||||||
// title: '重置'
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
//X轴
|
|
||||||
xAxis: {
|
|
||||||
name: '',
|
|
||||||
type: 'category',
|
|
||||||
data: [],
|
|
||||||
axisLine: {
|
|
||||||
show: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
//Y轴
|
|
||||||
yAxis: {
|
|
||||||
name: '',
|
|
||||||
type: 'value',
|
|
||||||
data: [],
|
|
||||||
axisLine: {
|
|
||||||
show: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
radar: {
|
|
||||||
// shape: 'circle',
|
|
||||||
},
|
|
||||||
//配置项
|
|
||||||
series: []
|
|
||||||
}
|
|
||||||
})
|
|
||||||
const indicator= ref([
|
|
||||||
{ name: 'Sales', max: 6500 },
|
|
||||||
{ name: 'Administration', max: 16000 },
|
|
||||||
{ name: 'Information Technology', max: 30000 },
|
|
||||||
{ name: 'Customer Support', max: 38000 },
|
|
||||||
{ name: 'Development', max: 52000 },
|
|
||||||
{ name: 'Marketing', max: 25000 }
|
|
||||||
])
|
|
||||||
//获取到拖拽后的数据
|
|
||||||
const getFinalInfo = (val) => {
|
|
||||||
// console.log('父组件获取最终数据', val)
|
|
||||||
if (val !== undefined) {
|
|
||||||
initInfo = val
|
|
||||||
}
|
|
||||||
}
|
|
||||||
getFinalInfo()
|
|
||||||
</script>
|
|
||||||
@@ -1,538 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div>
|
|
||||||
<el-card class="box-card box-card-h">
|
|
||||||
<el-row justify="space-between" class="x-y-axis">
|
|
||||||
<el-text>值轴/{{ boxName }}</el-text>
|
|
||||||
<el-tooltip
|
|
||||||
effect="dark"
|
|
||||||
:content="boxName+',数据类型必须一致!'"
|
|
||||||
placement="bottom"
|
|
||||||
>
|
|
||||||
<el-icon>
|
|
||||||
<Warning/>
|
|
||||||
</el-icon>
|
|
||||||
</el-tooltip>
|
|
||||||
</el-row>
|
|
||||||
<div class="drag-block">
|
|
||||||
<draggable
|
|
||||||
class="list-group"
|
|
||||||
:list="dragList"
|
|
||||||
itemKey="id"
|
|
||||||
:group="group"
|
|
||||||
@start="startDrag"
|
|
||||||
@change="dragChartItem"
|
|
||||||
>
|
|
||||||
<template #item="{ element,index }">
|
|
||||||
<div :id="element.dataType==='value'?'card_'+index:''" tabindex="1"
|
|
||||||
@click.stop="handleClickValueCard(element,index)">
|
|
||||||
<el-card shadow="hover" class="cards x-y-cards"
|
|
||||||
:style="{borderWidth:1,borderColor:element.dataType==='value'?element.color:'#e4e7ed'}">
|
|
||||||
<el-col :span="3">
|
|
||||||
<div>{{ element.label }}</div>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="13">
|
|
||||||
<div v-if="element.dataType==='value'" class="update-color">
|
|
||||||
<div class="update-color" @click.stop>
|
|
||||||
<span>图形:</span>
|
|
||||||
<el-color-picker v-model="element.color" :color="element.color"
|
|
||||||
@change="changeEchartsColor($event,index)" @active-change="handleActiveChange"/>
|
|
||||||
</div>
|
|
||||||
<div v-if="currentChart==='line'" class="update-color" @click.stop>
|
|
||||||
<span>阴影:</span>
|
|
||||||
<el-color-picker v-model="element.lineStyle.shadowColor" :color="element.lineStyle.shadowColor"
|
|
||||||
@change="changeShadowColor($event,index)" @active-change="handleActiveChange"/>
|
|
||||||
</div>
|
|
||||||
<div v-if="currentChart==='bar'" class="update-color" @click.stop>
|
|
||||||
<span>背景: </span>
|
|
||||||
<el-color-picker v-model="element.backgroundStyle.color" :color="element.backgroundStyle.color"
|
|
||||||
@change="changeBackgroundColor($event,index)" @active-change="handleActiveChange"/>
|
|
||||||
</div>
|
|
||||||
<div v-if="currentChart==='bar'" class="update-color" @click.stop>
|
|
||||||
<span >描边: </span>
|
|
||||||
<el-color-picker v-model="element.backgroundStyle.borderColor" :color="element.backgroundStyle.borderColor"
|
|
||||||
@change="changeBackgroundBorderColor($event,index)" @active-change="handleActiveChange"/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="4">
|
|
||||||
<div class="cards-right">
|
|
||||||
<span>{{ element.dataType }}</span>
|
|
||||||
<el-icon size="20" color="red" @click.stop="handleCancelAxis(element,index)"
|
|
||||||
style="cursor: pointer">
|
|
||||||
<CircleClose/>
|
|
||||||
</el-icon>
|
|
||||||
</div>
|
|
||||||
</el-col>
|
|
||||||
</el-card>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</draggable>
|
|
||||||
</div>
|
|
||||||
</el-card>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import draggable from 'vuedraggable'
|
|
||||||
|
|
||||||
const emit = defineEmits(["editBasicSettingList"])
|
|
||||||
const props = defineProps({
|
|
||||||
//box名字
|
|
||||||
boxName: {
|
|
||||||
type: String,
|
|
||||||
default: ''
|
|
||||||
},
|
|
||||||
//可供拖动的选项列表
|
|
||||||
dragOptions: {
|
|
||||||
type: Array,
|
|
||||||
default: []
|
|
||||||
},
|
|
||||||
//用于拖拽区域存放选项列表
|
|
||||||
dragList: {
|
|
||||||
type: Array,
|
|
||||||
default: []
|
|
||||||
},
|
|
||||||
//用于X轴区域存放拖动的选项
|
|
||||||
xAxisList: {
|
|
||||||
type: Array,
|
|
||||||
default: []
|
|
||||||
},
|
|
||||||
//用于Y轴区域存放拖动的选项
|
|
||||||
yAxisList: {
|
|
||||||
type: Array,
|
|
||||||
default: []
|
|
||||||
},
|
|
||||||
//标记正在拖动选项的数据类型是否value
|
|
||||||
flag: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false
|
|
||||||
},
|
|
||||||
//获取正在拖动选项的数据类型
|
|
||||||
startDataType: {
|
|
||||||
type: String,
|
|
||||||
default: ''
|
|
||||||
},
|
|
||||||
//初始化加载echarts函数
|
|
||||||
initCharts: {
|
|
||||||
type: Function,
|
|
||||||
default: null
|
|
||||||
},
|
|
||||||
//echarts的配置属性
|
|
||||||
chartOption: {
|
|
||||||
type: Array,
|
|
||||||
default: []
|
|
||||||
},
|
|
||||||
//当前echarts图形
|
|
||||||
currentChart: {
|
|
||||||
type: String,
|
|
||||||
default: 'line'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
//基础设置列表
|
|
||||||
const lineChartBasicSettingList = ref()
|
|
||||||
const barChartBasicSettingList = ref()
|
|
||||||
//选中类型为value的item所处的list列表
|
|
||||||
const valueCardInList = ref([])
|
|
||||||
//简化代码
|
|
||||||
let xList = reactive(props.xAxisList)
|
|
||||||
let yList = reactive(props.yAxisList)
|
|
||||||
let option = reactive(props.chartOption)
|
|
||||||
//路由刷新
|
|
||||||
const reload = inject("reload")
|
|
||||||
//自定义X/Y分组的拖入拖出事件
|
|
||||||
const group = ref({
|
|
||||||
name: 'people',
|
|
||||||
pull: true,
|
|
||||||
put: props.flag === true ? false : (props.boxName === 'X轴' ? () => handleGroupPut(xList, yList) : () => handleGroupPut(yList, xList))
|
|
||||||
})
|
|
||||||
//将改变的数据传到父组件
|
|
||||||
watch(() => lineChartBasicSettingList.value, (newVal) => {
|
|
||||||
emit("getLineChartBasicSettingList", newVal)
|
|
||||||
})
|
|
||||||
//将改变的数据传到父组件
|
|
||||||
watch(() => barChartBasicSettingList.value, (newVal) => {
|
|
||||||
emit("getBarChartBasicSettingList", newVal)
|
|
||||||
})
|
|
||||||
onMounted(() => {
|
|
||||||
document.addEventListener('click', nullBlockClick)
|
|
||||||
})
|
|
||||||
onBeforeUnmount(() => {
|
|
||||||
document.removeEventListener('click', nullBlockClick)
|
|
||||||
})
|
|
||||||
/**
|
|
||||||
* 设置chart的lineStyle
|
|
||||||
* @param sItem chartItem
|
|
||||||
* @param opacity 透明度
|
|
||||||
*/
|
|
||||||
const handleChangeLineStyle = (sItem, opacity) => {
|
|
||||||
sItem.lineStyle = {
|
|
||||||
shadowColor: sItem.lineStyle.shadowColor,
|
|
||||||
shadowBlur: sItem.lineStyle.shadowBlur,
|
|
||||||
opacity: opacity
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 用于取消charts选中透明度
|
|
||||||
*/
|
|
||||||
const handleChangeOpacity = (type, item) => {
|
|
||||||
if (props.currentChart === 'line') {
|
|
||||||
option.series.forEach((sItem) => {
|
|
||||||
if (type === 'more') {
|
|
||||||
if (sItem.name === item.label) {
|
|
||||||
handleChangeLineStyle(sItem, 1)
|
|
||||||
} else {
|
|
||||||
handleChangeLineStyle(sItem, 0.2)
|
|
||||||
}
|
|
||||||
} else if (type === 'single') {
|
|
||||||
handleChangeLineStyle(sItem, 1)
|
|
||||||
} else {
|
|
||||||
if (sItem.name !== item.label) {
|
|
||||||
handleChangeLineStyle(sItem, 1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 点击空白处, 清除选项选中状态
|
|
||||||
*/
|
|
||||||
const nullBlockClick = () => {
|
|
||||||
if (valueCardInList.value.length === 0) return;
|
|
||||||
valueCardInList.value.forEach((aItem, aIndex) => {
|
|
||||||
const card = document.getElementById('card_' + aIndex)
|
|
||||||
card.classList.remove('card-active')
|
|
||||||
})
|
|
||||||
clearBasicSetting()
|
|
||||||
//加载echarts
|
|
||||||
props.initCharts()
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 封装自定义X/Y分组的拖入事件
|
|
||||||
* @param aType 传入x/y区域数组
|
|
||||||
* @param bType 传入x/y区域数组
|
|
||||||
* @returns {boolean} 返回 true/false
|
|
||||||
*/
|
|
||||||
const handleGroupPut = (aType, bType) => {
|
|
||||||
let flag = false
|
|
||||||
let aLen = aType.length
|
|
||||||
let bLen = bType.length
|
|
||||||
if (aLen === 0 && bLen === 0) {
|
|
||||||
flag = props.startDataType === 'key';
|
|
||||||
} else if (aLen === 0 && bLen !== 0) {
|
|
||||||
flag = bType[0].dataType === 'key';
|
|
||||||
} else if (aLen !== 0 && bLen !== 0) {
|
|
||||||
const dragType = localStorage.getItem('dragType')
|
|
||||||
flag = props.startDataType === aType[0].dataType;
|
|
||||||
if (dragType === 'key') {
|
|
||||||
flag = aType[0].dataType !== 'value';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return flag
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 封装切换坐标轴数据类型为Category
|
|
||||||
* @param item 拖动的项
|
|
||||||
* @param label 坐标轴名称
|
|
||||||
* @param type 切换x/y轴
|
|
||||||
*/
|
|
||||||
const changeTypeToCategory = (item, label, type) => {
|
|
||||||
let axis
|
|
||||||
if (type === 'xAxis') {
|
|
||||||
axis = option.xAxis
|
|
||||||
} else {
|
|
||||||
axis = option.yAxis
|
|
||||||
}
|
|
||||||
axis.type = 'category'
|
|
||||||
axis.name = label
|
|
||||||
axis.data = item.data
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 封装清除坐标轴数据
|
|
||||||
* @param type 标志清除x/y轴
|
|
||||||
*/
|
|
||||||
const clearAxisData = (type) => {
|
|
||||||
let axis
|
|
||||||
if (type === 'xAxis') {
|
|
||||||
axis = option.xAxis
|
|
||||||
} else {
|
|
||||||
axis = option.yAxis
|
|
||||||
}
|
|
||||||
axis.name = ''
|
|
||||||
axis.data = []
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 封装key拖入左侧时的重置事件
|
|
||||||
* @param aList x/yList
|
|
||||||
* @param type x/yAxis
|
|
||||||
* @param item 选项item
|
|
||||||
* @param label 选项名
|
|
||||||
*/
|
|
||||||
const restoreChart = (aList, type,item,label) => {
|
|
||||||
let axis
|
|
||||||
if (type === 'xAxis') {
|
|
||||||
axis = option.xAxis
|
|
||||||
} else {
|
|
||||||
axis = option.yAxis
|
|
||||||
}
|
|
||||||
if (aList[0].dataType === 'value') {
|
|
||||||
aList.map((item) => {
|
|
||||||
props.dragOptions.unshift(item)
|
|
||||||
option.legend.selected[item.label] = false
|
|
||||||
})
|
|
||||||
aList.splice(0, aList.length)
|
|
||||||
option.legend.data.splice(0, option.legend.data.length)
|
|
||||||
option.series.splice(0, option.series.length)
|
|
||||||
axis.name = ''
|
|
||||||
option.xAxis.type = 'category'
|
|
||||||
option.yAxis.type = 'value'
|
|
||||||
} else {
|
|
||||||
changeTypeToCategory(item, label, type)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 拖拽类型为key的选项事件
|
|
||||||
* @param item 选项item
|
|
||||||
* @param label 选项名
|
|
||||||
*/
|
|
||||||
const dragTypeToKey = (item, label) => {
|
|
||||||
if (xList.length !== 0 && yList.length === 0) {
|
|
||||||
restoreChart(xList, 'xAxis',item,label)
|
|
||||||
clearAxisData('yAxis')
|
|
||||||
} else if (xList.length === 0 && yList.length !== 0) {
|
|
||||||
restoreChart(yList, 'yAxis',item,label)
|
|
||||||
clearAxisData('xAxis')
|
|
||||||
} else if (xList.length === 0 && yList.length === 0) {
|
|
||||||
//移入左侧待选列表
|
|
||||||
clearAxisData('xAxis')
|
|
||||||
clearAxisData('yAxis')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 拖拽类型为value的选项事件
|
|
||||||
* @param label 选项名
|
|
||||||
*/
|
|
||||||
const dragTypeToValue = (label) => {
|
|
||||||
//删除选中选项的图例
|
|
||||||
const legendIndex = option.legend.data.findIndex(object => object === label);
|
|
||||||
option.legend.data.splice(legendIndex, 1)
|
|
||||||
//删除echarts配置项series中符合该拖拽选项的item
|
|
||||||
const objectIndex = option.series.findIndex(object => object.name === label);
|
|
||||||
option.legend.selected[label] = false
|
|
||||||
option.series.splice(objectIndex, 1)
|
|
||||||
if (xList.length === 0) {
|
|
||||||
option.xAxis.name = ''
|
|
||||||
} else if (yList.length === 0) {
|
|
||||||
option.yAxis.name = ''
|
|
||||||
}
|
|
||||||
clearBasicSetting()
|
|
||||||
handleDeleteClassName(xList, yList)
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 封装清空基本设置
|
|
||||||
*/
|
|
||||||
const clearBasicSetting=()=>{
|
|
||||||
if(props.currentChart==='line'){
|
|
||||||
lineChartBasicSettingList.value = []
|
|
||||||
handleChangeOpacity('single')
|
|
||||||
}else if(props.currentChart==='bar'){
|
|
||||||
barChartBasicSettingList.value=[]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 开始拖拽事件
|
|
||||||
* @param event event事件
|
|
||||||
*/
|
|
||||||
const startDrag = (event) => {
|
|
||||||
localStorage.setItem('dragType', event.item._underlying_vm_.dataType)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 从X轴/Y轴区域移动选项到左/右侧结束事件
|
|
||||||
* @param event event事件
|
|
||||||
*/
|
|
||||||
const dragChartItem = (event) => {
|
|
||||||
if (event.removed === undefined) return;
|
|
||||||
let item = event.removed.element
|
|
||||||
let label = item.label
|
|
||||||
//拖动key的选项
|
|
||||||
if (item.dataType === "key") {
|
|
||||||
dragTypeToKey(item, label)
|
|
||||||
} else {
|
|
||||||
dragTypeToValue(label)
|
|
||||||
}
|
|
||||||
props.initCharts()
|
|
||||||
localStorage.removeItem('dragType')
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 选中数据类型为value的点击事件
|
|
||||||
* @param item 点击的选项item
|
|
||||||
* @param index 点击选项的下标
|
|
||||||
*/
|
|
||||||
const handleClickValueCard = (item, index) => {
|
|
||||||
document.addEventListener('click', nullBlockClick)
|
|
||||||
if (item.dataType === 'value' ) {
|
|
||||||
if(props.currentChart === 'line'){
|
|
||||||
changeCardActive(props.dragList, item)
|
|
||||||
lineChartBasicSettingList.value = [item]
|
|
||||||
}else if(props.currentChart === 'bar'){
|
|
||||||
changeCardActive(props.dragList, item)
|
|
||||||
barChartBasicSettingList.value = [item]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
props.initCharts()
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 封装选中类型为value的数据高亮
|
|
||||||
* @param list x/y区域list
|
|
||||||
* @param item 点击选项的item
|
|
||||||
*/
|
|
||||||
const changeCardActive = (list, item) => {
|
|
||||||
valueCardInList.value = list
|
|
||||||
emit('getCardActiveList',list)
|
|
||||||
if (list.length !== 0 && list[0].dataType === 'value') {
|
|
||||||
handleChangeOpacity('more', item)
|
|
||||||
list.forEach((aItem, aIndex) => {
|
|
||||||
const card = document.getElementById('card_' + aIndex)
|
|
||||||
if (aItem.label === item.label) {
|
|
||||||
card.classList.add('card-active')
|
|
||||||
} else {
|
|
||||||
card.classList.remove('card-active')
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 基础设置: 修改echarts数据颜色
|
|
||||||
* @param val 修改的标记大小
|
|
||||||
* @param index 修改的chart项下标
|
|
||||||
*/
|
|
||||||
const changeEchartsColor = (val, index) => {
|
|
||||||
document.addEventListener('click', nullBlockClick)
|
|
||||||
option.series[index].color = val
|
|
||||||
props.initCharts()
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 当选择颜色时移除空白点击事件
|
|
||||||
*/
|
|
||||||
const handleActiveChange = () => {
|
|
||||||
document.removeEventListener('click', nullBlockClick)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 基础设置: 修改echarts数据颜色
|
|
||||||
* @param val 修改的标记大小
|
|
||||||
* @param index 修改的chart项下标
|
|
||||||
*/
|
|
||||||
const changeShadowColor = (val, index) => {
|
|
||||||
option.series[index].lineStyle.shadowColor = val
|
|
||||||
props.initCharts()
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 基础设置:修改柱条背景颜色
|
|
||||||
* @param val 柱条颜色
|
|
||||||
* @param index 修改的chart项下标
|
|
||||||
*/
|
|
||||||
const changeBackgroundColor = (val, index) => {
|
|
||||||
option.series[index].backgroundStyle.color = val
|
|
||||||
props.initCharts()
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 基础设置:修改柱条描边颜色
|
|
||||||
* @param val 柱条描边颜色
|
|
||||||
* @param index 修改的chart项下标
|
|
||||||
*/
|
|
||||||
const changeBackgroundBorderColor = (val, index) => {
|
|
||||||
option.series[index].backgroundStyle.borderColor = val
|
|
||||||
props.initCharts()
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 封装从右侧区域拖出事件
|
|
||||||
* @param element 获取点击该拖出的选项事件
|
|
||||||
* @param index 点击该拖出选项的索引
|
|
||||||
* @param aList x/y区域的值
|
|
||||||
* @param bList x/y区域的值
|
|
||||||
* @param aAxis echarts配置项的x/y轴
|
|
||||||
* @param bAxis echarts配置项的x/y轴
|
|
||||||
*/
|
|
||||||
const handleCancel = (element, index, aList, bList, aAxis, bAxis) => {
|
|
||||||
aList.splice(index, 1)
|
|
||||||
props.dragOptions.push(element)
|
|
||||||
if (element.dataType === "key") {
|
|
||||||
aAxis.name = ''
|
|
||||||
aAxis.data = []
|
|
||||||
bAxis.name=''
|
|
||||||
bList.map((item) => {
|
|
||||||
props.dragOptions.unshift(item)
|
|
||||||
option.legend.selected[item.label] = false
|
|
||||||
})
|
|
||||||
bList.splice(0, bList.length)
|
|
||||||
option.legend.data.splice(0, option.legend.data.length)
|
|
||||||
option.series.splice(0, option.series.length)
|
|
||||||
// reload
|
|
||||||
props.initCharts()
|
|
||||||
} else {
|
|
||||||
if (bList.length !== 0 && aList.length === 0) {
|
|
||||||
if (bList[0].dataType === 'key') {
|
|
||||||
aAxis.name = ''
|
|
||||||
} else {
|
|
||||||
bAxis.name = ''
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
option.legend.data.splice(index, 1)
|
|
||||||
const objectIndex = option.series.findIndex(object => object.name === element.label);
|
|
||||||
option.legend.selected[element.label] = false
|
|
||||||
option.series.splice(objectIndex, 1)
|
|
||||||
props.initCharts()
|
|
||||||
}
|
|
||||||
if(props.currentChart==='line'){
|
|
||||||
handleChangeOpacity('not', element)
|
|
||||||
if (lineChartBasicSettingList.value === undefined) return;
|
|
||||||
lineChartBasicSettingList.value.splice(0, 1)
|
|
||||||
}else if(props.currentChart==='bar'){
|
|
||||||
if (barChartBasicSettingList.value === undefined) return;
|
|
||||||
barChartBasicSettingList.value.splice(0, 1)
|
|
||||||
}
|
|
||||||
// const basicIndex = lineChartBasicSettingList.value.findIndex(object => object.label === element.label)
|
|
||||||
// if (basicIndex !== -1) {
|
|
||||||
// lineChartBasicSettingList.value.splice(basicIndex, 1)
|
|
||||||
// }
|
|
||||||
handleDeleteClassName(aList, bList)
|
|
||||||
props.initCharts()
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 拖拽选项后,清除选中选项阴影
|
|
||||||
* @param aList x/y list
|
|
||||||
* @param bList x/y list
|
|
||||||
*/
|
|
||||||
const handleDeleteClassName = (aList, bList) => {
|
|
||||||
let axis = []
|
|
||||||
if (aList.length !== 0 && aList[0].dataType === 'value') {
|
|
||||||
axis = aList
|
|
||||||
} else if (bList.length !== 0 && bList[0].dataType === 'value') {
|
|
||||||
axis = bList
|
|
||||||
}
|
|
||||||
axis.forEach((aItem, aIndex) => {
|
|
||||||
const card = document.getElementById('card_' + aIndex)
|
|
||||||
card.classList.remove('card-active')
|
|
||||||
})
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 从右侧x/y轴区域取消选项
|
|
||||||
* @param element 该取消的项
|
|
||||||
* @param index 该取消项的下标
|
|
||||||
*/
|
|
||||||
const handleCancelAxis = (element, index) => {
|
|
||||||
if (props.boxName === 'X轴') {
|
|
||||||
handleCancel(element, index, xList, yList, option.xAxis, option.yAxis)
|
|
||||||
} else {
|
|
||||||
handleCancel(element, index, yList, xList, option.yAxis, option.xAxis)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
@@ -1,307 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div>
|
|
||||||
<el-card class="box-card">
|
|
||||||
<div class="drag-block">
|
|
||||||
<draggable
|
|
||||||
class="list-group"
|
|
||||||
:list="dragOptions"
|
|
||||||
itemKey="id"
|
|
||||||
group="people"
|
|
||||||
@start="startDrag"
|
|
||||||
@change="changeChartItem"
|
|
||||||
>
|
|
||||||
<template #item="{element}">
|
|
||||||
<el-card shadow="hover" class="cards">
|
|
||||||
<el-row justify="space-between">
|
|
||||||
<span>{{ element.label }}</span>
|
|
||||||
<span>{{ element.dataType }}</span>
|
|
||||||
</el-row>
|
|
||||||
</el-card>
|
|
||||||
</template>
|
|
||||||
</draggable>
|
|
||||||
</div>
|
|
||||||
</el-card>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import draggable from 'vuedraggable'
|
|
||||||
import {ElMessage} from "element-plus";
|
|
||||||
|
|
||||||
const emit = defineEmits(["editValueFlag", "editStartDataType"])
|
|
||||||
const props = defineProps({
|
|
||||||
//可供拖动的选项列表
|
|
||||||
dragOptions: {
|
|
||||||
type: Array,
|
|
||||||
default: []
|
|
||||||
},
|
|
||||||
//echarts的配置属性
|
|
||||||
chartOption: {
|
|
||||||
type: Object,
|
|
||||||
default: {}
|
|
||||||
},
|
|
||||||
//初始化加载echarts函数
|
|
||||||
initCharts: {
|
|
||||||
type: Function,
|
|
||||||
default: null
|
|
||||||
},
|
|
||||||
//用于X轴区域存放拖动的选项
|
|
||||||
xAxisList: {
|
|
||||||
type: Array,
|
|
||||||
default: []
|
|
||||||
},
|
|
||||||
//用于Y轴区域存放拖动的选项
|
|
||||||
yAxisList: {
|
|
||||||
type: Array,
|
|
||||||
default: []
|
|
||||||
},
|
|
||||||
//当前echarts图形
|
|
||||||
currentChart: {
|
|
||||||
type: String,
|
|
||||||
default: 'line'
|
|
||||||
},
|
|
||||||
//雷达图指示器
|
|
||||||
radarIndicator: {
|
|
||||||
type: Array,
|
|
||||||
default: []
|
|
||||||
}
|
|
||||||
})
|
|
||||||
//简化代码
|
|
||||||
let xList = reactive(props.xAxisList)
|
|
||||||
let yList = reactive(props.yAxisList)
|
|
||||||
let option = reactive(props.chartOption)
|
|
||||||
let chart = reactive(props.currentChart)
|
|
||||||
//获取正在拖动选项的数据类型
|
|
||||||
const startDragType = ref()
|
|
||||||
//标记正在拖动选项的数据类型是否value
|
|
||||||
const flag = ref(false)
|
|
||||||
//将改变的数据传到父组件
|
|
||||||
watch(() => flag.value, (newVal) => {
|
|
||||||
emit("editValueFlag", newVal)
|
|
||||||
})
|
|
||||||
watch(() => props.currentChart, (newVal) => {
|
|
||||||
chart = newVal
|
|
||||||
})
|
|
||||||
watch(() => startDragType.value, (newVal) => {
|
|
||||||
emit("editStartDataType", newVal)
|
|
||||||
})
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置修改后的echarts属性
|
|
||||||
* @param item 拖动的项
|
|
||||||
* @param label 拖拽选项的名称
|
|
||||||
* @returns Object
|
|
||||||
*/
|
|
||||||
const settingChartItem = (item, label) => {
|
|
||||||
if (chart === 'line') {
|
|
||||||
return {
|
|
||||||
id: item.id,//组件 ID
|
|
||||||
name: label,
|
|
||||||
// type: echartsValue.value ? echartsValue.value : item.type,
|
|
||||||
type: chart,
|
|
||||||
data: item.data,
|
|
||||||
smooth: true,
|
|
||||||
color: item.color,
|
|
||||||
symbol: item.symbol,
|
|
||||||
symbolSize: item.symbolSize,
|
|
||||||
showSymbol: item.showSymbol,
|
|
||||||
lineStyle: item.lineStyle,
|
|
||||||
// emphasis: item.emphasis
|
|
||||||
}
|
|
||||||
} else if (chart === 'bar') {
|
|
||||||
return {
|
|
||||||
id: item.id,
|
|
||||||
name: label,
|
|
||||||
type: chart,
|
|
||||||
data: item.data,
|
|
||||||
color: item.color,
|
|
||||||
showBackground: item.showBackground,
|
|
||||||
backgroundStyle: item.backgroundStyle
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 封拖拽数据类型为value
|
|
||||||
* @param item 拖动的项
|
|
||||||
* @param label 拖拽选项的名称
|
|
||||||
* @param selectedObj 图例选中状态表
|
|
||||||
*/
|
|
||||||
const dragValue = (item, label, selectedObj) => {
|
|
||||||
dragChart(item, label, 2)
|
|
||||||
option.legend.data.push(label)
|
|
||||||
let chartItem = settingChartItem(item, label)
|
|
||||||
option.series.push(chartItem)
|
|
||||||
for (const propertyName in selectedObj) {
|
|
||||||
if (propertyName === label) {
|
|
||||||
selectedObj[propertyName] = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 封装切换坐标轴数据类型为Category
|
|
||||||
* @param item 拖动的项
|
|
||||||
* @param label 坐标轴名称
|
|
||||||
* @param type 切换x/y轴
|
|
||||||
*/
|
|
||||||
const changeTypeToCategory = (item, label, type) => {
|
|
||||||
let axis
|
|
||||||
if (type === 'xAxis') {
|
|
||||||
axis = option.xAxis
|
|
||||||
} else {
|
|
||||||
axis = option.yAxis
|
|
||||||
}
|
|
||||||
axis.type = 'category'
|
|
||||||
axis.name = item.unit
|
|
||||||
axis.data = item.data
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 封装切换坐标轴数据类型为Value
|
|
||||||
* @param item 拖动的项item
|
|
||||||
* @param type 切换x/y轴
|
|
||||||
*/
|
|
||||||
const changeTypeToValue = (item, type) => {
|
|
||||||
let axis
|
|
||||||
if (type === 'xAxis') {
|
|
||||||
axis = option.xAxis
|
|
||||||
} else {
|
|
||||||
axis = option.yAxis
|
|
||||||
}
|
|
||||||
axis.type = 'value'
|
|
||||||
axis.name = item.unit
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 封装拖拽选项修改echarts属性
|
|
||||||
* @param item 拖动的项
|
|
||||||
* @param label 拖拽选项的名称
|
|
||||||
* @param index 区分拖的选项数据:1是key,2是value
|
|
||||||
*/
|
|
||||||
const dragChart = (item, label, index) => {
|
|
||||||
if (xList.length !== 0 && yList.length === 0) {
|
|
||||||
// console.log('x轴有值')
|
|
||||||
if (index === 1) {
|
|
||||||
changeTypeToCategory(item, label, 'xAxis')
|
|
||||||
} else {
|
|
||||||
changeTypeToValue(item, 'xAxis')
|
|
||||||
option.yAxis.type = 'category'
|
|
||||||
}
|
|
||||||
} else if (xList.length !== 0 && yList.length !== 0) {
|
|
||||||
// console.log('xy有值')
|
|
||||||
if (xList[0].dataType === 'value') {
|
|
||||||
if (index === 1) {
|
|
||||||
changeTypeToCategory(item, label)
|
|
||||||
}
|
|
||||||
changeTypeToValue(item, 'xAxis')
|
|
||||||
} else if (yList[0].dataType === 'value') {
|
|
||||||
if (index === 1) {
|
|
||||||
changeTypeToCategory(item, label, 'xAxis')
|
|
||||||
}
|
|
||||||
changeTypeToValue(item)
|
|
||||||
}
|
|
||||||
} else if (xList.length === 0 && yList.length !== 0) {
|
|
||||||
// console.log('y轴有值')
|
|
||||||
if (index === 1) {
|
|
||||||
changeTypeToCategory(item, label, 'yAxis')
|
|
||||||
} else {
|
|
||||||
option.xAxis.type = 'category'
|
|
||||||
changeTypeToValue(item)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 从左侧区域移动选项到右侧
|
|
||||||
* @param event 拖拽成功event事件
|
|
||||||
*/
|
|
||||||
const changeChartItem = (event) => {
|
|
||||||
if (event.removed === undefined) return;
|
|
||||||
let item = event.removed.element
|
|
||||||
if (chart === 'line'||chart === 'bar') {
|
|
||||||
let label = item.label
|
|
||||||
let selectedObj = option.legend.selected
|
|
||||||
if (item.dataType === "key") {
|
|
||||||
dragChart(item, label, 1)
|
|
||||||
} else {
|
|
||||||
if (flag.value) return;
|
|
||||||
dragValue(item, label, selectedObj)
|
|
||||||
}
|
|
||||||
} else if (chart === 'pie') {
|
|
||||||
let arr = []
|
|
||||||
xList.forEach(item => {
|
|
||||||
let obj = {
|
|
||||||
name: item.label,
|
|
||||||
value: item.value
|
|
||||||
}
|
|
||||||
arr.push(obj)
|
|
||||||
})
|
|
||||||
for (const propertyName in option.legend.selected) {
|
|
||||||
if (propertyName === item.label) {
|
|
||||||
option.legend.selected[propertyName] = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (item.dataType !== "key") {
|
|
||||||
option.legend.data.push(item.label)
|
|
||||||
}
|
|
||||||
option.series = [
|
|
||||||
{
|
|
||||||
type: 'pie',
|
|
||||||
radius: '50%',
|
|
||||||
data: arr
|
|
||||||
}
|
|
||||||
]
|
|
||||||
} else if (chart === 'radar') {
|
|
||||||
let arr = []
|
|
||||||
xList.forEach(item => {
|
|
||||||
let obj = {
|
|
||||||
name: item.label,
|
|
||||||
value: item.data
|
|
||||||
}
|
|
||||||
arr.push(obj)
|
|
||||||
})
|
|
||||||
console.log('arr',arr)
|
|
||||||
for (const propertyName in option.legend.selected) {
|
|
||||||
if (propertyName === item.label) {
|
|
||||||
option.legend.selected[propertyName] = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (item.dataType !== "key") {
|
|
||||||
option.legend.data.push(item.label)
|
|
||||||
}
|
|
||||||
option.radar={
|
|
||||||
indicator:props.radarIndicator
|
|
||||||
}
|
|
||||||
option.series = [
|
|
||||||
{
|
|
||||||
type: 'radar',
|
|
||||||
data: arr
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
props.initCharts()
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 左侧区域开始拖拽事件
|
|
||||||
* @param event 开始拖拽的event事件
|
|
||||||
*/
|
|
||||||
const startDrag = (event) => {
|
|
||||||
startDragType.value = event.item._underlying_vm_.dataType
|
|
||||||
if (xList.length === 0 && yList.length === 0) {
|
|
||||||
if (chart === 'line' || chart === 'bar') {
|
|
||||||
if (startDragType.value === "value") {
|
|
||||||
flag.value = true
|
|
||||||
ElMessage({
|
|
||||||
message: '请先拖动数据类型为key的选项到x轴/y轴.',
|
|
||||||
type: 'warning',
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
flag.value = false
|
|
||||||
}
|
|
||||||
} else if (chart === 'pie') {
|
|
||||||
console.log('拖动饼图')
|
|
||||||
flag.value = false
|
|
||||||
}else if (chart === 'radar') {
|
|
||||||
console.log('拖动雷达')
|
|
||||||
flag.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
@@ -1,307 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div>
|
|
||||||
<el-row :gutter="6">
|
|
||||||
<el-col :span="6">
|
|
||||||
<el-select v-model="echartsValue" filterable placeholder="请选择图形状" style="width: 100%" size="large"
|
|
||||||
@change="handleChangeEcharts">
|
|
||||||
<el-option v-for="chartItem in chartType"
|
|
||||||
:key="chartItem.value"
|
|
||||||
:label="chartItem.label"
|
|
||||||
:value="chartItem.value"/>
|
|
||||||
</el-select>
|
|
||||||
<!--左侧选项区域-->
|
|
||||||
<charts-options @editValueFlag="editValueFlag" @editStartDataType="editStartDataType"
|
|
||||||
:drag-options="ChartsItem" :chart-option="option" :init-charts="initChart"
|
|
||||||
:x-axis-list="xValueAxis" :y-axis-list="yValueAxis"
|
|
||||||
:current-chart="echartsValue" :radar-indicator="radarIndicator"/>
|
|
||||||
</el-col>
|
|
||||||
<!--X轴区域-->
|
|
||||||
<el-col :span="9" v-if="echartsValue==='bar'||echartsValue==='line'">
|
|
||||||
<axis-box :box-name="'X轴'" :drag-list="xValueAxis" :drag-options="ChartsItem" :x-axis-list="xValueAxis"
|
|
||||||
:y-axis-list="yValueAxis" :flag="valueFlag"
|
|
||||||
:start-data-type="startDataType" :chart-option="option" :init-charts="initChart"
|
|
||||||
@getLineChartBasicSettingList="getLineChartBasicSettingList"
|
|
||||||
@getBarChartBasicSettingList="getBarChartBasicSettingList" :current-chart="echartsValue"/>
|
|
||||||
</el-col>
|
|
||||||
<!--Y轴区域-->
|
|
||||||
<el-col :span="9" v-if="echartsValue==='bar'||echartsValue==='line'">
|
|
||||||
<axis-box :box-name="'Y轴'" :drag-list="yValueAxis" :drag-options="ChartsItem" :x-axis-list="xValueAxis"
|
|
||||||
:y-axis-list="yValueAxis" :flag="valueFlag"
|
|
||||||
:start-data-type="startDataType" :chart-option="option" :init-charts="initChart"
|
|
||||||
@getLineChartBasicSettingList="getLineChartBasicSettingList"
|
|
||||||
@getBarChartBasicSettingList="getBarChartBasicSettingList" :current-chart="echartsValue"/>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="9" v-if="echartsValue==='pie'">
|
|
||||||
<pie-box :drag-list="xValueAxis" :init-charts="initChart" :chart-option="option"/>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="9" v-if="echartsValue==='radar'">
|
|
||||||
<radar-box :drag-list="xValueAxis" :init-charts="initChart" :chart-option="option"/>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
<el-button @click.stop="saveData">保存</el-button>
|
|
||||||
<el-button v-if="echartsValue==='line'" @click.stop="openAdvancedSettings">高级设置</el-button>
|
|
||||||
<el-row :gutter="6">
|
|
||||||
<el-col :span="16">
|
|
||||||
<div id="container" ref="chart" @click.stop></div>
|
|
||||||
</el-col>
|
|
||||||
<!--基础设置-->
|
|
||||||
<el-col :span="8">
|
|
||||||
<!-- 折线图基础设置-->
|
|
||||||
<line-chart-basic-setting v-if="echartsValue==='line'" :basic-list="lineChartBasicSettingList"
|
|
||||||
:init-charts="initChart"
|
|
||||||
:chart-option="option"/>
|
|
||||||
<!-- 柱状图基础设置-->
|
|
||||||
<bar-chart-basic-setting v-if="echartsValue==='bar'" :basic-list="barChartBasicSettingList"
|
|
||||||
:init-charts="initChart"
|
|
||||||
:chart-option="option"/>
|
|
||||||
<!-- 饼图基础设置-->
|
|
||||||
<!-- <pie-chart-basic-setting v-if="echartsValue==='pie'"/>-->
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
<!--高级设置-->
|
|
||||||
<!-- 折线图高级设置-->
|
|
||||||
<line-chart-advanced-settings v-if="echartsValue==='line'" ref="advancedSettings" :init-charts="initChart"
|
|
||||||
:chart-option="option"/>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import * as echarts from 'echarts'
|
|
||||||
import draggable from 'vuedraggable'
|
|
||||||
import ChartsOptions from "./ChartsOptions.vue";
|
|
||||||
import AxisBox from "./AxisBox.vue";
|
|
||||||
import LineChartBasicSetting from "./lineChart/BasicSetting.vue";
|
|
||||||
import LineChartAdvancedSettings from "./lineChart/AdvancedSettings.vue";
|
|
||||||
import BarChartBasicSetting from "./barChart/BasicSetting.vue";
|
|
||||||
// import PieChartBasicSetting from "./pieChart/BasicSetting.vue";
|
|
||||||
import PieBox from "./pieChart/PieBox.vue";
|
|
||||||
import RadarBox from "./radarChart/RadarBox.vue";
|
|
||||||
// import BarChartAdvancedSettings from "./barChart/AdvancedSettings.vue";
|
|
||||||
|
|
||||||
const emit = defineEmits(["getFinalInfo"])
|
|
||||||
const props = defineProps({
|
|
||||||
info: {
|
|
||||||
type: Object,
|
|
||||||
default: {}
|
|
||||||
},
|
|
||||||
lineData: {
|
|
||||||
type: Array,
|
|
||||||
default: []
|
|
||||||
},
|
|
||||||
barData: {
|
|
||||||
type: Array,
|
|
||||||
default: []
|
|
||||||
},
|
|
||||||
pieData: {
|
|
||||||
type: Array,
|
|
||||||
default: []
|
|
||||||
},
|
|
||||||
radarData: {
|
|
||||||
type: Array,
|
|
||||||
default: []
|
|
||||||
},
|
|
||||||
radarIndicator: {
|
|
||||||
type: Array,
|
|
||||||
default: []
|
|
||||||
}
|
|
||||||
})
|
|
||||||
//图形: 1:折线图 2.柱状图 3.饼图
|
|
||||||
const chartType = reactive([
|
|
||||||
{
|
|
||||||
value: 'line',
|
|
||||||
label: '折线图',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: 'bar',
|
|
||||||
label: '柱状图',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: 'pie',
|
|
||||||
label: '饼图',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
value: 'radar',
|
|
||||||
label: '雷达图',
|
|
||||||
}
|
|
||||||
])
|
|
||||||
//基础设置列表
|
|
||||||
const lineChartBasicSettingList = ref([])
|
|
||||||
const barChartBasicSettingList = ref([])
|
|
||||||
const advancedSettings = ref()
|
|
||||||
//获取父组件传来的初始数据
|
|
||||||
const initInfo = reactive(props.info)
|
|
||||||
//从左侧获取拖动的选项的数据类型
|
|
||||||
const startDataType = ref()
|
|
||||||
//标记从左侧拖动选项数据类型是否是value
|
|
||||||
const valueFlag = ref(false)
|
|
||||||
//简化代码
|
|
||||||
let xValueAxis = reactive(initInfo.xValueAxis)
|
|
||||||
let yValueAxis = reactive(initInfo.yValueAxis)
|
|
||||||
const line_data = reactive(props.lineData)
|
|
||||||
const bar_data = reactive(props.barData)
|
|
||||||
const pie_data = reactive(props.pieData)
|
|
||||||
const radar_data = reactive(props.radarData)
|
|
||||||
let option = reactive(initInfo.echartsOptions)
|
|
||||||
|
|
||||||
//页面左上角select选择框绑定数据
|
|
||||||
const echartsValue = ref('line')
|
|
||||||
//可供拖动的选项列表
|
|
||||||
const ChartsItem = ref([])
|
|
||||||
//获取到container容器实例
|
|
||||||
const chart = ref(null);
|
|
||||||
//定义echarts实例
|
|
||||||
let myEcharts = reactive({});
|
|
||||||
onMounted(() => {
|
|
||||||
if (ChartsItem.value.length === 0) {
|
|
||||||
ChartsItem.value = line_data
|
|
||||||
}
|
|
||||||
//初始化echarts(不显示图)
|
|
||||||
let selectLegend = {}
|
|
||||||
ChartsItem.value.forEach(item => {
|
|
||||||
if (item.dataType !== 'key') {
|
|
||||||
selectLegend[item.label] = false
|
|
||||||
}
|
|
||||||
})
|
|
||||||
option.legend.selected = selectLegend
|
|
||||||
if (echartsValue.value === 'pie'||echartsValue.value === 'radar') {
|
|
||||||
isShowAxisLine(false)
|
|
||||||
} else {
|
|
||||||
isShowAxisLine(true)
|
|
||||||
}
|
|
||||||
//加载echarts
|
|
||||||
initChart();
|
|
||||||
})
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 修改valueFlag
|
|
||||||
* @param val 子组件传的动态值
|
|
||||||
*/
|
|
||||||
const editValueFlag = (val) => {
|
|
||||||
valueFlag.value = val
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 修改startDataType
|
|
||||||
* @param str 子组件传的动态值
|
|
||||||
*/
|
|
||||||
const editStartDataType = (str) => {
|
|
||||||
startDataType.value = str
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 用于其他组件获取基础设置列表
|
|
||||||
* @param str 子组件传的动态值
|
|
||||||
*/
|
|
||||||
const getLineChartBasicSettingList = (str) => {
|
|
||||||
lineChartBasicSettingList.value = str
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 修改option
|
|
||||||
* @param str 子组件传的动态值
|
|
||||||
*/
|
|
||||||
const getBarChartBasicSettingList = (str) => {
|
|
||||||
barChartBasicSettingList.value = str
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 切换echarts图类型事件
|
|
||||||
* @param e event事件
|
|
||||||
*/
|
|
||||||
const handleChangeEcharts = (e) => {
|
|
||||||
if (xValueAxis.length !== 0 || yValueAxis.length !== 0) {
|
|
||||||
|
|
||||||
xValueAxis.map((item) => {
|
|
||||||
ChartsItem.value.unshift(item)
|
|
||||||
option.legend.selected[item.label] = false
|
|
||||||
})
|
|
||||||
xValueAxis.splice(0, xValueAxis.length)
|
|
||||||
yValueAxis.map((item) => {
|
|
||||||
ChartsItem.value.unshift(item)
|
|
||||||
option.legend.selected[item.label] = false
|
|
||||||
})
|
|
||||||
yValueAxis.splice(0, yValueAxis.length)
|
|
||||||
option.legend.data.splice(0, option.legend.data.length)
|
|
||||||
option.series.splice(0, option.series.length)
|
|
||||||
option.xAxis.name = ''
|
|
||||||
option.xAxis.data = []
|
|
||||||
option.xAxis.type = 'category'
|
|
||||||
option.yAxis.name = ''
|
|
||||||
option.yAxis.data = []
|
|
||||||
option.yAxis.type = 'value'
|
|
||||||
initChart()
|
|
||||||
}
|
|
||||||
echartsValue.value = e
|
|
||||||
if (e === 'line') {
|
|
||||||
ChartsItem.value = line_data
|
|
||||||
isShowAxisLine(true)
|
|
||||||
option.radar={}
|
|
||||||
} else if (e === 'bar') {
|
|
||||||
ChartsItem.value = bar_data
|
|
||||||
isShowAxisLine(true)
|
|
||||||
option.radar={}
|
|
||||||
} else if (e === 'pie') {
|
|
||||||
ChartsItem.value = pie_data
|
|
||||||
isShowAxisLine(false)
|
|
||||||
option.radar={}
|
|
||||||
}else if (e === 'radar') {
|
|
||||||
ChartsItem.value = radar_data
|
|
||||||
isShowAxisLine(false)
|
|
||||||
option.radar.indicator = props.radarIndicator
|
|
||||||
}
|
|
||||||
let selectLegend = {}
|
|
||||||
ChartsItem.value.forEach(item => {
|
|
||||||
if (item.dataType !== 'key') {
|
|
||||||
selectLegend[item.label] = false
|
|
||||||
}
|
|
||||||
})
|
|
||||||
option.legend.selected = selectLegend
|
|
||||||
initChart()
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 是否显示x/y轴线
|
|
||||||
* @param type
|
|
||||||
*/
|
|
||||||
const isShowAxisLine = (type) => {
|
|
||||||
option.xAxis.axisLine.show = type
|
|
||||||
option.yAxis.axisLine.show = type
|
|
||||||
if (type === false) {
|
|
||||||
option.tooltip.trigger = 'item'
|
|
||||||
} else {
|
|
||||||
option.tooltip.trigger = 'axis'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 初始化echarts实例方法
|
|
||||||
*/
|
|
||||||
const initChart = () => {
|
|
||||||
console.log('initChartoption', option)
|
|
||||||
//3.初始化container容器
|
|
||||||
myEcharts = echarts.init(chart.value);
|
|
||||||
//5.传入数据
|
|
||||||
myEcharts.setOption(option,true);
|
|
||||||
//图表大小自适应窗口大小变化
|
|
||||||
window.onresize = () => {
|
|
||||||
myEcharts.resize();
|
|
||||||
}
|
|
||||||
//点击事件
|
|
||||||
// myEcharts.on('click', function (params) {
|
|
||||||
// console.log('dddd点击事件', params);
|
|
||||||
// });
|
|
||||||
// myEcharts.restore();
|
|
||||||
localStorage.removeItem('dragType')
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 保存数据
|
|
||||||
*/
|
|
||||||
const saveData = () => {
|
|
||||||
console.log('最终initInfo', initInfo)
|
|
||||||
emit("getFinalInfo", initInfo)
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 打开高级设置弹框
|
|
||||||
*/
|
|
||||||
const openAdvancedSettings = () => {
|
|
||||||
advancedSettings.value.showDrawer()
|
|
||||||
}
|
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|
||||||
@@ -1,86 +0,0 @@
|
|||||||
<template>
|
|
||||||
<el-drawer v-model="drawerVisible" direction="rtl">
|
|
||||||
<template #header>
|
|
||||||
<h4>高级设置</h4>
|
|
||||||
</template>
|
|
||||||
<template #default>
|
|
||||||
<el-form :model="settingsForm" class="advanced-setting">
|
|
||||||
<el-form-item label="是否点击图例改变图显示状态">
|
|
||||||
<el-switch active-text="是" inactive-text="否" v-model="settingsForm.isClickLegendToShow"
|
|
||||||
@change="changeIsClickLegend"/>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="是否显示提示框组件">
|
|
||||||
<el-switch active-text="是" inactive-text="否" v-model="settingsForm.isShowTooltip"
|
|
||||||
@change="changeIsShowTooltip"/>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
</template>
|
|
||||||
<template #footer>
|
|
||||||
<el-button @click="cancelSettings">取消</el-button>
|
|
||||||
<el-button type="primary" @click="confirmSettings">确认</el-button>
|
|
||||||
</template>
|
|
||||||
</el-drawer>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
const props = defineProps({
|
|
||||||
//初始化加载echarts函数
|
|
||||||
initCharts: {
|
|
||||||
type: Function,
|
|
||||||
default: null
|
|
||||||
},
|
|
||||||
//echarts的配置属性
|
|
||||||
chartOption: {
|
|
||||||
type: Array,
|
|
||||||
default: []
|
|
||||||
},
|
|
||||||
})
|
|
||||||
let option = reactive(props.chartOption)
|
|
||||||
//高级设置抽屉是否展开
|
|
||||||
const drawerVisible = ref(false)
|
|
||||||
//高级设置属性
|
|
||||||
const settingsForm = reactive({
|
|
||||||
isClickLegendToShow: option.legend.selectedMode,//打开点击图例改变图显示状态
|
|
||||||
isShowTooltip: option.tooltip.show//是否显示提示框组件
|
|
||||||
})
|
|
||||||
/**
|
|
||||||
* 打开高级设置弹窗
|
|
||||||
*/
|
|
||||||
const showDrawer = () => {
|
|
||||||
drawerVisible.value = true
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 高级设置: 取消按钮
|
|
||||||
*/
|
|
||||||
const cancelSettings = () => {
|
|
||||||
drawerVisible.value = false
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 高级设置: 确认按钮
|
|
||||||
*/
|
|
||||||
const confirmSettings = () => {
|
|
||||||
drawerVisible.value = false
|
|
||||||
props.initCharts()
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 高级设置:打开点击图例改变图显示状态
|
|
||||||
* @param val
|
|
||||||
*/
|
|
||||||
const changeIsClickLegend = (val) => {
|
|
||||||
option.legend.selectedMode = val
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 高级设置:是否显示提示框组件
|
|
||||||
* @param val
|
|
||||||
*/
|
|
||||||
const changeIsShowTooltip = (val) => {
|
|
||||||
option.tooltip.show = val
|
|
||||||
}
|
|
||||||
|
|
||||||
defineExpose({
|
|
||||||
showDrawer
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
@@ -1,140 +0,0 @@
|
|||||||
<template>
|
|
||||||
<el-scrollbar height="450px">
|
|
||||||
<div class="basic-setup" @click.stop>
|
|
||||||
柱状图基本设置
|
|
||||||
</div>
|
|
||||||
<div v-for="(settingItem) in basicList" class="setting" @click.stop>
|
|
||||||
<div class="setting-title">{{ settingItem.label }}</div>
|
|
||||||
<div class="setting-item">
|
|
||||||
<span>显示柱条背景: </span>
|
|
||||||
<el-switch active-text="是" inactive-text="否" v-model="settingItem.showBackground"
|
|
||||||
@change="changeIsShowBackground($event,settingItem)"/>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div v-if="settingItem.showBackground!==false">
|
|
||||||
<div class="setting-item">
|
|
||||||
<span>柱条描边宽度: </span>
|
|
||||||
<el-input-number v-model="settingItem.backgroundStyle.borderWidth" :min="0"
|
|
||||||
@change="changeBorderWidth($event,settingItem)"/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- <div class="setting-item" v-if="settingItem.backgroundStyle.borderWidth!==0">-->
|
|
||||||
<!-- <span>柱条描边颜色: </span>-->
|
|
||||||
<!-- <el-color-picker v-model="settingItem.backgroundStyle.borderColor"-->
|
|
||||||
<!-- :color="settingItem.backgroundStyle.borderColor"-->
|
|
||||||
<!-- @change="changeBorderColor($event,settingItem)"/>-->
|
|
||||||
<!-- </div>-->
|
|
||||||
<div class="setting-item" v-if="settingItem.backgroundStyle.borderWidth!==0">
|
|
||||||
<span>柱条描边类型: </span>
|
|
||||||
<el-select v-model="settingItem.backgroundStyle.borderType" @change="switchBorderType($event,settingItem)">
|
|
||||||
<el-option
|
|
||||||
v-for="symbolItem in borderTypeList"
|
|
||||||
:key="symbolItem.value"
|
|
||||||
:label="symbolItem.label"
|
|
||||||
:value="symbolItem.value"
|
|
||||||
/>
|
|
||||||
</el-select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</el-scrollbar>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
const props = defineProps({
|
|
||||||
//基础设置列表
|
|
||||||
basicList: {
|
|
||||||
type: Array,
|
|
||||||
default: []
|
|
||||||
},
|
|
||||||
//初始化加载echarts函数
|
|
||||||
initCharts: {
|
|
||||||
type: Function,
|
|
||||||
default: null
|
|
||||||
},
|
|
||||||
//echarts的配置属性
|
|
||||||
chartOption: {
|
|
||||||
type: Array,
|
|
||||||
default: []
|
|
||||||
},
|
|
||||||
})
|
|
||||||
let option = reactive(props.chartOption)
|
|
||||||
//图形标记列表
|
|
||||||
const borderTypeList = ref([
|
|
||||||
{value: 'solid', label: '实线'},
|
|
||||||
{value: 'dashed', label: '虚线'},
|
|
||||||
{value: 'dotted', label: '点线'}
|
|
||||||
])
|
|
||||||
/**
|
|
||||||
* 封装基本设置修改echarts属性事件
|
|
||||||
* @param item 修改的项
|
|
||||||
* @param type option.series中的属性名
|
|
||||||
* @param val 获取修改的值
|
|
||||||
*/
|
|
||||||
const changeSingleParams = (item, type, val) => {
|
|
||||||
option.series.forEach((sItem, sIndex) => {
|
|
||||||
if (sItem.name === item.label) {
|
|
||||||
getSeriesParams(type, sIndex, val)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 根据changeSingleParams方法传的动态type,封装数据修改事件
|
|
||||||
* @param type option.series中的属性名
|
|
||||||
* @param index 修改某项属性的下标
|
|
||||||
* @param val 获取修改的值
|
|
||||||
*/
|
|
||||||
const getSeriesParams = (type, index, val) => {
|
|
||||||
let seriesItem = option.series[index]
|
|
||||||
switch (type) {
|
|
||||||
case 'showBackground':
|
|
||||||
return seriesItem.showBackground = val
|
|
||||||
case 'color':
|
|
||||||
return seriesItem.backgroundStyle.color = val
|
|
||||||
case 'borderWidth':
|
|
||||||
return seriesItem.backgroundStyle.borderWidth = val
|
|
||||||
case 'borderColor':
|
|
||||||
return seriesItem.backgroundStyle.borderColor = val
|
|
||||||
case 'borderType':
|
|
||||||
return seriesItem.backgroundStyle.borderType = val
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 基础设置:修改是否显示柱条背景
|
|
||||||
* @param val 是否显示
|
|
||||||
* @param item 修改的chart项
|
|
||||||
*/
|
|
||||||
const changeIsShowBackground = (val, item) => {
|
|
||||||
changeSingleParams(item, 'showBackground', val)
|
|
||||||
props.initCharts()
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 基础设置:修改柱条描边宽度
|
|
||||||
* @param val 宽度
|
|
||||||
* @param item 修改的chart项
|
|
||||||
*/
|
|
||||||
const changeBorderWidth = (val, item) => {
|
|
||||||
changeSingleParams(item, 'borderWidth', val)
|
|
||||||
props.initCharts()
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 基础设置:修改柱条的描边颜色
|
|
||||||
* @param val 颜色
|
|
||||||
* @param item 修改的chart项
|
|
||||||
*/
|
|
||||||
const changeBorderColor = (val, item) => {
|
|
||||||
changeSingleParams(item, 'borderColor', val)
|
|
||||||
props.initCharts()
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 基础设置:修改柱条的描边类型
|
|
||||||
* @param val 类型
|
|
||||||
* @param item 修改的chart项
|
|
||||||
*/
|
|
||||||
const switchBorderType = (val, item) => {
|
|
||||||
changeSingleParams(item, 'borderType', val)
|
|
||||||
props.initCharts()
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
@@ -1,86 +0,0 @@
|
|||||||
<template>
|
|
||||||
<el-drawer v-model="drawerVisible" direction="rtl">
|
|
||||||
<template #header>
|
|
||||||
<h4>高级设置</h4>
|
|
||||||
</template>
|
|
||||||
<template #default>
|
|
||||||
<el-form :model="settingsForm" class="advanced-setting">
|
|
||||||
<el-form-item label="是否点击图例改变图显示状态">
|
|
||||||
<el-switch active-text="是" inactive-text="否" v-model="settingsForm.isClickLegendToShow"
|
|
||||||
@change="changeIsClickLegend"/>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="是否显示提示框组件">
|
|
||||||
<el-switch active-text="是" inactive-text="否" v-model="settingsForm.isShowTooltip"
|
|
||||||
@change="changeIsShowTooltip"/>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
</template>
|
|
||||||
<template #footer>
|
|
||||||
<el-button @click="cancelSettings">取消</el-button>
|
|
||||||
<el-button type="primary" @click="confirmSettings">确认</el-button>
|
|
||||||
</template>
|
|
||||||
</el-drawer>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
const props = defineProps({
|
|
||||||
//初始化加载echarts函数
|
|
||||||
initCharts: {
|
|
||||||
type: Function,
|
|
||||||
default: null
|
|
||||||
},
|
|
||||||
//echarts的配置属性
|
|
||||||
chartOption: {
|
|
||||||
type: Array,
|
|
||||||
default: []
|
|
||||||
},
|
|
||||||
})
|
|
||||||
let option = reactive(props.chartOption)
|
|
||||||
//高级设置抽屉是否展开
|
|
||||||
const drawerVisible = ref(false)
|
|
||||||
//高级设置属性
|
|
||||||
const settingsForm = reactive({
|
|
||||||
isClickLegendToShow: option.legend.selectedMode,//打开点击图例改变图显示状态
|
|
||||||
isShowTooltip: option.tooltip.show//是否显示提示框组件
|
|
||||||
})
|
|
||||||
/**
|
|
||||||
* 打开高级设置弹窗
|
|
||||||
*/
|
|
||||||
const showDrawer = () => {
|
|
||||||
drawerVisible.value = true
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 高级设置: 取消按钮
|
|
||||||
*/
|
|
||||||
const cancelSettings = () => {
|
|
||||||
drawerVisible.value = false
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 高级设置: 确认按钮
|
|
||||||
*/
|
|
||||||
const confirmSettings = () => {
|
|
||||||
drawerVisible.value = false
|
|
||||||
props.initCharts()
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 高级设置:打开点击图例改变图显示状态
|
|
||||||
* @param val
|
|
||||||
*/
|
|
||||||
const changeIsClickLegend = (val) => {
|
|
||||||
option.legend.selectedMode = val
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 高级设置:是否显示提示框组件
|
|
||||||
* @param val
|
|
||||||
*/
|
|
||||||
const changeIsShowTooltip = (val) => {
|
|
||||||
option.tooltip.show = val
|
|
||||||
}
|
|
||||||
|
|
||||||
defineExpose({
|
|
||||||
showDrawer
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
@@ -1,160 +0,0 @@
|
|||||||
<template>
|
|
||||||
<el-scrollbar height="450px">
|
|
||||||
<div class="basic-setup" @click.stop>
|
|
||||||
折线图基本设置
|
|
||||||
</div>
|
|
||||||
<div v-for="(settingItem) in basicList" class="setting" @click.stop>
|
|
||||||
<div class="setting-title">{{ settingItem.label }}</div>
|
|
||||||
<!-- <div class="setting-item">-->
|
|
||||||
<!-- <span>图形: </span>-->
|
|
||||||
<!-- <el-select v-model="settingItem.type" @change="switchChart($event,settingItem)">-->
|
|
||||||
<!-- <el-option-->
|
|
||||||
<!-- v-for="chartItem in [{value: 'line',label: '折线图'},{value: 'bar',label: '柱状图'}]"-->
|
|
||||||
<!-- :key="chartItem.value"-->
|
|
||||||
<!-- :label="chartItem.label"-->
|
|
||||||
<!-- :value="chartItem.value"-->
|
|
||||||
<!-- />-->
|
|
||||||
<!-- </el-select>-->
|
|
||||||
<!-- </div>-->
|
|
||||||
<div class="setting-item">
|
|
||||||
<span>显示标记: </span>
|
|
||||||
<el-switch active-text="是" inactive-text="否" v-model="settingItem.showSymbol"
|
|
||||||
@change="changeIsShowSymbol($event,settingItem)"/>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="setting-item" v-if="settingItem.showSymbol===true">
|
|
||||||
<span>标记: </span>
|
|
||||||
<el-select v-model="settingItem.symbol" @change="switchSymbol($event,settingItem)">
|
|
||||||
<el-option
|
|
||||||
v-for="symbolItem in symbolList"
|
|
||||||
:key="symbolItem.value"
|
|
||||||
:label="symbolItem.label"
|
|
||||||
:value="symbolItem.value"
|
|
||||||
/>
|
|
||||||
</el-select>
|
|
||||||
</div>
|
|
||||||
<div class="setting-item" v-if="settingItem.showSymbol===true">
|
|
||||||
<span>标记大小: </span>
|
|
||||||
<el-input-number v-model="settingItem.symbolSize" :min="1" @change="changeSymbolSize($event,settingItem)"/>
|
|
||||||
</div>
|
|
||||||
<div class="setting-item">
|
|
||||||
<span>阴影模糊大小: </span>
|
|
||||||
<el-input-number v-model="settingItem.lineStyle.shadowBlur" :min="0" @change="changeShadowBlur($event,settingItem)"/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</el-scrollbar>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
const props = defineProps({
|
|
||||||
//基础设置列表
|
|
||||||
basicList: {
|
|
||||||
type: Array,
|
|
||||||
default: []
|
|
||||||
},
|
|
||||||
//初始化加载echarts函数
|
|
||||||
initCharts: {
|
|
||||||
type: Function,
|
|
||||||
default: null
|
|
||||||
},
|
|
||||||
//echarts的配置属性
|
|
||||||
chartOption: {
|
|
||||||
type: Array,
|
|
||||||
default: []
|
|
||||||
},
|
|
||||||
})
|
|
||||||
//图形标记列表
|
|
||||||
const symbolList = ref([
|
|
||||||
{value: 'none', label: '不显示标记'},
|
|
||||||
{value: 'circle', label: '圆形'},
|
|
||||||
{value: 'rect', label: '矩形'},
|
|
||||||
{value: 'triangle', label: '三角形'},
|
|
||||||
{value: 'diamond', label: '钻石形'},
|
|
||||||
{value: 'roundRect', label: '圆角矩形'},
|
|
||||||
{value: 'pin', label: '圆钉形'},
|
|
||||||
{value: 'arrow', label: '箭头形'},
|
|
||||||
])
|
|
||||||
let option = reactive(props.chartOption)
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 封装基本设置修改echarts属性事件
|
|
||||||
* @param item 修改的项
|
|
||||||
* @param type option.series中的属性名
|
|
||||||
* @param val 获取修改的值
|
|
||||||
*/
|
|
||||||
const changeSingleParams = (item, type, val) => {
|
|
||||||
option.series.forEach((sItem, sIndex) => {
|
|
||||||
if (sItem.name === item.label) {
|
|
||||||
getSeriesParams(type, sIndex, val)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 根据changeSingleParams方法传的动态type,封装数据修改事件
|
|
||||||
* @param type option.series中的属性名
|
|
||||||
* @param index 修改某项属性的下标
|
|
||||||
* @param val 获取修改的值
|
|
||||||
*/
|
|
||||||
const getSeriesParams = (type, index, val) => {
|
|
||||||
let seriesItem = option.series[index]
|
|
||||||
switch (type) {
|
|
||||||
case 'type':
|
|
||||||
return seriesItem.type = val
|
|
||||||
case 'showSymbol':
|
|
||||||
return seriesItem.showSymbol = val
|
|
||||||
case 'symbol':
|
|
||||||
return seriesItem.symbol = val
|
|
||||||
case 'symbolSize':
|
|
||||||
return seriesItem.symbolSize = val
|
|
||||||
case 'shadowBlur':
|
|
||||||
return seriesItem.lineStyle.shadowBlur = val
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 基础设置:是否显示标记
|
|
||||||
* @param val 修改的标记大小
|
|
||||||
* @param item 修改的chart项
|
|
||||||
*/
|
|
||||||
const changeIsShowSymbol = (val, item) => {
|
|
||||||
changeSingleParams(item, 'showSymbol', val)
|
|
||||||
props.initCharts()
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 基础设置:切换chart的形状
|
|
||||||
* @param val 修改的标记大小
|
|
||||||
* @param item 修改的chart项
|
|
||||||
*/
|
|
||||||
const switchChart = (val, item) => {
|
|
||||||
changeSingleParams(item, 'type', val)
|
|
||||||
props.initCharts()
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 基础设置:修改标记
|
|
||||||
* @param val 修改的标记大小
|
|
||||||
* @param item 修改的chart项
|
|
||||||
*/
|
|
||||||
const switchSymbol = (val, item) => {
|
|
||||||
changeSingleParams(item, 'symbol', val)
|
|
||||||
props.initCharts()
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 基础设置:修改标记大小
|
|
||||||
* @param val 修改的标记大小
|
|
||||||
* @param item 修改的chart项
|
|
||||||
*/
|
|
||||||
const changeSymbolSize = (val, item) => {
|
|
||||||
changeSingleParams(item, 'symbolSize', val)
|
|
||||||
props.initCharts()
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 基础设置:修改图形阴影的模糊大小
|
|
||||||
* @param val 修改的阴影的模糊大小
|
|
||||||
* @param item 修改的chart项
|
|
||||||
*/
|
|
||||||
const changeShadowBlur = (val, item) => {
|
|
||||||
changeSingleParams(item, 'shadowBlur', val)
|
|
||||||
props.initCharts()
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
<template>
|
|
||||||
<el-scrollbar height="450px">
|
|
||||||
<div class="basic-setup" @click.stop>
|
|
||||||
饼图基本设置
|
|
||||||
</div>
|
|
||||||
</el-scrollbar>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
export default {
|
|
||||||
name: "BasicSetting"
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
|
|
||||||
</style>
|
|
||||||
@@ -1,116 +0,0 @@
|
|||||||
<template>
|
|
||||||
<el-card class="box-card box-card-h">
|
|
||||||
<el-row justify="space-between" class="x-y-axis">
|
|
||||||
<el-text>饼图数据项</el-text>
|
|
||||||
<el-tooltip
|
|
||||||
effect="dark"
|
|
||||||
:content="'数据类型必须是数字!'"
|
|
||||||
placement="bottom"
|
|
||||||
>
|
|
||||||
<el-icon>
|
|
||||||
<Warning/>
|
|
||||||
</el-icon>
|
|
||||||
</el-tooltip>
|
|
||||||
</el-row>
|
|
||||||
<div class="drag-block">
|
|
||||||
<draggable
|
|
||||||
class="list-group"
|
|
||||||
:list="dragList"
|
|
||||||
itemKey="id"
|
|
||||||
group="people"
|
|
||||||
@start="startDrag"
|
|
||||||
@change="dragChartItem"
|
|
||||||
>
|
|
||||||
<template #item="{ element,index }">
|
|
||||||
<div>
|
|
||||||
<el-card shadow="hover" class="cards x-y-cards">
|
|
||||||
<el-col :span="8">
|
|
||||||
<div>{{ element.label }}</div>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="8">
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="8">
|
|
||||||
<div class="cards-right">
|
|
||||||
<span>{{ element.dataType }}</span>
|
|
||||||
<!-- <el-icon size="20" color="red" @click.stop="handleCancelAxis(element,index)"-->
|
|
||||||
<!-- style="cursor: pointer">-->
|
|
||||||
<!-- <CircleClose/>-->
|
|
||||||
<!-- </el-icon>-->
|
|
||||||
</div>
|
|
||||||
</el-col>
|
|
||||||
</el-card>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</draggable>
|
|
||||||
</div>
|
|
||||||
</el-card>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import draggable from 'vuedraggable'
|
|
||||||
const props = defineProps({
|
|
||||||
//用于拖拽区域存放选项列表
|
|
||||||
dragList: {
|
|
||||||
type: Array,
|
|
||||||
default: []
|
|
||||||
},
|
|
||||||
//初始化加载echarts函数
|
|
||||||
initCharts: {
|
|
||||||
type: Function,
|
|
||||||
default: null
|
|
||||||
},
|
|
||||||
//echarts的配置属性
|
|
||||||
chartOption: {
|
|
||||||
type: Array,
|
|
||||||
default: []
|
|
||||||
},
|
|
||||||
})
|
|
||||||
let option = reactive(props.chartOption)
|
|
||||||
/**
|
|
||||||
* 开始拖拽事件
|
|
||||||
* @param event event事件
|
|
||||||
*/
|
|
||||||
const startDrag = (event) => {
|
|
||||||
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 从X轴/Y轴区域移动选项到左/右侧结束事件
|
|
||||||
* @param event event事件
|
|
||||||
*/
|
|
||||||
const dragChartItem = (event) => {
|
|
||||||
console.log('dragChartItem',event)
|
|
||||||
if (event.removed === undefined) return;
|
|
||||||
let item = event.removed.element
|
|
||||||
let label = item.label
|
|
||||||
dragTypeToValue(label)
|
|
||||||
props.initCharts()
|
|
||||||
// localStorage.removeItem('dragType')
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 拖拽类型为value的选项事件
|
|
||||||
* @param label 选项名
|
|
||||||
*/
|
|
||||||
const dragTypeToValue = (label) => {
|
|
||||||
console.log('dragTypeToValue',label,option)
|
|
||||||
//删除选中选项的图例
|
|
||||||
const legendIndex = option.legend.data.findIndex(object => object === label);
|
|
||||||
option.legend.data.splice(legendIndex, 1)
|
|
||||||
//删除echarts配置项series中符合该拖拽选项的item
|
|
||||||
const objectIndex = option.series[0].data.findIndex(object => object.name === label);
|
|
||||||
option.legend.selected[label] = false
|
|
||||||
option.series[0].data.splice(objectIndex, 1)
|
|
||||||
if(option.series[0].data.length===0){
|
|
||||||
option.series.splice(0,1)
|
|
||||||
}
|
|
||||||
// clearBasicSetting()
|
|
||||||
}
|
|
||||||
const handleCancelAxis = (element, index) => {
|
|
||||||
console.log('拖出xxx')
|
|
||||||
dragTypeToValue(element.label)
|
|
||||||
props.initCharts()
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
|
|
||||||
</style>
|
|
||||||
@@ -1,110 +0,0 @@
|
|||||||
<template>
|
|
||||||
<el-card class="box-card box-card-h">
|
|
||||||
<el-row justify="space-between" class="x-y-axis">
|
|
||||||
<el-text>雷达图数据项</el-text>
|
|
||||||
<el-tooltip
|
|
||||||
effect="dark"
|
|
||||||
:content="'数据类型必须是数字!'"
|
|
||||||
placement="bottom"
|
|
||||||
>
|
|
||||||
<el-icon>
|
|
||||||
<Warning/>
|
|
||||||
</el-icon>
|
|
||||||
</el-tooltip>
|
|
||||||
</el-row>
|
|
||||||
<div class="drag-block">
|
|
||||||
<draggable
|
|
||||||
class="list-group"
|
|
||||||
:list="dragList"
|
|
||||||
itemKey="id"
|
|
||||||
group="people"
|
|
||||||
@start="startDrag"
|
|
||||||
@change="dragChartItem"
|
|
||||||
>
|
|
||||||
<template #item="{ element,index }">
|
|
||||||
<div>
|
|
||||||
<el-card shadow="hover" class="cards x-y-cards">
|
|
||||||
<el-col :span="8">
|
|
||||||
<div>{{ element.label }}</div>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="8">
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="8">
|
|
||||||
<div class="cards-right">
|
|
||||||
<span>{{ element.dataType }}</span>
|
|
||||||
<!-- <el-icon size="20" color="red" @click.stop="handleCancelAxis(element,index)"-->
|
|
||||||
<!-- style="cursor: pointer">-->
|
|
||||||
<!-- <CircleClose/>-->
|
|
||||||
<!-- </el-icon>-->
|
|
||||||
</div>
|
|
||||||
</el-col>
|
|
||||||
</el-card>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</draggable>
|
|
||||||
</div>
|
|
||||||
</el-card>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import draggable from 'vuedraggable'
|
|
||||||
const props = defineProps({
|
|
||||||
//用于拖拽区域存放选项列表
|
|
||||||
dragList: {
|
|
||||||
type: Array,
|
|
||||||
default: []
|
|
||||||
},
|
|
||||||
//初始化加载echarts函数
|
|
||||||
initCharts: {
|
|
||||||
type: Function,
|
|
||||||
default: null
|
|
||||||
},
|
|
||||||
//echarts的配置属性
|
|
||||||
chartOption: {
|
|
||||||
type: Array,
|
|
||||||
default: []
|
|
||||||
},
|
|
||||||
})
|
|
||||||
let option = reactive(props.chartOption)
|
|
||||||
/**
|
|
||||||
* 开始拖拽事件
|
|
||||||
* @param event event事件
|
|
||||||
*/
|
|
||||||
const startDrag = (event) => {
|
|
||||||
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 从X轴/Y轴区域移动选项到左/右侧结束事件
|
|
||||||
* @param event event事件
|
|
||||||
*/
|
|
||||||
const dragChartItem = (event) => {
|
|
||||||
console.log('dragChartItem',event)
|
|
||||||
if (event.removed === undefined) return;
|
|
||||||
let item = event.removed.element
|
|
||||||
let label = item.label
|
|
||||||
dragTypeToValue(label)
|
|
||||||
props.initCharts()
|
|
||||||
// localStorage.removeItem('dragType')
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* 拖拽类型为value的选项事件
|
|
||||||
* @param label 选项名
|
|
||||||
*/
|
|
||||||
const dragTypeToValue = (label) => {
|
|
||||||
//删除选中选项的图例
|
|
||||||
const legendIndex = option.legend.data.findIndex(object => object === label);
|
|
||||||
option.legend.data.splice(legendIndex, 1)
|
|
||||||
//删除echarts配置项series中符合该拖拽选项的item
|
|
||||||
const objectIndex = option.series[0].data.findIndex(object => object.name === label);
|
|
||||||
option.legend.selected[label] = false
|
|
||||||
option.series[0].data.splice(objectIndex, 1)
|
|
||||||
// clearBasicSetting()
|
|
||||||
if(option.series[0].data.length===0){
|
|
||||||
option.series.splice(0,1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
|
|
||||||
</style>
|
|
||||||
@@ -1,233 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div>
|
|
||||||
<EchartsEditor :info="initInfo" :line-data="lineChartsItem" :bar-data="barChartsItem" :pie-data="pieChartsItem"
|
|
||||||
:radar-data="radarChartsItem" :radar-indicator="indicator" @getFinalInfo="getFinalInfo"/>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import EchartsEditor from "./components/EchartsEditor.vue";
|
|
||||||
//入参
|
|
||||||
const lineChartsItem = ref([
|
|
||||||
{
|
|
||||||
id: 1,
|
|
||||||
unit: '年份',
|
|
||||||
type: '',
|
|
||||||
dataType: 'key',
|
|
||||||
color: '',
|
|
||||||
label: '年份',
|
|
||||||
symbol: "",
|
|
||||||
symbolSize: 0,
|
|
||||||
showSymbol: false,
|
|
||||||
lineStyle: {
|
|
||||||
shadowColor: '',//阴影颜色
|
|
||||||
shadowBlur: 0,//图形阴影的模糊大小
|
|
||||||
opacity: 1
|
|
||||||
},
|
|
||||||
data: ['2013', '2014', '2015', '2016', '2017', '2018']
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 2,
|
|
||||||
unit: '年销量',
|
|
||||||
type: 'line',
|
|
||||||
dataType: 'value',
|
|
||||||
color: '#9a60b4',//图形颜色
|
|
||||||
label: '华北',
|
|
||||||
symbol: "triangle",//标记的图形circle:圆形,rect:矩形,triangle:三角形,diamond:钻石形,roundRect:圆角矩形,pin:圆钉形,arrow:箭头形,none:不显示标记
|
|
||||||
symbolSize: 8,//标记的大小
|
|
||||||
showSymbol: true,//是否显示标记,如果 false 则只有在 tooltip hover 的时候显示。
|
|
||||||
lineStyle: {
|
|
||||||
shadowColor: '',//阴影颜色
|
|
||||||
shadowBlur: 0,//图形阴影的模糊大小
|
|
||||||
opacity: 1//图形透明度
|
|
||||||
},
|
|
||||||
data: [40, 80, 20, 120, 140, 50]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 3,
|
|
||||||
unit: '年销量',
|
|
||||||
type: 'line',
|
|
||||||
dataType: 'value',
|
|
||||||
color: '#3ba272',
|
|
||||||
label: '华东',
|
|
||||||
symbol: "circle",
|
|
||||||
symbolSize: 8,
|
|
||||||
showSymbol: true,
|
|
||||||
lineStyle: {
|
|
||||||
shadowColor: '',//阴影颜色
|
|
||||||
shadowBlur: 0,//图形阴影的模糊大小
|
|
||||||
opacity: 1
|
|
||||||
},
|
|
||||||
data: [140, 180, 120, 40, 50, 150]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 4,
|
|
||||||
unit: '年销量',
|
|
||||||
type: 'line',
|
|
||||||
dataType: 'value',
|
|
||||||
color: '#5470c6',
|
|
||||||
label: '华南',
|
|
||||||
symbol: "rect",
|
|
||||||
symbolSize: 8,
|
|
||||||
showSymbol: true,
|
|
||||||
lineStyle: {
|
|
||||||
shadowColor: '',//阴影颜色
|
|
||||||
shadowBlur: 0,//图形阴影的模糊大小
|
|
||||||
opacity: 1
|
|
||||||
},
|
|
||||||
data: [110, 143, 68, 90, 120, 130]
|
|
||||||
}
|
|
||||||
])
|
|
||||||
const barChartsItem = ref([
|
|
||||||
{
|
|
||||||
id: 1,
|
|
||||||
unit: '年份',
|
|
||||||
type: '',
|
|
||||||
dataType: 'key',
|
|
||||||
color: '',
|
|
||||||
label: '年份',
|
|
||||||
showBackground: false,
|
|
||||||
backgroundStyle: {
|
|
||||||
color: '',
|
|
||||||
borderWidth: 0,
|
|
||||||
borderColor: '',
|
|
||||||
borderType: 'solid',
|
|
||||||
},
|
|
||||||
data: ['2013', '2014', '2015', '2016', '2017', '2018']
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 2,
|
|
||||||
unit: '销售金额',
|
|
||||||
type: 'bar',
|
|
||||||
dataType: 'value',
|
|
||||||
color: '#9a60b4',//图形颜色
|
|
||||||
label: '王五',
|
|
||||||
showBackground: true,//是否显示柱条的背景色
|
|
||||||
backgroundStyle: {
|
|
||||||
color: '#e5e2e2',//柱条的颜色
|
|
||||||
borderWidth: 0,//柱条的描边宽度,默认不描边。
|
|
||||||
borderColor: '#000',//柱条的描边颜色
|
|
||||||
borderType: 'dotted',//柱条的描边类型,默认为实线,支持 'dashed', 'dotted'
|
|
||||||
},
|
|
||||||
data: [40, 80, 20, 120, 140, 50]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 3,
|
|
||||||
unit: '销售金额',
|
|
||||||
type: 'bar',
|
|
||||||
dataType: 'value',
|
|
||||||
color: '#3ba272',
|
|
||||||
label: '李四',
|
|
||||||
showBackground: true,
|
|
||||||
backgroundStyle: {
|
|
||||||
color: '#e5e2e2',
|
|
||||||
borderWidth: 0,
|
|
||||||
borderColor: '#000',
|
|
||||||
borderType: 'dashed',
|
|
||||||
},
|
|
||||||
data: [140, 180, 120, 40, 50, 150]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 4,
|
|
||||||
unit: '销售金额',
|
|
||||||
type: 'bar',
|
|
||||||
dataType: 'value',
|
|
||||||
color: '#2644a4',
|
|
||||||
label: '张三',
|
|
||||||
showBackground: true,
|
|
||||||
backgroundStyle: {
|
|
||||||
color: '#e5e2e2',
|
|
||||||
borderWidth: 0,
|
|
||||||
borderColor: '#000',
|
|
||||||
borderType: 'solid',
|
|
||||||
},
|
|
||||||
data: [110, 143, 68, 90, 120, 130]
|
|
||||||
}
|
|
||||||
])
|
|
||||||
const pieChartsItem = ref([
|
|
||||||
{id: 1, label: '京东', dataType: 'value', value: 335},
|
|
||||||
{id: 2, label: '菜鸟', dataType: 'value', value: 310},
|
|
||||||
{id: 3, label: '总部', dataType: 'value', value: 234},
|
|
||||||
{id: 4, label: '小电商', dataType: 'value', value: 135},
|
|
||||||
])
|
|
||||||
const radarChartsItem = ref([
|
|
||||||
{label: 'Allocated Budget', dataType: 'value', data: [4200, 3000, 20000, 35000, 50000, 18000]},
|
|
||||||
{label: 'Actual Spending', dataType: 'value', data: [5000, 14000, 28000, 26000, 42000, 21000]},
|
|
||||||
])
|
|
||||||
//定义好echarts的配置数据
|
|
||||||
let initInfo = reactive({
|
|
||||||
xValueAxis: [],
|
|
||||||
yValueAxis: [],
|
|
||||||
//echarts配置数据
|
|
||||||
echartsOptions: {
|
|
||||||
//图例
|
|
||||||
legend: {
|
|
||||||
data: [],
|
|
||||||
selected: {},
|
|
||||||
selectedMode: false
|
|
||||||
},
|
|
||||||
//离容器四侧的距离
|
|
||||||
grid: {
|
|
||||||
left: 40, // 左边距
|
|
||||||
right: 60, // 右边距
|
|
||||||
top: 40, // 顶边距
|
|
||||||
bottom: 20, // 底边距
|
|
||||||
// containLabel: true,
|
|
||||||
},
|
|
||||||
//提示框组件
|
|
||||||
tooltip: {
|
|
||||||
show: true,
|
|
||||||
trigger: 'axis'
|
|
||||||
},
|
|
||||||
//工具栏
|
|
||||||
// toolbox: {
|
|
||||||
// feature: {
|
|
||||||
// //重置按钮显示
|
|
||||||
// restore: {
|
|
||||||
// show: true,
|
|
||||||
// title: '重置'
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
//X轴
|
|
||||||
xAxis: {
|
|
||||||
name: '',
|
|
||||||
type: 'category',
|
|
||||||
data: [],
|
|
||||||
axisLine: {
|
|
||||||
show: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
//Y轴
|
|
||||||
yAxis: {
|
|
||||||
name: '',
|
|
||||||
type: 'value',
|
|
||||||
data: [],
|
|
||||||
axisLine: {
|
|
||||||
show: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
radar: {
|
|
||||||
// shape: 'circle',
|
|
||||||
},
|
|
||||||
//配置项
|
|
||||||
series: []
|
|
||||||
}
|
|
||||||
})
|
|
||||||
const indicator= ref([
|
|
||||||
{ name: 'Sales', max: 6500 },
|
|
||||||
{ name: 'Administration', max: 16000 },
|
|
||||||
{ name: 'Information Technology', max: 30000 },
|
|
||||||
{ name: 'Customer Support', max: 38000 },
|
|
||||||
{ name: 'Development', max: 52000 },
|
|
||||||
{ name: 'Marketing', max: 25000 }
|
|
||||||
])
|
|
||||||
//获取到拖拽后的数据
|
|
||||||
const getFinalInfo = (val) => {
|
|
||||||
// console.log('父组件获取最终数据', val)
|
|
||||||
if (val !== undefined) {
|
|
||||||
initInfo = val
|
|
||||||
}
|
|
||||||
}
|
|
||||||
getFinalInfo()
|
|
||||||
</script>
|
|
||||||
@@ -1,115 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div
|
|
||||||
class="root"
|
|
||||||
@click="changeStatus"
|
|
||||||
:style="{
|
|
||||||
width: rootWidth + 'em',
|
|
||||||
height: height + 'em',
|
|
||||||
borderRadius: radius + 'em',
|
|
||||||
}"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
class="strip"
|
|
||||||
:style="{
|
|
||||||
width: stripWidth + 'em',
|
|
||||||
height: height + 'em',
|
|
||||||
borderRadius: radius + 'em',
|
|
||||||
}"
|
|
||||||
>
|
|
||||||
<div
|
|
||||||
class="node"
|
|
||||||
:style="{ width: nodeWidth + 'em', height: height + 'em' }"
|
|
||||||
></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<el-tag v-if="checkValue === -1" type="primary">对内提供</el-tag>
|
|
||||||
<el-tag v-if="checkValue === 0" type="info">开发</el-tag>
|
|
||||||
<el-tag v-if="checkValue === 1" type="success">对外提供</el-tag>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
/**
|
|
||||||
* @author: JimTT
|
|
||||||
* @description: 三选项开关Switch组件
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { ref, onMounted, watch } from "vue";
|
|
||||||
const emit = defineEmits(["update-check"]);
|
|
||||||
const props = defineProps({
|
|
||||||
size: {
|
|
||||||
type: String,
|
|
||||||
default: "1",
|
|
||||||
},
|
|
||||||
check: {
|
|
||||||
type: Number,
|
|
||||||
default: -1,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
let rootWidth = ref(3);
|
|
||||||
let height = ref(1);
|
|
||||||
let stripWidth = ref(1);
|
|
||||||
let nodeWidth = ref(1);
|
|
||||||
let radius = ref(1);
|
|
||||||
let direct = ref(1);
|
|
||||||
let checkValue = ref(-1);
|
|
||||||
|
|
||||||
const changeStatus = () => {
|
|
||||||
if (checkValue.value === 1) direct.value = 0;
|
|
||||||
else if (checkValue.value === -1) direct.value = 1;
|
|
||||||
checkValue.value =
|
|
||||||
direct.value === 1 ? checkValue.value + 1 : checkValue.value - 1;
|
|
||||||
stripWidth.value = (2 + checkValue.value) * Number(props.size);
|
|
||||||
emit("update-check", checkValue);
|
|
||||||
};
|
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
if (props.check === 1) direct.value = 0;
|
|
||||||
checkValue.value = props.check;
|
|
||||||
stripWidth.value = (2 + checkValue.value) * Number(props.size);
|
|
||||||
rootWidth.value *= Number(props.size);
|
|
||||||
height.value *= Number(props.size);
|
|
||||||
nodeWidth.value *= Number(props.size);
|
|
||||||
radius.value *= Number(props.size);
|
|
||||||
});
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => props.check,
|
|
||||||
(newValue) => {
|
|
||||||
if (newValue === 1) direct.value = 0;
|
|
||||||
checkValue.value = newValue;
|
|
||||||
stripWidth.value = (2 + checkValue.value) * Number(props.size);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped lang="scss">
|
|
||||||
.root {
|
|
||||||
position: relative;
|
|
||||||
display: inline-block;
|
|
||||||
box-sizing: content-box;
|
|
||||||
font-size: 30px;
|
|
||||||
background-color: white;
|
|
||||||
border: 1px solid rgba(221, 221, 221, 1);
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
.node {
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
right: 0;
|
|
||||||
background-color: white;
|
|
||||||
border-radius: 100%;
|
|
||||||
box-shadow: 0 3px 1px 0 rgba(0, 0, 0, 0.05), 0 2px 2px 0 rgba(0, 0, 0, 0.1),
|
|
||||||
0 3px 3px 0 rgba(0, 0, 0, 0.05);
|
|
||||||
transition: transform 0.3s cubic-bezier(0.3, 1.05, 0.4, 1.05);
|
|
||||||
}
|
|
||||||
|
|
||||||
.strip {
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
background: rgba(95, 184, 120, 1);
|
|
||||||
transition: width 0.3s cubic-bezier(0.3, 1.05, 0.4, 1.05);
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,145 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="top-btn">
|
|
||||||
<div>{{ titleType }}参数</div>
|
|
||||||
<div>
|
|
||||||
<span @click="handleAdd">
|
|
||||||
<el-button :disabled="isDisabled" icon="Plus"></el-button>
|
|
||||||
</span>
|
|
||||||
<span @click="handleSub">
|
|
||||||
<el-button :icon="Minus" :disabled="isDisabled" icon="Plus"></el-button>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<el-table
|
|
||||||
:empty-text="emptyText"
|
|
||||||
:data="columnList"
|
|
||||||
row-key="columnId"
|
|
||||||
:lazy="true"
|
|
||||||
:header-cell-style="{ background: '#f5f5f8' }"
|
|
||||||
style="width: 550px; margin-bottom: 15px"
|
|
||||||
ref="topSearchColumn"
|
|
||||||
>
|
|
||||||
<el-table-column label="映射字段" align="center" prop="mapField">
|
|
||||||
<template #default="scope">
|
|
||||||
<el-select
|
|
||||||
v-model="scope.row.mappingKey"
|
|
||||||
placeholder="映射字段"
|
|
||||||
filterable
|
|
||||||
clearable
|
|
||||||
>
|
|
||||||
<el-option
|
|
||||||
v-for="item in mapFieldType"
|
|
||||||
:value="item.value + ''"
|
|
||||||
:label="item.label"
|
|
||||||
>
|
|
||||||
</el-option>
|
|
||||||
</el-select>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="查询字段" prop="mappingKey" align="center">
|
|
||||||
<template #default="scope">
|
|
||||||
<el-input
|
|
||||||
v-model="scope.row.mappingValue"
|
|
||||||
@change="handleInputChange"
|
|
||||||
placeholder="查询字段"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="类型" prop="inputType" align="center">
|
|
||||||
<template #default="scope">
|
|
||||||
<el-select
|
|
||||||
v-model="scope.row.inputType"
|
|
||||||
placeholder="类型"
|
|
||||||
filterable
|
|
||||||
clearable
|
|
||||||
>
|
|
||||||
<el-option value="number" label="number"> </el-option>
|
|
||||||
<el-option value="string" label="string"> </el-option>
|
|
||||||
</el-select>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="描述" prop="description" align="center">
|
|
||||||
<template #default="scope">
|
|
||||||
<el-input v-model="scope.row.description" placeholder="字段描述" />
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="必填" prop="description" align="center">
|
|
||||||
<template #default="scope">
|
|
||||||
<el-switch v-model="scope.row.required" />
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
/**
|
|
||||||
* @author: JimTT
|
|
||||||
* @description: 动态表格组件
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { defineExpose, defineProps, watch } from "vue";
|
|
||||||
import { Minus } from "@element-plus/icons-vue";
|
|
||||||
|
|
||||||
const props = defineProps({
|
|
||||||
titleType: {
|
|
||||||
type: String,
|
|
||||||
default: "Params",
|
|
||||||
},
|
|
||||||
initColumList: {
|
|
||||||
type: Array,
|
|
||||||
default: [],
|
|
||||||
},
|
|
||||||
isDisabled: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true,
|
|
||||||
},
|
|
||||||
mapFieldType: {
|
|
||||||
type: Array,
|
|
||||||
default: [],
|
|
||||||
},
|
|
||||||
emptyText: {
|
|
||||||
type: String,
|
|
||||||
default: "",
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const columnList = ref([...props.initColumList]);
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => props.initColumList,
|
|
||||||
(cur, preCur) => {
|
|
||||||
console.log(cur);
|
|
||||||
console.log("======");
|
|
||||||
console.log(preCur);
|
|
||||||
columnList.value = cur;
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
const handleAdd = () => {
|
|
||||||
let obj = {
|
|
||||||
mappingValue: null,
|
|
||||||
mappingKey: null,
|
|
||||||
mappingType: 0,
|
|
||||||
};
|
|
||||||
columnList.value.push(obj);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleSub = () => {
|
|
||||||
columnList.value.pop();
|
|
||||||
};
|
|
||||||
|
|
||||||
defineExpose({
|
|
||||||
columnList,
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.isPk {
|
|
||||||
position: absolute;
|
|
||||||
color: red;
|
|
||||||
}
|
|
||||||
.top-btn {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,740 +0,0 @@
|
|||||||
<template>
|
|
||||||
<el-form :model="queryParams" inline class="query-form" ref="queryForm">
|
|
||||||
<el-form-item label="接口地址" prop="portalName">
|
|
||||||
<el-input
|
|
||||||
v-model="queryParams.path"
|
|
||||||
placeholder="请输暴露地址"
|
|
||||||
></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="接口名称" prop="portalName">
|
|
||||||
<el-input
|
|
||||||
v-model="queryParams.portalName"
|
|
||||||
placeholder="请输入接口名称"
|
|
||||||
></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="是否匿名" prop="portalName">
|
|
||||||
<el-select
|
|
||||||
v-model="queryParams.anonymity"
|
|
||||||
placeholder="请选择是否匿名"
|
|
||||||
clearable
|
|
||||||
filterable
|
|
||||||
>
|
|
||||||
<el-option
|
|
||||||
:label="item.label"
|
|
||||||
:value="item.value"
|
|
||||||
v-for="item in permissionType"
|
|
||||||
/>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="接口类型" prop="type">
|
|
||||||
<el-select
|
|
||||||
v-model="queryParams.type"
|
|
||||||
placeholder="请选择接口类型"
|
|
||||||
clearable
|
|
||||||
filterable
|
|
||||||
>
|
|
||||||
<el-option label="本地接口" value="本地接口" />
|
|
||||||
<el-option label="第三方接口" value="第三方接口" />
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item>
|
|
||||||
<el-button type="primary" @click="getList" :icon="Search">搜索</el-button>
|
|
||||||
<el-button @click="handleReset" :icon="Refresh">重置</el-button>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
<div class="query-btn">
|
|
||||||
<el-button
|
|
||||||
type="primary"
|
|
||||||
v-perm="['query:portal:add-custom']"
|
|
||||||
@click="handleAdd('Local')"
|
|
||||||
:icon="Plus"
|
|
||||||
plain
|
|
||||||
>新增本地接口</el-button
|
|
||||||
>
|
|
||||||
<el-button
|
|
||||||
type="danger"
|
|
||||||
:icon="Plus"
|
|
||||||
v-perm="['query:portal:add-other']"
|
|
||||||
@click="handleAdd('Third')"
|
|
||||||
plain
|
|
||||||
>导入第三方接口
|
|
||||||
</el-button>
|
|
||||||
</div>
|
|
||||||
<div class="table">
|
|
||||||
<el-table
|
|
||||||
:data="list"
|
|
||||||
row-key="adapterId"
|
|
||||||
:lazy="true"
|
|
||||||
ref="singleTable"
|
|
||||||
v-loading="loading"
|
|
||||||
v-tabh
|
|
||||||
>
|
|
||||||
<el-table-column type="selection" width="55" />
|
|
||||||
<el-table-column label="序号" type="index" width="60" />
|
|
||||||
<el-table-column prop="portalName" label="接口名称" align="center" />
|
|
||||||
<el-table-column prop="permissionType" label="是否匿名" align="center">
|
|
||||||
<template #default="scope">
|
|
||||||
<tag dict-type="permission_type" :value="scope.row.permissionType" />
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column prop="type" label="接口类型" align="center">
|
|
||||||
<template #default="scope">
|
|
||||||
<tag dict-type="portal_type" :value="scope.row.type" />
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column prop="path" label="接口url" align="center" />
|
|
||||||
<el-table-column prop="queryName" label="查询名称 " align="center" />
|
|
||||||
<el-table-column prop="queryType" label="查询类型" align="center">
|
|
||||||
<template #default="scope">
|
|
||||||
<tag dict-type="custom_query_type" :value="scope.row.queryType" />
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column prop="adapterCodeType" label="适配器类型" align="center">
|
|
||||||
<template #default="scope">
|
|
||||||
<tag
|
|
||||||
dict-type="data_adapter_type"
|
|
||||||
:value="scope.row.adapterCodeType"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column prop="state" label="状态" align="center">
|
|
||||||
<template #default="scope">
|
|
||||||
<ThreeSwitch size="0.7" :check="1" @UpdateCheck="handleUpdateCheck" />
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column prop="createTime" label="创建时间" align="center" />
|
|
||||||
<el-table-column prop="updateTime" label="更新时间" align="center" />
|
|
||||||
<el-table-column prop="remark" label="备注" align="center">
|
|
||||||
<template #default="scope">
|
|
||||||
{{ scope.row.remark || "--" }}
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="操作" width="350" align="center">
|
|
||||||
<template #default="scope">
|
|
||||||
<el-button
|
|
||||||
type="primary"
|
|
||||||
size="small"
|
|
||||||
v-perm="['query:adapter:edit']"
|
|
||||||
@click="handleEdit(scope.row.adapterId)"
|
|
||||||
link
|
|
||||||
>接口详情
|
|
||||||
</el-button>
|
|
||||||
<el-button
|
|
||||||
type="primary"
|
|
||||||
size="small"
|
|
||||||
@click="handleEdit(scope.row)"
|
|
||||||
link
|
|
||||||
>编辑
|
|
||||||
</el-button>
|
|
||||||
<el-button
|
|
||||||
v-if="scope.row.createDataAdapter"
|
|
||||||
type="primary"
|
|
||||||
size="small"
|
|
||||||
@click="handleDesign(scope.row)"
|
|
||||||
link
|
|
||||||
>设计
|
|
||||||
</el-button>
|
|
||||||
<el-button
|
|
||||||
v-if="scope.row.createDataAdapter"
|
|
||||||
type="primary"
|
|
||||||
size="small"
|
|
||||||
@click="handlePublish(scope.row.portalId)"
|
|
||||||
link
|
|
||||||
>上线
|
|
||||||
</el-button>
|
|
||||||
<popover-delete
|
|
||||||
:name="scope.row.portalName"
|
|
||||||
:type="'接口'"
|
|
||||||
:perm="['query:adapter:del']"
|
|
||||||
@delete="handleDelete(scope.row.portalId)"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
|
||||||
</div>
|
|
||||||
<paging
|
|
||||||
:current-page="pageInfo.pageNum"
|
|
||||||
:page-size="pageInfo.pageSize"
|
|
||||||
:page-sizes="[10, 20, 30, 40, 50]"
|
|
||||||
:total="total"
|
|
||||||
@changeSize="handleSizeChange"
|
|
||||||
@goPage="handleCurrentChange"
|
|
||||||
/>
|
|
||||||
<el-dialog v-model="isModalVisited" :title="title" width="1200px">
|
|
||||||
<div>
|
|
||||||
<el-form
|
|
||||||
label-width="100px"
|
|
||||||
:model="form"
|
|
||||||
:rules="formRules"
|
|
||||||
ref="formInstance"
|
|
||||||
class="dialog-content"
|
|
||||||
>
|
|
||||||
<div class="dialog-content-left">
|
|
||||||
<el-row>
|
|
||||||
<el-col :span="24" v-if="isLocalAdd">
|
|
||||||
<el-form-item label="查询类型" prop="queryType">
|
|
||||||
<el-select
|
|
||||||
v-model="form.queryType"
|
|
||||||
placeholder="请选择查询类型"
|
|
||||||
@change="handleSelectQuery"
|
|
||||||
>
|
|
||||||
<el-option
|
|
||||||
v-for="item in cacheStore.getDict('custom_query_type')"
|
|
||||||
:label="item.label"
|
|
||||||
:value="item.value"
|
|
||||||
></el-option>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="24" v-if="isLocalAdd">
|
|
||||||
<el-form-item label="查询名称" prop="queryId">
|
|
||||||
<el-select
|
|
||||||
v-model="form.queryId"
|
|
||||||
placeholder="请选择一个自定义查询"
|
|
||||||
@change="handleSelectQueryDetail(form.queryId)"
|
|
||||||
>
|
|
||||||
<el-option
|
|
||||||
v-for="item in queryListType"
|
|
||||||
:label="item.label"
|
|
||||||
:value="item.value"
|
|
||||||
></el-option>
|
|
||||||
<template #empty>请先选择查询类型</template>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="24" v-if="!isLocalAdd">
|
|
||||||
<el-form-item label="三方接口Url" prop="url">
|
|
||||||
<el-input
|
|
||||||
v-model="form.url"
|
|
||||||
placeholder="请输入完整的第三方接口Url"
|
|
||||||
></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="24">
|
|
||||||
<el-form-item label="接口名称" prop="portalName">
|
|
||||||
<el-input
|
|
||||||
v-model="form.portalName"
|
|
||||||
placeholder="请输入接口名称"
|
|
||||||
></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="24">
|
|
||||||
<el-form-item label="是否匿名" prop="permissionType">
|
|
||||||
<el-radio-group v-model="form.permissionType">
|
|
||||||
<el-radio
|
|
||||||
v-for="item in cacheStore.getDict('permission_type')"
|
|
||||||
:label="item.value"
|
|
||||||
>{{ item.label }}</el-radio
|
|
||||||
>
|
|
||||||
</el-radio-group>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="24">
|
|
||||||
<el-form-item label="接口方法" prop="requestMethod">
|
|
||||||
<el-select
|
|
||||||
v-model="form.requestMethod"
|
|
||||||
disabled
|
|
||||||
placeholder="Get"
|
|
||||||
></el-select>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="24">
|
|
||||||
<el-form-item label="接口url" prop="path">
|
|
||||||
<el-input
|
|
||||||
v-model="form.path"
|
|
||||||
placeholder="请输入接口url"
|
|
||||||
></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="24">
|
|
||||||
<el-form-item label="适配器来源" prop="createDataAdapter">
|
|
||||||
<el-radio-group
|
|
||||||
v-model="form.createDataAdapter"
|
|
||||||
@change="handleAdapterRadioChange"
|
|
||||||
>
|
|
||||||
<el-radio :label="true">新增适配器</el-radio>
|
|
||||||
<el-radio :label="false">选择一个适配器</el-radio>
|
|
||||||
</el-radio-group>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="24" v-if="form.createDataAdapter">
|
|
||||||
<el-form-item label="适配器语言" prop="adapterCodeType">
|
|
||||||
<el-select
|
|
||||||
v-model="form.adapterCodeType"
|
|
||||||
placeholder="请选择适配器使用的编程语言"
|
|
||||||
>
|
|
||||||
<el-option
|
|
||||||
v-for="item in cacheStore.getDict('data_adapter_type')"
|
|
||||||
:label="item.label"
|
|
||||||
:value="item.value"
|
|
||||||
/>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="24" v-if="!form.createDataAdapter">
|
|
||||||
<el-form-item label="适配器" prop="adapterId">
|
|
||||||
<el-select
|
|
||||||
v-model="form.adapterId"
|
|
||||||
placeholder="请选择一个适配器"
|
|
||||||
>
|
|
||||||
<el-option
|
|
||||||
v-for="item in adapterListType"
|
|
||||||
:value="item.adapterId"
|
|
||||||
:label="item.adapterName"
|
|
||||||
/>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="24">
|
|
||||||
<el-form-item label="备注" prop="remark">
|
|
||||||
<el-input
|
|
||||||
v-model="form.remark"
|
|
||||||
placeholder="请输入备注"
|
|
||||||
></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<FieldTable
|
|
||||||
ref="fieldTableRef"
|
|
||||||
:init-colum-list="initColumList"
|
|
||||||
title-type="Params"
|
|
||||||
:is-disabled="false"
|
|
||||||
:mapFieldType="mapFieldType"
|
|
||||||
empty-text="空"
|
|
||||||
@fieldTableData="handleFieldTableData"
|
|
||||||
/>
|
|
||||||
<FieldTable title-type="Headers" empty-text="请求方法不支持" />
|
|
||||||
<FieldTable title-type="Body" empty-text="请求方法不支持" />
|
|
||||||
</div>
|
|
||||||
</el-form>
|
|
||||||
</div>
|
|
||||||
<template #footer>
|
|
||||||
<span>
|
|
||||||
<el-button @click="handleCancel">取消</el-button>
|
|
||||||
<el-button type="primary" @click="handleSubmit(formInstance)"
|
|
||||||
>确定</el-button
|
|
||||||
>
|
|
||||||
</span>
|
|
||||||
</template>
|
|
||||||
</el-dialog>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import {
|
|
||||||
getPortalList,
|
|
||||||
getQueryList,
|
|
||||||
getAdapterList,
|
|
||||||
getMapFields,
|
|
||||||
addPortal,
|
|
||||||
getPortalDetail,
|
|
||||||
updatePortal,
|
|
||||||
deletePortal,
|
|
||||||
publishPortal,
|
|
||||||
} from "@/api/custom-query/portal.js";
|
|
||||||
import Tag from "@/components/Tag.vue";
|
|
||||||
import { ElMessage, ElMessageBox } from "element-plus";
|
|
||||||
import { Search, Refresh, Plus } from "@element-plus/icons-vue";
|
|
||||||
import Paging from "@/components/pagination/index.vue";
|
|
||||||
import ThreeSwitch from "./ThreeSwitch.vue";
|
|
||||||
import FieldTable from "./fieldTable.vue";
|
|
||||||
import { useCacheStore } from "@/stores/cache";
|
|
||||||
import { useRouter } from "vue-router";
|
|
||||||
import { nextTick, reactive, watchEffect } from "vue";
|
|
||||||
|
|
||||||
const router = useRouter();
|
|
||||||
const cacheStore = useCacheStore();
|
|
||||||
const queryParams = reactive({
|
|
||||||
anonymity: "",
|
|
||||||
path: "",
|
|
||||||
portalName: "",
|
|
||||||
type: "",
|
|
||||||
});
|
|
||||||
|
|
||||||
const form = reactive({
|
|
||||||
queryType: null,
|
|
||||||
queryId: null,
|
|
||||||
url: null,
|
|
||||||
portalName: null,
|
|
||||||
anonymity: true,
|
|
||||||
type: null,
|
|
||||||
path: null,
|
|
||||||
createDataAdapter: false,
|
|
||||||
adapterCodeType: null,
|
|
||||||
dataAdapter: {
|
|
||||||
type: null,
|
|
||||||
},
|
|
||||||
adapterId: null,
|
|
||||||
remark: null,
|
|
||||||
});
|
|
||||||
|
|
||||||
const initColumList = ref([]);
|
|
||||||
//
|
|
||||||
const pageInfo = reactive({
|
|
||||||
pageNum: 1,
|
|
||||||
pageSize: 10,
|
|
||||||
});
|
|
||||||
const list = ref([]);
|
|
||||||
const queryForm = ref([]);
|
|
||||||
const loading = ref(true);
|
|
||||||
const total = ref();
|
|
||||||
const title = ref("");
|
|
||||||
|
|
||||||
//
|
|
||||||
const isEdit = ref(false);
|
|
||||||
const isLocalAdd = ref(false);
|
|
||||||
const isModalVisited = ref(false);
|
|
||||||
|
|
||||||
//
|
|
||||||
const fieldTableRef = ref(null);
|
|
||||||
const formInstance = ref(null);
|
|
||||||
|
|
||||||
//
|
|
||||||
const queryListType = ref(null);
|
|
||||||
const adapterListType = ref(null);
|
|
||||||
const mapFieldType = ref(null);
|
|
||||||
const permissionType = ref(null);
|
|
||||||
|
|
||||||
//
|
|
||||||
const formRules = ref({
|
|
||||||
queryType: [{ required: true, message: "请选择查询类型", trigger: "blur" }],
|
|
||||||
queryId: [{ required: true, message: "请选择查询名称", trigger: "blur" }],
|
|
||||||
portalName: [{ required: true, message: "请输入接口名称", trigger: "blur" }],
|
|
||||||
anonymity: [{ required: true, message: "请选择是否匿名", trigger: "blur" }],
|
|
||||||
path: [{ required: true, message: "请输入接口路径", trigger: "blur" }],
|
|
||||||
createDataAdapter: [
|
|
||||||
{ required: true, message: "请选择适配器来源", trigger: "blur" },
|
|
||||||
],
|
|
||||||
adapterCodeType: [
|
|
||||||
{ required: true, message: "请选择一个适配器语言", trigger: "blur" },
|
|
||||||
],
|
|
||||||
remark: [{ required: false }],
|
|
||||||
});
|
|
||||||
|
|
||||||
// 获取列表
|
|
||||||
const getList = async () => {
|
|
||||||
let params = {
|
|
||||||
...queryParams,
|
|
||||||
...pageInfo,
|
|
||||||
};
|
|
||||||
loading.value = true;
|
|
||||||
getPortalList(params).then((res) => {
|
|
||||||
if (res.code === 1000) {
|
|
||||||
list.value = res?.data?.rows;
|
|
||||||
total.value = res?.data?.total;
|
|
||||||
loading.value = false;
|
|
||||||
} else {
|
|
||||||
ElMessage.error(res.msg);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
getAdapterList().then((res) => {
|
|
||||||
if (res.code === 1000) {
|
|
||||||
adapterListType.value = res?.data?.rows;
|
|
||||||
} else {
|
|
||||||
ElMessage.error(res.msg);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
//重置form表单
|
|
||||||
const restFrom = () => {
|
|
||||||
form.queryType = null;
|
|
||||||
form.queryId = null;
|
|
||||||
form.portalName = null;
|
|
||||||
form.anonymity = null;
|
|
||||||
form.path = null;
|
|
||||||
form.createDataAdapter = null;
|
|
||||||
form.adapterId = null;
|
|
||||||
form.dataAdapter.type = null;
|
|
||||||
form.remark = null;
|
|
||||||
form.type = null;
|
|
||||||
mapFieldType.value = null;
|
|
||||||
};
|
|
||||||
|
|
||||||
// 添加
|
|
||||||
const handleAdd = (type) => {
|
|
||||||
restFrom();
|
|
||||||
isModalVisited.value = true;
|
|
||||||
isEdit.value = false;
|
|
||||||
console.log(isEdit);
|
|
||||||
switch (type) {
|
|
||||||
case "Local": {
|
|
||||||
title.value = "新增本地接口";
|
|
||||||
isLocalAdd.value = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "Third": {
|
|
||||||
title.value = "导入三方接口";
|
|
||||||
isLocalAdd.value = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
nextTick(() => {
|
|
||||||
// 清空校验
|
|
||||||
formInstance.value.clearValidate();
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
//编辑
|
|
||||||
const handleEdit = async (row) => {
|
|
||||||
isEdit.value = true;
|
|
||||||
try {
|
|
||||||
if (row.type === "LOCAL") {
|
|
||||||
const { code, data } = await getPortalDetail(row.portalId);
|
|
||||||
if (code === 1000) {
|
|
||||||
form.queryType = data.queryType + "";
|
|
||||||
await handleSelectQuery();
|
|
||||||
title.value = "修改本地接口";
|
|
||||||
isLocalAdd.value = true;
|
|
||||||
isModalVisited.value = true;
|
|
||||||
form.queryId = data.queryId;
|
|
||||||
form.portalId = data.portalId;
|
|
||||||
form.portalName = data.portalName;
|
|
||||||
form.anonymity = data.anonymity;
|
|
||||||
form.path = data.path;
|
|
||||||
form.createDataAdapter = data.createDataAdapter;
|
|
||||||
form.adapterCodeType = data.adapterCodeType;
|
|
||||||
form.permissionType = data.permissionType;
|
|
||||||
form.adapterId = data.adapterId;
|
|
||||||
form.remark = data.remark;
|
|
||||||
form.type = data.type;
|
|
||||||
initColumList.value = data.mappings;
|
|
||||||
await handleSelectQueryDetail(data.queryId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (row.type === "EXTERNAL") {
|
|
||||||
const { code, data } = await getPortalDetail(row.portalId);
|
|
||||||
if (code === 1000) {
|
|
||||||
form.queryType = data.queryType + "";
|
|
||||||
await handleSelectQuery();
|
|
||||||
title.value = "修改第三方接口";
|
|
||||||
isLocalAdd.value = false;
|
|
||||||
isModalVisited.value = true;
|
|
||||||
form.queryId = data.queryId;
|
|
||||||
form.portalId = data.portalId;
|
|
||||||
form.portalName = data.portalName;
|
|
||||||
form.anonymity = data.anonymity;
|
|
||||||
form.path = data.path;
|
|
||||||
form.createDataAdapter = data.createDataAdapter;
|
|
||||||
form.adapterCodeType = data.adapterCodeType;
|
|
||||||
form.permissionType = data.permissionType;
|
|
||||||
form.adapterId = data.adapterId;
|
|
||||||
form.remark = data.remark;
|
|
||||||
form.type = data.type;
|
|
||||||
form.url = data.url;
|
|
||||||
initColumList.value = data.mappings;
|
|
||||||
await handleSelectQueryDetail(data.queryId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
console.log(err);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// 设计
|
|
||||||
const handleDesign = (data) => {
|
|
||||||
router.push({
|
|
||||||
path: `/custom/query/data/adapter/design/${data.adapterId}`,
|
|
||||||
query: {
|
|
||||||
special: true,
|
|
||||||
portalId: data.portalId,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
//删除
|
|
||||||
const handleDelete = async (portalId) => {
|
|
||||||
deletePortal(portalId).then((res) => {
|
|
||||||
if (res.code === 1000) {
|
|
||||||
ElMessage.success(res.msg);
|
|
||||||
getList();
|
|
||||||
} else {
|
|
||||||
ElMessage.error(res.msg);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
//取消
|
|
||||||
const handleCancel = () => {
|
|
||||||
restFrom();
|
|
||||||
isModalVisited.value = false;
|
|
||||||
nextTick(() => {
|
|
||||||
// 清空校验
|
|
||||||
formInstance.value.clearValidate();
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// 跳转适配器
|
|
||||||
const routerToAdapter = (adapterId, portalId) => {
|
|
||||||
ElMessageBox.confirm("是否立即去设计你的新增适配器", "Warning", {
|
|
||||||
confirmButtonText: "确认",
|
|
||||||
cancelButtonText: "取消",
|
|
||||||
type: "warning",
|
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
router.push({
|
|
||||||
path: `/custom/query/data/adapter/design/${adapterId}`,
|
|
||||||
query: {
|
|
||||||
special: true,
|
|
||||||
portalId: portalId,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
ElMessage({
|
|
||||||
type: "info",
|
|
||||||
message: "取消成功",
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// 发布接口
|
|
||||||
const handlePublish = async (portalId) => {
|
|
||||||
try {
|
|
||||||
const { code, msg } = await publishPortal({
|
|
||||||
portalId,
|
|
||||||
});
|
|
||||||
if (code === 1000) {
|
|
||||||
ElMessage({ type: "success", message: "发布成功" });
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
console.log("Publish Failed:", err);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// 提交
|
|
||||||
const handleSubmit = async (instance) => {
|
|
||||||
await instance.validate((success, fields) => {
|
|
||||||
if (success) {
|
|
||||||
// 本地接口提交
|
|
||||||
if (isLocalAdd.value && !isEdit.value) {
|
|
||||||
addPortal({
|
|
||||||
...form,
|
|
||||||
type: "LOCAL",
|
|
||||||
mappings: fieldTableRef.value.columnList,
|
|
||||||
requestMethod: "GET",
|
|
||||||
}).then((res) => {
|
|
||||||
const { portalId, adapterId } = res.data;
|
|
||||||
isModalVisited.value = false;
|
|
||||||
ElMessage({
|
|
||||||
type: "success",
|
|
||||||
message: "提交成功",
|
|
||||||
});
|
|
||||||
routerToAdapter(adapterId, portalId);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// 三方接口提交
|
|
||||||
if (!isLocalAdd.value && !isEdit.value) {
|
|
||||||
addPortal({
|
|
||||||
...form,
|
|
||||||
type: "EXTERNAL",
|
|
||||||
mappings: fieldTableRef.value.columnList,
|
|
||||||
interfaceRequestMethod: "GET",
|
|
||||||
contentType: "application/json",
|
|
||||||
requestMethod: "GET",
|
|
||||||
}).then((res) => {
|
|
||||||
const { portalId, adapterId } = res.data;
|
|
||||||
isModalVisited.value = false;
|
|
||||||
ElMessage({
|
|
||||||
type: "success",
|
|
||||||
message: "提交成功",
|
|
||||||
});
|
|
||||||
routerToAdapter(adapterId, portalId);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// 接口修改
|
|
||||||
if (isEdit.value) {
|
|
||||||
updatePortal({
|
|
||||||
...form,
|
|
||||||
mappings: fieldTableRef.value.columnList,
|
|
||||||
interfaceRequestMethod: "GET",
|
|
||||||
contentType: "application/json",
|
|
||||||
requestMethod: "GET",
|
|
||||||
}).then(() => {
|
|
||||||
ElMessage({
|
|
||||||
type: "success",
|
|
||||||
message: "提交成功",
|
|
||||||
});
|
|
||||||
getList();
|
|
||||||
});
|
|
||||||
isModalVisited.value = false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
console.log("error submit!", fields);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
// 查询类型下拉框change事件
|
|
||||||
const handleSelectQuery = async () => {
|
|
||||||
if (form.queryType) {
|
|
||||||
try {
|
|
||||||
const { code, data } = await getQueryList(form.queryType);
|
|
||||||
if (code === 1000) {
|
|
||||||
form.queryId = null;
|
|
||||||
queryListType.value = data;
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
console.log(err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// 查询具体结果下拉框事件
|
|
||||||
const handleSelectQueryDetail = async (queryId) => {
|
|
||||||
try {
|
|
||||||
const { code, data } = await getMapFields(queryId);
|
|
||||||
if (code === 1000) {
|
|
||||||
mapFieldType.value = data;
|
|
||||||
}
|
|
||||||
} catch (err) {
|
|
||||||
console.log(err);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
//重置搜索
|
|
||||||
const handleReset = () => {
|
|
||||||
console.log("重置~~");
|
|
||||||
};
|
|
||||||
|
|
||||||
// 适配器来源切换
|
|
||||||
const handleAdapterRadioChange = () => {
|
|
||||||
form.dataAdapter.type = null;
|
|
||||||
};
|
|
||||||
|
|
||||||
// 三选项开关切换事件
|
|
||||||
const handleUpdateCheck = (value) => {
|
|
||||||
// TODO::
|
|
||||||
};
|
|
||||||
|
|
||||||
//切换每页显示条数
|
|
||||||
const handleSizeChange = async (val) => {
|
|
||||||
pageInfo.pageSize = val;
|
|
||||||
await getList();
|
|
||||||
};
|
|
||||||
|
|
||||||
//点击页码进行分页功能
|
|
||||||
const handleCurrentChange = async (val) => {
|
|
||||||
pageInfo.pageNum = val;
|
|
||||||
await getList();
|
|
||||||
};
|
|
||||||
|
|
||||||
//
|
|
||||||
getList();
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped lang="scss">
|
|
||||||
.dialog-content {
|
|
||||||
display: flex;
|
|
||||||
.dialog-content-left {
|
|
||||||
width: 50%;
|
|
||||||
margin-right: 15px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.third-dialog-content {
|
|
||||||
display: flex;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,112 +0,0 @@
|
|||||||
<template>
|
|
||||||
<el-form inline class="query-form" ref="queryForm" @submit.prevent="getData">
|
|
||||||
<el-form-item v-for="column in uniCons" :key="column.ucId"
|
|
||||||
:label="column.ucName" :prop="column.ucName">
|
|
||||||
<el-input :placeholder="column.ucDescribe" :type="column.ucType" v-model="column.query" clearable
|
|
||||||
></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item>
|
|
||||||
<el-button type="primary" @click="getData" :icon="Search">搜索</el-button>
|
|
||||||
<el-button @click="handleReset" :icon="Refresh">重置</el-button>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
<el-table :data="tableData" v-loading="tableLoading" :max-height="tableHeight" v-tabh>
|
|
||||||
<el-table-column v-for="column in uniColumns" :key="column.prop" :prop="column.prop"
|
|
||||||
:label="column.label" align="center"/>
|
|
||||||
</el-table>
|
|
||||||
<paging :current-page="pageInfo.pageNum" :page-size="pageInfo.pageSize" :page-sizes="[10, 20, 30, 40,50]"
|
|
||||||
:total="total" @changeSize="handleSizeChange" @goPage="handleCurrentChange"/>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import {Search, Refresh} from '@element-plus/icons-vue'
|
|
||||||
import {getPageInfo,getPageData} from "@/api/custom-query/query-page";
|
|
||||||
import {reactive} from "vue";
|
|
||||||
import Paging from "@/components/pagination/index.vue";
|
|
||||||
import {ElMessage} from "element-plus";
|
|
||||||
|
|
||||||
const router = useRouter()
|
|
||||||
let path = router.currentRoute.value.path.split("/")
|
|
||||||
const queryId = reactive(path[path.length-1])
|
|
||||||
const queryForm = ref([])
|
|
||||||
const tableData = ref([])
|
|
||||||
const uniCons = ref([])
|
|
||||||
const uniColumns = ref([])
|
|
||||||
const tableLoading = ref(true)
|
|
||||||
const total = ref()
|
|
||||||
const pageInfo = reactive({
|
|
||||||
pageNum: 1,
|
|
||||||
pageSize: 10,
|
|
||||||
})
|
|
||||||
const tableHeight = ref(document.documentElement.scrollHeight - 245 + 'px')
|
|
||||||
|
|
||||||
const initPage = () => {
|
|
||||||
tableLoading.value = true
|
|
||||||
getPageInfo(queryId,pageInfo).then(res=>{
|
|
||||||
let data = res.data
|
|
||||||
uniColumns.value = data.uniColumns
|
|
||||||
uniCons.value = data.uniCons
|
|
||||||
let table = data.table
|
|
||||||
tableData.value = table.rows
|
|
||||||
total.value = table.total
|
|
||||||
tableLoading.value = false
|
|
||||||
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const changeInput = (val,column) => {
|
|
||||||
console.log(val,column)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
const getData = () => {
|
|
||||||
tableLoading.value = true
|
|
||||||
let queryData = []
|
|
||||||
uniCons.value.forEach(con=>{
|
|
||||||
if (con.query){
|
|
||||||
let queryItem = {
|
|
||||||
query:con.query,
|
|
||||||
ucId: con.ucId
|
|
||||||
}
|
|
||||||
queryData.push(queryItem)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
tableLoading.value = true
|
|
||||||
getPageData(pageInfo,{list:queryData,queryId}).then(res=>{
|
|
||||||
if(res.code===1000){
|
|
||||||
let data = res.data
|
|
||||||
tableData.value = data.rows
|
|
||||||
total.value = data.total
|
|
||||||
tableLoading.value = false
|
|
||||||
}else {
|
|
||||||
ElMessage.error(res.msg);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
//重置搜索
|
|
||||||
const handleReset = () => {
|
|
||||||
uniCons.value.forEach(con=>{
|
|
||||||
con.query=''
|
|
||||||
})
|
|
||||||
getData()
|
|
||||||
}
|
|
||||||
//切换每页显示条数
|
|
||||||
const handleSizeChange = (val) => {
|
|
||||||
pageInfo.pageSize = val
|
|
||||||
getData()
|
|
||||||
}
|
|
||||||
|
|
||||||
//点击页码进行分页功能
|
|
||||||
const handleCurrentChange = (val) => {
|
|
||||||
pageInfo.pageNum = val
|
|
||||||
getData()
|
|
||||||
}
|
|
||||||
|
|
||||||
initPage()
|
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
|
|
||||||
</style>
|
|
||||||
@@ -1,486 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div>
|
|
||||||
<el-form ref="queryForm" class="query-form" :model="sqlQueryParams">
|
|
||||||
<el-row :gutter="20">
|
|
||||||
<el-col :span="18">
|
|
||||||
<div class="code-editor" v-if="editLoading">
|
|
||||||
<sql-code-edit v-model:value="sqlQueryParams.uniSql" :editor-placeholder="'请输入sql语句进行查询'"
|
|
||||||
:editor-height="300" :tab-size="2" @change="changeSqlCode"/>
|
|
||||||
</div>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="6">
|
|
||||||
<el-form-item label-width="55px" label="名称" prop="uqName">
|
|
||||||
<el-input v-model="sqlQueryParams.uqName" placeholder="请输入名称" clearable :style="{width: '100%'}">
|
|
||||||
</el-input>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label-width="55px" label="描述" prop="uqDescribe">
|
|
||||||
<el-input v-model="sqlQueryParams.uqDescribe" placeholder="请输入描述" clearable :style="{width: '100%'}">
|
|
||||||
</el-input>
|
|
||||||
</el-form-item>
|
|
||||||
<!-- <el-form-item v-for="column in uniCons" :key="column.ucId"-->
|
|
||||||
<!-- :label="column.ucName">-->
|
|
||||||
<!-- <el-input :placeholder="column.ucDescribe" :type="column.ucType" v-model="column.query" clearable-->
|
|
||||||
<!-- @input="changeInput($event)"></el-input>-->
|
|
||||||
<!-- </el-form-item>-->
|
|
||||||
<!-- <el-button type="primary" @click="getSqlQueryInfo" link>搜索</el-button>-->
|
|
||||||
<el-button type="primary" @click="handleReset" link>重置</el-button>
|
|
||||||
<el-button type="primary" @click="handleAdd" link>新增</el-button>
|
|
||||||
<el-button type="primary" @click="previewSqlHandle" link>预览</el-button>
|
|
||||||
<el-button type="primary" @click="submitForm" link>保存</el-button>
|
|
||||||
<el-button type="primary" @click="handleTopLine" link>上线</el-button>
|
|
||||||
<el-button v-if="previewTable.length!==0" type="primary" @click="handleGetParams" link>字段提取</el-button>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
</el-form>
|
|
||||||
<div class="table">
|
|
||||||
<el-table :data="columns" row-key="columnId" :max-height="tableHeight"
|
|
||||||
:header-cell-style="{'background':'#f5f7fa'}" >
|
|
||||||
<el-table-column label="序号" type="index" min-width="5%"/>
|
|
||||||
<el-table-column label="查询名称" min-width="10%">
|
|
||||||
<template #default="scope">
|
|
||||||
<el-input v-model="scope.row.ucName"></el-input>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="条件描述" min-width="10%">
|
|
||||||
<template #default="scope">
|
|
||||||
<el-input v-model="scope.row.ucDescribe"></el-input>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="key" min-width="10%">
|
|
||||||
<template #default="scope">
|
|
||||||
<el-input v-model="scope.row.ucKey"></el-input>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="条件" min-width="10%">
|
|
||||||
<template #default="scope">
|
|
||||||
<el-select v-model="scope.row.ucCon" @change="ucTypeChang(scope.$index,scope.row)">
|
|
||||||
<el-option label="=" value="EQ"/>
|
|
||||||
<el-option label="!=" value="NE"/>
|
|
||||||
<el-option label=">" value="GT"/>
|
|
||||||
<el-option label=">=" value="GTE"/>
|
|
||||||
<el-option label="<" value="LT"/>
|
|
||||||
<el-option label="<=" value="LTE"/>
|
|
||||||
<el-option label="LIKE" value="LIKE"/>
|
|
||||||
<el-option label="BETWEEN" value="BETWEEN"/>
|
|
||||||
</el-select>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="显示类型" min-width="12%">
|
|
||||||
<template #default="scope">
|
|
||||||
<el-select v-model="scope.row.ucType" @change="ucTypeChang(scope.$index,scope.row)">
|
|
||||||
<el-option label="文本框" value="input"/>
|
|
||||||
<el-option label="日期控件" value="datetime"/>
|
|
||||||
</el-select>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="模拟数据" min-width="18%">
|
|
||||||
<template #default="scope">
|
|
||||||
<el-input v-if="scope.row.type == 1" placeholder="请输入模拟数据" v-model="scope.row.ucMock"></el-input>
|
|
||||||
<div v-else-if="scope.row.type == 2">
|
|
||||||
<el-row :gutter="15">
|
|
||||||
<el-col :span="12">
|
|
||||||
<el-input placeholder="开始值" v-model="scope.row.ucMock.begin"></el-input>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="12">
|
|
||||||
<el-input placeholder="结束值" v-model="scope.row.ucMock.end"></el-input>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
</div>
|
|
||||||
<el-date-picker
|
|
||||||
v-else-if="scope.row.type ==3"
|
|
||||||
v-model="scope.row.ucMock"
|
|
||||||
type="date"
|
|
||||||
format="YYYY-MM-DD"
|
|
||||||
value-format="YYYY-MM-DD"
|
|
||||||
placeholder="选择日期时间"
|
|
||||||
>
|
|
||||||
</el-date-picker>
|
|
||||||
<el-date-picker v-else-if="scope.row.type ==4"
|
|
||||||
v-model="scope.row.ucMock"
|
|
||||||
size="small"
|
|
||||||
style="width: 240px"
|
|
||||||
value-format="yyyy-MM-dd"
|
|
||||||
type="daterange"
|
|
||||||
range-separator="-"
|
|
||||||
start-placeholder="开始日期"
|
|
||||||
end-placeholder="结束日期"
|
|
||||||
></el-date-picker>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="操作" min-width="10%">
|
|
||||||
<template #default="scope">
|
|
||||||
<el-button type="primary" size="mini" @click="handleDelete(scope.$index,scope.row)" link>删除</el-button>
|
|
||||||
<el-button type="primary" @click="submitForm" link>提交</el-button>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
|
||||||
</div>
|
|
||||||
<div v-if="previewVisible">
|
|
||||||
<div class="table">
|
|
||||||
<el-table :data="previewTable" v-loading="previewLoading" :max-height="tableHeight"
|
|
||||||
:header-cell-style="{'background':'#f5f7fa'}">
|
|
||||||
<el-table-column label="序号" type="index" min-width="6%"/>
|
|
||||||
<el-table-column v-for="column in uniColumns" :key="column.prop" :prop="column.prop"
|
|
||||||
:label="column.label" align="center" min-width="10%"/>
|
|
||||||
</el-table>
|
|
||||||
</div>
|
|
||||||
<paging :current-page="pageInfo.pageNum" :page-size="pageInfo.pageSize" :page-sizes="[10, 20, 30, 40,50]"
|
|
||||||
:total="total" @changeSize="handleSizeChange" @goPage="handleCurrentChange"/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<el-dialog v-model="isTopLineVisited" title="上线" width="700px">
|
|
||||||
<el-form :model="form" :rules="formRules" class="query-form" ref="formInstance">
|
|
||||||
<el-form-item label="上级菜单">
|
|
||||||
<el-tree-select v-model="form.parentId" :data="menuOpt" style="width: 100%;"
|
|
||||||
filterable :check-strictly="true"/>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
<template #footer>
|
|
||||||
<el-button @click="handleCancel">取消</el-button>
|
|
||||||
<el-button type="primary" @click="handleSubmit(formInstance)">
|
|
||||||
确定
|
|
||||||
</el-button>
|
|
||||||
</template>
|
|
||||||
</el-dialog>
|
|
||||||
|
|
||||||
<el-dialog v-model="isFieldVisited" title="字段提取" width="800px">
|
|
||||||
<el-button type="primary" @click="handleAddField">新增字段</el-button>
|
|
||||||
<el-table :data="uniColumns" row-key="columnId" :max-height="tableHeight"
|
|
||||||
:header-cell-style="{'background':'#f5f7fa'}">
|
|
||||||
<el-table-column label="字段名称" type="index" width="120px">
|
|
||||||
<template #default="scope">
|
|
||||||
{{ scope.row.prop }}
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="字段别名" >
|
|
||||||
<template #default="scope">
|
|
||||||
<el-input v-model="scope.row.label"></el-input>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="显示类型" >
|
|
||||||
<template #default="scope">
|
|
||||||
<el-select v-model="scope.row.displayType" placeholder="请选择显示类型" clearable filterable @change="displayTypeChange(scope.$index,scope.row)">
|
|
||||||
<el-option
|
|
||||||
v-for="item in cacheStore.getDict('display_type')"
|
|
||||||
:key="item.value"
|
|
||||||
:label="item.label"
|
|
||||||
:value="item.value"
|
|
||||||
/>
|
|
||||||
</el-select>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="显示参数" >
|
|
||||||
<template #default="scope">
|
|
||||||
<el-select v-if="scope.row.displayType == 'date'" v-model="scope.row.displayParam" placeholder="请选择显示参数" clearable filterable>
|
|
||||||
<el-option
|
|
||||||
v-for="item in cacheStore.getDict('date_format')"
|
|
||||||
:key="item.value"
|
|
||||||
:label="item.label"
|
|
||||||
:value="item.value"
|
|
||||||
/>
|
|
||||||
</el-select>
|
|
||||||
<el-select v-if="scope.row.displayType == 'dict'" v-model="scope.row.displayParam" placeholder="请选择显示参数" clearable filterable>
|
|
||||||
<el-option
|
|
||||||
v-for="item in dictOption"
|
|
||||||
:key="item.value"
|
|
||||||
:label="item.label"
|
|
||||||
:value="item.value"
|
|
||||||
/>
|
|
||||||
</el-select>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="操作" >
|
|
||||||
<template #default="scope">
|
|
||||||
<el-button type="primary" size="mini" @click="handleFieldDelete(scope.$index,scope.row)" link>删除</el-button>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
|
||||||
<template #footer>
|
|
||||||
<el-button @click="handleFieldCancel">取消</el-button>
|
|
||||||
<el-button type="primary" @click="handleFieldSubmit">
|
|
||||||
确定
|
|
||||||
</el-button>
|
|
||||||
</template>
|
|
||||||
</el-dialog>
|
|
||||||
<el-dialog v-model="isAddFieldVisited" title="新增字段" width="400px">
|
|
||||||
<el-form ref="queryForm" :model="addFieldParams" :rules="rules">
|
|
||||||
<el-row :gutter="20">
|
|
||||||
<el-col :span="24">
|
|
||||||
<el-form-item label="字段名称" prop="prop">
|
|
||||||
<el-input v-model="addFieldParams.prop" placeholder="请输入字段名称" clearable >
|
|
||||||
</el-input>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="字段别名" prop="label">
|
|
||||||
<el-input v-model="addFieldParams.label" placeholder="请输入字段别名" clearable >
|
|
||||||
</el-input>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
</el-form>
|
|
||||||
</el-dialog>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import SqlCodeEdit from "@/components/codeEdit/SqlCodeEdit.vue";
|
|
||||||
import {useRouter} from "vue-router";
|
|
||||||
import {getSqlInfo, previewSql, saveSqlQueryParams, sqlToLine} from "@/api/custom-query/sql-search";
|
|
||||||
import {getMenuOpt} from '@/api/system/menuman.js'
|
|
||||||
import {ElMessage} from "element-plus";
|
|
||||||
import {reactive} from "vue";
|
|
||||||
import Paging from "@/components/pagination/index.vue";
|
|
||||||
import {useCacheStore} from "@/stores/cache";
|
|
||||||
import {getDictOption} from "@/api/system/dict-type";
|
|
||||||
const cacheStore = useCacheStore()
|
|
||||||
const previewTable = ref([])
|
|
||||||
const uniColumns = ref([])
|
|
||||||
const previewLoading = ref(false)
|
|
||||||
const queryForm = ref()
|
|
||||||
const dictOption = ref([])
|
|
||||||
const menuOpt = ref([])
|
|
||||||
const previewVisible = ref(false)
|
|
||||||
const isTopLineVisited = ref(false)
|
|
||||||
const isAddFieldVisited = ref(false)
|
|
||||||
const isFieldVisited = ref(false)
|
|
||||||
const form = ref({
|
|
||||||
parentId: ''
|
|
||||||
})
|
|
||||||
const total = ref(0)
|
|
||||||
const pageInfo = reactive({
|
|
||||||
pageNum: 1,
|
|
||||||
pageSize: 10,
|
|
||||||
})
|
|
||||||
const formInstance = ref()
|
|
||||||
const formRules = ref({
|
|
||||||
parentId: [{required: true, message: '请选择上级菜单', trigger: 'blur'}]
|
|
||||||
})
|
|
||||||
const router = useRouter();
|
|
||||||
const queryId = reactive(router.currentRoute.value.params.queryId)
|
|
||||||
const addFieldParams=reactive({
|
|
||||||
prop:'',
|
|
||||||
label:''
|
|
||||||
})
|
|
||||||
const sqlQueryParams = reactive({
|
|
||||||
uniSql: '',
|
|
||||||
uqName: null,
|
|
||||||
uqDescribe: null,
|
|
||||||
// columnList: []
|
|
||||||
})
|
|
||||||
const editLoading = ref(true)
|
|
||||||
const loading = ref(false)
|
|
||||||
const rules = ref({
|
|
||||||
uqName: [{required: true, message: '请输入名称', trigger: 'blur'}],
|
|
||||||
uqDescribe: [{required: true, message: '请输入描述', trigger: 'blur'}]
|
|
||||||
})
|
|
||||||
const tableHeight = ref(document.documentElement.scrollHeight - 245 + 'px')
|
|
||||||
const list = ref([])
|
|
||||||
const columns = ref([])
|
|
||||||
const uniCons = ref([])
|
|
||||||
const getDictInfo= async () => {
|
|
||||||
getDictOption().then(res => {
|
|
||||||
if (res.code === 1000) {
|
|
||||||
dictOption.value = res.data
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
const ucTypeChang = (index, row) => {
|
|
||||||
if (row.ucType == 'input' && row.ucCon != 'BETWEEN') {
|
|
||||||
if (typeof (row.ucMock) != 'string') {
|
|
||||||
row.ucMock = ''
|
|
||||||
}
|
|
||||||
row.type = 1
|
|
||||||
} else if (row.ucType == 'input' && row.ucCon == 'BETWEEN') {
|
|
||||||
row.type = 2
|
|
||||||
row.ucMock = {begin: '', end: ''}
|
|
||||||
} else if (row.ucType == 'datetime' && row.ucCon != 'BETWEEN') {
|
|
||||||
row.type = 3
|
|
||||||
row.ucMock = ''
|
|
||||||
} else if (row.ucType == 'datetime' && row.ucCon == 'BETWEEN') {
|
|
||||||
row.type = 4
|
|
||||||
row.ucMock = []
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const displayTypeChange=(index, row)=>{
|
|
||||||
if(row.displayType=='dict'){
|
|
||||||
|
|
||||||
}else if(row.displayType=='date'){
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const getSqlQueryInfo = () => {
|
|
||||||
getSqlInfo(queryId).then(res => {
|
|
||||||
if (res.code === 1000) {
|
|
||||||
columns.value = res.data.uniCons
|
|
||||||
sqlQueryParams.uniSql=res.data.uniSql
|
|
||||||
sqlQueryParams.uqName=res.data.uqName
|
|
||||||
sqlQueryParams.uqDescribe=res.data.uqDescribe
|
|
||||||
} else {
|
|
||||||
ElMessage.error(res.msg)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
//重置搜索
|
|
||||||
const handleReset = () => {
|
|
||||||
sqlQueryParams.uniSql = ' '
|
|
||||||
queryForm.value.resetFields()
|
|
||||||
}
|
|
||||||
const handleAdd = () => {
|
|
||||||
let row = {
|
|
||||||
id: null,
|
|
||||||
uqId: queryId,
|
|
||||||
ucName: '',
|
|
||||||
ucCon: '',
|
|
||||||
ucDescribe: '',
|
|
||||||
ucKey: '',
|
|
||||||
ucMock: '',
|
|
||||||
ucType: '',
|
|
||||||
type: 1
|
|
||||||
}
|
|
||||||
columns.value.push(row)
|
|
||||||
}
|
|
||||||
const handleAddField=()=>{
|
|
||||||
// isAddFieldVisited.value=true
|
|
||||||
let row={
|
|
||||||
prop:'',
|
|
||||||
label:''
|
|
||||||
}
|
|
||||||
uniColumns.value.push(row)
|
|
||||||
}
|
|
||||||
const handleDelete = (index, row) => {
|
|
||||||
columns.value.splice(index, 1)
|
|
||||||
}
|
|
||||||
const submitForm = () => {
|
|
||||||
let data = {
|
|
||||||
queryId: queryId,
|
|
||||||
uniSql: sqlQueryParams.uniSql,
|
|
||||||
uniCons: columns.value,
|
|
||||||
uniColumns: uniColumns.value
|
|
||||||
}
|
|
||||||
editLoading.value = false;
|
|
||||||
saveSqlQueryParams(data).then(res => {
|
|
||||||
if (res.code === 1000) {
|
|
||||||
nextTick(() => {
|
|
||||||
editLoading.value = true;
|
|
||||||
})
|
|
||||||
ElMessage.success(res.msg)
|
|
||||||
} else {
|
|
||||||
ElMessage.error(res.msg)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
//实时获取sql语句
|
|
||||||
const changeSqlCode = (val) => {
|
|
||||||
sqlQueryParams.uniSql = val
|
|
||||||
}
|
|
||||||
|
|
||||||
const previewSqlHandle = () => {
|
|
||||||
if (sqlQueryParams.uniSql == '') {
|
|
||||||
ElMessage({
|
|
||||||
message: '请先输入sql语句再进行预览!',
|
|
||||||
type: 'warning',
|
|
||||||
})
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
previewLoading.value = true
|
|
||||||
let data = {
|
|
||||||
queryId: queryId,
|
|
||||||
uniSql: sqlQueryParams.uniSql,
|
|
||||||
uniCons: columns.value,
|
|
||||||
uniColumns: uniColumns.value
|
|
||||||
}
|
|
||||||
previewSql(data, pageInfo).then(res => {
|
|
||||||
if (res.code === 1000) {
|
|
||||||
ElMessage.success(res.msg)
|
|
||||||
previewLoading.value = false
|
|
||||||
previewVisible.value = true
|
|
||||||
previewTable.value = res.data.table.rows
|
|
||||||
total.value = res.data.table.total
|
|
||||||
let keyList = []
|
|
||||||
for (let key in res.data.table.rows[0]) {
|
|
||||||
let keyObject = {
|
|
||||||
label: key,
|
|
||||||
prop: key,
|
|
||||||
}
|
|
||||||
keyList.push(keyObject)
|
|
||||||
}
|
|
||||||
uniColumns.value = keyList
|
|
||||||
} else {
|
|
||||||
ElMessage.error(res.msg)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
//切换每页显示条数
|
|
||||||
const handleSizeChange = (val) => {
|
|
||||||
pageInfo.pageSize = val
|
|
||||||
previewSqlHandle()
|
|
||||||
}
|
|
||||||
|
|
||||||
//点击页码进行分页功能
|
|
||||||
const handleCurrentChange = (val) => {
|
|
||||||
pageInfo.pageNum = val
|
|
||||||
previewSqlHandle()
|
|
||||||
}
|
|
||||||
//点击上线按钮弹出选择菜单框
|
|
||||||
const handleTopLine = () => {
|
|
||||||
getMenuOpt().then(res => {
|
|
||||||
menuOpt.value = [{
|
|
||||||
value: 0,
|
|
||||||
label: "一级目录",
|
|
||||||
children: res.data
|
|
||||||
}]
|
|
||||||
})
|
|
||||||
isTopLineVisited.value = true
|
|
||||||
}
|
|
||||||
//提取字段
|
|
||||||
const handleGetParams = () => {
|
|
||||||
isFieldVisited.value = true
|
|
||||||
}
|
|
||||||
const restForm = () => {
|
|
||||||
form.value = {
|
|
||||||
parentId: ''
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//取消
|
|
||||||
const handleCancel = () => {
|
|
||||||
restForm();
|
|
||||||
isTopLineVisited.value = false;
|
|
||||||
};
|
|
||||||
const handleFieldCancel = () => {
|
|
||||||
isFieldVisited.value = false;
|
|
||||||
};
|
|
||||||
const handleFieldSubmit = () => {
|
|
||||||
isFieldVisited.value = false;
|
|
||||||
}
|
|
||||||
const handleSubmit = async (instance) => {
|
|
||||||
if (!instance) return
|
|
||||||
instance.validate(async (valid, fields) => {
|
|
||||||
if (!valid) return
|
|
||||||
let data = {
|
|
||||||
menuId: form.value.parentId,
|
|
||||||
queryId: queryId,
|
|
||||||
uniSql: sqlQueryParams.uniSql,
|
|
||||||
uniCons: columns.value,
|
|
||||||
uniColumns: uniColumns.value
|
|
||||||
}
|
|
||||||
sqlToLine(data).then(res => {
|
|
||||||
if (res.code === 1000) {
|
|
||||||
ElMessage.success(res.msg)
|
|
||||||
router.push({path: `/custom/query/sql`})
|
|
||||||
} else {
|
|
||||||
ElMessage.error(res.msg)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
getDictInfo()
|
|
||||||
getSqlQueryInfo()
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
.code-editor {
|
|
||||||
border: 1px solid #b3b3b3;
|
|
||||||
border-radius: 10px;
|
|
||||||
overflow: hidden;
|
|
||||||
margin-bottom: 10px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,351 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div>
|
|
||||||
<el-form :model="queryParams" inline class="query-form" ref="queryForm">
|
|
||||||
<el-form-item label="名称" prop="uqName">
|
|
||||||
<el-input v-model="queryParams.uqName" placeholder="请输入名称" clearable></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="是否发布" prop="publish">
|
|
||||||
<el-select v-model="queryParams.publish" placeholder="请选择发布类型" clearable filterable>
|
|
||||||
<el-option label="已发布" value="2"/>
|
|
||||||
<el-option label="未发布" value="0"/>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item>
|
|
||||||
<el-button type="primary" @click="getList" :icon="Search">搜索</el-button>
|
|
||||||
<el-button @click="handleReset" :icon="Refresh">重置</el-button>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
<div class="query-btn">
|
|
||||||
<el-button type="primary" @click="handleAdd" :icon="Plus" plain>新增</el-button>
|
|
||||||
<el-button type="danger" :icon="Delete"
|
|
||||||
@click="handleMoreDelete(uqIds)" :disabled="disabled" plain>删除
|
|
||||||
</el-button>
|
|
||||||
</div>
|
|
||||||
<div class="table">
|
|
||||||
<el-table
|
|
||||||
:data="list"
|
|
||||||
row-key="id"
|
|
||||||
:lazy="true"
|
|
||||||
ref="singleTable"
|
|
||||||
v-loading="loading"
|
|
||||||
@selection-change="handleSelect"
|
|
||||||
v-tabh
|
|
||||||
>
|
|
||||||
<el-table-column type="selection" width="55"/>
|
|
||||||
<el-table-column label="序号" type="index" width="60" align="center"/>
|
|
||||||
<el-table-column prop="uqName" label="名称" align="center"/>
|
|
||||||
<el-table-column prop="dataSourceId" label="数据源" align="center">
|
|
||||||
<template #default="scope">
|
|
||||||
<el-tag >{{getDataSourceOptionItem(scope.row.dataSourceId)}}</el-tag>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column prop="publish" label="发布类型" align="center">
|
|
||||||
<template #default="scope">
|
|
||||||
<tag dict-type="publish_type" :value="scope.row.publish"/>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column prop="uqDescribe" label="描述" align="center"/>
|
|
||||||
<el-table-column prop="createTime" label="创建时间" align="center"/>
|
|
||||||
<el-table-column prop="updateTime" label="更新时间" align="center"/>
|
|
||||||
<el-table-column label="操作">
|
|
||||||
<template #default="scope">
|
|
||||||
<div v-if="scope.row.publish == false">
|
|
||||||
<el-button type="primary" size="mini"
|
|
||||||
@click="handleEdit(scope.row.id)" link>编辑
|
|
||||||
</el-button>
|
|
||||||
<el-button type="primary" size="mini"
|
|
||||||
@click="handleDesign(scope.row)" link>设计
|
|
||||||
</el-button>
|
|
||||||
<popover-delete :name="scope.row.uqName" :type="'SQL查询'"
|
|
||||||
@delete="handleDelete(scope.row.id)"/>
|
|
||||||
</div>
|
|
||||||
<div v-else>
|
|
||||||
<el-button type="primary" size="mini" @click="handleDownLine(scope.row)"
|
|
||||||
:icon="Bottom" style="color: red" link>下线
|
|
||||||
</el-button>
|
|
||||||
<!-- <el-button type="primary" size="mini"-->
|
|
||||||
<!-- @click="handleView(scope.row)" :icon="View" link>预览-->
|
|
||||||
<!-- </el-button>-->
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
|
||||||
</div>
|
|
||||||
<paging :current-page="pageInfo.pageNum" :page-size="pageInfo.pageSize" :page-sizes="[10, 20, 30, 40,50]"
|
|
||||||
:total="total" @changeSize="handleSizeChange" @goPage="handleCurrentChange"/>
|
|
||||||
<el-dialog v-model="isVisited" :title="title" width="600px">
|
|
||||||
<el-form :model="form" ref="formInstance" :rules="formRules" class="dialog-form">
|
|
||||||
<el-row>
|
|
||||||
<el-col :span="24">
|
|
||||||
<el-form-item label="数据源" prop="dataSourceId" v-if="title==='新增入Sql查询'">
|
|
||||||
<el-select v-model="form.dataSourceId" placeholder="数据源" clearable filterable>
|
|
||||||
<el-option
|
|
||||||
v-for="item in dataSourceOption"
|
|
||||||
:key="item.value"
|
|
||||||
:label="item.label"
|
|
||||||
:value="item.value"
|
|
||||||
/>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="数据源" prop="dataSourceId" v-else>
|
|
||||||
<el-text>{{ getDataSourceOptionItem(form.dataSourceId) }}</el-text>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="名称" prop="uqName">
|
|
||||||
<el-input v-model="form.uqName" placeholder="请输入sql查询名称"></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="描述" prop="uqDescribe">
|
|
||||||
<el-input v-model="form.uqDescribe" placeholder="请输入描述"></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<!-- <el-col :span="11" >-->
|
|
||||||
<!-- <el-form-item label="发布类型" prop="publish">-->
|
|
||||||
<!-- <el-radio-group v-model="form.publish">-->
|
|
||||||
<!-- <el-radio border :label="1">已发布</el-radio>-->
|
|
||||||
<!-- <el-radio border :label="0">未发布</el-radio>-->
|
|
||||||
<!-- </el-radio-group>-->
|
|
||||||
<!-- </el-form-item>-->
|
|
||||||
<!-- </el-col>-->
|
|
||||||
</el-row>
|
|
||||||
</el-form>
|
|
||||||
<template #footer>
|
|
||||||
<span>
|
|
||||||
<el-button @click="handleCancel">取消</el-button>
|
|
||||||
<el-button type="primary" @click="handleSubmit(formInstance)">确定</el-button>
|
|
||||||
</span>
|
|
||||||
</template>
|
|
||||||
</el-dialog>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import {Search, Refresh, Plus, Delete, Edit, Bottom, View} from '@element-plus/icons-vue'
|
|
||||||
import {ElMessage, ElMessageBox} from "element-plus";
|
|
||||||
import {useRouter} from "vue-router";
|
|
||||||
import {getSqlList, delSql, addSql, editSql, getSqlDetails} from "@/api/custom-query/sql";
|
|
||||||
import {getDataSourceOption} from "@/api/custom-query/datamodel";
|
|
||||||
import {sqlDownLine} from "@/api/custom-query/sql-search";
|
|
||||||
import Paging from "@/components/pagination/index.vue";
|
|
||||||
|
|
||||||
const router = useRouter()
|
|
||||||
const queryParams = reactive({
|
|
||||||
preview: '',
|
|
||||||
publish: '',
|
|
||||||
type: '',
|
|
||||||
uqName: '',
|
|
||||||
})
|
|
||||||
const dataSourceOption = ref([])
|
|
||||||
const queryForm = ref([])
|
|
||||||
const uqIds = ref([])
|
|
||||||
const uqNameList = ref([])
|
|
||||||
const list = ref([])
|
|
||||||
const total = ref()
|
|
||||||
const loading = ref(true)
|
|
||||||
const disabled = ref(true)
|
|
||||||
const title = ref('')
|
|
||||||
const isVisited = ref(false)
|
|
||||||
const pageInfo = reactive({
|
|
||||||
pageNum: 1,
|
|
||||||
pageSize: 10,
|
|
||||||
})
|
|
||||||
const form = ref()
|
|
||||||
const formInstance = ref()
|
|
||||||
const formRules = ref({
|
|
||||||
dataSourceId: [{required: true, message: '请选择数据源', trigger: "blur"}],
|
|
||||||
uqName: [{required: true, message: '请输入Sql查询名称', trigger: 'blur'}],
|
|
||||||
uqDescribe: [{required: true, message: '请输入描述', trigger: 'blur'}],
|
|
||||||
})
|
|
||||||
//获取数据源select的option
|
|
||||||
const getOption =async () => {
|
|
||||||
await getDataSourceOption().then(res => {
|
|
||||||
if (res.code === 1000) {
|
|
||||||
dataSourceOption.value = res.data
|
|
||||||
// getList();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const getDataSourceOptionItem = (dataSourceId) => {
|
|
||||||
for (let item of dataSourceOption.value) {
|
|
||||||
if (item.value === dataSourceId) {
|
|
||||||
return item.label;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
//重置搜索
|
|
||||||
const handleReset = () => {
|
|
||||||
queryForm.value.resetFields()
|
|
||||||
getList()
|
|
||||||
}
|
|
||||||
//获取数据
|
|
||||||
const getList = async () => {
|
|
||||||
let params = {
|
|
||||||
...queryParams,
|
|
||||||
...pageInfo
|
|
||||||
}
|
|
||||||
loading.value = true
|
|
||||||
getSqlList(params).then(res => {
|
|
||||||
if (res.code === 1000) {
|
|
||||||
list.value = res.data.rows
|
|
||||||
total.value = res.data.total
|
|
||||||
loading.value = false
|
|
||||||
} else {
|
|
||||||
ElMessage.error(res.msg)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
//重置from表单
|
|
||||||
const restFrom = () => {
|
|
||||||
form.value = {
|
|
||||||
dataSourceId: null,
|
|
||||||
uqName: null,
|
|
||||||
uqDescribe: null
|
|
||||||
}
|
|
||||||
getOption()
|
|
||||||
}
|
|
||||||
//添加
|
|
||||||
const handleAdd = async () => {
|
|
||||||
formRules.value.dataSourceId[0].required = true
|
|
||||||
restFrom()
|
|
||||||
title.value = "新增入Sql查询"
|
|
||||||
isVisited.value = true
|
|
||||||
nextTick(() => {
|
|
||||||
// 清空校验
|
|
||||||
formInstance.value.clearValidate()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
//修改
|
|
||||||
const handleEdit = async (id) => {
|
|
||||||
restFrom()
|
|
||||||
getSqlDetails(id).then(res => {
|
|
||||||
console.log('详情', res.data)
|
|
||||||
if (res.code === 1000) {
|
|
||||||
formRules.value.dataSourceId[0].required = false
|
|
||||||
form.value = res.data
|
|
||||||
title.value = "编辑入Sql查询"
|
|
||||||
isVisited.value = true
|
|
||||||
nextTick(() => {
|
|
||||||
// 清空校验
|
|
||||||
formInstance.value.clearValidate()
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
ElMessage.error(res.msg)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
//设计
|
|
||||||
const handleDesign = (row) => {
|
|
||||||
//sql 设计页面
|
|
||||||
router.push({path: `/custom/query/sql/design/${row.id}`})
|
|
||||||
}
|
|
||||||
//下线
|
|
||||||
const handleDownLine = (row) => {
|
|
||||||
ElMessageBox.confirm(`确认撤销名称为${row.uqName}的数据吗? 撤销后分配的查询权限将全部失效`, '系统提示', {
|
|
||||||
confirmButtonText: '确定',
|
|
||||||
cancelButtonText: '取消',
|
|
||||||
type: 'warning',
|
|
||||||
customClass: 'red-warning'
|
|
||||||
}).then(() => {
|
|
||||||
sqlDownLine(row.id).then(res => {
|
|
||||||
if (res.code === 1000) {
|
|
||||||
ElMessage.success(res.msg)
|
|
||||||
getList()
|
|
||||||
} else {
|
|
||||||
ElMessage.error(res.msg)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
//单个删除
|
|
||||||
const handleDelete = async (id) => {
|
|
||||||
delSql(id).then(res => {
|
|
||||||
if (res.code === 1000) {
|
|
||||||
ElMessage.success(res.msg)
|
|
||||||
getList()
|
|
||||||
} else {
|
|
||||||
ElMessage.error(res.msg)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
//多删
|
|
||||||
const handleMoreDelete = (uqIds) => {
|
|
||||||
ElMessageBox.confirm(`确认删除名称为${uqNameList}的SQL查询吗?`, '系统提示', {
|
|
||||||
confirmButtonText: '确定',
|
|
||||||
cancelButtonText: '取消',
|
|
||||||
type: 'warning'
|
|
||||||
}).then(() => {
|
|
||||||
handleDelete(uqIds)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
//取消
|
|
||||||
const handleCancel = () => {
|
|
||||||
restFrom()
|
|
||||||
isVisited.value = false
|
|
||||||
}
|
|
||||||
|
|
||||||
//提交
|
|
||||||
const handleSubmit = async (instance) => {
|
|
||||||
if (!instance) return
|
|
||||||
instance.validate(async (valid) => {
|
|
||||||
if (!valid) return
|
|
||||||
if (title.value === '新增入Sql查询') {
|
|
||||||
addSql(form.value).then(res => {
|
|
||||||
if (res.code === 1000) {
|
|
||||||
ElMessage.success(res.msg)
|
|
||||||
getList()
|
|
||||||
isVisited.value = false
|
|
||||||
} else {
|
|
||||||
ElMessage.error(res.msg)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
editSql(form.value).then(res => {
|
|
||||||
if (res.code === 1000) {
|
|
||||||
ElMessage.success(res.msg)
|
|
||||||
getList()
|
|
||||||
isVisited.value = false
|
|
||||||
} else {
|
|
||||||
ElMessage.error(res.msg)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
//勾选table数据行事件
|
|
||||||
const handleSelect = async (selection) => {
|
|
||||||
if (selection.length !== 0) {
|
|
||||||
disabled.value = false
|
|
||||||
uqIds.value=selection.map(item => item.id).join()
|
|
||||||
uqNameList.value = selection.map(item => item.uqName).join()
|
|
||||||
} else {
|
|
||||||
disabled.value = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//切换每页显示条数
|
|
||||||
const handleSizeChange = async (val) => {
|
|
||||||
pageInfo.pageSize = val
|
|
||||||
await getList()
|
|
||||||
}
|
|
||||||
|
|
||||||
//点击页码进行分页功能
|
|
||||||
const handleCurrentChange = async (val) => {
|
|
||||||
pageInfo.pageNum = val
|
|
||||||
await getList()
|
|
||||||
}
|
|
||||||
getOption()
|
|
||||||
getList()
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss">
|
|
||||||
.red-warning {
|
|
||||||
.el-message-box__content {
|
|
||||||
.el-message-box__container {
|
|
||||||
.el-icon {
|
|
||||||
color: red !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,378 +0,0 @@
|
|||||||
<template>
|
|
||||||
<el-dialog v-model="isVisited" title="编辑表格" width="1150px">
|
|
||||||
<el-form :model="queryParams" inline label-width="100px" :rules="rules">
|
|
||||||
<el-row>
|
|
||||||
<el-col :span="7">
|
|
||||||
<el-form-item label="表名: " prop="table.tableName">
|
|
||||||
<el-text>{{ queryParams.table.tableName }}</el-text>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="数据源名称: ">
|
|
||||||
<el-text>{{ dataSourceName }}</el-text>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="数据源类型: " prop="table.dataSourceType">
|
|
||||||
<el-text>{{ queryParams.table.dataSourceType }}</el-text>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="角色: " prop="roleIds" style="width: 300px">
|
|
||||||
<el-select
|
|
||||||
v-model="queryParams.roleIds"
|
|
||||||
multiple
|
|
||||||
placeholder="请选择角色"
|
|
||||||
filterable
|
|
||||||
clearable
|
|
||||||
>
|
|
||||||
<el-option
|
|
||||||
v-for="item in roleList"
|
|
||||||
:key="item.value"
|
|
||||||
:label="item.label"
|
|
||||||
:value="item.value"
|
|
||||||
/>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item
|
|
||||||
label="表描述: "
|
|
||||||
prop="table.tableComment"
|
|
||||||
style="width: 300px"
|
|
||||||
>
|
|
||||||
<el-input
|
|
||||||
v-model="queryParams.table.tableComment"
|
|
||||||
:rows="2"
|
|
||||||
type="textarea"
|
|
||||||
placeholder="请输入表描述"
|
|
||||||
></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="17">
|
|
||||||
<el-form-item>
|
|
||||||
<el-button type="primary" @click="handleAddRelation" :icon="Plus"
|
|
||||||
>新增</el-button
|
|
||||||
>
|
|
||||||
<el-button type="danger" @click="handleDelete" :icon="Delete"
|
|
||||||
>删除</el-button
|
|
||||||
>
|
|
||||||
</el-form-item>
|
|
||||||
<div class="table">
|
|
||||||
<el-table
|
|
||||||
:data="queryParams.relationMappings"
|
|
||||||
row-key="mainId"
|
|
||||||
v-loading="loading"
|
|
||||||
@selection-change="handleSelectionChange"
|
|
||||||
:header-cell-style="{ background: '#f5f5f8' }"
|
|
||||||
ref="relationalMap"
|
|
||||||
>
|
|
||||||
<el-table-column
|
|
||||||
type="selection"
|
|
||||||
width="55"
|
|
||||||
align="center"
|
|
||||||
prop="index"
|
|
||||||
/>
|
|
||||||
<el-table-column
|
|
||||||
label="序号"
|
|
||||||
align="center"
|
|
||||||
type="index"
|
|
||||||
width="60"
|
|
||||||
/>
|
|
||||||
<el-table-column label="外键" prop="mainKey" align="center">
|
|
||||||
<template #default="scope">
|
|
||||||
<el-select
|
|
||||||
v-model="scope.row.mainKey"
|
|
||||||
placeholder="外键"
|
|
||||||
filterable
|
|
||||||
clearable
|
|
||||||
>
|
|
||||||
<el-option
|
|
||||||
v-for="item in queryParams.columnList"
|
|
||||||
:key="item.id"
|
|
||||||
:label="item.columnName + ':' + item.columnComment"
|
|
||||||
:value="item.columnName"
|
|
||||||
>
|
|
||||||
</el-option>
|
|
||||||
</el-select>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="关联表" prop="childId" align="center">
|
|
||||||
<template #default="scope">
|
|
||||||
<el-select
|
|
||||||
v-model="scope.row.childId"
|
|
||||||
placeholder="关联表"
|
|
||||||
filterable
|
|
||||||
clearable
|
|
||||||
>
|
|
||||||
<el-option
|
|
||||||
v-for="(item, index) in tableInfoList"
|
|
||||||
:key="index"
|
|
||||||
:label="item.label"
|
|
||||||
:value="item.value"
|
|
||||||
>
|
|
||||||
</el-option>
|
|
||||||
</el-select>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="关联字段" prop="childKey" align="center">
|
|
||||||
<template #default="scope">
|
|
||||||
<el-select
|
|
||||||
v-model="scope.row.childKey"
|
|
||||||
placeholder="关联字段"
|
|
||||||
@visible-change="
|
|
||||||
handleVisibleChange(
|
|
||||||
scope.row.childId,
|
|
||||||
scope.$index,
|
|
||||||
$event
|
|
||||||
)
|
|
||||||
"
|
|
||||||
filterable
|
|
||||||
clearable
|
|
||||||
>
|
|
||||||
<el-option
|
|
||||||
v-for="(item, index) in scope.row.childListColumn"
|
|
||||||
:key="index"
|
|
||||||
:label="item.label"
|
|
||||||
:value="item.value"
|
|
||||||
>
|
|
||||||
</el-option>
|
|
||||||
</el-select>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="关联方式" prop="type" align="center">
|
|
||||||
<template #default="scope">
|
|
||||||
<el-select
|
|
||||||
v-model="scope.row.type"
|
|
||||||
multiple
|
|
||||||
placeholder="关联方式"
|
|
||||||
filterable
|
|
||||||
clearable
|
|
||||||
>
|
|
||||||
<el-option label="hasOne" value="1" />
|
|
||||||
<el-option label="hasMany" value="2" />
|
|
||||||
<el-option label="belongsTo" value="3" />
|
|
||||||
</el-select>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
|
||||||
</div>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
<el-divider content-position="center">ER可视化查询字段信息</el-divider>
|
|
||||||
<el-table
|
|
||||||
:data="queryParams.columnList"
|
|
||||||
row-key="columnId"
|
|
||||||
:lazy="true"
|
|
||||||
v-loading="loading"
|
|
||||||
:header-cell-style="{ background: '#f5f5f8' }"
|
|
||||||
style="height: 400px"
|
|
||||||
ref="topSearchColumn"
|
|
||||||
>
|
|
||||||
<el-table-column label="序号" align="center" type="index" width="60" />
|
|
||||||
<el-table-column label="列名称" prop="columnName" align="center">
|
|
||||||
<template #default="scope">
|
|
||||||
<span>{{ scope.row.columnName }}</span>
|
|
||||||
<span class="isPk" v-if="scope.row.pk">*</span>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="列描述" prop="columnComment" align="center">
|
|
||||||
<template #default="scope">
|
|
||||||
<el-input
|
|
||||||
v-model="scope.row.columnComment"
|
|
||||||
placeholder="请输入列描述"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="列类型" prop="columnType" align="center">
|
|
||||||
<template #default="scope">
|
|
||||||
<span>{{ scope.row.columnType }}</span>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="是否使用" prop="use" align="center">
|
|
||||||
<template #default="scope">
|
|
||||||
<el-checkbox v-model="scope.row.use" />
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
|
||||||
</el-form>
|
|
||||||
<template #footer>
|
|
||||||
<span>
|
|
||||||
<el-button @click="handleCancel">取消</el-button>
|
|
||||||
<el-button type="primary" @click="handleSubmit">确定</el-button>
|
|
||||||
</span>
|
|
||||||
</template>
|
|
||||||
</el-dialog>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import { defineExpose, defineProps } from "vue";
|
|
||||||
import { Plus, Delete } from "@element-plus/icons-vue";
|
|
||||||
import { ElMessage } from "element-plus";
|
|
||||||
import {
|
|
||||||
getTableDetails,
|
|
||||||
editTable,
|
|
||||||
getAssociationFieldOption,
|
|
||||||
getAssociationTableOption,
|
|
||||||
} from "@/api/custom-query/table";
|
|
||||||
import { getRoleOption } from "@/api/role/role";
|
|
||||||
|
|
||||||
const isVisited = ref(false);
|
|
||||||
let queryParams = reactive({
|
|
||||||
table: {
|
|
||||||
dataSourceId: "",
|
|
||||||
dataSourceType: "",
|
|
||||||
tableName: "",
|
|
||||||
tableComment: "",
|
|
||||||
},
|
|
||||||
roleIds: [],
|
|
||||||
relationMappings: [],
|
|
||||||
columnList: [],
|
|
||||||
});
|
|
||||||
const roleList = ref([]);
|
|
||||||
const mainIdArray = ref([]);
|
|
||||||
const loading = ref(true);
|
|
||||||
const tableInfoList = ref([]);
|
|
||||||
const rules = reactive({
|
|
||||||
roleIds: [
|
|
||||||
{
|
|
||||||
required: true,
|
|
||||||
message: "请选择角色",
|
|
||||||
trigger: ["blur", "change"],
|
|
||||||
type: "array",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
});
|
|
||||||
|
|
||||||
const props = defineProps({
|
|
||||||
tableId: {
|
|
||||||
type: String,
|
|
||||||
default: "",
|
|
||||||
},
|
|
||||||
dataSourceName: {
|
|
||||||
type: String,
|
|
||||||
default: "",
|
|
||||||
},
|
|
||||||
});
|
|
||||||
const restForm = () => {
|
|
||||||
queryParams = {
|
|
||||||
table: {
|
|
||||||
dataSourceId: "",
|
|
||||||
dataSourceType: "",
|
|
||||||
tableName: "",
|
|
||||||
tableComment: "",
|
|
||||||
},
|
|
||||||
roleIds: [],
|
|
||||||
relationMappings: [],
|
|
||||||
columnList: [],
|
|
||||||
};
|
|
||||||
};
|
|
||||||
//获取角色option
|
|
||||||
const getRole = () => {
|
|
||||||
getRoleOption().then((res) => {
|
|
||||||
if (res.code === 1000) {
|
|
||||||
roleList.value = res.data;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
//获取关联表option
|
|
||||||
const getAssociationOption = async (id) => {
|
|
||||||
getAssociationTableOption(id).then((res) => {
|
|
||||||
if (res.code === 1000) {
|
|
||||||
tableInfoList.value = res.data;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
//获取对应关联表的关联字段
|
|
||||||
const handleVisibleChange = (id, index, e) => {
|
|
||||||
if (e === true) {
|
|
||||||
getAssociationFieldOption(id).then((res) => {
|
|
||||||
if (res.code === 1000) {
|
|
||||||
queryParams.relationMappings[index].childListColumn = res.data;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
//获取表详情
|
|
||||||
const getTableDetail = async () => {
|
|
||||||
loading.value = true;
|
|
||||||
await getTableDetails(props.tableId).then((res) => {
|
|
||||||
if (res.code === 1000) {
|
|
||||||
loading.value = false;
|
|
||||||
if (res.data.roleIds) {
|
|
||||||
queryParams.table = res.data.table;
|
|
||||||
getAssociationOption(res.data.table.dataSourceId);
|
|
||||||
}
|
|
||||||
if (res.data.roleIds) {
|
|
||||||
queryParams.roleIds = res.data.roleIds;
|
|
||||||
}
|
|
||||||
if (res.data.relationMappings) {
|
|
||||||
queryParams.relationMappings = res.data.relationMappings;
|
|
||||||
}
|
|
||||||
if (res.data.roleIds) {
|
|
||||||
queryParams.columnList = res.data.columnList;
|
|
||||||
}
|
|
||||||
isVisited.value = true;
|
|
||||||
} else {
|
|
||||||
ElMessage.error(res.msg);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
//编辑表格中的selection
|
|
||||||
const handleSelectionChange = (selection) => {
|
|
||||||
console.log("selection", selection);
|
|
||||||
mainIdArray.value = selection.map((item) => item.mainId);
|
|
||||||
};
|
|
||||||
//新增表之间关联关系
|
|
||||||
const handleAddRelation = () => {
|
|
||||||
let obj = {
|
|
||||||
mainId: queryParams.table.tableId,
|
|
||||||
childId: null,
|
|
||||||
mainKey: null,
|
|
||||||
childKey: null,
|
|
||||||
type: [],
|
|
||||||
childListColumn: [],
|
|
||||||
};
|
|
||||||
queryParams.relationMappings.push(obj);
|
|
||||||
};
|
|
||||||
//删除表之间关联关系
|
|
||||||
const handleDelete = () => {
|
|
||||||
queryParams.relationMappings.forEach((item, index) => {
|
|
||||||
mainIdArray.value.forEach((mainId) => {
|
|
||||||
if (item.mainId === mainId) {
|
|
||||||
queryParams.relationMappings.splice(index, 1);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
|
||||||
//取消
|
|
||||||
const handleCancel = () => {
|
|
||||||
isVisited.value = false;
|
|
||||||
};
|
|
||||||
//提交
|
|
||||||
const handleSubmit = async () => {
|
|
||||||
let params = {
|
|
||||||
...queryParams,
|
|
||||||
};
|
|
||||||
editTable(params).then((res) => {
|
|
||||||
if (res.code === 1000) {
|
|
||||||
ElMessage.success(res.msg);
|
|
||||||
isVisited.value = false;
|
|
||||||
} else {
|
|
||||||
ElMessage.error(res.msg);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
const show = () => {
|
|
||||||
isVisited.value = true;
|
|
||||||
getTableDetail();
|
|
||||||
getRole();
|
|
||||||
};
|
|
||||||
defineExpose({
|
|
||||||
show,
|
|
||||||
restForm,
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
.isPk {
|
|
||||||
/*width: 5px;*/
|
|
||||||
/*height: 5px;*/
|
|
||||||
/*border-radius: 4px;*/
|
|
||||||
/*background-color: red;*/
|
|
||||||
position: absolute;
|
|
||||||
color: red;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,201 +0,0 @@
|
|||||||
<template>
|
|
||||||
<el-dialog v-model="isVisited" title="导入表格" width="1000px">
|
|
||||||
<el-form :model="queryParams" inline ref="queryForm" class="query-form" style="margin: 0">
|
|
||||||
<el-form-item label="数据源" prop="dataSourceId">
|
|
||||||
<el-select v-model="queryParams.dataSourceId" placeholder="数据源" clearable filterable>
|
|
||||||
<el-option
|
|
||||||
v-for="item in dataSourceOption"
|
|
||||||
:key="item.value"
|
|
||||||
:label="item.label"
|
|
||||||
:value="item.value"
|
|
||||||
/>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="表名称" prop="tableName">
|
|
||||||
<el-input v-model="queryParams.tableName" placeholder="请输入表名称" clearable></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="表描述" prop="tableComment">
|
|
||||||
<el-input v-model="queryParams.tableComment" placeholder="请输入表描述" clearable></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="创建时间" prop="dateValue">
|
|
||||||
<el-config-provider>
|
|
||||||
<el-date-picker
|
|
||||||
v-model="dateValue"
|
|
||||||
type="datetimerange"
|
|
||||||
:shortcuts="shortcuts"
|
|
||||||
start-placeholder="开始日期"
|
|
||||||
end-placeholder="结束日期"
|
|
||||||
value-format="YYYY-MM-DD HH:mm:ss"
|
|
||||||
/>
|
|
||||||
</el-config-provider>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item>
|
|
||||||
<el-button type="primary" @click="searchTableSearch" :icon="Search">搜索</el-button>
|
|
||||||
<el-button @click="handleReset" :icon="Refresh">重置</el-button>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
<div class="table">
|
|
||||||
<el-table
|
|
||||||
:data="list"
|
|
||||||
row-key="tableId"
|
|
||||||
:lazy="true"
|
|
||||||
v-loading="loading"
|
|
||||||
@selection-change="handleSelect"
|
|
||||||
>
|
|
||||||
<el-table-column type="selection" width="55"/>
|
|
||||||
<el-table-column label="序号" type="index" width="60" align="center"/>
|
|
||||||
<el-table-column prop="tableName" label="表名称" align="center"/>
|
|
||||||
<el-table-column prop="tableComment" label="表描述" align="center"/>
|
|
||||||
<el-table-column prop="createTime" label="创建时间" sortable align="center"/>
|
|
||||||
<el-table-column prop="updateTime" label="更新时间" sortable align="center"/>
|
|
||||||
</el-table>
|
|
||||||
</div>
|
|
||||||
<paging :current-page="pageInfo.pageNum" :page-size="pageInfo.pageSize" :page-sizes="[10, 20, 30, 40,50]"
|
|
||||||
:total="total" @changeSize="handleSizeChange" @goPage="handleCurrentChange"/>
|
|
||||||
<template #footer>
|
|
||||||
<span>
|
|
||||||
<el-button @click="handleCancel">取消</el-button>
|
|
||||||
<el-button type="primary" @click="handleSubmit">确定</el-button>
|
|
||||||
</span>
|
|
||||||
</template>
|
|
||||||
</el-dialog>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import {Search, Refresh} from '@element-plus/icons-vue'
|
|
||||||
import {defineExpose, defineProps} from "vue";
|
|
||||||
import {getDynamicTableList} from "@/api/custom-query/table";
|
|
||||||
import {ElMessage} from "element-plus";
|
|
||||||
import {addTableInfo} from "@/api/custom-query/table";
|
|
||||||
import Paging from "@/components/pagination/index.vue";
|
|
||||||
|
|
||||||
const emit = defineEmits(['importSuccess','changeEdit'])
|
|
||||||
|
|
||||||
let queryParams = reactive({
|
|
||||||
dataSourceId: '',
|
|
||||||
tableName: '',
|
|
||||||
tableComment: ''
|
|
||||||
})
|
|
||||||
const pageInfo = reactive({
|
|
||||||
pageNum: 1,
|
|
||||||
pageSize: 10,
|
|
||||||
})
|
|
||||||
const list = ref([])
|
|
||||||
const tableNameArray = ref([])
|
|
||||||
const queryForm = ref()
|
|
||||||
const loading = ref(true)
|
|
||||||
const dateValue = ref();
|
|
||||||
const shortcuts = [
|
|
||||||
{
|
|
||||||
text: "上周",
|
|
||||||
value: () => {
|
|
||||||
const end = new Date();
|
|
||||||
const start = new Date();
|
|
||||||
start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
|
|
||||||
return [start, end];
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: "上月",
|
|
||||||
value: () => {
|
|
||||||
const end = new Date();
|
|
||||||
const start = new Date();
|
|
||||||
start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
|
|
||||||
return [start, end];
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: "三月前",
|
|
||||||
value: () => {
|
|
||||||
const end = new Date();
|
|
||||||
const start = new Date();
|
|
||||||
start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
|
|
||||||
return [start, end];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
];
|
|
||||||
const total = ref(0)
|
|
||||||
const isVisited = ref(false)
|
|
||||||
const props = defineProps({
|
|
||||||
dataSourceOption: {
|
|
||||||
type: Array,
|
|
||||||
default: []
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
const show = () => {
|
|
||||||
isVisited.value = true
|
|
||||||
queryParams.dataSourceId = props.dataSourceOption[0].value
|
|
||||||
dateValue.value = []
|
|
||||||
searchTableSearch()
|
|
||||||
}
|
|
||||||
const searchTableSearch = async () => {
|
|
||||||
let params = {
|
|
||||||
...queryParams,
|
|
||||||
...pageInfo
|
|
||||||
}
|
|
||||||
const date = dateValue.value;
|
|
||||||
if (date !== undefined && date !== null) {
|
|
||||||
params.startTime = date[0];
|
|
||||||
params.endTime = date[1];
|
|
||||||
}
|
|
||||||
loading.value = true
|
|
||||||
getDynamicTableList(params).then(res => {
|
|
||||||
if (res.code === 1000) {
|
|
||||||
list.value = res.data.rows
|
|
||||||
total.value = res.data.total
|
|
||||||
loading.value = false
|
|
||||||
} else {
|
|
||||||
list.value = []
|
|
||||||
ElMessage.error(res.msg)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
//确定
|
|
||||||
const handleSubmit =async () => {
|
|
||||||
addTableInfo({
|
|
||||||
dataSourceId: queryParams.dataSourceId,
|
|
||||||
tables: tableNameArray.value
|
|
||||||
}).then(res => {
|
|
||||||
if (res.code === 1000) {
|
|
||||||
ElMessage.success(res.msg)
|
|
||||||
isVisited.value = false
|
|
||||||
emit("importSuccess")
|
|
||||||
if (tableNameArray.value.length === 1) {
|
|
||||||
if(res.data){
|
|
||||||
emit("changeEdit",res.data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
ElMessage.error(res.msg)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
//勾选table数据行事件
|
|
||||||
const handleSelect = (selection) => {
|
|
||||||
tableNameArray.value=selection.map(item => item.tableName)
|
|
||||||
}
|
|
||||||
//重置功能
|
|
||||||
const handleReset = () => {
|
|
||||||
queryParams.dataSourceId = props.dataSourceOption[0].value
|
|
||||||
queryForm.value.resetFields()
|
|
||||||
dateValue.value = []
|
|
||||||
searchTableSearch()
|
|
||||||
}
|
|
||||||
//切换每页显示条数
|
|
||||||
const handleSizeChange = (val) => {
|
|
||||||
pageInfo.pageSize = val
|
|
||||||
searchTableSearch()
|
|
||||||
}
|
|
||||||
|
|
||||||
//点击页码进行分页功能
|
|
||||||
const handleCurrentChange = (val) => {
|
|
||||||
pageInfo.pageNum = val
|
|
||||||
searchTableSearch()
|
|
||||||
}
|
|
||||||
|
|
||||||
defineExpose({
|
|
||||||
show
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
|
|
||||||
@@ -1,249 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div>
|
|
||||||
<el-form :model="queryParams" inline class="query-form" ref="queryForm">
|
|
||||||
<el-form-item label="数据源" prop="dataSourceId">
|
|
||||||
<el-select v-model="queryParams.dataSourceId" placeholder="数据源" clearable filterable>
|
|
||||||
<el-option
|
|
||||||
v-for="item in dataSourceOption"
|
|
||||||
:key="item.value"
|
|
||||||
:label="item.label"
|
|
||||||
:value="item.value"
|
|
||||||
/>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="表名称" prop="tableName">
|
|
||||||
<el-input v-model="queryParams.tableName" placeholder="请输入名称" clearable></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="创建时间" prop="dateValue">
|
|
||||||
<el-config-provider>
|
|
||||||
<el-date-picker
|
|
||||||
v-model="dateValue"
|
|
||||||
type="datetimerange"
|
|
||||||
:shortcuts="shortcuts"
|
|
||||||
start-placeholder="开始日期"
|
|
||||||
end-placeholder="结束日期"
|
|
||||||
value-format="YYYY-MM-DD HH:mm:ss"
|
|
||||||
/>
|
|
||||||
</el-config-provider>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item>
|
|
||||||
<el-button type="primary" @click="getList" :icon="Search">搜索</el-button>
|
|
||||||
<el-button @click="handleReset" :icon="Refresh">重置</el-button>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
<div class="query-btn">
|
|
||||||
<el-button type="info" @click="handleImport" :icon="UploadFilled" plain>导入</el-button>
|
|
||||||
<el-button type="warning" :icon="Download" plain>导出</el-button>
|
|
||||||
</div>
|
|
||||||
<div class="table">
|
|
||||||
<el-table
|
|
||||||
:data="list"
|
|
||||||
row-key="tableId"
|
|
||||||
:lazy="true"
|
|
||||||
ref="singleTable"
|
|
||||||
v-loading="loading"
|
|
||||||
v-tabh
|
|
||||||
>
|
|
||||||
<!-- <el-table-column type="selection" width="55"/>-->
|
|
||||||
<el-table-column label="序号" type="index" width="60" align="center"/>
|
|
||||||
<el-table-column prop="tableName" label="表名" align="center"/>
|
|
||||||
<el-table-column prop="dataSourceId" label="数据源名称" align="center">
|
|
||||||
<template #default="scope">
|
|
||||||
<el-tag> {{ getDataSourceOptionItem(scope.row.dataSourceId) }}</el-tag>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column prop="dataSourceType" label="数据源类型" align="center"/>
|
|
||||||
<el-table-column prop="tableComment" label="表描述" align="center"/>
|
|
||||||
<el-table-column prop="createTime" label="创建时间" align="center"/>
|
|
||||||
<el-table-column label="操作">
|
|
||||||
<template #default="scope">
|
|
||||||
<el-button type="primary" size="mini"
|
|
||||||
@click="handleEdit(scope.row.tableId)" link>编辑
|
|
||||||
</el-button>
|
|
||||||
<el-button type="primary" size="mini"
|
|
||||||
@click="handleSynchronization(scope.row.tableId)" link>同步
|
|
||||||
</el-button>
|
|
||||||
<popover-delete :name="scope.row.tableName" :type="'表格'"
|
|
||||||
@delete="handleDelete(scope.row.tableId)"/>
|
|
||||||
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
|
||||||
</div>
|
|
||||||
<paging :current-page="pageInfo.pageNum" :page-size="pageInfo.pageSize" :page-sizes="[10, 20, 30, 40,50]"
|
|
||||||
:total="total" @changeSize="handleSizeChange" @goPage="handleCurrentChange"/>
|
|
||||||
<import-table ref="importTableRef" :data-source-option="dataSourceOption" @importSuccess="getList"
|
|
||||||
@changeEdit="changeEdit"/>
|
|
||||||
|
|
||||||
<edit-table ref="editTableRef" :data-source-name="dataSourceName" :table-id="editTableId"/>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import ImportTable from './importTable.vue'
|
|
||||||
import EditTable from "./editTable.vue";
|
|
||||||
import {Search, Refresh, Delete, Edit, UploadFilled, Download} from '@element-plus/icons-vue'
|
|
||||||
import {ElMessage, ElMessageBox} from "element-plus";
|
|
||||||
import {useRouter} from "vue-router";
|
|
||||||
import {getTableInfo, delTable} from "@/api/custom-query/table";
|
|
||||||
import {getDataSourceOption} from "@/api/custom-query/datamodel";
|
|
||||||
import Paging from "@/components/pagination/index.vue";
|
|
||||||
import {syncDatabase} from "../../../api/custom-query/table";
|
|
||||||
|
|
||||||
|
|
||||||
const router = useRouter()
|
|
||||||
const queryParams = reactive({
|
|
||||||
dataSourceId: '',
|
|
||||||
tableName: '',
|
|
||||||
startTime: '',
|
|
||||||
endTime: ''
|
|
||||||
})
|
|
||||||
const importTableRef = ref(null)
|
|
||||||
const editTableRef = ref(null)
|
|
||||||
const editTableId = ref()
|
|
||||||
const queryForm = ref([])
|
|
||||||
const list = ref([])
|
|
||||||
const dateValue = ref();
|
|
||||||
const shortcuts = [
|
|
||||||
{
|
|
||||||
text: "上周",
|
|
||||||
value: () => {
|
|
||||||
const end = new Date();
|
|
||||||
const start = new Date();
|
|
||||||
start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
|
|
||||||
return [start, end];
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: "上月",
|
|
||||||
value: () => {
|
|
||||||
const end = new Date();
|
|
||||||
const start = new Date();
|
|
||||||
start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
|
|
||||||
return [start, end];
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: "三月前",
|
|
||||||
value: () => {
|
|
||||||
const end = new Date();
|
|
||||||
const start = new Date();
|
|
||||||
start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
|
|
||||||
return [start, end];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
];
|
|
||||||
const dataSourceName = ref()
|
|
||||||
const dataSourceOption = ref()
|
|
||||||
const total = ref()
|
|
||||||
const loading = ref(true)
|
|
||||||
const isVisited = ref(false)
|
|
||||||
const pageInfo = reactive({
|
|
||||||
pageNum: 1,
|
|
||||||
pageSize: 10,
|
|
||||||
})
|
|
||||||
const formInstance = ref()
|
|
||||||
|
|
||||||
//重置搜索
|
|
||||||
const handleReset = () => {
|
|
||||||
queryForm.value.resetFields()
|
|
||||||
getList()
|
|
||||||
}
|
|
||||||
//获取数据
|
|
||||||
const getList = async () => {
|
|
||||||
let params = {
|
|
||||||
...queryParams,
|
|
||||||
...pageInfo
|
|
||||||
}
|
|
||||||
const date = dateValue.value;
|
|
||||||
if (date !== undefined && date !== null) {
|
|
||||||
params.startTime = date[0];
|
|
||||||
params.endTime = date[1];
|
|
||||||
}
|
|
||||||
loading.value = true
|
|
||||||
getTableInfo(params).then(res => {
|
|
||||||
if (res.code === 1000) {
|
|
||||||
list.value = res.data.rows
|
|
||||||
total.value = res.data.total
|
|
||||||
loading.value = false
|
|
||||||
} else {
|
|
||||||
ElMessage.error(res.msg)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
//获取数据源select的option
|
|
||||||
const getOption = () => {
|
|
||||||
getDataSourceOption().then(res => {
|
|
||||||
if (res.code === 1000) {
|
|
||||||
dataSourceOption.value = res.data
|
|
||||||
getList();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
//通过id查询数据源名称
|
|
||||||
const getDataSourceOptionItem = (dataSourceId) => {
|
|
||||||
for (let item of dataSourceOption.value) {
|
|
||||||
if (item.value === dataSourceId) {
|
|
||||||
dataSourceName.value = item.label
|
|
||||||
return item.label;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
//添加
|
|
||||||
const handleImport = async () => {
|
|
||||||
nextTick(() => {
|
|
||||||
importTableRef.value.show()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
//导入单个表格, 直接进入编辑页面
|
|
||||||
const changeEdit = (data) => {
|
|
||||||
editTableId.value = data
|
|
||||||
nextTick(() => {
|
|
||||||
editTableRef.value.show()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
//修改
|
|
||||||
const handleEdit = async (tableId) => {
|
|
||||||
editTableId.value = tableId
|
|
||||||
nextTick(() => {
|
|
||||||
editTableRef.value.show()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
//同步
|
|
||||||
const handleSynchronization = async (tableId) => {
|
|
||||||
syncDatabase(tableId).then(res => {
|
|
||||||
if (res.code === 1000) {
|
|
||||||
ElMessage.success(res.msg)
|
|
||||||
getList()
|
|
||||||
} else {
|
|
||||||
ElMessage.error(res.msg)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
//删除
|
|
||||||
const handleDelete = async (tableId) => {
|
|
||||||
delTable(tableId).then(res => {
|
|
||||||
if (res.code === 1000) {
|
|
||||||
ElMessage.success(res.msg)
|
|
||||||
getList()
|
|
||||||
} else {
|
|
||||||
ElMessage.error(res.msg)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
//切换每页显示条数
|
|
||||||
const handleSizeChange = (val) => {
|
|
||||||
pageInfo.pageSize = val
|
|
||||||
getList()
|
|
||||||
}
|
|
||||||
|
|
||||||
//点击页码进行分页功能
|
|
||||||
const handleCurrentChange = (val) => {
|
|
||||||
pageInfo.pageNum = val
|
|
||||||
getList()
|
|
||||||
}
|
|
||||||
getOption();
|
|
||||||
</script>
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div>
|
|
||||||
<template v-if="displayType === 'image'">
|
|
||||||
<el-image :src="columnProp" :style="{width: params.width+'px',height: params.height+'px',borderRadius:params.circle+'%'}">
|
|
||||||
<template #error>
|
|
||||||
<el-image :style="{width: params.width+'px',height: params.height+'px',borderRadius:params.circle+'%'}"
|
|
||||||
:src="avatar"></el-image>
|
|
||||||
</template>
|
|
||||||
</el-image>
|
|
||||||
</template>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import avatar from "@/assets/default_avatar.png"
|
|
||||||
|
|
||||||
const props = defineProps({
|
|
||||||
displayType: {
|
|
||||||
type: String,
|
|
||||||
default: ""
|
|
||||||
},
|
|
||||||
columnProp: {
|
|
||||||
type: Object,
|
|
||||||
default: {}
|
|
||||||
},params: {
|
|
||||||
type: Object,
|
|
||||||
default: {}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
watch(props.params,(val)=>{
|
|
||||||
props.params=val
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
|
|
||||||
</style>
|
|
||||||
@@ -1,62 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="top-dialog">
|
|
||||||
<el-dialog v-model="isSettingImageVisited" title="图片设置" width="700px">
|
|
||||||
<el-form label-width="70px" :model="imageSettingParams">
|
|
||||||
<el-row>
|
|
||||||
<el-col :span="24">
|
|
||||||
<el-form-item label="设置方式" prop="method">
|
|
||||||
<el-radio-group v-model="imageSettingParams.imgSettingMethod" @change="imgSettingMethodChange">
|
|
||||||
<el-radio-button label="default">默认</el-radio-button>
|
|
||||||
<el-radio-button label="custom">自定义</el-radio-button>
|
|
||||||
</el-radio-group>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<template v-if="imageSettingParams.imgSettingMethod==='custom'">
|
|
||||||
<el-col :span="12">
|
|
||||||
<el-form-item label="宽度" prop="width">
|
|
||||||
<el-input-number v-model="imageSettingParams.width" min="20"></el-input-number>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="12">
|
|
||||||
<el-form-item label="高度" prop="height">
|
|
||||||
<el-input-number v-model="imageSettingParams.height" min="20"></el-input-number>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="12">
|
|
||||||
<el-form-item label="边框圆角" prop="circle">
|
|
||||||
<el-input-number v-model="imageSettingParams.circle" min="0" max="50"></el-input-number>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
</template>
|
|
||||||
<el-col :span="24">
|
|
||||||
<el-form-item label="示例">
|
|
||||||
<template v-if="imageSettingParams.imgSettingMethod === 'custom'">
|
|
||||||
<el-image :src="defaultAvatar"
|
|
||||||
:style="{height: imageSettingParams.width+'px',height: imageSettingParams.height+'px',borderRadius:imageSettingParams.circle+'%'}"
|
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
<template v-else>
|
|
||||||
<el-image :src="defaultAvatar"/>
|
|
||||||
</template>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
</el-form>
|
|
||||||
</el-dialog>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import {reactive} from "vue";
|
|
||||||
|
|
||||||
const imageSettingParams = reactive({
|
|
||||||
imgSettingMethod: "default",
|
|
||||||
width: 150,
|
|
||||||
height: 150,
|
|
||||||
circle:0
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped>
|
|
||||||
|
|
||||||
</style>
|
|
||||||
@@ -1,352 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div>
|
|
||||||
<el-form :model="queryParams" inline class="query-form" ref="queryForm">
|
|
||||||
<el-form-item label="名称" prop="uqName">
|
|
||||||
<el-input v-model="queryParams.uqName" placeholder="请输入名称" clearable></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="是否发布" prop="publish">
|
|
||||||
<el-select v-model="queryParams.publish" placeholder="请选择发布类型" clearable filterable>
|
|
||||||
<el-option label="已发布" value="1"/>
|
|
||||||
<el-option label="未发布" value="0"/>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item>
|
|
||||||
<el-button type="primary" @click="getList" :icon="Search">搜索</el-button>
|
|
||||||
<el-button @click="handleReset" :icon="Refresh">重置</el-button>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
<div class="query-btn">
|
|
||||||
<el-button type="primary" @click="handleAdd" :icon="Plus" plain>新增</el-button>
|
|
||||||
<el-button type="danger" :icon="Delete"
|
|
||||||
@click="handleMoreDelete(uqIds)" :disabled="disabled" plain>删除
|
|
||||||
</el-button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="table">
|
|
||||||
<el-table
|
|
||||||
:data="list"
|
|
||||||
row-key="id"
|
|
||||||
:lazy="true"
|
|
||||||
ref="singleTable"
|
|
||||||
v-loading="loading"
|
|
||||||
@selection-change="handleSelect"
|
|
||||||
v-tabh
|
|
||||||
>
|
|
||||||
<el-table-column type="selection" width="55"/>
|
|
||||||
<el-table-column label="序号" type="index" width="60" align="center"/>
|
|
||||||
<el-table-column prop="uqName" label="名称" align="center"/>
|
|
||||||
<el-table-column prop="dataSourceId" label="数据源" align="center">
|
|
||||||
<template #default="scope">
|
|
||||||
<el-tag >{{getDataSourceOptionItem(scope.row.dataSourceId)}}</el-tag>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column prop="publish" label="发布类型" align="center">
|
|
||||||
<template #default="scope">
|
|
||||||
<tag dict-type="publish_type" :value="scope.row.publish"/>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column prop="uqDescribe" label="描述" align="center"/>
|
|
||||||
<el-table-column prop="createTime" label="创建时间" align="center"/>
|
|
||||||
<el-table-column prop="updateTime" label="更新时间" align="center"/>
|
|
||||||
<el-table-column label="操作" align="center">
|
|
||||||
<template #default="scope">
|
|
||||||
<div v-if="scope.row.publish == false">
|
|
||||||
<el-button type="primary" size="mini"
|
|
||||||
@click="handleEdit(scope.row.id)" link>编辑
|
|
||||||
</el-button>
|
|
||||||
<el-button type="primary" size="mini"
|
|
||||||
@click="handleDesign(scope.row)" link>设计
|
|
||||||
</el-button>
|
|
||||||
<popover-delete :name="scope.row.uqName" :type="'拓扑图查询'"
|
|
||||||
@delete="handleDelete(scope.row.id)"/>
|
|
||||||
</div>
|
|
||||||
<div v-else>
|
|
||||||
<el-button type="primary" size="mini" @click="handleDownLine(scope.row)"
|
|
||||||
:icon="Bottom" style="color: red" link>下线
|
|
||||||
</el-button>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
|
||||||
</div>
|
|
||||||
<paging :current-page="pageInfo.pageNum" :page-size="pageInfo.pageSize" :page-sizes="[10, 20, 30, 40,50]"
|
|
||||||
:total="total" @changeSize="handleSizeChange" @goPage="handleCurrentChange"/>
|
|
||||||
<el-dialog v-model="isVisited" :title="title" width="600px">
|
|
||||||
<el-form :model="form" ref="formInstance" :rules="formRules" class="dialog-form">
|
|
||||||
<el-row>
|
|
||||||
<el-col :span="24">
|
|
||||||
<el-form-item label="数据源" prop="dataSourceId" v-if="title=='新增拓扑'">
|
|
||||||
<el-select v-model="form.dataSourceId" placeholder="数据源" clearable filterable>
|
|
||||||
<el-option
|
|
||||||
v-for="item in dataSourceOption"
|
|
||||||
:key="item.value"
|
|
||||||
:label="item.label"
|
|
||||||
:value="item.value"
|
|
||||||
/>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="数据源" prop="dataSourceId" v-else>
|
|
||||||
<el-text>{{ getDataSourceOptionItem(form.dataSourceId) }}</el-text>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="名称" prop="uqName">
|
|
||||||
<el-input v-model="form.uqName" placeholder="请输入topo名称"></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="描述" prop="uqDescribe">
|
|
||||||
<el-input v-model="form.uqDescribe" placeholder="请输入描述"></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<!-- <el-col :span="11" >-->
|
|
||||||
<!-- <el-form-item label="发布类型" prop="publish">-->
|
|
||||||
<!-- <el-radio-group v-model="form.publish">-->
|
|
||||||
<!-- <el-radio border :label="1">已发布</el-radio>-->
|
|
||||||
<!-- <el-radio border :label="0">未发布</el-radio>-->
|
|
||||||
<!-- </el-radio-group>-->
|
|
||||||
<!-- </el-form-item>-->
|
|
||||||
<!-- </el-col>-->
|
|
||||||
</el-row>
|
|
||||||
</el-form>
|
|
||||||
<template #footer>
|
|
||||||
<span>
|
|
||||||
<el-button @click="handleCancel">取消</el-button>
|
|
||||||
<el-button type="primary" @click="handleSubmit(formInstance)">确定</el-button>
|
|
||||||
</span>
|
|
||||||
</template>
|
|
||||||
</el-dialog>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import {Search, Refresh, Plus, Delete, Edit,Bottom,View} from '@element-plus/icons-vue'
|
|
||||||
import {ElMessage, ElMessageBox} from "element-plus";
|
|
||||||
import {useRouter} from "vue-router";
|
|
||||||
import {getTopoList, delTopo, addTopo, editTopo, getTopoDetails} from "@/api/custom-query/topo";
|
|
||||||
import {getDataSourceOption} from "@/api/custom-query/datamodel";
|
|
||||||
import {topoDownLine} from "@/api/custom-query/topo-search";
|
|
||||||
import Paging from "@/components/pagination/index.vue";
|
|
||||||
import Tag from '@/components/Tag.vue'
|
|
||||||
const router = useRouter()
|
|
||||||
const queryParams = reactive({
|
|
||||||
preview: '',
|
|
||||||
publish: '',
|
|
||||||
type: '',
|
|
||||||
uqName: '',
|
|
||||||
})
|
|
||||||
const dataSourceOption = ref()
|
|
||||||
const queryForm = ref([])
|
|
||||||
const list = ref([])
|
|
||||||
const uqIds = ref([])
|
|
||||||
const uqNameList = ref([])
|
|
||||||
const total = ref()
|
|
||||||
const loading = ref(true)
|
|
||||||
const disabled = ref(true)
|
|
||||||
const title = ref('')
|
|
||||||
const isVisited = ref(false)
|
|
||||||
const pageInfo = reactive({
|
|
||||||
pageNum: 1,
|
|
||||||
pageSize: 10,
|
|
||||||
})
|
|
||||||
const form = ref()
|
|
||||||
const formInstance = ref()
|
|
||||||
const formRules = ref({
|
|
||||||
dataSourceId: [{required: true, message: '请选择数据源', trigger: "blur"}],
|
|
||||||
uqName: [{required: true, message: '请输入topo名称', trigger: 'blur'}],
|
|
||||||
uqDescribe: [{required: true, message: '请输入描述', trigger: 'blur'}],
|
|
||||||
})
|
|
||||||
//获取数据源select的option
|
|
||||||
const getOption = () => {
|
|
||||||
console.log('getOpeion')
|
|
||||||
getDataSourceOption().then(res => {
|
|
||||||
if (res.code === 1000) {
|
|
||||||
dataSourceOption.value = res.data
|
|
||||||
// getList();
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
const getDataSourceOptionItem = (dataSourceId) => {
|
|
||||||
if(dataSourceOption.value===undefined)return;
|
|
||||||
for (let item of dataSourceOption.value) {
|
|
||||||
if (item.value === dataSourceId) {
|
|
||||||
return item.label;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
//重置搜索
|
|
||||||
const handleReset = () => {
|
|
||||||
queryForm.value.resetFields()
|
|
||||||
getList()
|
|
||||||
}
|
|
||||||
//获取数据
|
|
||||||
const getList = async () => {
|
|
||||||
console.log('getList')
|
|
||||||
let params = {
|
|
||||||
...queryParams,
|
|
||||||
...pageInfo
|
|
||||||
}
|
|
||||||
loading.value = true
|
|
||||||
getTopoList(params).then(res => {
|
|
||||||
if (res.code === 1000) {
|
|
||||||
list.value = res.data.rows
|
|
||||||
total.value = res.data.total
|
|
||||||
loading.value = false
|
|
||||||
} else {
|
|
||||||
ElMessage.error(res.msg)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
//重置from表单
|
|
||||||
const restFrom = () => {
|
|
||||||
form.value = {
|
|
||||||
dataSourceId: null,
|
|
||||||
uqName: null,
|
|
||||||
uqDescribe: null
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
//添加
|
|
||||||
const handleAdd = async () => {
|
|
||||||
formRules.value.dataSourceId[0].required = true
|
|
||||||
restFrom()
|
|
||||||
title.value = "新增拓扑"
|
|
||||||
isVisited.value = true
|
|
||||||
nextTick(() => {
|
|
||||||
// 清空校验
|
|
||||||
formInstance.value.clearValidate()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
//修改
|
|
||||||
const handleEdit = async (id) => {
|
|
||||||
restFrom()
|
|
||||||
getTopoDetails(id).then(res => {
|
|
||||||
console.log('详情', res.data)
|
|
||||||
if (res.code === 1000) {
|
|
||||||
formRules.value.dataSourceId[0].required = false
|
|
||||||
form.value = res.data
|
|
||||||
title.value = "编辑拓扑"
|
|
||||||
isVisited.value = true
|
|
||||||
nextTick(() => {
|
|
||||||
// 清空校验
|
|
||||||
formInstance.value.clearValidate()
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
ElMessage.error(res.msg)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
//设计
|
|
||||||
const handleDesign = (row) => {
|
|
||||||
router.push({path: `/topo/design/${row.id}`})
|
|
||||||
}
|
|
||||||
//下线
|
|
||||||
const handleDownLine = (row) => {
|
|
||||||
ElMessageBox.confirm(`确认撤销名称为${row.uqName}的数据吗? 撤销后分配的查询权限将全部失效`, '系统提示', {
|
|
||||||
confirmButtonText: '确定',
|
|
||||||
cancelButtonText: '取消',
|
|
||||||
type: 'warning',
|
|
||||||
customClass: 'red-warning'
|
|
||||||
}).then(() => {
|
|
||||||
topoDownLine(row.id).then(res => {
|
|
||||||
if (res.code === 1000) {
|
|
||||||
ElMessage.success(res.msg)
|
|
||||||
getList()
|
|
||||||
} else {
|
|
||||||
ElMessage.error(res.msg)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
//查看
|
|
||||||
const handleView=(id)=>{
|
|
||||||
//router.push({path: `/custom/query/page/${id}`})
|
|
||||||
}
|
|
||||||
//单个删除
|
|
||||||
const handleDelete = async (id) => {
|
|
||||||
delTopo(id).then(res => {
|
|
||||||
if (res.code === 1000) {
|
|
||||||
ElMessage.success(res.msg)
|
|
||||||
getList()
|
|
||||||
} else {
|
|
||||||
ElMessage.error(res.msg)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
//多删
|
|
||||||
const handleMoreDelete = (uqIds) => {
|
|
||||||
ElMessageBox.confirm(`确认删除名称为${uqNameList.value}的拓扑图查询吗?`, '系统提示', {
|
|
||||||
confirmButtonText: '确定',
|
|
||||||
cancelButtonText: '取消',
|
|
||||||
type: 'warning'
|
|
||||||
}).then(() => {
|
|
||||||
handleDelete(uqIds)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
//取消
|
|
||||||
const handleCancel = () => {
|
|
||||||
restFrom()
|
|
||||||
isVisited.value = false
|
|
||||||
}
|
|
||||||
|
|
||||||
//提交
|
|
||||||
const handleSubmit = async (instance) => {
|
|
||||||
if (!instance) return
|
|
||||||
instance.validate(async (valid) => {
|
|
||||||
if (!valid) return
|
|
||||||
if (title.value === '新增拓扑') {
|
|
||||||
addTopo(form.value).then(res => {
|
|
||||||
if (res.code === 1000) {
|
|
||||||
ElMessage.success(res.msg)
|
|
||||||
getList()
|
|
||||||
isVisited.value = false
|
|
||||||
} else {
|
|
||||||
ElMessage.error(res.msg)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
editTopo(form.value).then(res => {
|
|
||||||
if (res.code === 1000) {
|
|
||||||
ElMessage.success(res.msg)
|
|
||||||
getList()
|
|
||||||
isVisited.value = false
|
|
||||||
} else {
|
|
||||||
ElMessage.error(res.msg)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
//勾选table数据行事件
|
|
||||||
const handleSelect = async (selection) => {
|
|
||||||
if (selection.length !== 0) {
|
|
||||||
disabled.value = false
|
|
||||||
uqIds.value=selection.map(item => item.id).join()
|
|
||||||
uqNameList.value = selection.map(item => item.uqName).join()
|
|
||||||
} else {
|
|
||||||
disabled.value = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//切换每页显示条数
|
|
||||||
const handleSizeChange = async (val) => {
|
|
||||||
pageInfo.pageSize = val
|
|
||||||
await getList()
|
|
||||||
}
|
|
||||||
|
|
||||||
//点击页码进行分页功能
|
|
||||||
const handleCurrentChange = async (val) => {
|
|
||||||
pageInfo.pageNum = val
|
|
||||||
await getList()
|
|
||||||
}
|
|
||||||
getOption()
|
|
||||||
getList()
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss">
|
|
||||||
.red-warning{
|
|
||||||
.el-message-box__content{
|
|
||||||
.el-message-box__container{
|
|
||||||
.el-icon{
|
|
||||||
color: red !important;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,81 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author: clay
|
|
||||||
* @data: 2021/5/14 23:20
|
|
||||||
* @email: clay@hchyun.com
|
|
||||||
* @description: node er图点击事件
|
|
||||||
*/
|
|
||||||
let vm = null;
|
|
||||||
|
|
||||||
const sendThis = (_this) => {
|
|
||||||
vm = _this;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default {
|
|
||||||
sendThis,
|
|
||||||
name: "click-er-edge",
|
|
||||||
options: {
|
|
||||||
getEvents() {
|
|
||||||
return {
|
|
||||||
"edge:click": "onEdgeClick",
|
|
||||||
"edge:contextmenu": "onEdgeRightClick"
|
|
||||||
};
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* 点击连线函数
|
|
||||||
* @param event
|
|
||||||
*/
|
|
||||||
onEdgeClick(event) {
|
|
||||||
let clickEdge = event.item;
|
|
||||||
clickEdge.setState("selected", !clickEdge.hasState("selected"));
|
|
||||||
this.singleClickEdge(event)
|
|
||||||
// vm.editCurrentFocus("edge")
|
|
||||||
// this.updateVmData(event);
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* 右键点击线
|
|
||||||
* @param event
|
|
||||||
*/
|
|
||||||
onEdgeRightClick(event) {
|
|
||||||
this.singleClickEdge(event)
|
|
||||||
},
|
|
||||||
singleClickEdge(event) {
|
|
||||||
let graph = vm.getGraph();
|
|
||||||
let clickEdge = event.item;
|
|
||||||
let clickEdgeModel = toRaw(clickEdge.getModel());
|
|
||||||
let selectedEdges = graph.findAllByState("edge", "selected");
|
|
||||||
// 如果当前点击节点不是之前选中的单个节点,才进行下面的处理
|
|
||||||
if (!(selectedEdges.length === 1 && clickEdgeModel.id === selectedEdges[0].getModel().id)) {
|
|
||||||
// 先取消所有节点的选中状态
|
|
||||||
graph.findAllByState("edge", "selected").forEach(edge => {
|
|
||||||
edge.setState("selected", false);
|
|
||||||
});
|
|
||||||
// 再添加该节点的选中状态
|
|
||||||
clickEdge.setState("selected", true);
|
|
||||||
vm.editCurrentFocus("edge")
|
|
||||||
this.updateVmData(event);
|
|
||||||
}else {
|
|
||||||
vm.editCurrentFocus("edge")
|
|
||||||
this.updateVmData(event);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
updateVmData(event) {
|
|
||||||
// 更新vm的data: selectedEdge 和 selectedEdgeParams
|
|
||||||
let clickEdge = event.item;
|
|
||||||
if (clickEdge.hasState("selected")) {
|
|
||||||
let clickEdgeModel = toRaw(clickEdge.getModel());
|
|
||||||
vm.editSelectedEdge(clickEdge)
|
|
||||||
let edgeAppConfig = { ...vm.getEdgeAppConfig() };
|
|
||||||
Object.keys(edgeAppConfig).forEach(function(key) {
|
|
||||||
edgeAppConfig[key] = "";
|
|
||||||
});
|
|
||||||
vm.editSelectedEdgeParams({
|
|
||||||
label: clickEdgeModel.label || "",
|
|
||||||
relationalItem: clickEdgeModel.relationalItem,
|
|
||||||
sourceColumn: clickEdgeModel.sourceColumn,
|
|
||||||
targetColumn: clickEdgeModel.targetColumn,
|
|
||||||
appConfig: { ...edgeAppConfig, ...clickEdgeModel.appConfig }
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,157 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author: clay
|
|
||||||
* @data: 2021/5/14 23:20
|
|
||||||
* @email: clay@hchyun.com
|
|
||||||
* @description: node er图点击事件
|
|
||||||
*/
|
|
||||||
const isInBBox = (point, bbox) => {
|
|
||||||
const {
|
|
||||||
x,
|
|
||||||
y
|
|
||||||
} = point;
|
|
||||||
const {
|
|
||||||
minX,
|
|
||||||
minY,
|
|
||||||
maxX,
|
|
||||||
maxY
|
|
||||||
} = bbox;
|
|
||||||
|
|
||||||
return x < maxX && x > minX && y > minY && y < maxY;
|
|
||||||
};
|
|
||||||
|
|
||||||
let vm = null;
|
|
||||||
const sendThis = (_this) => {
|
|
||||||
vm = _this;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default {
|
|
||||||
sendThis,
|
|
||||||
name: "click-er-node",
|
|
||||||
options: {
|
|
||||||
getEvents() {
|
|
||||||
return {
|
|
||||||
wheel: "scroll",
|
|
||||||
"node:click": "onNodeClick",
|
|
||||||
"node:contextmenu": "onNodeRightClick",
|
|
||||||
"canvas:click": "onCanvasClick"
|
|
||||||
};
|
|
||||||
},
|
|
||||||
//滚动事件监听
|
|
||||||
scroll(event) {
|
|
||||||
//禁止滚动的默认事件
|
|
||||||
event.preventDefault();
|
|
||||||
let graph = vm.getGraph()
|
|
||||||
// ↓|| vm.getClickCtrlValue() === true
|
|
||||||
if (vm.getClickCtrlValue()) {
|
|
||||||
if (graph && !graph.destroyed) {
|
|
||||||
if (event.deltaY > 0) {
|
|
||||||
graph.zoom(0.8, {x: event.x, y: event.y})
|
|
||||||
} else {
|
|
||||||
graph.zoom(1.2, {x: event.x, y: event.y})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
//graph.getNodes()获取 Combo 中所有子节点
|
|
||||||
const nodes = graph.getNodes().filter((n) => {
|
|
||||||
const bbox = n.getBBox();//获取元素的包围盒。
|
|
||||||
//将 clientX/clientY 坐标系的坐标值转换为 pointX/pointY 的坐标值。
|
|
||||||
return isInBBox(graph.getPointByClient(event.clientX, event.clientY), bbox);
|
|
||||||
});
|
|
||||||
if (nodes) {
|
|
||||||
nodes.forEach((node) => {
|
|
||||||
const model = node.getModel();
|
|
||||||
if (model.columns.length < 9) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const idx = model.startIndex || 0; // 获取model的startIndex属性,如果没有则使用0赋值给变量idx
|
|
||||||
// this.start = idx; // 这里将idx赋值给变量this.start
|
|
||||||
let startX = model.startX || 0.5; // 获取model的startX属性,如果没有则使用0.5赋值给变量startX
|
|
||||||
//正值向下滚动,负值向上滚动
|
|
||||||
let startIndex = idx + event.deltaY * 0.018; // 计算startIndex值,将idx与event的deltaY属性值乘以0.018相加赋值给变量startIndex
|
|
||||||
if ((model.columns.length - idx) < 10 && startIndex > idx) { // 判断条件,判断model的columns数组的长度减去idx的值是否小于10,并且startIndex的值是否大于idx
|
|
||||||
return; // 如果条件满足,则结束函数的执行
|
|
||||||
}
|
|
||||||
startX -= event.deltaX;//deltaX 属性在向右滚动时返回正值,向左滚动时返回负值,否则为 0。
|
|
||||||
|
|
||||||
//对startIndex进行边界检查和调整
|
|
||||||
if (startIndex < 0) {
|
|
||||||
startIndex = 0;
|
|
||||||
}
|
|
||||||
if (startX > 0) {
|
|
||||||
startX = 0;
|
|
||||||
}
|
|
||||||
if (startIndex > model.columns.length - 1) {
|
|
||||||
startIndex = model.columns.length - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
graph.update(node, {
|
|
||||||
startIndex,
|
|
||||||
startX
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
//节点左键点击监听
|
|
||||||
onNodeClick(event) {
|
|
||||||
if (event) {
|
|
||||||
vm.editCurrentFocus("node")
|
|
||||||
vm.editRightMenuShow(false)
|
|
||||||
this.shrinkage(event);
|
|
||||||
this.updateVmData(event);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* todo 右键打开设置面板
|
|
||||||
* @param event
|
|
||||||
*/
|
|
||||||
onNodeRightClick(event) {
|
|
||||||
this.updateVmData(event);
|
|
||||||
vm.editTableColumnEditOpen(true)
|
|
||||||
},
|
|
||||||
onCanvasClick() {
|
|
||||||
vm.editCurrentFocus("canvas")
|
|
||||||
vm.editRightMenuShow(false)
|
|
||||||
},
|
|
||||||
updateVmData(event) {
|
|
||||||
let clickNode = event.item;
|
|
||||||
clickNode.setState("selected", true);
|
|
||||||
vm.editSelectedNode(clickNode);
|
|
||||||
let clickNodeModel = toRaw(clickNode.getModel());
|
|
||||||
let nodeAppConfig = {...vm.getNodeAppConfig()};
|
|
||||||
Object.keys(nodeAppConfig).forEach(function (key) {
|
|
||||||
nodeAppConfig[key] = "";
|
|
||||||
});
|
|
||||||
vm.editSelectedNodeParams({
|
|
||||||
label: clickNodeModel.label || "",
|
|
||||||
columns: clickNodeModel.columns,
|
|
||||||
appConfig: {...nodeAppConfig, ...clickNodeModel.appConfig}
|
|
||||||
})
|
|
||||||
},
|
|
||||||
shrinkage(e) {
|
|
||||||
if (!e.item) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const graph = vm.getGraph();
|
|
||||||
const name=e.shape.get("name")
|
|
||||||
if (name === "collapse") {
|
|
||||||
graph.updateItem(e.item, {
|
|
||||||
collapsed: true,
|
|
||||||
size: [300, 50],
|
|
||||||
height: 44
|
|
||||||
});
|
|
||||||
setTimeout(() => graph.layout(), 100);
|
|
||||||
} else if (name === "expand") {
|
|
||||||
graph.updateItem(e.item, {
|
|
||||||
collapsed: false,
|
|
||||||
size: [300, 500],
|
|
||||||
height: 316
|
|
||||||
});
|
|
||||||
setTimeout(() => graph.layout(), 100);
|
|
||||||
}
|
|
||||||
// else {
|
|
||||||
// const model = e.item.getModel();
|
|
||||||
// }
|
|
||||||
},
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,232 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author: clay
|
|
||||||
* @data: 2019/07/16
|
|
||||||
* @description: edit mode: 通过拖拽节点上的锚点添加连线
|
|
||||||
*/
|
|
||||||
import utils from "../../utils";
|
|
||||||
import theme from "../theme";
|
|
||||||
import {ElMessage} from "element-plus";
|
|
||||||
|
|
||||||
// 用来获取调用此js的vue组件实例(this)
|
|
||||||
let vm = null;
|
|
||||||
|
|
||||||
const sendThis = (_this) => {
|
|
||||||
vm = _this;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default {
|
|
||||||
sendThis, // 暴露函数
|
|
||||||
name: "drag-add-edge",
|
|
||||||
options: {
|
|
||||||
getEvents() {
|
|
||||||
return {
|
|
||||||
"node:mousedown": "onNodeMousedown",
|
|
||||||
"node:mouseup": "onNodeMouseup",
|
|
||||||
"edge:mouseup": "onEdgeMouseup",
|
|
||||||
"mousemove": "onMousemove"
|
|
||||||
};
|
|
||||||
},
|
|
||||||
onNodeMousedown(event) {
|
|
||||||
let self = this;
|
|
||||||
// 交互过程中的信息
|
|
||||||
self.evtInfo = {
|
|
||||||
action: null,
|
|
||||||
node: event.item,
|
|
||||||
target: event.target,
|
|
||||||
};
|
|
||||||
if (self.evtInfo.target && self.evtInfo.target.attrs.name) {
|
|
||||||
// todo...未来可能针对锚点增加其它功能(例如拖拽调整大小)
|
|
||||||
switch (self.evtInfo.target.attrs.name) {
|
|
||||||
case "anchor"://点击锚点中间
|
|
||||||
self.evtInfo.action = "drawEdge";
|
|
||||||
break;
|
|
||||||
case "anchorBg"://点击锚点
|
|
||||||
self.evtInfo.action = "drawEdge";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (self.evtInfo && self.evtInfo.action) {
|
|
||||||
self[self.evtInfo.action].start.call(self, event);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onNodeMouseup(event) {
|
|
||||||
let self = this;
|
|
||||||
if (self.evtInfo && self.evtInfo.action) {
|
|
||||||
self[self.evtInfo.action].stop.call(self, event);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onEdgeMouseup(event) {
|
|
||||||
let self = this;
|
|
||||||
if (self.evtInfo && self.evtInfo.action === "drawEdge") {
|
|
||||||
self[self.evtInfo.action].stop.call(self, event);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onMousemove(event) {
|
|
||||||
let self = this;
|
|
||||||
if (self.evtInfo && self.evtInfo.action) {
|
|
||||||
self[self.evtInfo.action].move.call(self, event);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
drawEdge: {
|
|
||||||
isMoving: false,
|
|
||||||
currentLine: null,
|
|
||||||
start: function (event) {
|
|
||||||
let self = this;
|
|
||||||
let themeStyle = theme.defaultStyle; // todo...先使用默认主题,后期可能增加其它风格的主体
|
|
||||||
|
|
||||||
// ************** 暂存【连线】前的数据状态 start **************
|
|
||||||
let graph = vm.getGraph();
|
|
||||||
self.historyData = JSON.stringify(graph.save());
|
|
||||||
// ************** 暂存【连线】前的数据状态 end **************
|
|
||||||
|
|
||||||
let sourceAnchor = self.evtInfo.node.getAnchorPoints();
|
|
||||||
let sourceNodeModel = toRaw(self.evtInfo.node.getModel());
|
|
||||||
// 锚点数据
|
|
||||||
let anchorPoints = self.evtInfo.node.getAnchorPoints();
|
|
||||||
// 处理线条目标点
|
|
||||||
if (anchorPoints && anchorPoints.length) {
|
|
||||||
// 获取距离指定坐标最近的一个锚点
|
|
||||||
sourceAnchor = self.evtInfo.node.getLinkPoint({
|
|
||||||
x: event.x,
|
|
||||||
y: event.y
|
|
||||||
})
|
|
||||||
}
|
|
||||||
// let relational = vm.getRelationalMap().get(sourceNodeModel.tableId)
|
|
||||||
let relational = vm.getRelationalMap().map(item => {
|
|
||||||
if (item.mainId === sourceNodeModel.tableId) {
|
|
||||||
return item
|
|
||||||
}
|
|
||||||
})
|
|
||||||
//item.columnName+':'+item.columnComment
|
|
||||||
let columns = []
|
|
||||||
sourceNodeModel.columns.forEach(item => {
|
|
||||||
let column = {
|
|
||||||
columnName: item.columnName,
|
|
||||||
columnComment: item.columnComment
|
|
||||||
}
|
|
||||||
columns.push(column)
|
|
||||||
})
|
|
||||||
self.drawEdge.currentLine = self.graph.addItem("edge", {
|
|
||||||
// id: G6.Util.uniqueId(), // 这种生成id的方式有bug,会重复
|
|
||||||
id: utils.generateUUID(),
|
|
||||||
// 起始节点
|
|
||||||
source: sourceNodeModel.id,
|
|
||||||
sourceColumn: columns,
|
|
||||||
sourceAnchor: sourceAnchor ? sourceAnchor.anchorIndex : "",
|
|
||||||
// 终止节点/位置
|
|
||||||
relational: relational,
|
|
||||||
target: {
|
|
||||||
x: event.x,
|
|
||||||
y: event.y
|
|
||||||
},
|
|
||||||
type: self.graph.$C.edge.type || "top-cubic",
|
|
||||||
style: themeStyle.edgeStyle.default || self.graph.$C.edge.style
|
|
||||||
});
|
|
||||||
self.drawEdge.isMoving = true;
|
|
||||||
},
|
|
||||||
move(event) {
|
|
||||||
let self = this;
|
|
||||||
if (self.drawEdge.isMoving && self.drawEdge.currentLine) {
|
|
||||||
self.graph.updateItem(self.drawEdge.currentLine, {
|
|
||||||
target: {
|
|
||||||
x: event.x,
|
|
||||||
y: event.y
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
stop(event) {
|
|
||||||
let self = this;
|
|
||||||
if (self.drawEdge.isMoving) {
|
|
||||||
if (self.drawEdge.currentLine === event.item) {
|
|
||||||
// 画线过程中点击则移除当前画线
|
|
||||||
self.graph.removeItem(event.item);
|
|
||||||
} else {
|
|
||||||
let targetNode = event.item;
|
|
||||||
let targetNodeModel = toRaw(targetNode.getModel());//节点的数据模型
|
|
||||||
let targetAnchor = null;
|
|
||||||
// 锚点数据
|
|
||||||
let anchorPoints = targetNode.getAnchorPoints();
|
|
||||||
// 处理线条目标点
|
|
||||||
let relational = self.drawEdge.currentLine.getModel().relational//边的数据模型,start函数中定义的包含该节点的关联关系
|
|
||||||
let starts = false;
|
|
||||||
let relationalItem = null;
|
|
||||||
if (relational) {
|
|
||||||
relational.map(item => {
|
|
||||||
if (item) {
|
|
||||||
if (item.childId === targetNodeModel.tableId) {
|
|
||||||
starts = true
|
|
||||||
relationalItem = item
|
|
||||||
} else {
|
|
||||||
starts = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
// 去掉关系验证
|
|
||||||
// starts = true
|
|
||||||
if (starts) {
|
|
||||||
if (anchorPoints && anchorPoints.length > 0) {
|
|
||||||
// 获取距离指定坐标最近的一个锚点
|
|
||||||
targetAnchor = targetNode.getLinkPoint({
|
|
||||||
x: event.x,
|
|
||||||
y: event.y
|
|
||||||
});
|
|
||||||
}
|
|
||||||
let columns = []
|
|
||||||
targetNodeModel.columns.forEach(item => {
|
|
||||||
let column = {
|
|
||||||
columnName: item.columnName,
|
|
||||||
columnComment: item.columnComment
|
|
||||||
}
|
|
||||||
columns.push(column)
|
|
||||||
})
|
|
||||||
self.graph.updateItem(self.drawEdge.currentLine, {
|
|
||||||
target: targetNodeModel.id,
|
|
||||||
relationalItem: relationalItem,
|
|
||||||
targetAnchor: targetAnchor ? targetAnchor.anchorIndex : "",
|
|
||||||
targetColumn: columns,
|
|
||||||
});
|
|
||||||
|
|
||||||
// ************** 记录historyData的逻辑 start **************
|
|
||||||
if (self.historyData) {
|
|
||||||
let graph = self.graph;
|
|
||||||
// 如果当前点过【撤销】了,拖拽节点后没有【重做】功能
|
|
||||||
// 重置undoCount,拖拽后的数据给(当前所在historyIndex + 1),且清空这个时间点之后的记录
|
|
||||||
if (vm.getUndoCount() > 0) {
|
|
||||||
vm.editHistoryIndex(vm.getHistoryIndex() - vm.getUndoCount()); // 此时的historyIndex应当更新为【撤销】后所在的索引位置
|
|
||||||
for (let i = 1; i <= vm.getUndoCount(); i++) {
|
|
||||||
let key = `graph_history_${vm.getHistoryIndex() + i}`;
|
|
||||||
vm.removeHistoryData(key);
|
|
||||||
}
|
|
||||||
vm.editUndoCount(0)
|
|
||||||
} else {
|
|
||||||
// 正常顺序执行的情况,记录拖拽线 前的数据状态
|
|
||||||
let key = `graph_history_${vm.getHistoryIndex()}`;
|
|
||||||
vm.addHistoryData(key, self.historyData);
|
|
||||||
}
|
|
||||||
// 记录拖线后的数据状态
|
|
||||||
const index = vm.getHistoryIndex() + 1;
|
|
||||||
vm.editHistoryIndex(index);
|
|
||||||
let key = `graph_history_${index}`;
|
|
||||||
let currentData = JSON.stringify(graph.save());
|
|
||||||
vm.addHistoryData(key, currentData);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (self.evtInfo.node.getModel().tableId === targetNodeModel.tableId) {
|
|
||||||
ElMessage.warning("不可连接自身")
|
|
||||||
} else {
|
|
||||||
ElMessage.warning("两表之间无关联关系")
|
|
||||||
}
|
|
||||||
self.graph.removeItem(self.drawEdge.currentLine);
|
|
||||||
}
|
|
||||||
// ************** 记录historyData的逻辑 end **************
|
|
||||||
}
|
|
||||||
}
|
|
||||||
self.drawEdge.currentLine = null;
|
|
||||||
self.drawEdge.isMoving = false;
|
|
||||||
self.evtInfo = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,57 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author: clay
|
|
||||||
* @data: 2019/07/16
|
|
||||||
* @description: edit mode: 鼠标拖动节点的交互(记录拖拽前后的数据,用于【撤销】和【重做】)
|
|
||||||
*/
|
|
||||||
|
|
||||||
// 用来获取调用此js的vue组件实例(this)
|
|
||||||
let vm = null
|
|
||||||
let historyData = null
|
|
||||||
|
|
||||||
const sendThis = (_this) => {
|
|
||||||
vm = _this
|
|
||||||
}
|
|
||||||
|
|
||||||
export default {
|
|
||||||
sendThis, // 暴露函数
|
|
||||||
name: 'drag-event-edit',
|
|
||||||
options: {
|
|
||||||
getEvents() {
|
|
||||||
return {
|
|
||||||
'node:dragstart': 'onNodeDragstart',
|
|
||||||
'node:dragend': 'onNodeDragend'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onNodeDragstart() {
|
|
||||||
let graph = vm.getGraph()
|
|
||||||
if(graph.cfg){
|
|
||||||
historyData = JSON.stringify(graph.save())
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onNodeDragend() {
|
|
||||||
if (historyData) {
|
|
||||||
let graph = vm.getGraph()
|
|
||||||
// 如果当前点过【撤销】了,拖拽节点后没有【重做】功能
|
|
||||||
// 重置undoCount,拖拽后的数据给(当前所在historyIndex + 1),且清空这个时间点之后的记录
|
|
||||||
if (vm.getUndoCount() > 0) {
|
|
||||||
vm.editHistoryIndex( vm.getHistoryIndex() - vm.getUndoCount()) // 此时的historyIndex应当更新为【撤销】后所在的索引位置
|
|
||||||
for (let i = 1; i <= vm.getUndoCount(); i++) {
|
|
||||||
let key = `graph_history_${vm.getHistoryIndex() + i}`
|
|
||||||
vm.removeHistoryData(key)
|
|
||||||
}
|
|
||||||
vm.editUndoCount(0);
|
|
||||||
} else {
|
|
||||||
// 正常顺序执行的情况,记录拖拽前的数据状态
|
|
||||||
let key = `graph_history_${vm.getHistoryIndex()}`
|
|
||||||
vm.addHistoryData(key, historyData)
|
|
||||||
}
|
|
||||||
// 记录拖拽后的数据状态
|
|
||||||
const index=vm.getHistoryIndex()+ 1;
|
|
||||||
vm.editHistoryIndex(index);
|
|
||||||
let key = `graph_history_${index}`
|
|
||||||
let currentData = JSON.stringify(graph.save())
|
|
||||||
vm.addHistoryData(key, currentData)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author: clay
|
|
||||||
* @data: 2019/07/16
|
|
||||||
* @description: edit mode: 悬浮交互
|
|
||||||
*/
|
|
||||||
// 用来获取调用此js的vue组件实例(this)
|
|
||||||
let vm = null;
|
|
||||||
let hourItem = null;
|
|
||||||
const sendThis = (topo) => {
|
|
||||||
vm = topo;
|
|
||||||
};
|
|
||||||
export default {
|
|
||||||
sendThis, // 暴露函数
|
|
||||||
name: "hover-event-edit",
|
|
||||||
options: {
|
|
||||||
getEvents() {
|
|
||||||
return {
|
|
||||||
"node:mouseover": "onNodeHover",
|
|
||||||
// "node:mouseout": "onNodeOut",
|
|
||||||
// "mouseleave":"onNodeLeave",
|
|
||||||
};
|
|
||||||
},
|
|
||||||
onNodeHover(event) {
|
|
||||||
let graph = vm.getGraph();
|
|
||||||
let hoverNode = event.item;
|
|
||||||
const name = event.shape.get("name");//todo ??
|
|
||||||
const item = event.item;
|
|
||||||
if (name && name.startsWith("item")) {
|
|
||||||
graph.updateItem(item, {//更新元素,包括更新数据、样式等
|
|
||||||
selectedIndex: Number(name.split("-")[1])
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
graph.updateItem(item, {
|
|
||||||
selectedIndex: NaN
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (name && name.startsWith("marker")) {
|
|
||||||
hoverNode.setState("hover", true, graph);
|
|
||||||
hourItem=hoverNode;
|
|
||||||
}else {
|
|
||||||
if (hourItem!=null){
|
|
||||||
hourItem.setState("hover", false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// onNodeOut(event) {
|
|
||||||
// console.log('移出节点')
|
|
||||||
// const name = event.shape.get("name");
|
|
||||||
// let hoverNode = event.item;
|
|
||||||
// console.log('name',name)
|
|
||||||
// if (name && name.startsWith("marker")) {
|
|
||||||
// hoverNode.setState("hover", false);
|
|
||||||
// }
|
|
||||||
// if (hourItem!=null){
|
|
||||||
// hourItem.setState("hover", false)
|
|
||||||
// }
|
|
||||||
// hoverNode.setState("hover", false);
|
|
||||||
// },
|
|
||||||
// onNodeLeave(event) {
|
|
||||||
// console.log('移出节点2')
|
|
||||||
// if (hourItem!=null){
|
|
||||||
// hourItem.setState("hover", false)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author: clay
|
|
||||||
* @data: 2019/07/16
|
|
||||||
* @description: register behaviors
|
|
||||||
*/
|
|
||||||
|
|
||||||
import dragAddEdge from './drag-add-edge'
|
|
||||||
import hoverEventEdit from './hover-event-edit'
|
|
||||||
import dragEventEdit from './drag-event-edit'
|
|
||||||
import keyupEventEdit from './keyup-event-edit'
|
|
||||||
import clickErNode from './click-er-node'
|
|
||||||
import clickErEdge from './click-er-edge'
|
|
||||||
|
|
||||||
const obj = {
|
|
||||||
dragAddEdge,
|
|
||||||
hoverEventEdit,
|
|
||||||
dragEventEdit,
|
|
||||||
keyupEventEdit,
|
|
||||||
clickErNode,
|
|
||||||
clickErEdge
|
|
||||||
}
|
|
||||||
|
|
||||||
export default {
|
|
||||||
obj,
|
|
||||||
register(G6) {
|
|
||||||
Object.values(obj).map(item => {
|
|
||||||
G6.registerBehavior(item.name, item.options)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,67 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author: clay
|
|
||||||
* @data: 2019/07/16
|
|
||||||
* @description: edit mode: 键盘事件的交互,主要是删除节点和连线(记录删除前后的数据,用于【撤销】和【重做】)
|
|
||||||
*/
|
|
||||||
|
|
||||||
// 用来获取调用此js的vue组件实例(this)
|
|
||||||
let vm = null;
|
|
||||||
|
|
||||||
const sendThis = (_this) => {
|
|
||||||
vm = _this;
|
|
||||||
};
|
|
||||||
|
|
||||||
export default {
|
|
||||||
sendThis, // 暴露函数
|
|
||||||
name: "keyup-event-edit",
|
|
||||||
options: {
|
|
||||||
getEvents() {
|
|
||||||
return {
|
|
||||||
"keyup": "onKeyup",
|
|
||||||
"keydown": "onKeydown",
|
|
||||||
};
|
|
||||||
},
|
|
||||||
onKeyup(event) {
|
|
||||||
let graph = vm.getGraph();
|
|
||||||
let selectedNodes = graph.findAllByState("node", "selected");
|
|
||||||
let selectedEdges = graph.findAllByState("edge", "selected");
|
|
||||||
//按住键盘delete-46删除功能
|
|
||||||
if (event.keyCode === 46 && (selectedNodes.length > 0 || selectedEdges.length > 0)) {
|
|
||||||
// ************** 记录【删除】前的数据状态 start **************
|
|
||||||
let historyData = JSON.stringify(graph.save());
|
|
||||||
let key = `graph_history_${vm.getHistoryIndex()}`;
|
|
||||||
vm.addHistoryData(key, historyData);
|
|
||||||
// ************** 记录【删除】前的数据状态 end **************
|
|
||||||
|
|
||||||
// 开始删除
|
|
||||||
selectedNodes.forEach(item=>graph.removeItem(item))
|
|
||||||
selectedEdges.forEach(item=>graph.removeItem(item))
|
|
||||||
// ************** 记录【删除】后的数据状态 start **************
|
|
||||||
// 如果当前点过【撤销】了,拖拽节点后将取消【重做】功能
|
|
||||||
// 重置undoCount,【删除】后的数据状态给(当前所在historyIndex + 1),且清空这个时间点之后的记录
|
|
||||||
if (vm.getUndoCount() > 0) {
|
|
||||||
vm.editHistoryIndex( vm.getHistoryIndex() - vm.getUndoCount()); // 此时的historyIndex应当更新为【撤销】后所在的索引位置
|
|
||||||
for (let i = 1; i <= vm.getUndoCount(); i++) {
|
|
||||||
let key = `graph_history_${vm.getHistoryIndex() + i}`;
|
|
||||||
vm.removeHistoryData(key);
|
|
||||||
}
|
|
||||||
vm.editUndoCount(0);
|
|
||||||
}
|
|
||||||
// 记录【删除】后的数据状态
|
|
||||||
const index=vm.getHistoryIndex()+ 1;
|
|
||||||
vm.editHistoryIndex(index);
|
|
||||||
key = `graph_history_${index}`;
|
|
||||||
let currentData = JSON.stringify(graph.save());
|
|
||||||
vm.addHistoryData(key, currentData);
|
|
||||||
// ************** 记录【删除】后的数据状态 end **************
|
|
||||||
} else if (event.keyCode == 17) {//ctrl键,将状态传给父组件,在clickErNode里面编写功能(按住ctrl,滚动后放大缩小ER图)
|
|
||||||
vm.editClickCtrl(false)//松开则为false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
onKeydown(event) {
|
|
||||||
if (event.keyCode == 17) {//ctrl键
|
|
||||||
vm.editClickCtrl(true)//为true时:一直按着ctrl,以实现滚轮放大缩小功能
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
@@ -1,91 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="footer-bar">
|
|
||||||
<div class="links">
|
|
||||||
<ul>
|
|
||||||
<li>
|
|
||||||
<a href="https://github.com/clay" target="_blank">
|
|
||||||
<i class="iconfont icon-github"></i>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a href="javascript:void(0);">
|
|
||||||
<i class="fab fa-weixin"></i>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a href="javascript:void(0);">更新日志</a>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<a href="https://github.com/clay/style-guide" target="_blank">代码规范</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
<div class="copyright">
|
|
||||||
<ul>
|
|
||||||
<li class="nav-item">
|
|
||||||
<span>ClayTop 0.1.0</span>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<span>|</span>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
|
||||||
<span>ChainCloud FE</span>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
const home = () => {
|
|
||||||
this.$router.push({
|
|
||||||
path: '/'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
.footer-bar {
|
|
||||||
.links {
|
|
||||||
float: left;
|
|
||||||
|
|
||||||
ul {
|
|
||||||
padding-left: 60px;
|
|
||||||
}
|
|
||||||
|
|
||||||
li {
|
|
||||||
display: inline;
|
|
||||||
padding: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
i {
|
|
||||||
font-size: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
a {
|
|
||||||
color: rgba(255, 255, 255, 0.45);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.copyright {
|
|
||||||
float: right;
|
|
||||||
|
|
||||||
ul {
|
|
||||||
padding-right: 60px;
|
|
||||||
}
|
|
||||||
|
|
||||||
li {
|
|
||||||
display: inline;
|
|
||||||
padding: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
i {
|
|
||||||
font-size: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
a {
|
|
||||||
color: rgba(255, 255, 255, 0.45);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,91 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="header-bar">
|
|
||||||
<el-row>
|
|
||||||
<el-col :span="8" style="text-align: left">
|
|
||||||
<router-link to="/">
|
|
||||||
<div class="navbar-brand">
|
|
||||||
<img id="logo" src="@/assets/logo.svg" width="38px" height="38px" alt="ClayTop"/>
|
|
||||||
<span> ClayTop </span>
|
|
||||||
</div>
|
|
||||||
</router-link>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="8" style="text-align: center">
|
|
||||||
<div class="navbar-title"> </div>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="8" style="text-align: right">
|
|
||||||
<div class="navbar-btns">
|
|
||||||
<el-button type="primary" @click="home" link>首页</el-button>
|
|
||||||
<el-button type="primary" @click="about" link>关于ClayTop</el-button>
|
|
||||||
<el-button type="primary" @click="tutorial" link>使用教程</el-button>
|
|
||||||
<el-button type="primary" @click="$message('敬请期待...')" link>其它</el-button>
|
|
||||||
</div>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
const home = () => {
|
|
||||||
this.$router.push({
|
|
||||||
path: '/'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
const about = () => {
|
|
||||||
this.$router.push({
|
|
||||||
path: '/about'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
const tutorial = () => {
|
|
||||||
this.$message({
|
|
||||||
dangerouslyUseHTMLString: true,
|
|
||||||
message: '<div style="text-align: left">时间原因,暂未编写。<br/><br/>目前【开发方式】和【使用方式】可先参考 README.md。 <br/><br/><div style="text-align: right">—— by clay</div></div>',
|
|
||||||
type: 'info',
|
|
||||||
center: true,
|
|
||||||
duration: 5000,
|
|
||||||
showClose: false,
|
|
||||||
offset: 100
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
.header-bar {
|
|
||||||
.navbar-brand {
|
|
||||||
display: inline-block;
|
|
||||||
margin: 0 18px 0 35px;
|
|
||||||
/*padding: 0 0 0 8px;*/
|
|
||||||
line-height: 22px;
|
|
||||||
font-size: 20px;
|
|
||||||
|
|
||||||
img {
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
|
|
||||||
span {
|
|
||||||
vertical-align: middle;
|
|
||||||
/*font-family: "Microsoft YaHei";*/
|
|
||||||
color: #06080A;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.navbar-title {
|
|
||||||
vertical-align: middle;
|
|
||||||
text-align: center;
|
|
||||||
font-size: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.navbar-btns {
|
|
||||||
vertical-align: middle;
|
|
||||||
text-align: right;
|
|
||||||
|
|
||||||
.el-button:last-child {
|
|
||||||
margin-right: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.el-button--text {
|
|
||||||
color: #06080A;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author: clay
|
|
||||||
* @data: 2019/08/16
|
|
||||||
* @description: 线条的后期设置
|
|
||||||
*/
|
|
||||||
|
|
||||||
export default {
|
|
||||||
type: 'top-cubic',
|
|
||||||
style: {
|
|
||||||
startArrow: false,
|
|
||||||
endArrow: true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author: clay
|
|
||||||
* @data: 2019/08/16
|
|
||||||
* @description: 配置
|
|
||||||
*/
|
|
||||||
|
|
||||||
import edge from './edge'
|
|
||||||
|
|
||||||
export default {
|
|
||||||
edge
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author: Clay
|
|
||||||
* @data: 2019/07/18
|
|
||||||
* @description: 线公共方法
|
|
||||||
*/
|
|
||||||
|
|
||||||
import utils from '../../utils'
|
|
||||||
|
|
||||||
export default {
|
|
||||||
draw(cfg, group) {
|
|
||||||
const { startPoint, endPoint } = cfg
|
|
||||||
const keyShape = group.addShape('path', {
|
|
||||||
className: 'edge-shape',
|
|
||||||
attrs: {
|
|
||||||
...cfg.style,
|
|
||||||
path: [
|
|
||||||
['M', startPoint.x, startPoint.y],
|
|
||||||
['L', endPoint.x, endPoint.y]
|
|
||||||
]
|
|
||||||
},
|
|
||||||
name: 'edge-shape'
|
|
||||||
})
|
|
||||||
keyShape.attrs.endArrow = true
|
|
||||||
return keyShape
|
|
||||||
},
|
|
||||||
setState(name, value, item) {
|
|
||||||
// 设置边状态
|
|
||||||
utils.edge.setState(name, value, item)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author: clay
|
|
||||||
* @data: 2019/07/18
|
|
||||||
* @description: register edges
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
import topCubic from './top-cubic'
|
|
||||||
|
|
||||||
const obj = {
|
|
||||||
topCubic
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function(G6) {
|
|
||||||
Object.values(obj).map(item => {
|
|
||||||
G6.registerEdge(item.name, item.options, item.extendName)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author: Clay
|
|
||||||
* @data: 2019/07/18
|
|
||||||
* @description: 曲线
|
|
||||||
*/
|
|
||||||
|
|
||||||
import base from './base'
|
|
||||||
export default {
|
|
||||||
name: 'top-cubic',
|
|
||||||
extendName: 'cubic',
|
|
||||||
options: {
|
|
||||||
...base
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,92 +0,0 @@
|
|||||||
<template>
|
|
||||||
<button
|
|
||||||
class="cc-button"
|
|
||||||
@click="handleClick"
|
|
||||||
:disabled="buttonDisabled"
|
|
||||||
:class="[
|
|
||||||
type ? 'cc-button--' + type : '',
|
|
||||||
buttonSize ? 'cc-button--' + buttonSize : '',
|
|
||||||
{
|
|
||||||
'is-disabled': buttonDisabled,
|
|
||||||
'is-plain': plain
|
|
||||||
}
|
|
||||||
]"
|
|
||||||
>
|
|
||||||
<span><slot></slot></span>
|
|
||||||
</button>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import {defineProps, computed} from "vue";
|
|
||||||
|
|
||||||
const emit = defineEmits(['click'])
|
|
||||||
const props = defineProps({
|
|
||||||
type: {
|
|
||||||
type: String,
|
|
||||||
default: 'default'
|
|
||||||
},
|
|
||||||
size: {
|
|
||||||
type: String,
|
|
||||||
default: ''
|
|
||||||
},
|
|
||||||
disabled: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false
|
|
||||||
},
|
|
||||||
plain: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
const buttonSize = computed(() => {
|
|
||||||
return props.size
|
|
||||||
})
|
|
||||||
const buttonDisabled = computed(() => {
|
|
||||||
return props.disabled
|
|
||||||
})
|
|
||||||
|
|
||||||
const handleClick = (evt) => {
|
|
||||||
emit('click', evt)
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
.cc-button {
|
|
||||||
display: inline-block;
|
|
||||||
line-height: 1;
|
|
||||||
white-space: nowrap;
|
|
||||||
cursor: pointer;
|
|
||||||
background: #fff;
|
|
||||||
border: 1px solid #dcdfe6;
|
|
||||||
color: #606266;
|
|
||||||
-webkit-appearance: none;
|
|
||||||
text-align: center;
|
|
||||||
-webkit-box-sizing: border-box;
|
|
||||||
box-sizing: border-box;
|
|
||||||
outline: 0;
|
|
||||||
margin: 0;
|
|
||||||
-webkit-transition: .1s;
|
|
||||||
transition: .1s;
|
|
||||||
font-weight: 500;
|
|
||||||
padding: 12px 20px;
|
|
||||||
font-size: 14px;
|
|
||||||
border-radius: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.cc-button:focus, .cc-button:hover {
|
|
||||||
color: #409eff;
|
|
||||||
border-color: #c6e2ff;
|
|
||||||
background-color: #ecf5ff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.cc-button--mini, .cc-button--mini.is-round {
|
|
||||||
padding: 7px 15px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.cc-button--mini, .cc-button--small {
|
|
||||||
font-size: 12px;
|
|
||||||
border-radius: 3px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="cc-checkbox" :class="{ 'checkbox-checked': checkVal }">
|
|
||||||
<input
|
|
||||||
id="checkbox"
|
|
||||||
type="checkbox"
|
|
||||||
v-model="checkVal"
|
|
||||||
@change="handleChange"
|
|
||||||
/>
|
|
||||||
<label for="checkbox"></label>
|
|
||||||
<slot></slot>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import {ref} from "vue";
|
|
||||||
|
|
||||||
const emit = defineEmits(['change'])
|
|
||||||
const checkVal = ref(false);
|
|
||||||
|
|
||||||
const handleChange = () => {
|
|
||||||
emit('change', checkVal.value)
|
|
||||||
}
|
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
.cc-checkbox {
|
|
||||||
display: inline-block;
|
|
||||||
color: #606266;
|
|
||||||
font-size: 14px;
|
|
||||||
|
|
||||||
input[type='checkbox'] + label {
|
|
||||||
margin: 0 8px;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
input[type='checkbox'] + label::before {
|
|
||||||
content: '\a0';
|
|
||||||
display: inline-block;
|
|
||||||
position: relative;
|
|
||||||
border: 1px solid #dcdfe6;
|
|
||||||
border-radius: 2px;
|
|
||||||
-webkit-box-sizing: border-box;
|
|
||||||
box-sizing: border-box;
|
|
||||||
width: 14px;
|
|
||||||
height: 14px;
|
|
||||||
line-height: 0.9;
|
|
||||||
background-color: #fff;
|
|
||||||
z-index: 1;
|
|
||||||
-webkit-transition: border-color .25s cubic-bezier(.71, -.46, .29, 1.46), background-color .25s cubic-bezier(.71, -.46, .29, 1.46);
|
|
||||||
transition: border-color .25s cubic-bezier(.71, -.46, .29, 1.46), background-color .25s cubic-bezier(.71, -.46, .29, 1.46);
|
|
||||||
}
|
|
||||||
|
|
||||||
input[type='checkbox']:checked + label::before {
|
|
||||||
content: '\2714';
|
|
||||||
color: #fff;
|
|
||||||
background-color: #409eff;
|
|
||||||
border-color: #409eff;
|
|
||||||
}
|
|
||||||
|
|
||||||
input[type='checkbox'] {
|
|
||||||
opacity: 0;
|
|
||||||
outline: 0;
|
|
||||||
position: absolute;
|
|
||||||
margin: 0;
|
|
||||||
width: 0;
|
|
||||||
height: 0;
|
|
||||||
z-index: -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.checkbox-checked {
|
|
||||||
color: #409eff;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="graph-op">
|
|
||||||
<span v-for="edgeItem in dropdownItems" @click="onItemClick(edgeItem.value, $event)">{{ edgeItem.label }}</span>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import $ from 'jquery'
|
|
||||||
import {defineProps, ref, watch} from "vue";
|
|
||||||
|
|
||||||
const emit = defineEmits(['change'])
|
|
||||||
const props = defineProps({
|
|
||||||
dropdownItems: {
|
|
||||||
type: Array,
|
|
||||||
default() {
|
|
||||||
return []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
defaultIndex: {
|
|
||||||
type: Number,
|
|
||||||
default() {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
const activeIndex = ref(props.defaultIndex)
|
|
||||||
const timeout = ref(null)
|
|
||||||
//todo 可能有问题
|
|
||||||
watch(() => activeIndex.value, (value) => {
|
|
||||||
emit('change', activeIndex.value)
|
|
||||||
})
|
|
||||||
|
|
||||||
const onItemClick = (index, e) => {
|
|
||||||
let lineList = $('.iconfonts')
|
|
||||||
for (let i = 0; i < lineList.length; i++) {
|
|
||||||
lineList[i].style.backgroundColor = '#ffffff'
|
|
||||||
}
|
|
||||||
// if (e.path[0].style.backgroundColor == 'rgb(255, 255, 255)') {
|
|
||||||
// e.path[0].style.backgroundColor = '#ebeef2'
|
|
||||||
// }
|
|
||||||
if (index !== activeIndex.value) {
|
|
||||||
activeIndex.value = index
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
.iconfonts {
|
|
||||||
color: #666666;
|
|
||||||
font-size: 12px;
|
|
||||||
line-height: 20px;
|
|
||||||
height: 20px;
|
|
||||||
padding-bottom: 2px;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
.graph-op {
|
|
||||||
display: inline-block;
|
|
||||||
vertical-align: middle;
|
|
||||||
span {
|
|
||||||
width: 120px;
|
|
||||||
margin: 0 6px;
|
|
||||||
color: #a8a8a8;
|
|
||||||
text-align: center;
|
|
||||||
border-radius: 2px;
|
|
||||||
display: inline-block;
|
|
||||||
border: 1px solid rgba(2, 2, 2, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
span:hover {
|
|
||||||
cursor: pointer;
|
|
||||||
border: 1px solid #E9E9E9;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author: clay
|
|
||||||
* @data: 2019/11/14
|
|
||||||
* @description: ClayTop内部的通用组件
|
|
||||||
*/
|
|
||||||
|
|
||||||
import Checkbox from './checkbox.vue'
|
|
||||||
import Button from './button.vue'
|
|
||||||
import Dropdown from './dropdown.vue'
|
|
||||||
import Loading from './loading.vue'
|
|
||||||
|
|
||||||
export {
|
|
||||||
Checkbox,
|
|
||||||
Button,
|
|
||||||
Dropdown,
|
|
||||||
Loading
|
|
||||||
}
|
|
||||||
@@ -1,91 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="model-overlay">
|
|
||||||
<div class="cc-loading">
|
|
||||||
<svg class="circular" viewBox="0 0 50 50">
|
|
||||||
<circle cx="25" cy="25" r="20" fill="none" stroke="#409EFF" stroke-width="5%" stroke-linecap="round"/>
|
|
||||||
</svg>
|
|
||||||
</div>
|
|
||||||
<span class="loading-text">{{ loadingText }}</span>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import {defineProps} from "vue";
|
|
||||||
|
|
||||||
const props = defineProps({
|
|
||||||
loadingText: {
|
|
||||||
type: String,
|
|
||||||
default: '加载中...'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
.model-overlay {
|
|
||||||
position: fixed;
|
|
||||||
left: 0;
|
|
||||||
top: 0;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
text-align: center;
|
|
||||||
z-index: 1000;
|
|
||||||
overflow: auto;
|
|
||||||
background-color: transparent;
|
|
||||||
}
|
|
||||||
|
|
||||||
.cc-loading {
|
|
||||||
position: absolute;
|
|
||||||
width: 50px;
|
|
||||||
top: 45%;
|
|
||||||
left: 50%;
|
|
||||||
|
|
||||||
&:before {
|
|
||||||
content: '';
|
|
||||||
display: block;
|
|
||||||
padding-top: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.circular {
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
animation: rotate 2s linear infinite;
|
|
||||||
}
|
|
||||||
|
|
||||||
circle {
|
|
||||||
animation: circle-dash 1.5s ease-in-out infinite;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes circle-dash {
|
|
||||||
0% {
|
|
||||||
stroke-dasharray: 1, 125;
|
|
||||||
stroke-dashoffset: 0;
|
|
||||||
}
|
|
||||||
50% {
|
|
||||||
stroke-dasharray: 100, 125;
|
|
||||||
stroke-dashoffset: -25px;
|
|
||||||
}
|
|
||||||
100% {
|
|
||||||
stroke-dasharray: 100, 125;
|
|
||||||
stroke-dashoffset: -125px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes rotate {
|
|
||||||
from {
|
|
||||||
transform: rotate(0deg);
|
|
||||||
}
|
|
||||||
to {
|
|
||||||
transform: rotate(360deg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.loading-text {
|
|
||||||
position: absolute;
|
|
||||||
top: calc(45% + 60px);
|
|
||||||
left: calc(50% - 10px);
|
|
||||||
color: #409EFF;
|
|
||||||
font-size: 14px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,162 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author: clay
|
|
||||||
* @data: 2019/07/05
|
|
||||||
* @description: 图的布局方式/图的初始化
|
|
||||||
*/
|
|
||||||
|
|
||||||
// import d3 from '../plugins/d3-installer'
|
|
||||||
import * as d3 from 'd3'
|
|
||||||
import theme from '../theme'
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 图的布局方式/图的初始化
|
|
||||||
* @type {{commonGraph: (function(*, *): G6.Graph)}}
|
|
||||||
*/
|
|
||||||
const initGraph = {
|
|
||||||
/**
|
|
||||||
* 一般布局
|
|
||||||
* @param G6
|
|
||||||
* @param options
|
|
||||||
* @returns {G6.Graph}
|
|
||||||
*/
|
|
||||||
commonGraph: function(G6, options) {
|
|
||||||
let graphData = options.graphData
|
|
||||||
let themeStyle = theme.defaultStyle // todo...先使用默认主题,后期可能增加其它风格的主体
|
|
||||||
// 生成G6实例
|
|
||||||
let graph = new G6.Graph({
|
|
||||||
plugins: options.plugins,//向 graph 注册插件
|
|
||||||
container: options.container,//图的 DOM 容器,可以传入该 DOM 的 id 或者直接传入容器的 HTML 节点对象。
|
|
||||||
width: options.width,//指定画布宽度,单位为 'px',默认为画布容器宽度。
|
|
||||||
height: options.height,//指定画布高度
|
|
||||||
// layout: {
|
|
||||||
// type: 'random',
|
|
||||||
// width: options.width,
|
|
||||||
// height: options.height
|
|
||||||
// },
|
|
||||||
defaultNode: {//默认状态下节点的配置
|
|
||||||
type: 'dice-er-box',
|
|
||||||
labelCfg: {
|
|
||||||
position: 'bottom'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
defaultEdge: {//默认状态下线的配置
|
|
||||||
type: 'top-cubic',
|
|
||||||
labelCfg: {
|
|
||||||
position: 'center',
|
|
||||||
autoRotate: false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
nodeStateStyles: themeStyle.nodeStyle,//各个状态下节点的样式
|
|
||||||
// nodeStyle: {
|
|
||||||
// selected: {
|
|
||||||
// shadowColor: '#626262',
|
|
||||||
// shadowBlur: 8,
|
|
||||||
// shadowOffsetX: -1,
|
|
||||||
// shadowOffsetY: 3
|
|
||||||
// }
|
|
||||||
// },
|
|
||||||
edgeStateStyles:{
|
|
||||||
edgeStyle: {
|
|
||||||
default: {
|
|
||||||
stroke: '#e2e2e2',
|
|
||||||
lineWidth: 3,
|
|
||||||
lineAppendWidth: 10
|
|
||||||
},
|
|
||||||
selected: {
|
|
||||||
shadowColor: '#626262',
|
|
||||||
shadowBlur: 3
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},//各个状态下边的样式
|
|
||||||
modes: options.modes//设置画布的交互模式
|
|
||||||
})
|
|
||||||
// 将 read 方法分解成 data() 和 render 方法,便于整个生命周期的管理
|
|
||||||
graph.read(graphData)
|
|
||||||
// 渲染图
|
|
||||||
graph.render()
|
|
||||||
// 返回G6实例
|
|
||||||
return graph
|
|
||||||
},
|
|
||||||
/**
|
|
||||||
* 力导布局
|
|
||||||
* @param G6
|
|
||||||
* @param options
|
|
||||||
* @returns {*}
|
|
||||||
*/
|
|
||||||
forceLayoutGraph: function(resolve, G6, options) {
|
|
||||||
let graphData = options.graphData
|
|
||||||
let themeStyle = theme.defaultStyle // todo...先使用默认主题,后期可能增加其它风格的主体
|
|
||||||
// 生成G6实例
|
|
||||||
let graph = new G6.Graph({
|
|
||||||
container: options.container,
|
|
||||||
width: options.width,
|
|
||||||
height: options.height,
|
|
||||||
nodeStateStyles: themeStyle.nodeStyle,
|
|
||||||
edgeStateStyles: themeStyle.edgeStyle
|
|
||||||
})
|
|
||||||
// 初始化力导布局
|
|
||||||
let simulation = d3
|
|
||||||
.forceSimulation()
|
|
||||||
.force(
|
|
||||||
'link',
|
|
||||||
d3
|
|
||||||
.forceLink()
|
|
||||||
.id(function(d) {
|
|
||||||
return d.id
|
|
||||||
})
|
|
||||||
.distance(linkDistance)
|
|
||||||
.strength(0.5)
|
|
||||||
)
|
|
||||||
.force('charge', d3.forceManyBody().strength(-500).distanceMax(500).distanceMin(100))
|
|
||||||
.force('center', d3.forceCenter(options.width / 2, options.height / 2))
|
|
||||||
// 定义节点数据
|
|
||||||
simulation.nodes(graphData.nodes).on('tick', ticked)
|
|
||||||
// 定义连线数据
|
|
||||||
let edges = []
|
|
||||||
for (let i = 0; i < graphData.edges.length; i++) {
|
|
||||||
edges.push({
|
|
||||||
id: graphData.edges[i].id,
|
|
||||||
source: graphData.edges[i].source,
|
|
||||||
target: graphData.edges[i].target
|
|
||||||
})
|
|
||||||
}
|
|
||||||
simulation.force('link').links(edges)
|
|
||||||
graph.data(graphData)
|
|
||||||
graph.render()
|
|
||||||
|
|
||||||
function linkDistance(d) {
|
|
||||||
return 150
|
|
||||||
}
|
|
||||||
|
|
||||||
function ticked() {
|
|
||||||
// protect: planA: 移除事件监听器 planB: 手动停止力模拟
|
|
||||||
if (graph.destroyed) {
|
|
||||||
// simulation.nodes(graphData.nodes).on('tick', null)
|
|
||||||
simulation.stop()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (!graph.get('data')) {
|
|
||||||
// 若是第一次渲染,定义数据,渲染
|
|
||||||
graph.data(graphData)
|
|
||||||
graph.render()
|
|
||||||
} else {
|
|
||||||
// 后续渲染,直接刷新所有点和边的位置
|
|
||||||
graph.refreshPositions()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 控制时间: 只布局10秒
|
|
||||||
let t = setTimeout(function() {
|
|
||||||
simulation.stop()
|
|
||||||
resolve(graph)
|
|
||||||
}, 10000)
|
|
||||||
|
|
||||||
// 判断force-layout结束
|
|
||||||
simulation.on('end', () => {
|
|
||||||
clearTimeout(t)
|
|
||||||
resolve(graph)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default initGraph
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
<template>
|
|
||||||
<el-button @click="handleClick">设计</el-button>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import {useRouter} from "vue-router";
|
|
||||||
|
|
||||||
const router = useRouter()
|
|
||||||
const handleClick=()=>{
|
|
||||||
router.push('/top/edit/1')
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
@@ -1,302 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author: clay
|
|
||||||
* @data: 2021/5/15 0:16
|
|
||||||
* @email: clay@hchyun.com
|
|
||||||
* @description: draw anchor 绘制锚点
|
|
||||||
*/
|
|
||||||
import utils from '../../utils/index'
|
|
||||||
|
|
||||||
const itemHeight = 30;
|
|
||||||
export default {
|
|
||||||
name: 'dice-er-box',
|
|
||||||
options: {
|
|
||||||
/**
|
|
||||||
* 响应节点的状态变化。
|
|
||||||
* 在需要使用动画来响应状态变化时需要被复写
|
|
||||||
* @param {String} name 状态名称
|
|
||||||
* @param {Object} value 状态值
|
|
||||||
* @param {item} item 节点
|
|
||||||
*/
|
|
||||||
setState(name, value, item) {
|
|
||||||
// 设置节点状态
|
|
||||||
utils.node.setState(name, value, item);
|
|
||||||
// 设置锚点状态
|
|
||||||
utils.anchor.setState(name, value, item);
|
|
||||||
},
|
|
||||||
draw(cfg, group) {
|
|
||||||
const width = 250;
|
|
||||||
const height = 316;
|
|
||||||
const itemCount = 10;
|
|
||||||
const boxStyle = {
|
|
||||||
stroke: "#096DD9",
|
|
||||||
radius: 4,
|
|
||||||
};
|
|
||||||
|
|
||||||
const {
|
|
||||||
columns = [],
|
|
||||||
startIndex = 0,
|
|
||||||
selectedIndex,
|
|
||||||
collapsed,
|
|
||||||
icon,
|
|
||||||
} = cfg;
|
|
||||||
const list = columns;
|
|
||||||
const afterList = list.slice(
|
|
||||||
Math.floor(startIndex),
|
|
||||||
Math.floor(startIndex + itemCount - 1)
|
|
||||||
);
|
|
||||||
const offsetY = (0.5 - (startIndex % 1)) * itemHeight + 30;
|
|
||||||
|
|
||||||
//设置表名的容器
|
|
||||||
group.addShape("rect", {
|
|
||||||
attrs: {
|
|
||||||
fill: boxStyle.stroke,
|
|
||||||
height: 30,
|
|
||||||
width,
|
|
||||||
radius: [boxStyle.radius, boxStyle.radius, 0, 0],
|
|
||||||
},
|
|
||||||
draggable: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
//设置左侧字体的边距
|
|
||||||
let fontLeft = 12;
|
|
||||||
|
|
||||||
// 设置图标
|
|
||||||
if (icon && icon.show !== false) {
|
|
||||||
group.addShape("image", {
|
|
||||||
attrs: {
|
|
||||||
x: 8,
|
|
||||||
y: 8,
|
|
||||||
height: 16,
|
|
||||||
width: 16,
|
|
||||||
...icon,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
fontLeft += 18;
|
|
||||||
}
|
|
||||||
|
|
||||||
//设置表名
|
|
||||||
group.addShape("text", {
|
|
||||||
attrs: {
|
|
||||||
y: 22,
|
|
||||||
x: fontLeft,
|
|
||||||
fill: "#fff",
|
|
||||||
text: cfg.label,
|
|
||||||
fontSize: 12,
|
|
||||||
fontWeight: 500,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
//设置收缩部分的容器
|
|
||||||
group.addShape("rect", {
|
|
||||||
attrs: {
|
|
||||||
x: 0,
|
|
||||||
y: collapsed ? 30 : 300,
|
|
||||||
height: 15,
|
|
||||||
width,
|
|
||||||
fill: "#eee",
|
|
||||||
radius: [0, 0, boxStyle.radius, boxStyle.radius],
|
|
||||||
cursor: "pointer",
|
|
||||||
},
|
|
||||||
name: collapsed ? "expand" : "collapse",
|
|
||||||
});
|
|
||||||
|
|
||||||
//设置收缩显示字符
|
|
||||||
group.addShape("text", {
|
|
||||||
attrs: {
|
|
||||||
x: width / 2 - 6,
|
|
||||||
y: (collapsed ? 30 : 300) + 12,
|
|
||||||
text: collapsed ? "+" : "-",
|
|
||||||
width,
|
|
||||||
fill: "#000",
|
|
||||||
radius: [0, 0, boxStyle.radius, boxStyle.radius],
|
|
||||||
cursor: "pointer",
|
|
||||||
},
|
|
||||||
name: collapsed ? "expand" : "collapse",
|
|
||||||
});
|
|
||||||
|
|
||||||
//设置外边框
|
|
||||||
const keyshape = group.addShape("rect", {
|
|
||||||
attrs: {
|
|
||||||
name: 'border',
|
|
||||||
x: 0,
|
|
||||||
y: 0,
|
|
||||||
width,
|
|
||||||
height: collapsed ? 45 : height,
|
|
||||||
...boxStyle,
|
|
||||||
},
|
|
||||||
//是否被允许拖拽
|
|
||||||
draggable: true
|
|
||||||
});
|
|
||||||
|
|
||||||
//如果收缩状态,则返回当前图形
|
|
||||||
if (collapsed) {
|
|
||||||
return keyshape;
|
|
||||||
}
|
|
||||||
//添加空白组
|
|
||||||
const listContainer = group.addGroup({});
|
|
||||||
//todo 设置裁剪对象,字体加粗?
|
|
||||||
listContainer.setClip({
|
|
||||||
type: "rect",
|
|
||||||
attrs: {
|
|
||||||
x: -8,
|
|
||||||
y: 30,
|
|
||||||
width: width + 16,
|
|
||||||
height: 300 - 30,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
listContainer.addShape({
|
|
||||||
type: "rect",
|
|
||||||
attrs: {
|
|
||||||
x: 1,
|
|
||||||
y: 30,
|
|
||||||
width: width - 2,
|
|
||||||
height: 300 - 30,
|
|
||||||
fill: "#fff",
|
|
||||||
},
|
|
||||||
draggable: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
//如果list中的column字段超过10个
|
|
||||||
if (list.length > itemCount) {
|
|
||||||
const barStyle = {
|
|
||||||
width: 4,
|
|
||||||
padding: 0,
|
|
||||||
boxStyle: {
|
|
||||||
stroke: "#00000022",
|
|
||||||
},
|
|
||||||
innerStyle: {
|
|
||||||
fill: "#00000022",
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
listContainer.addShape("rect", {
|
|
||||||
attrs: {
|
|
||||||
y: 30,
|
|
||||||
x: width - barStyle.padding - barStyle.width,
|
|
||||||
width: barStyle.width,
|
|
||||||
height: height - 30,
|
|
||||||
...barStyle.boxStyle,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
//设置矩形高度
|
|
||||||
const indexHeight =
|
|
||||||
afterList.length > itemCount ?
|
|
||||||
(afterList.length / list.length) * height :
|
|
||||||
10;
|
|
||||||
|
|
||||||
listContainer.addShape("rect", {
|
|
||||||
attrs: {
|
|
||||||
y: 30 +
|
|
||||||
barStyle.padding +
|
|
||||||
(startIndex / (list.length-8)) * (height - 30),
|
|
||||||
x: width - barStyle.padding - barStyle.width,
|
|
||||||
width: barStyle.width,
|
|
||||||
height: Math.min(height, indexHeight),
|
|
||||||
...barStyle.innerStyle,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
//渲染显示区域
|
|
||||||
if (afterList) {
|
|
||||||
afterList.forEach((e, i) => {
|
|
||||||
//设置选中的列
|
|
||||||
const isSelected = Math.floor(startIndex) + i === Number(selectedIndex);
|
|
||||||
let {
|
|
||||||
columnName = "", columnType,columnComment
|
|
||||||
} = e;
|
|
||||||
if (columnComment){
|
|
||||||
columnName+= " : " + columnComment
|
|
||||||
}
|
|
||||||
if (columnType) {
|
|
||||||
columnName += " - " + columnType;
|
|
||||||
}
|
|
||||||
const label = columnName.length > 26 ? columnName.slice(0, 24) + "..." : columnName;
|
|
||||||
|
|
||||||
listContainer.addShape("rect", {
|
|
||||||
attrs: {
|
|
||||||
x: 1,
|
|
||||||
y: i * itemHeight - itemHeight / 2 + offsetY,
|
|
||||||
width: width - 4,
|
|
||||||
height: itemHeight,
|
|
||||||
radius: 2,
|
|
||||||
fill:isSelected ? "#ddd" : "#fff",
|
|
||||||
lineWidth: 1,
|
|
||||||
cursor: "pointer",
|
|
||||||
},
|
|
||||||
name: `item-${Math.floor(startIndex) + i}-content`,
|
|
||||||
draggable: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
listContainer.addShape("text", {
|
|
||||||
attrs: {
|
|
||||||
x: 12,
|
|
||||||
y: i * itemHeight + offsetY + 6,
|
|
||||||
text: label,
|
|
||||||
fontSize: 12,
|
|
||||||
fill: "#000",
|
|
||||||
fontFamily: "Avenir,-apple-system,BlinkMacSystemFont,Segoe UI,PingFang SC,Hiragino Sans GB,Microsoft YaHei,Helvetica Neue,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol",
|
|
||||||
full: e,
|
|
||||||
fontWeight: isSelected ? 500 : 100,
|
|
||||||
cursor: "pointer",
|
|
||||||
},
|
|
||||||
name: `item-${Math.floor(startIndex) + i}`,
|
|
||||||
});
|
|
||||||
|
|
||||||
//未来设置字段之间有锚点
|
|
||||||
// if (!cfg.hideDot) {
|
|
||||||
// utils.anchor.erDrawLeft(group, label, 0, i * itemHeight + offsetY)
|
|
||||||
// utils.anchor.erDrawLeft(group,label,width,i * itemHeight + offsetY)
|
|
||||||
// listContainer.addShape("marker", {
|
|
||||||
// attrs: {
|
|
||||||
// x: 0,
|
|
||||||
// y: i * itemHeight + offsetY,
|
|
||||||
// r: 3,
|
|
||||||
// stroke: boxStyle.stroke,
|
|
||||||
// fill: "white",
|
|
||||||
// radius: 2,
|
|
||||||
// lineWidth: 1,
|
|
||||||
// cursor: "crosshair",
|
|
||||||
// },
|
|
||||||
//
|
|
||||||
// name: 'marker-shape'
|
|
||||||
// });
|
|
||||||
// listContainer.addShape("marker", {
|
|
||||||
// attrs: {
|
|
||||||
// x: width,
|
|
||||||
// y: i * itemHeight + offsetY,
|
|
||||||
// r: 3,
|
|
||||||
// stroke: boxStyle.stroke,
|
|
||||||
// fill: "white",
|
|
||||||
// radius: 2,
|
|
||||||
// lineWidth: 1,
|
|
||||||
// cursor: "crosshair",
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// },
|
|
||||||
// name: 'marker-shape'
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return keyshape;
|
|
||||||
},
|
|
||||||
// getAnchorPoints() {
|
|
||||||
// return [
|
|
||||||
// [0, 0],
|
|
||||||
// [1, 0],
|
|
||||||
// ];
|
|
||||||
// },
|
|
||||||
// 绘制后附加锚点
|
|
||||||
afterDraw(cfg, group) {
|
|
||||||
// 绘制锚点
|
|
||||||
utils.anchor.drawMark(cfg, group)
|
|
||||||
},
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author: clay
|
|
||||||
* @data: 2019/07/05
|
|
||||||
* @description: register nodes
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
import diceErBox from './dice-er-box'
|
|
||||||
const obj = {
|
|
||||||
diceErBox
|
|
||||||
}
|
|
||||||
|
|
||||||
export default {
|
|
||||||
obj,
|
|
||||||
register(G6) {
|
|
||||||
Object.values(obj).map(item => {
|
|
||||||
G6.registerNode(item.name, item.options, item.extendName)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,177 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author: clay
|
|
||||||
* @data: 2019/11/20
|
|
||||||
* @description: dark style
|
|
||||||
*/
|
|
||||||
|
|
||||||
export default {
|
|
||||||
// 节点样式
|
|
||||||
nodeStyle: {
|
|
||||||
default: {
|
|
||||||
stroke: '#CED4D9',
|
|
||||||
fill: 'transparent',
|
|
||||||
shadowOffsetX: 0,
|
|
||||||
shadowOffsetY: 4,
|
|
||||||
shadowBlur: 10,
|
|
||||||
shadowColor: 'rgba(13, 26, 38, 0.08)',
|
|
||||||
lineWidth: 1,
|
|
||||||
radius: 4,
|
|
||||||
strokeOpacity: 0.7
|
|
||||||
},
|
|
||||||
selected: {
|
|
||||||
shadowColor: '#ff240b',
|
|
||||||
shadowBlur: 4,
|
|
||||||
shadowOffsetX: 0,
|
|
||||||
shadowOffsetY: 0
|
|
||||||
// shadowColor: '#626262',
|
|
||||||
// shadowBlur: 8,
|
|
||||||
// shadowOffsetX: -1,
|
|
||||||
// shadowOffsetY: 3
|
|
||||||
},
|
|
||||||
unselected: {
|
|
||||||
shadowColor: ''
|
|
||||||
}
|
|
||||||
},
|
|
||||||
//todo 节点标签样式??修改不起
|
|
||||||
nodeLabelCfg: {
|
|
||||||
positions: 'center',
|
|
||||||
style: {
|
|
||||||
fill: '#fff'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// 连线样式
|
|
||||||
edgeStyle: {
|
|
||||||
default: {
|
|
||||||
stroke: '#000000',
|
|
||||||
lineWidth: 2,
|
|
||||||
strokeOpacity: 0.92,
|
|
||||||
lineAppendWidth: 10
|
|
||||||
// endArrow: true
|
|
||||||
},
|
|
||||||
active: {
|
|
||||||
shadowColor: 'red',
|
|
||||||
shadowBlur: 4,
|
|
||||||
shadowOffsetX: 0,
|
|
||||||
shadowOffsetY: 0
|
|
||||||
},
|
|
||||||
inactive: {
|
|
||||||
shadowColor: ''
|
|
||||||
},
|
|
||||||
selected: {
|
|
||||||
shadowColor: '#ff240b',
|
|
||||||
shadowBlur: 4,
|
|
||||||
shadowOffsetX: 0,
|
|
||||||
shadowOffsetY: 0
|
|
||||||
},
|
|
||||||
unselected: {
|
|
||||||
shadowColor: ''
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// 锚点样式
|
|
||||||
anchorStyle: {
|
|
||||||
default: {
|
|
||||||
radius: 3,
|
|
||||||
symbol: 'circle',
|
|
||||||
fill: '#FFFFFF',
|
|
||||||
fillOpacity: 0,
|
|
||||||
stroke: '#1890FF',
|
|
||||||
strokeOpacity: 0,
|
|
||||||
cursor: 'crosshair'
|
|
||||||
},
|
|
||||||
hover: {
|
|
||||||
fillOpacity: 1,
|
|
||||||
strokeOpacity: 1
|
|
||||||
},
|
|
||||||
unhover: {
|
|
||||||
fillOpacity: 0,
|
|
||||||
strokeOpacity: 0
|
|
||||||
},
|
|
||||||
active: {
|
|
||||||
fillOpacity: 1,
|
|
||||||
strokeOpacity: 1
|
|
||||||
},
|
|
||||||
inactive: {
|
|
||||||
fillOpacity: 0,
|
|
||||||
strokeOpacity: 0
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// 锚点背景样式
|
|
||||||
anchorBgStyle: {
|
|
||||||
default: {
|
|
||||||
radius: 10,
|
|
||||||
symbol: 'circle',
|
|
||||||
fill: '#1890FF',
|
|
||||||
fillOpacity: 0,
|
|
||||||
stroke: '#1890FF',
|
|
||||||
strokeOpacity: 0,
|
|
||||||
cursor: 'crosshair'
|
|
||||||
},
|
|
||||||
hover: {
|
|
||||||
fillOpacity: 1,
|
|
||||||
strokeOpacity: 1
|
|
||||||
},
|
|
||||||
unhover: {
|
|
||||||
fillOpacity: 0,
|
|
||||||
strokeOpacity: 0
|
|
||||||
},
|
|
||||||
active: {
|
|
||||||
fillOpacity: 0.3,
|
|
||||||
strokeOpacity: 0.5
|
|
||||||
},
|
|
||||||
inactive: {
|
|
||||||
fillOpacity: 0,
|
|
||||||
strokeOpacity: 0
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
nodeActivedOutterStyle: { lineWidth: 0 },
|
|
||||||
groupSelectedOutterStyle: { stroke: '#E0F0FF', lineWidth: 2 },
|
|
||||||
nodeSelectedOutterStyle: { stroke: '#E0F0FF', lineWidth: 2 },
|
|
||||||
edgeActivedStyle: { stroke: '#1890FF', strokeOpacity: .92 },
|
|
||||||
nodeActivedStyle: { fill: '#F3F9FF', stroke: '#1890FF' },
|
|
||||||
groupActivedStyle: { stroke: '#1890FF' },
|
|
||||||
edgeSelectedStyle: { lineWidth: 2, strokeOpacity: .92, stroke: '#A3B1BF' },
|
|
||||||
nodeSelectedStyle: { fill: '#F3F9FF', stroke: '#1890FF', fillOpacity: .4 },
|
|
||||||
groupSelectedStyle: { stroke: '#1890FF', fillOpacity: .92 },
|
|
||||||
|
|
||||||
groupBackgroundPadding: [40, 10, 10, 10],
|
|
||||||
groupLabelOffsetX: 10,
|
|
||||||
groupLabelOffsetY: 10,
|
|
||||||
edgeLabelStyle: { fill: '#666', textAlign: 'center', textBaseline: 'middle' },
|
|
||||||
edgeLabelRectPadding: 4,
|
|
||||||
edgeLabelRectStyle: { fill: 'white' },
|
|
||||||
nodeLabelStyle: { fill: '#666', textAlign: 'center', textBaseline: 'middle' },
|
|
||||||
groupStyle: { stroke: '#CED4D9', radius: 4 },
|
|
||||||
groupLabelStyle: { fill: '#666', textAlign: 'left', textBaseline: 'top' },
|
|
||||||
multiSelectRectStyle: { fill: '#1890FF', fillOpacity: .08, stroke: '#1890FF', opacity: .1 },
|
|
||||||
dragNodeHoverToGroupStyle: { stroke: '#1890FF', lineWidth: 2 },
|
|
||||||
dragNodeLeaveFromGroupStyle: { stroke: '#BAE7FF', lineWidth: 2 },
|
|
||||||
anchorPointStyle: { radius: 3.5, fill: '#fff', stroke: '#1890FF', lineAppendWidth: 12 },
|
|
||||||
anchorHotsoptStyle: { radius: 12, fill: '#1890FF', fillOpacity: .25 },
|
|
||||||
anchorHotsoptActivedStyle: { radius: 14 },
|
|
||||||
anchorPointHoverStyle: { radius: 4, fill: '#1890FF', fillOpacity: 1, stroke: '#1890FF' },
|
|
||||||
nodeControlPointStyle: { radius: 4, fill: '#fff', shadowBlur: 4, shadowColor: '#666' },
|
|
||||||
edgeControlPointStyle: { radius: 6, symbol: 'square', lineAppendWidth: 6, fillOpacity: 0, strokeOpacity: 0 },
|
|
||||||
nodeSelectedBoxStyle: { stroke: '#C2C2C2' },
|
|
||||||
cursor: {
|
|
||||||
panningCanvas: '-webkit-grabbing',
|
|
||||||
beforePanCanvas: '-webkit-grab',
|
|
||||||
hoverNode: 'move',
|
|
||||||
hoverEffectiveAnchor: 'crosshair',
|
|
||||||
hoverEdge: 'default',
|
|
||||||
hoverGroup: 'move',
|
|
||||||
hoverUnEffectiveAnchor: 'default',
|
|
||||||
hoverEdgeControllPoint: 'crosshair',
|
|
||||||
multiSelect: 'crosshair'
|
|
||||||
},
|
|
||||||
nodeDelegationStyle: {
|
|
||||||
stroke: '#1890FF',
|
|
||||||
fill: '#1890FF',
|
|
||||||
fillOpacity: .08,
|
|
||||||
lineDash: [4, 4],
|
|
||||||
radius: 4,
|
|
||||||
lineWidth: 1
|
|
||||||
},
|
|
||||||
edgeDelegationStyle: { stroke: '#1890FF', lineDash: [4, 4], lineWidth: 1 }
|
|
||||||
}
|
|
||||||
@@ -1,179 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author: clay
|
|
||||||
* @data: 2019/08/15
|
|
||||||
* @description: default style
|
|
||||||
*/
|
|
||||||
|
|
||||||
export default {
|
|
||||||
// 节点样式
|
|
||||||
nodeStyle: {
|
|
||||||
default: {
|
|
||||||
stroke: '#CED4D9',
|
|
||||||
fill: 'transparent',
|
|
||||||
// shadowOffsetX: 0,
|
|
||||||
// shadowOffsetY: 4,
|
|
||||||
shadowBlur: 10,
|
|
||||||
shadowColor: 'rgba(13, 26, 38, 0.08)',
|
|
||||||
lineWidth: 1,
|
|
||||||
radius: 4,
|
|
||||||
strokeOpacity: 0.7
|
|
||||||
},
|
|
||||||
selected: {
|
|
||||||
shadowColor: '#ff240b',
|
|
||||||
shadowBlur: 2,
|
|
||||||
// shadowOffsetX: 0,
|
|
||||||
// shadowOffsetY: 0,
|
|
||||||
// fontSize:'50'
|
|
||||||
// shadowColor: '#626262',
|
|
||||||
// shadowBlur: 8,
|
|
||||||
// shadowOffsetX: -1,
|
|
||||||
// shadowOffsetY: 3
|
|
||||||
},
|
|
||||||
unselected: {
|
|
||||||
shadowColor: ''
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// 节点标签样式
|
|
||||||
nodeLabelCfg: {
|
|
||||||
positions: 'center',
|
|
||||||
style: {
|
|
||||||
fill: '#000'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// 连线样式
|
|
||||||
edgeStyle: {
|
|
||||||
default: {
|
|
||||||
stroke: '#A3B1BF',
|
|
||||||
lineWidth: 2,
|
|
||||||
strokeOpacity: 0.92,
|
|
||||||
lineAppendWidth: 10
|
|
||||||
// endArrow: true
|
|
||||||
},
|
|
||||||
active: {
|
|
||||||
shadowColor: 'red',
|
|
||||||
shadowBlur: 4,
|
|
||||||
shadowOffsetX: 0,
|
|
||||||
shadowOffsetY: 0
|
|
||||||
},
|
|
||||||
inactive: {
|
|
||||||
shadowColor: ''
|
|
||||||
},
|
|
||||||
selected: {
|
|
||||||
shadowColor: '#ff240b',
|
|
||||||
shadowBlur: 4,
|
|
||||||
shadowOffsetX: 0,
|
|
||||||
shadowOffsetY: 0
|
|
||||||
},
|
|
||||||
unselected: {
|
|
||||||
shadowColor: ''
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// 锚点样式
|
|
||||||
anchorStyle: {
|
|
||||||
default: {
|
|
||||||
r: 3,
|
|
||||||
symbol: 'circle',
|
|
||||||
lineWidth: 1,
|
|
||||||
fill: '#FFFFFF',
|
|
||||||
fillOpacity: 1,
|
|
||||||
stroke: '#096DD9',
|
|
||||||
strokeOpacity: 1,
|
|
||||||
cursor: 'crosshair'
|
|
||||||
},
|
|
||||||
hover: {
|
|
||||||
fillOpacity: 0.3,
|
|
||||||
strokeOpacity: 0.5
|
|
||||||
},
|
|
||||||
unhover: {
|
|
||||||
fillOpacity: 0,
|
|
||||||
strokeOpacity: 0
|
|
||||||
},
|
|
||||||
active: {
|
|
||||||
fillOpacity: 1,
|
|
||||||
strokeOpacity: 1
|
|
||||||
},
|
|
||||||
inactive: {
|
|
||||||
fillOpacity: 0,
|
|
||||||
strokeOpacity: 0
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// 锚点背景样式
|
|
||||||
anchorBgStyle: {
|
|
||||||
default: {
|
|
||||||
r: 10,
|
|
||||||
symbol: 'circle',
|
|
||||||
fill: '#1890FF',
|
|
||||||
fillOpacity: 0,
|
|
||||||
stroke: '#1890FF',
|
|
||||||
strokeOpacity: 0,
|
|
||||||
cursor: 'crosshair'
|
|
||||||
},
|
|
||||||
hover: {
|
|
||||||
fillOpacity: 1,
|
|
||||||
strokeOpacity: 1
|
|
||||||
},
|
|
||||||
unhover: {
|
|
||||||
fillOpacity: 0,
|
|
||||||
strokeOpacity: 0
|
|
||||||
},
|
|
||||||
active: {
|
|
||||||
fillOpacity: 0.3,
|
|
||||||
strokeOpacity: 0.5
|
|
||||||
},
|
|
||||||
inactive: {
|
|
||||||
fillOpacity: 0,
|
|
||||||
strokeOpacity: 0
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
nodeActivedOutterStyle: { lineWidth: 0 },
|
|
||||||
groupSelectedOutterStyle: { stroke: '#E0F0FF', lineWidth: 2 },
|
|
||||||
nodeSelectedOutterStyle: { stroke: '#E0F0FF', lineWidth: 2 },
|
|
||||||
edgeActivedStyle: { stroke: '#1890FF', strokeOpacity: .92 },
|
|
||||||
nodeActivedStyle: { fill: '#F3F9FF', stroke: '#1890FF' },
|
|
||||||
groupActivedStyle: { stroke: '#1890FF' },
|
|
||||||
edgeSelectedStyle: { lineWidth: 2, strokeOpacity: .92, stroke: '#A3B1BF' },
|
|
||||||
nodeSelectedStyle: { fill: '#F3F9FF', stroke: '#1890FF', fillOpacity: .4 },
|
|
||||||
groupSelectedStyle: { stroke: '#1890FF', fillOpacity: .92 },
|
|
||||||
|
|
||||||
groupBackgroundPadding: [40, 10, 10, 10],
|
|
||||||
groupLabelOffsetX: 10,
|
|
||||||
groupLabelOffsetY: 10,
|
|
||||||
edgeLabelStyle: { fill: '#666', textAlign: 'center', textBaseline: 'middle' },
|
|
||||||
edgeLabelRectPadding: 4,
|
|
||||||
edgeLabelRectStyle: { fill: 'white' },
|
|
||||||
nodeLabelStyle: { fill: '#666', textAlign: 'center', textBaseline: 'middle' },
|
|
||||||
groupStyle: { stroke: '#CED4D9', radius: 4 },
|
|
||||||
groupLabelStyle: { fill: '#666', textAlign: 'left', textBaseline: 'top' },
|
|
||||||
multiSelectRectStyle: { fill: '#1890FF', fillOpacity: .08, stroke: '#1890FF', opacity: .1 },
|
|
||||||
dragNodeHoverToGroupStyle: { stroke: '#1890FF', lineWidth: 2 },
|
|
||||||
dragNodeLeaveFromGroupStyle: { stroke: '#BAE7FF', lineWidth: 2 },
|
|
||||||
anchorPointStyle: { radius: 3.5, fill: '#fff', stroke: '#1890FF', lineAppendWidth: 12 },
|
|
||||||
anchorHotsoptStyle: { radius: 12, fill: '#1890FF', fillOpacity: .25 },
|
|
||||||
anchorHotsoptActivedStyle: { radius: 14 },
|
|
||||||
anchorPointHoverStyle: { radius: 4, fill: '#1890FF', fillOpacity: 1, stroke: '#1890FF' },
|
|
||||||
nodeControlPointStyle: { radius: 4, fill: '#fff', shadowBlur: 4, shadowColor: '#666' },
|
|
||||||
edgeControlPointStyle: { radius: 6, symbol: 'square', lineAppendWidth: 6, fillOpacity: 0, strokeOpacity: 0 },
|
|
||||||
nodeSelectedBoxStyle: { stroke: '#C2C2C2' },
|
|
||||||
cursor: {
|
|
||||||
panningCanvas: '-webkit-grabbing',
|
|
||||||
beforePanCanvas: '-webkit-grab',
|
|
||||||
hoverNode: 'move',
|
|
||||||
hoverEffectiveAnchor: 'crosshair',
|
|
||||||
hoverEdge: 'default',
|
|
||||||
hoverGroup: 'move',
|
|
||||||
hoverUnEffectiveAnchor: 'default',
|
|
||||||
hoverEdgeControllPoint: 'crosshair',
|
|
||||||
multiSelect: 'crosshair'
|
|
||||||
},
|
|
||||||
nodeDelegationStyle: {
|
|
||||||
stroke: '#1890FF',
|
|
||||||
fill: '#1890FF',
|
|
||||||
fillOpacity: .08,
|
|
||||||
lineDash: [4, 4],
|
|
||||||
radius: 4,
|
|
||||||
lineWidth: 1
|
|
||||||
},
|
|
||||||
edgeDelegationStyle: { stroke: '#1890FF', lineDash: [4, 4], lineWidth: 1 }
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author: clay
|
|
||||||
* @data: 2019/08/15
|
|
||||||
* @description: 编辑器主题样式 - 节点、连线的预设样式
|
|
||||||
*/
|
|
||||||
|
|
||||||
import defaultStyle from './default-style'
|
|
||||||
import darkStyle from './dark-style'
|
|
||||||
import officeStyle from './office-style'
|
|
||||||
|
|
||||||
export default {
|
|
||||||
defaultStyle,
|
|
||||||
darkStyle,
|
|
||||||
officeStyle
|
|
||||||
}
|
|
||||||
@@ -1,177 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author: clay
|
|
||||||
* @data: 2019/11/21
|
|
||||||
* @description: office style
|
|
||||||
*/
|
|
||||||
|
|
||||||
export default {
|
|
||||||
// 节点样式
|
|
||||||
nodeStyle: {
|
|
||||||
default: {
|
|
||||||
stroke: '#CED4D9',
|
|
||||||
fill: '#FFFFFF',
|
|
||||||
shadowOffsetX: 0,
|
|
||||||
shadowOffsetY: 4,
|
|
||||||
shadowBlur: 10,
|
|
||||||
shadowColor: 'rgba(13, 26, 38, 0.08)',
|
|
||||||
lineWidth: 1,
|
|
||||||
radius: 4,
|
|
||||||
strokeOpacity: 0.7
|
|
||||||
},
|
|
||||||
selected: {
|
|
||||||
shadowColor: '#ff240b',
|
|
||||||
shadowBlur: 4,
|
|
||||||
shadowOffsetX: 1,
|
|
||||||
shadowOffsetY: 1
|
|
||||||
// shadowColor: '#626262',
|
|
||||||
// shadowBlur: 8,
|
|
||||||
// shadowOffsetX: -1,
|
|
||||||
// shadowOffsetY: 3
|
|
||||||
},
|
|
||||||
unselected: {
|
|
||||||
shadowColor: ''
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// 节点标签样式
|
|
||||||
nodeLabelCfg: {
|
|
||||||
positions: 'center',
|
|
||||||
style: {
|
|
||||||
fill: '#000'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// 连线样式
|
|
||||||
edgeStyle: {
|
|
||||||
default: {
|
|
||||||
stroke: '#41c23a',
|
|
||||||
lineWidth: 2,
|
|
||||||
strokeOpacity: 0.92,
|
|
||||||
lineAppendWidth: 10
|
|
||||||
// endArrow: true
|
|
||||||
},
|
|
||||||
active: {
|
|
||||||
shadowColor: 'red',
|
|
||||||
shadowBlur: 4,
|
|
||||||
shadowOffsetX: 0,
|
|
||||||
shadowOffsetY: 0
|
|
||||||
},
|
|
||||||
inactive: {
|
|
||||||
shadowColor: ''
|
|
||||||
},
|
|
||||||
selected: {
|
|
||||||
shadowColor: '#ff240b',
|
|
||||||
shadowBlur: 4,
|
|
||||||
shadowOffsetX: 0,
|
|
||||||
shadowOffsetY: 0
|
|
||||||
},
|
|
||||||
unselected: {
|
|
||||||
shadowColor: ''
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// 锚点样式
|
|
||||||
anchorStyle: {
|
|
||||||
default: {
|
|
||||||
radius: 3,
|
|
||||||
symbol: 'circle',
|
|
||||||
fill: '#FFFFFF',
|
|
||||||
fillOpacity: 0,
|
|
||||||
stroke: '#1890FF',
|
|
||||||
strokeOpacity: 0,
|
|
||||||
cursor: 'crosshair'
|
|
||||||
},
|
|
||||||
hover: {
|
|
||||||
fillOpacity: 1,
|
|
||||||
strokeOpacity: 1
|
|
||||||
},
|
|
||||||
unhover: {
|
|
||||||
fillOpacity: 0,
|
|
||||||
strokeOpacity: 0
|
|
||||||
},
|
|
||||||
active: {
|
|
||||||
fillOpacity: 1,
|
|
||||||
strokeOpacity: 1
|
|
||||||
},
|
|
||||||
inactive: {
|
|
||||||
fillOpacity: 0,
|
|
||||||
strokeOpacity: 0
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// 锚点背景样式
|
|
||||||
anchorBgStyle: {
|
|
||||||
default: {
|
|
||||||
radius: 10,
|
|
||||||
symbol: 'circle',
|
|
||||||
fill: '#1890FF',
|
|
||||||
fillOpacity: 0,
|
|
||||||
stroke: '#1890FF',
|
|
||||||
strokeOpacity: 0,
|
|
||||||
cursor: 'crosshair'
|
|
||||||
},
|
|
||||||
hover: {
|
|
||||||
fillOpacity: 1,
|
|
||||||
strokeOpacity: 1
|
|
||||||
},
|
|
||||||
unhover: {
|
|
||||||
fillOpacity: 0,
|
|
||||||
strokeOpacity: 0
|
|
||||||
},
|
|
||||||
active: {
|
|
||||||
fillOpacity: 0.3,
|
|
||||||
strokeOpacity: 0.5
|
|
||||||
},
|
|
||||||
inactive: {
|
|
||||||
fillOpacity: 0,
|
|
||||||
strokeOpacity: 0
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
nodeActivedOutterStyle: { lineWidth: 0 },
|
|
||||||
groupSelectedOutterStyle: { stroke: '#E0F0FF', lineWidth: 2 },
|
|
||||||
nodeSelectedOutterStyle: { stroke: '#E0F0FF', lineWidth: 2 },
|
|
||||||
edgeActivedStyle: { stroke: '#1890FF', strokeOpacity: .92 },
|
|
||||||
nodeActivedStyle: { fill: '#F3F9FF', stroke: '#1890FF' },
|
|
||||||
groupActivedStyle: { stroke: '#1890FF' },
|
|
||||||
edgeSelectedStyle: { lineWidth: 2, strokeOpacity: .92, stroke: '#A3B1BF' },
|
|
||||||
nodeSelectedStyle: { fill: '#F3F9FF', stroke: '#1890FF', fillOpacity: .4 },
|
|
||||||
groupSelectedStyle: { stroke: '#1890FF', fillOpacity: .92 },
|
|
||||||
|
|
||||||
groupBackgroundPadding: [40, 10, 10, 10],
|
|
||||||
groupLabelOffsetX: 10,
|
|
||||||
groupLabelOffsetY: 10,
|
|
||||||
edgeLabelStyle: { fill: '#666', textAlign: 'center', textBaseline: 'middle' },
|
|
||||||
edgeLabelRectPadding: 4,
|
|
||||||
edgeLabelRectStyle: { fill: 'white' },
|
|
||||||
nodeLabelStyle: { fill: '#666', textAlign: 'center', textBaseline: 'middle' },
|
|
||||||
groupStyle: { stroke: '#CED4D9', radius: 4 },
|
|
||||||
groupLabelStyle: { fill: '#666', textAlign: 'left', textBaseline: 'top' },
|
|
||||||
multiSelectRectStyle: { fill: '#1890FF', fillOpacity: .08, stroke: '#1890FF', opacity: .1 },
|
|
||||||
dragNodeHoverToGroupStyle: { stroke: '#1890FF', lineWidth: 2 },
|
|
||||||
dragNodeLeaveFromGroupStyle: { stroke: '#BAE7FF', lineWidth: 2 },
|
|
||||||
anchorPointStyle: { radius: 3.5, fill: '#fff', stroke: '#1890FF', lineAppendWidth: 12 },
|
|
||||||
anchorHotsoptStyle: { radius: 12, fill: '#1890FF', fillOpacity: .25 },
|
|
||||||
anchorHotsoptActivedStyle: { radius: 14 },
|
|
||||||
anchorPointHoverStyle: { radius: 4, fill: '#1890FF', fillOpacity: 1, stroke: '#1890FF' },
|
|
||||||
nodeControlPointStyle: { radius: 4, fill: '#fff', shadowBlur: 4, shadowColor: '#666' },
|
|
||||||
edgeControlPointStyle: { radius: 6, symbol: 'square', lineAppendWidth: 6, fillOpacity: 0, strokeOpacity: 0 },
|
|
||||||
nodeSelectedBoxStyle: { stroke: '#C2C2C2' },
|
|
||||||
cursor: {
|
|
||||||
panningCanvas: '-webkit-grabbing',
|
|
||||||
beforePanCanvas: '-webkit-grab',
|
|
||||||
hoverNode: 'move',
|
|
||||||
hoverEffectiveAnchor: 'crosshair',
|
|
||||||
hoverEdge: 'default',
|
|
||||||
hoverGroup: 'move',
|
|
||||||
hoverUnEffectiveAnchor: 'default',
|
|
||||||
hoverEdgeControllPoint: 'crosshair',
|
|
||||||
multiSelect: 'crosshair'
|
|
||||||
},
|
|
||||||
nodeDelegationStyle: {
|
|
||||||
stroke: '#1890FF',
|
|
||||||
fill: '#1890FF',
|
|
||||||
fillOpacity: .08,
|
|
||||||
lineDash: [4, 4],
|
|
||||||
radius: 4,
|
|
||||||
lineWidth: 1
|
|
||||||
},
|
|
||||||
edgeDelegationStyle: { stroke: '#1890FF', lineDash: [4, 4], lineWidth: 1 }
|
|
||||||
}
|
|
||||||
@@ -1,217 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="toolbar">
|
|
||||||
<div class="left">
|
|
||||||
<!-- <el-checkbox class="edge-enabled" title="连线模式" @change="$parent.enableEdgeHandler"></el-checkbox>-->
|
|
||||||
<!-- <dropdown-->
|
|
||||||
<!-- class="edge-shape"-->
|
|
||||||
<!-- :dropdown-items="edgeShapeList"-->
|
|
||||||
<!-- @change="changeEdgeShapeHandler"-->
|
|
||||||
<!-- >-->
|
|
||||||
<!-- </dropdown>-->
|
|
||||||
<el-button size="mini" @click="router.push('/custom/query/topo')">返回</el-button>
|
|
||||||
</div>
|
|
||||||
<div class="center">
|
|
||||||
<div class="graph-ops">
|
|
||||||
<svg-icon name="undo" title="撤回" :class-name="disableUndo ? 'disabled-icon':'er-icon'"
|
|
||||||
@handle="undoHandler(disableUndo)"/>
|
|
||||||
<svg-icon name="redo" title="重做" :class-name="disableRedo ? 'disabled-icon':'er-icon'" @handle="redoHandler"/>
|
|
||||||
<span class="separator"></span>
|
|
||||||
<svg-icon name="copy" title="复制" :class-name="disableCopy ? 'disabled-icon':'er-icon'" @handle="copyHandler"/>
|
|
||||||
<svg-icon name="paste" title="粘贴" :class-name="disablePaste ? 'disabled-icon':'er-icon'"
|
|
||||||
@handle="pasteHandler"/>
|
|
||||||
<svg-icon name="clear" title="删除" :class-name="disableDelete ? 'disabled-icon':'er-icon'"
|
|
||||||
@handle="deleteHandler"/>
|
|
||||||
<span class="separator"></span>
|
|
||||||
<svg-icon name="zoom-in" title="放大" :class-name="'er-icon'" @handle="zoomInHandler"/>
|
|
||||||
<svg-icon name="zoom-out" title="缩小" :class-name="'er-icon'" @handle="zoomOutHandler"/>
|
|
||||||
<svg-icon name="fit" title="适应画布" :class-name="'er-icon'" @handle="autoZoomHandler"/>
|
|
||||||
<svg-icon name="actual_size" title="实际尺寸" :class-name="'er-icon'" @handle="resetZoomHandler"/>
|
|
||||||
<span class="separator"></span>
|
|
||||||
<!--id="multi-select"-->
|
|
||||||
<svg-icon name="selector" title="框选" id="multi-select" :class-name="'er-icon'" @handle="multiSelectHandler"/>
|
|
||||||
|
|
||||||
<!-- <div v-if="graphMode === 'edit'" class="iconfont zx">-->
|
|
||||||
<!-- <dropdown-->
|
|
||||||
<!-- class="edge-shape"-->
|
|
||||||
<!-- :dropdown-items="edgeShapeList"-->
|
|
||||||
<!-- @change="changeEdgeShapeHandler"-->
|
|
||||||
<!-- >-->
|
|
||||||
<!-- </dropdown>-->
|
|
||||||
<!-- </div>-->
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="right">
|
|
||||||
<el-button size="mini" @click="autoLayout">自动布局</el-button>
|
|
||||||
<!--<el-button size="mini" @click="circularLayoutHandler">环形布局</el-button>-->
|
|
||||||
<!--<el-button size="mini" @click="radialLayoutHandler">辐射</el-button>-->
|
|
||||||
<!--<el-button size="mini" @click="mdsLayoutHandler">MDS</el-button>-->
|
|
||||||
<!--<el-button size="mini" @click="dagreLayoutHandler">层次</el-button>-->
|
|
||||||
<!--<el-button size="mini" @click="autoLayoutHandler">自动(old)</el-button>-->
|
|
||||||
<!-- todo 返回到预览模式 -->
|
|
||||||
<el-button size="mini" @click="handlePreview('preview')">预览</el-button>
|
|
||||||
<el-button size="mini" @click="saveDataHandler">保存</el-button>
|
|
||||||
<el-button size="mini" @click="handleTopLine">上线</el-button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import SvgIcon from '@/components/svgIcon/index.vue'
|
|
||||||
import Dropdown from './elements/dropdown.vue'
|
|
||||||
import {defineProps} from "vue";
|
|
||||||
import {useRouter} from "vue-router";
|
|
||||||
|
|
||||||
const router = useRouter()
|
|
||||||
|
|
||||||
const emit = defineEmits(["autoLayout", "handlePreview", "saveDataHandler",
|
|
||||||
"undoHandler", "redoHandler", "copyHandler", "pasteHandler", "deleteHandler", "zoomInHandler",
|
|
||||||
"zoomOutHandler", "autoZoomHandler", "resetZoomHandler", "multiSelectHandler"]);
|
|
||||||
const props = defineProps({
|
|
||||||
disableUndo: {
|
|
||||||
type: String, //参数类型
|
|
||||||
default: String, //默认值
|
|
||||||
},
|
|
||||||
disableRedo: {
|
|
||||||
type: String, //参数类型
|
|
||||||
default: String, //默认值
|
|
||||||
},
|
|
||||||
disableCopy: {
|
|
||||||
type: String, //参数类型
|
|
||||||
default: String, //默认值
|
|
||||||
},
|
|
||||||
disablePaste: {
|
|
||||||
type: String, //参数类型
|
|
||||||
default: String, //默认值
|
|
||||||
},
|
|
||||||
disableDelete: {
|
|
||||||
type: String, //参数类型
|
|
||||||
default: String, //默认值
|
|
||||||
},
|
|
||||||
graphMode: {
|
|
||||||
type: String, //参数类型
|
|
||||||
default: String, //默认值
|
|
||||||
},
|
|
||||||
edgeShapeList: {
|
|
||||||
type: Array, //参数类型
|
|
||||||
default: [], //默认值
|
|
||||||
}
|
|
||||||
})
|
|
||||||
const autoLayout = () => {
|
|
||||||
emit('autoLayout');
|
|
||||||
}
|
|
||||||
const handlePreview = (graphMode) => {
|
|
||||||
emit('handlePreview', graphMode);
|
|
||||||
}
|
|
||||||
const saveDataHandler = () => {
|
|
||||||
emit('saveDataHandler');
|
|
||||||
}
|
|
||||||
const handleTopLine = () => {
|
|
||||||
emit('handleTopLine');
|
|
||||||
}
|
|
||||||
const undoHandler = (flag) => {
|
|
||||||
if (flag) return
|
|
||||||
emit('undoHandler');
|
|
||||||
}
|
|
||||||
const redoHandler = () => {
|
|
||||||
emit('redoHandler');
|
|
||||||
}
|
|
||||||
const copyHandler = () => {
|
|
||||||
emit('copyHandler');
|
|
||||||
}
|
|
||||||
const pasteHandler = () => {
|
|
||||||
emit('pasteHandler');
|
|
||||||
}
|
|
||||||
const deleteHandler = () => {
|
|
||||||
emit('deleteHandler');
|
|
||||||
}
|
|
||||||
const zoomInHandler = () => {
|
|
||||||
emit('zoomInHandler');
|
|
||||||
}
|
|
||||||
const zoomOutHandler = () => {
|
|
||||||
emit('zoomOutHandler');
|
|
||||||
}
|
|
||||||
const autoZoomHandler = () => {
|
|
||||||
emit('autoZoomHandler');
|
|
||||||
}
|
|
||||||
const resetZoomHandler = () => {
|
|
||||||
emit('resetZoomHandler');
|
|
||||||
}
|
|
||||||
const multiSelectHandler = () => {
|
|
||||||
emit('multiSelectHandler');
|
|
||||||
}
|
|
||||||
const changeEdgeShapeHandler = () => {
|
|
||||||
emit('changeEdgeShapeHandler');
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
<style>
|
|
||||||
|
|
||||||
</style>
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
.zx {
|
|
||||||
float: right;
|
|
||||||
}
|
|
||||||
|
|
||||||
.toolbar {
|
|
||||||
padding-right: 10px;
|
|
||||||
color: #333;
|
|
||||||
text-align: left;
|
|
||||||
vertical-align: middle;
|
|
||||||
line-height: 42px;
|
|
||||||
background-color: #ffffff;
|
|
||||||
border: 1px solid #E9E9E9;
|
|
||||||
box-shadow: 0 8px 12px 0 rgba(0, 52, 107, 0.04);
|
|
||||||
user-select: none;
|
|
||||||
-webkit-user-select: none;
|
|
||||||
-moz-user-select: none;
|
|
||||||
-ms-user-select: none;
|
|
||||||
|
|
||||||
.left {
|
|
||||||
display: inline-block;
|
|
||||||
width: 12%;
|
|
||||||
padding-left: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.center {
|
|
||||||
display: inline-block;
|
|
||||||
width: 58%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.right {
|
|
||||||
display: inline-block;
|
|
||||||
width: 30%;
|
|
||||||
text-align: right;
|
|
||||||
}
|
|
||||||
|
|
||||||
.edge-enabled {
|
|
||||||
width: 40%;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.edge-shape {
|
|
||||||
width: 100%;
|
|
||||||
/*margin-right: 20px;*/
|
|
||||||
line-height: 25px;
|
|
||||||
text-align: center;
|
|
||||||
/*border-right: 1px solid #E6E9ED;*/
|
|
||||||
}
|
|
||||||
|
|
||||||
.graph-ops {
|
|
||||||
display: inline-block;
|
|
||||||
vertical-align: middle;
|
|
||||||
margin-left: 20px;
|
|
||||||
|
|
||||||
.icon-select {
|
|
||||||
background-color: #EEEEEE;
|
|
||||||
}
|
|
||||||
|
|
||||||
.separator {
|
|
||||||
margin-right: 5px;
|
|
||||||
border-left: 1px solid #E9E9E9;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.button {
|
|
||||||
margin: 0 5px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,183 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="toolbar">
|
|
||||||
<div class="left">
|
|
||||||
<dropdown
|
|
||||||
class="theme-style"
|
|
||||||
:dropdown-items="themeOptions"
|
|
||||||
@change="toggleThemeChange"
|
|
||||||
>
|
|
||||||
</dropdown>
|
|
||||||
</div>
|
|
||||||
<div class="center">
|
|
||||||
<div class="graph-ops">
|
|
||||||
<svg-icon name="zoom-in" title="放大" id="zoom-in" @handle="zoomInHandler"/>
|
|
||||||
<svg-icon name="zoom-out" title="缩小" @handle="zoomOutHandler"/>
|
|
||||||
<svg-icon name="fit" title="适应画布" @handle="autoZoomHandler"/>
|
|
||||||
<svg-icon name="actual_size" title="实际尺寸" @handle="resetZoomHandler"/>
|
|
||||||
<span class="separator"></span>
|
|
||||||
<el-checkbox @change="enableMinimapHandler">导航器</el-checkbox>
|
|
||||||
<dropdown :dropdown-items="refreshOptions" @change="toggleAutoRefresh"></dropdown>
|
|
||||||
</div>
|
|
||||||
<div class="right">
|
|
||||||
<el-button size="mini" @click="manualRefreshHandler">刷新</el-button>
|
|
||||||
<el-button size="mini" @click="handleEdit('edit')">编辑</el-button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import SvgIcon from '@/components/svgIcon/index.vue'
|
|
||||||
import Dropdown from './elements/dropdown.vue'
|
|
||||||
import {ref} from "vue";
|
|
||||||
const emit = defineEmits([ "handleEdit","zoomInHandler",
|
|
||||||
"zoomOutHandler","autoZoomHandler","resetZoomHandler","enableMinimapHandler","autoRefreshHandler","manualRefreshHandler"]);
|
|
||||||
|
|
||||||
const themeOptions = ref([
|
|
||||||
{value: 'defaultStyle', label: '默认主题'},
|
|
||||||
{value: 'darkStyle', label: '暗黑风格'},
|
|
||||||
{value: 'officeStyle', label: '办公风格'}
|
|
||||||
])
|
|
||||||
const refreshOptions = ref([
|
|
||||||
{value: -1, label: '不自动刷新'},
|
|
||||||
{value: 10000, label: '10秒自动刷新'},
|
|
||||||
{value: 30000, label: '30秒自动刷新'},
|
|
||||||
{value: 60000, label: '60秒自动刷新'}
|
|
||||||
])
|
|
||||||
|
|
||||||
const toggleThemeChange = (clickItem) => {
|
|
||||||
emit('changeGraphTheme',clickItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
const changeThemeActiveIndex = (index) => {
|
|
||||||
// 给父组件调用(代码触发主题修改)
|
|
||||||
themeOptions.value.activeIndex = index
|
|
||||||
}
|
|
||||||
const zoomInHandler = () => {
|
|
||||||
emit('zoomInHandler');
|
|
||||||
}
|
|
||||||
const zoomOutHandler = () => {
|
|
||||||
emit('zoomOutHandler');
|
|
||||||
}
|
|
||||||
const autoZoomHandler = () => {
|
|
||||||
emit('autoZoomHandler');
|
|
||||||
}
|
|
||||||
const resetZoomHandler = () => {
|
|
||||||
emit('resetZoomHandler');
|
|
||||||
}
|
|
||||||
const enableMinimapHandler = (e) => {
|
|
||||||
emit('enableMinimapHandler',e);
|
|
||||||
}
|
|
||||||
const toggleAutoRefresh = (activeIndex) => {
|
|
||||||
emit('autoRefreshHandler',activeIndex);
|
|
||||||
}
|
|
||||||
const manualRefreshHandler = () => {
|
|
||||||
emit('manualRefreshHandler');
|
|
||||||
}
|
|
||||||
const handleEdit = (graphMode) => {
|
|
||||||
emit('handleEdit', graphMode);
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
.toolbar {
|
|
||||||
padding-right: 10px;
|
|
||||||
color: #333;
|
|
||||||
text-align: left;
|
|
||||||
vertical-align: middle;
|
|
||||||
line-height: 42px;
|
|
||||||
background-color: #ffffff;
|
|
||||||
border: 1px solid #E9E9E9;
|
|
||||||
box-shadow: 0 8px 12px 0 rgba(0, 52, 107, 0.04);
|
|
||||||
user-select: none;
|
|
||||||
-webkit-user-select: none;
|
|
||||||
-moz-user-select: none;
|
|
||||||
-ms-user-select: none;
|
|
||||||
|
|
||||||
.left {
|
|
||||||
display: inline-block;
|
|
||||||
width: 12%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.center {
|
|
||||||
display: inline-block;
|
|
||||||
width: 58%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.right {
|
|
||||||
display: inline-block;
|
|
||||||
width: 30%;
|
|
||||||
text-align: right;
|
|
||||||
}
|
|
||||||
|
|
||||||
.edge-enabled {
|
|
||||||
width: 40%;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.edge-type {
|
|
||||||
width: 60%;
|
|
||||||
line-height: 25px;
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
.theme-style {
|
|
||||||
width: 100%;
|
|
||||||
line-height: 25px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.graph-ops {
|
|
||||||
display: inline-block;
|
|
||||||
vertical-align: middle;
|
|
||||||
margin-left: 20px;
|
|
||||||
|
|
||||||
i {
|
|
||||||
width: 20px;
|
|
||||||
height: 20px;
|
|
||||||
margin: 0 6px;
|
|
||||||
line-height: 20px;
|
|
||||||
color: #a8a8a8;
|
|
||||||
text-align: center;
|
|
||||||
border-radius: 2px;
|
|
||||||
display: inline-block;
|
|
||||||
border: 1px solid rgba(2, 2, 2, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
i:hover {
|
|
||||||
cursor: pointer;
|
|
||||||
border: 1px solid #E9E9E9;
|
|
||||||
}
|
|
||||||
|
|
||||||
.disabled {
|
|
||||||
color: rgba(0, 0, 0, 0.25);
|
|
||||||
}
|
|
||||||
|
|
||||||
.disabled:hover {
|
|
||||||
cursor: not-allowed;
|
|
||||||
border: 1px solid rgba(2, 2, 2, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
.icon-select {
|
|
||||||
background-color: #EEEEEE;
|
|
||||||
}
|
|
||||||
|
|
||||||
.separator {
|
|
||||||
margin: 4px;
|
|
||||||
border-left: 1px solid #E9E9E9;
|
|
||||||
}
|
|
||||||
|
|
||||||
.auto-refresh {
|
|
||||||
margin: 0 8px 0 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.checkbox {
|
|
||||||
margin: 0 6px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.button {
|
|
||||||
margin: 0 5px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
File diff suppressed because one or more lines are too long
@@ -1,312 +0,0 @@
|
|||||||
<template>
|
|
||||||
<topology
|
|
||||||
ref="topologyRef"
|
|
||||||
@handleSave="handleSave"
|
|
||||||
@handlePreview="handlePreview"
|
|
||||||
@handleTopoLine="handleTopoLine"
|
|
||||||
:node-type-list="nodeTypeList"
|
|
||||||
:node-app-config="nodeAppConfig"
|
|
||||||
:edge-app-config="edgeAppConfig"
|
|
||||||
:relational-map="relationalMap"
|
|
||||||
>
|
|
||||||
</topology>
|
|
||||||
<div class="top-dialog">
|
|
||||||
<el-dialog title="预览" width="1500px" v-model="previewShow" @close="closePreview" @submit.prevent="handlePreviewData">
|
|
||||||
<el-form inline class="query-form" ref="queryForm" >
|
|
||||||
<el-form-item v-for="column in uniCons" :key="column.ucId"
|
|
||||||
:label="column.ucName">
|
|
||||||
<el-input :placeholder="column.ucDescribe" :type="column.ucType" v-model="column.query" clearable
|
|
||||||
></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item>
|
|
||||||
<el-button type="primary" @click="handlePreviewData" :icon="Search">搜索</el-button>
|
|
||||||
<el-button @click="handleReset" :icon="Refresh">重置</el-button>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
<div class="table">
|
|
||||||
<el-table :data="previewTable" v-loading="previewLoading">
|
|
||||||
<el-table-column v-for="column in uniColumns" :key="column.prop" :prop="column.prop"
|
|
||||||
:label="column.label" align="center">
|
|
||||||
<template #default="scope">
|
|
||||||
<template v-if="column.displayType === 'date'">
|
|
||||||
{{ simpleDateMoreFormat(scope.row[column.prop], column.displayParam) }}
|
|
||||||
</template>
|
|
||||||
<template v-if="column.displayType === 'text'">
|
|
||||||
{{ scope.row[column.prop] }}
|
|
||||||
</template>
|
|
||||||
<template v-if="column.displayType === 'image'">
|
|
||||||
<change-image :displayType="'image'" :column-prop="scope.row[column.prop]" :params="imageSettingParams"></change-image>
|
|
||||||
<!-- <el-image :src="scope.row[column.prop]">-->
|
|
||||||
<!-- <template #error>-->
|
|
||||||
<!-- <div class="image-slot">-->
|
|
||||||
<!-- <el-image :src="avatar"></el-image>-->
|
|
||||||
<!-- </div>-->
|
|
||||||
<!-- </template>-->
|
|
||||||
<!-- </el-image>-->
|
|
||||||
</template>
|
|
||||||
<template v-if="column.displayType === 'dict'">
|
|
||||||
{{ scope.row[column.prop] }} 字典
|
|
||||||
</template>
|
|
||||||
<template v-if="column.displayType === 'html'">
|
|
||||||
<div v-html="scope.row[column.prop]"></div>
|
|
||||||
超文本标记
|
|
||||||
</template>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
|
||||||
</div>
|
|
||||||
<paging :current-page="pageInfo.pageNum" :page-size="pageInfo.pageSize" :page-sizes="[10, 20, 30, 40,50]"
|
|
||||||
:total="total" @changeSize="handleSizeChange" @goPage="handleCurrentChange"/>
|
|
||||||
</el-dialog>
|
|
||||||
</div>
|
|
||||||
<div class="top-dialog">
|
|
||||||
<el-dialog v-model="isTopLineVisited" title="上线" width="700px">
|
|
||||||
<el-form :model="form" :rules="formRules" class="query-form" ref="formInstance">
|
|
||||||
<el-form-item label="上级菜单">
|
|
||||||
<el-tree-select v-model="form.parentId" :data="menuOpt" style="width: 100%;"
|
|
||||||
:filter-node-method="filterNodeMethod" filterable :check-strictly="true"/>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
<template #footer>
|
|
||||||
<span>
|
|
||||||
<el-button @click="handleCancel">取消</el-button>
|
|
||||||
<el-button type="primary" @click="handleSubmit(formInstance)">
|
|
||||||
确定
|
|
||||||
</el-button>
|
|
||||||
</span>
|
|
||||||
</template>
|
|
||||||
</el-dialog>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup>
|
|
||||||
import Topology from "@/views/custom-query/topo/top/topology.vue"
|
|
||||||
import {getTopoDragInfo, saveTopo, previewTopo, previewTopologyData, topoToLine} from "@/api/custom-query/topo-search"
|
|
||||||
import {simpleDateMoreFormat} from "./utils/date.js";
|
|
||||||
import {reactive} from "vue";
|
|
||||||
import {ElMessage} from "element-plus";
|
|
||||||
import {Search, Refresh} from '@element-plus/icons-vue'
|
|
||||||
import {getMenuOpt} from '@/api/system/menuman.js'
|
|
||||||
import Paging from "@/components/pagination/index.vue";
|
|
||||||
import ChangeImage from "./components/changeImage/ChangeImage.vue";
|
|
||||||
const router = useRouter()
|
|
||||||
const params = reactive(router.currentRoute.value.params)
|
|
||||||
const isTopLineVisited = ref(false)
|
|
||||||
const form = ref({
|
|
||||||
parentId: ''
|
|
||||||
})
|
|
||||||
const formRules = ref({
|
|
||||||
parentId: [{required: true, message: '请选择上级菜单', trigger: 'blur'}]
|
|
||||||
})
|
|
||||||
const imageSettingParams = ref({})
|
|
||||||
const formInstance = ref()
|
|
||||||
const menuOpt = ref([])
|
|
||||||
const topologyRef = ref()
|
|
||||||
const pageInfo = reactive({
|
|
||||||
pageNum: 1,
|
|
||||||
pageSize: 10,
|
|
||||||
})
|
|
||||||
const jsonData = ref()
|
|
||||||
const queryForm = ref([])
|
|
||||||
const queryValue = ref(null)
|
|
||||||
const total = ref(0)
|
|
||||||
const previewLoading = ref(true)
|
|
||||||
const nodeTypeList = ref([])
|
|
||||||
const relationalMap = ref(new Map())
|
|
||||||
const graphDefaultData = ref([])
|
|
||||||
const previewShow = ref(false)
|
|
||||||
const previewTable = ref({})
|
|
||||||
const uniColumns = ref({})
|
|
||||||
const uniCons = ref({})
|
|
||||||
const ucId = ref(null)
|
|
||||||
|
|
||||||
const nodeAppConfig = reactive({
|
|
||||||
// ip: '节点IP',
|
|
||||||
// port: '节点端口',
|
|
||||||
// sysName: '设备名称'
|
|
||||||
})
|
|
||||||
const edgeAppConfig = reactive({
|
|
||||||
associated: "查询方式",
|
|
||||||
sourceColumn: "主表字段",
|
|
||||||
targetColumn: "关联字段"
|
|
||||||
})
|
|
||||||
|
|
||||||
const closePreview = () => {
|
|
||||||
previewShow.value = false
|
|
||||||
}
|
|
||||||
const handleSave = (json) => {
|
|
||||||
// if(JSON.parse(json).edges.length!==JSON.parse(json).nodes.length-1){
|
|
||||||
// ElMessage.warning('图与图之间尚未构成联系, 请检查后保存')
|
|
||||||
// }else {
|
|
||||||
saveTopo({
|
|
||||||
queryId: params.queryId,
|
|
||||||
topJson: json
|
|
||||||
}).then(res => {
|
|
||||||
if (res.code === 1000) {
|
|
||||||
ElMessage.success(res.msg)
|
|
||||||
} else {
|
|
||||||
ElMessage.error(res.msg)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
//点击上线按钮弹框
|
|
||||||
const handleTopoLine = (json) => {
|
|
||||||
getMenuOpt().then(res => {
|
|
||||||
menuOpt.value = [{
|
|
||||||
value: 0,
|
|
||||||
label: "一级目录",
|
|
||||||
children: res.data
|
|
||||||
}]
|
|
||||||
})
|
|
||||||
jsonData.value = json
|
|
||||||
isTopLineVisited.value = true
|
|
||||||
}
|
|
||||||
const filterNodeMethod = (value, data) => data.label.includes(value)
|
|
||||||
|
|
||||||
const restForm = () => {
|
|
||||||
form.value = {
|
|
||||||
parentId: ''
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//取消
|
|
||||||
const handleCancel = () => {
|
|
||||||
restForm();
|
|
||||||
isTopLineVisited.value = false;
|
|
||||||
};
|
|
||||||
const handleSubmit = async (instance) => {
|
|
||||||
if (!instance) return
|
|
||||||
instance.validate(async (valid, fields) => {
|
|
||||||
if (!valid) return
|
|
||||||
topoToLine({
|
|
||||||
menuId: form.value.parentId,
|
|
||||||
queryId: params.queryId,
|
|
||||||
topJson: jsonData.value
|
|
||||||
}).then(res => {
|
|
||||||
if (res.code === 1000) {
|
|
||||||
ElMessage.success(res.msg)
|
|
||||||
router.push('/custom/query/topo')
|
|
||||||
} else {
|
|
||||||
ElMessage.error(res.msg)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const handlePreview = (json) => {
|
|
||||||
imageSettingParams.value=topologyRef.value.imageSettingParams
|
|
||||||
previewLoading.value = true
|
|
||||||
previewTopo({
|
|
||||||
queryId: params.queryId,
|
|
||||||
topJson: json,
|
|
||||||
}).then(res => {
|
|
||||||
console.log('预览', res)
|
|
||||||
if (res.code === 1000) {
|
|
||||||
previewShow.value = true
|
|
||||||
previewTable.value = res.data.table.rows
|
|
||||||
uniColumns.value = res.data.uniColumns
|
|
||||||
uniCons.value = res.data.uniCons
|
|
||||||
total.value = res.data.table.total
|
|
||||||
previewLoading.value = false
|
|
||||||
uniCons.value.forEach(item => {
|
|
||||||
ucId.value = item.ucId
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
ElMessage.error(res.msg)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
//重置搜索
|
|
||||||
const handleReset = () => {
|
|
||||||
uniCons.value.forEach(con => {
|
|
||||||
con.query = ''
|
|
||||||
})
|
|
||||||
handlePreviewData()
|
|
||||||
}
|
|
||||||
|
|
||||||
const handlePreviewData = () => {
|
|
||||||
previewLoading.value = true
|
|
||||||
let queryData = []
|
|
||||||
uniCons.value.forEach(con => {
|
|
||||||
if (con.query) {
|
|
||||||
let queryItem = {
|
|
||||||
query: con.query,
|
|
||||||
ucId: con.ucId
|
|
||||||
}
|
|
||||||
queryData.push(queryItem)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
previewTopologyData({
|
|
||||||
list: queryData,
|
|
||||||
queryId: params.queryId
|
|
||||||
}, pageInfo).then(res => {
|
|
||||||
previewTable.value = res.data.rows
|
|
||||||
total.value = res.data.total
|
|
||||||
previewLoading.value = false
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
const getDragInfo = async () => {
|
|
||||||
let queryId = params.queryId
|
|
||||||
getTopoDragInfo(queryId).then(res => {
|
|
||||||
if (res.code === 1000) {
|
|
||||||
// console.log('拖拽数据', res.data)
|
|
||||||
nodeTypeList.value = res.data.tableList
|
|
||||||
// for (let relationalItem of res.data.relational) {
|
|
||||||
// let item = relationalMap.value.get(relationalItem.mainId)
|
|
||||||
// if (null == item) {
|
|
||||||
// item = [];
|
|
||||||
// }
|
|
||||||
// item.push(relationalItem)
|
|
||||||
// relationalMap.value.set(relationalItem.mainId,item)
|
|
||||||
// }
|
|
||||||
// console.log('res.data.relational', res.data.relational)
|
|
||||||
if (res.data.relational.length === 0) {
|
|
||||||
relationalMap.value = []
|
|
||||||
} else {
|
|
||||||
relationalMap.value = res.data.relational
|
|
||||||
}
|
|
||||||
if (res.data.topJson === null) {
|
|
||||||
let data = {
|
|
||||||
nodes: [],
|
|
||||||
edges: [],
|
|
||||||
combos: [],
|
|
||||||
groups: []
|
|
||||||
}
|
|
||||||
topologyRef.value.initTopo(data);
|
|
||||||
} else {
|
|
||||||
graphDefaultData.value = JSON.parse(res.data.topJson)
|
|
||||||
topologyRef.value.initTopo(graphDefaultData.value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
//切换每页显示条数
|
|
||||||
const handleSizeChange = (val) => {
|
|
||||||
pageInfo.pageSize = val
|
|
||||||
handlePreviewData()
|
|
||||||
}
|
|
||||||
|
|
||||||
//点击页码进行分页功能
|
|
||||||
const handleCurrentChange = (val) => {
|
|
||||||
pageInfo.pageNum = val
|
|
||||||
handlePreviewData()
|
|
||||||
}
|
|
||||||
getDragInfo()
|
|
||||||
</script>
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
.demo-topology {
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<style lang="scss">
|
|
||||||
html {
|
|
||||||
overflow-x: hidden;
|
|
||||||
overflow-y: hidden;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author: clay
|
|
||||||
* @data: 2019/08/15
|
|
||||||
* @description: 画锚点
|
|
||||||
*/
|
|
||||||
|
|
||||||
import theme from '@/views/custom-query/topo/top/theme'
|
|
||||||
export default function(cfg, group) {
|
|
||||||
const themeStyle = theme.defaultStyle // todo...先使用默认主题,后期可能增加其它风格的主体
|
|
||||||
let { anchorPoints, width, height, id } = cfg
|
|
||||||
if (anchorPoints && anchorPoints.length) {
|
|
||||||
for (let i = 0, len = anchorPoints.length; i < len; i++) {
|
|
||||||
let [x, y] = anchorPoints[i]
|
|
||||||
// 计算Marker中心点坐标
|
|
||||||
let anchorX = x * width
|
|
||||||
let anchorY = y * height
|
|
||||||
// 添加锚点背景
|
|
||||||
let anchorBgShape = group.addShape('marker', {
|
|
||||||
id: id + '_anchor_bg_' + i,
|
|
||||||
attrs: {
|
|
||||||
name: 'anchorBg',
|
|
||||||
x: anchorX,
|
|
||||||
y: anchorY,
|
|
||||||
// 锚点默认样式
|
|
||||||
...themeStyle.anchorBgStyle.default
|
|
||||||
},
|
|
||||||
draggable: false,
|
|
||||||
name: 'markerBg-shape'
|
|
||||||
})
|
|
||||||
// 添加锚点Marker形状
|
|
||||||
let anchorShape = group.addShape('marker', {
|
|
||||||
id: id + '_anchor_' + i,
|
|
||||||
attrs: {
|
|
||||||
name: 'anchor',
|
|
||||||
x: anchorX,
|
|
||||||
y: anchorY,
|
|
||||||
// 锚点默认样式
|
|
||||||
...themeStyle.anchorStyle.default
|
|
||||||
},
|
|
||||||
draggable: false,
|
|
||||||
name: 'marker-shape'
|
|
||||||
})
|
|
||||||
|
|
||||||
anchorShape.on('mouseenter', function() {
|
|
||||||
anchorBgShape.attr({
|
|
||||||
...themeStyle.anchorBgStyle.active
|
|
||||||
})
|
|
||||||
})
|
|
||||||
anchorShape.on('mouseleave', function() {
|
|
||||||
anchorBgShape.attr({
|
|
||||||
...themeStyle.anchorBgStyle.inactive
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author: clay
|
|
||||||
* @data: 2019/08/15
|
|
||||||
* @description: anchor
|
|
||||||
*/
|
|
||||||
|
|
||||||
import setState from './set-state'
|
|
||||||
import drawMark from './draw_mark'
|
|
||||||
|
|
||||||
export default {
|
|
||||||
setState,
|
|
||||||
drawMark,
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author: clay
|
|
||||||
* @data: 2019/08/15
|
|
||||||
* @description: set anchor state
|
|
||||||
*/
|
|
||||||
import theme from '@/views/custom-query/topo/top/theme'
|
|
||||||
|
|
||||||
export default function (name, value, item) {
|
|
||||||
const themeStyle = theme.defaultStyle
|
|
||||||
if (name === 'hover') {
|
|
||||||
let group = item.getContainer()
|
|
||||||
let children = group.get('children')
|
|
||||||
for (let i = 0, len = children.length; i < len; i++) {
|
|
||||||
let child = children[i]
|
|
||||||
// 处理锚点状态
|
|
||||||
if (child.attrs.name === 'anchorBg') {
|
|
||||||
if (value) {
|
|
||||||
child.attr(themeStyle.anchorStyle.hover)
|
|
||||||
} else {
|
|
||||||
child.attr(themeStyle.anchorStyle.unhover)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author: clay
|
|
||||||
* @data: 2019/08/15
|
|
||||||
* @description: update anchor
|
|
||||||
*/
|
|
||||||
|
|
||||||
export default function(cfg, group) {
|
|
||||||
let { anchorPoints, width, height, id } = cfg
|
|
||||||
if (anchorPoints && anchorPoints.length) {
|
|
||||||
for (let i = 0, len = anchorPoints.length; i < len; i++) {
|
|
||||||
let [x, y] = anchorPoints[i]
|
|
||||||
// 计算Marker中心点坐标
|
|
||||||
let originX = -width / 2
|
|
||||||
let originY = -height / 2
|
|
||||||
let anchorX = x * width + originX
|
|
||||||
let anchorY = y * height + originY
|
|
||||||
// 锚点背景
|
|
||||||
let anchorBgShape = group.findById(id + '_anchor_bg_' + i)
|
|
||||||
// 锚点
|
|
||||||
let anchorShape = group.findById(id + '_anchor_' + i)
|
|
||||||
anchorBgShape.attr({
|
|
||||||
x: anchorX,
|
|
||||||
y: anchorY
|
|
||||||
})
|
|
||||||
anchorShape.attr({
|
|
||||||
x: anchorX,
|
|
||||||
y: anchorY
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author: clay
|
|
||||||
* @data: 2021/5/11 17:28
|
|
||||||
* @email: clay@hchyun.com
|
|
||||||
* @description: node
|
|
||||||
*/
|
|
||||||
import setState from './set-state'
|
|
||||||
|
|
||||||
export default {
|
|
||||||
setState
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user