Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
<meta charset="UTF-8">
|
||||
<link rel="icon" href="/favicon.ico">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<!-- <title>科研管理平台</title>-->
|
||||
<title>科研管理平台</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 64 KiB |
@@ -1,61 +0,0 @@
|
||||
import request from '@/utils/request.js'
|
||||
|
||||
// 请求数据源适配器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'
|
||||
})
|
||||
}
|
||||
|
||||
@@ -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,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'
|
||||
})
|
||||
}
|
||||
@@ -222,9 +222,6 @@ const singleFileList = ref([])
|
||||
if (props.formData.fileList !== null && props.formData.fileList?.length > 0) {
|
||||
allFileList.value = props.formData.fileList
|
||||
}
|
||||
watch(() => props.showTable, (newVal) => {
|
||||
props.showTable = newVal
|
||||
}, {deep: true})
|
||||
watch(() => props.showSingleTable, (newVal) => {
|
||||
props.showSingleTable = newVal
|
||||
}, {deep: true})
|
||||
@@ -237,7 +234,7 @@ watch(() => props.formData.fileList, (newVal) => {
|
||||
}
|
||||
}, {deep: true})
|
||||
watch(() => props.otherFileList, (newVal) => {
|
||||
// console.log('newotherFileList', newVal, props.formData)
|
||||
// console.log('newotherFileList', newVal)
|
||||
if (props.preview) {
|
||||
if (props.formData.fileList === null || props.formData.fileList?.length === 0) {
|
||||
allFileList.value = newVal
|
||||
@@ -250,6 +247,10 @@ watch(() => props.otherFileList, (newVal) => {
|
||||
allFileList.value = newVal
|
||||
}
|
||||
}, {deep: true})
|
||||
|
||||
watch(() => props.showTable, (newVal) => {
|
||||
props.showTable = newVal
|
||||
}, {deep: true})
|
||||
watch(() => props.singleList, (newVal) => {
|
||||
// console.log('singleFile', newVal)
|
||||
singleFileList.value = newVal
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<!-- <el-button color="#DED0B2" style="float: right;margin: 0 10px 10px 0" @click="exportTable">导出</el-button>-->
|
||||
<el-button color="#DED0B2" style="float: right;margin: 0 10px 10px 0" @click="exportTable">导出</el-button>
|
||||
<el-table ref="table" :data="tableData" style="width: 100%;height: 479px" :show-summary="true" border
|
||||
:summary-method="getSummaries" v-loading="loading" :header-cell-style="{background:'#f5f7fa'}">
|
||||
<el-table-column type="index" label="序号" align="center" width="60"/>
|
||||
@@ -16,7 +16,6 @@
|
||||
<template #default="scope">
|
||||
<div v-if="scope.row.researchStage !== null && scope.row.researchStage !== null && scope.row.researchStage !== undefined">
|
||||
<el-tag effect="plain">{{scope.row.researchStage==1?'开发阶段':'研究阶段'}}</el-tag>
|
||||
<!-- <Tag dictType="research_stage" :value="scope.row.researchStage"/>-->
|
||||
</div>
|
||||
<div v-else>--</div>
|
||||
</template>
|
||||
@@ -30,6 +29,8 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<!-- <Tag dictType="research_stage" :value="scope.row.researchStage"/>-->
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
|
||||
@@ -50,7 +50,7 @@ const tableConfig = reactive({
|
||||
type: 'index',
|
||||
label: '序号',
|
||||
align: 'center',
|
||||
width: 90,
|
||||
width: 85,
|
||||
},
|
||||
{
|
||||
prop: 'originalFileName',
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div class="logo" ref="logo">
|
||||
<!-- <span v-if="!siderbarStore.isCollapse">科研管理平台</span>-->
|
||||
<span v-if="!siderbarStore.isCollapse">科研管理平台</span>
|
||||
<span v-if="!siderbarStore.isCollapse"></span>
|
||||
</div>
|
||||
<el-scrollbar :height="`calc(100vh - ${logoHeight}px)`" style="background-color: #ffffff">
|
||||
|
||||
@@ -82,15 +82,6 @@ const router = createRouter({
|
||||
breadcrumb: true
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/rapid/gen/edit/:tableId(\\d+)',
|
||||
name: 'genEdit',
|
||||
component: () => import('@/views/rapid/gen/editTable.vue'),
|
||||
meta: {
|
||||
title: '数据库生成配置',
|
||||
breadcrumb: true
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/workflow/process/edit/:deploymentId',
|
||||
name: 'processEdit',
|
||||
@@ -154,53 +145,8 @@ const router = createRouter({
|
||||
breadcrumb: false
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/custom/query/sql/design/:queryId',
|
||||
name: 'sql',
|
||||
component: () => import('@/views/custom-query/sql/SqlDesign.vue'),
|
||||
meta: {
|
||||
title: '自定义sql查询配置',
|
||||
breadcrumb: true
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/custom/query/data/adapter/design/:queryId',
|
||||
name: 'dataAdapter',
|
||||
component: () => import('@/views/custom-query/data-adapter/DataAdapterDesign.vue'),
|
||||
meta: {
|
||||
title: '自定义数据适配器',
|
||||
breadcrumb: true
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/custom/query/echarts/design/:queryId',
|
||||
name: 'echarts',
|
||||
component: () => import('@/views/custom-query/echarts-editor/EchartsDesign.vue'),
|
||||
meta: {
|
||||
title: '自定义echarts查询配置',
|
||||
breadcrumb: true
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/rapid/data/:dsId(\\d+)',
|
||||
name: 'rapid',
|
||||
component: () => import('@/views/rapid/gen/index.vue'),
|
||||
meta: {
|
||||
title: '数据源关联数据',
|
||||
breadcrumb: true
|
||||
}
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/topo/design/:queryId',
|
||||
name: 'topEdit',
|
||||
component: () => import('@/views/custom-query/topo/topologyDesign.vue'),
|
||||
meta: {
|
||||
title: 'top',
|
||||
breadcrumb: false
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/forbidden',
|
||||
name: 'forbidden',
|
||||
|
||||
@@ -35,12 +35,12 @@ serveice.interceptors.response.use(response => {
|
||||
const status = response.status;
|
||||
switch (status) {
|
||||
case 401:
|
||||
ElMessageBox.confirm('登录状态已过期,请重新登录', '系统提示', {
|
||||
confirmButtonText: '重新登录',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
closeOnClickModal: false
|
||||
}).then(() => {
|
||||
// ElMessageBox.confirm('登录状态已过期,请重新登录', '系统提示', {
|
||||
// confirmButtonText: '重新登录',
|
||||
// cancelButtonText: '取消',
|
||||
// type: 'warning',
|
||||
// closeOnClickModal: false
|
||||
// }).then(() => {
|
||||
removeToken()
|
||||
let path = window.location.pathname;
|
||||
let query = window.location.search
|
||||
@@ -49,7 +49,7 @@ serveice.interceptors.response.use(response => {
|
||||
query: query
|
||||
}))
|
||||
window.location.href = `${window.location.origin}/api/auth/cas/login`
|
||||
})
|
||||
// })
|
||||
return Promise.reject('会话已过期,请重新登录')
|
||||
case 402:
|
||||
break;
|
||||
|
||||
@@ -95,6 +95,7 @@
|
||||
</el-form>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
|
||||
</el-card>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
<template>
|
||||
<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-model="queryParams.code" :editor-placeholder="'请输入java代码'" :editor-height="250"
|
||||
:tab-size="2"/>
|
||||
</div>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="模拟数据" prop="mockData">
|
||||
<el-input v-model="queryParams.mockData" placeholder="请输入模拟数据" :rows="4" 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-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import JavaCodeEdit from "@/components/codeEdit/JavaCodeEdit.vue";
|
||||
import {ElMessage} from "element-plus";
|
||||
import {executeAdapterMockData, getDataAdapterDetails,editDataAdapter} from "@/api/custom-query/adapter";
|
||||
import {useRouter} from "vue-router";
|
||||
|
||||
const router = useRouter();
|
||||
const queryId = reactive(router.currentRoute.value.params.queryId)
|
||||
const queryParams = ref({
|
||||
adapterName:null,
|
||||
type:null,
|
||||
source:"CUSTOM",
|
||||
code: null,
|
||||
mockData: null
|
||||
})
|
||||
|
||||
const getDetails = async () => {
|
||||
await getDataAdapterDetails(queryId).then(res => {
|
||||
if (res.code === 1000) {
|
||||
queryParams.value = res.data
|
||||
} else {
|
||||
ElMessage.error(res.msg)
|
||||
}
|
||||
})
|
||||
}
|
||||
getDetails()
|
||||
const handleSave=()=>{
|
||||
editDataAdapter(queryParams.value).then(res => {
|
||||
if (res.code === 1000) {
|
||||
ElMessage.success(res.msg)
|
||||
} else {
|
||||
ElMessage.error(res.msg)
|
||||
}
|
||||
})
|
||||
}
|
||||
const handleExecute = () => {
|
||||
executeAdapterMockData(queryParams.value).then(res => {
|
||||
console.log('handleExecute',res)
|
||||
if (res.code === 1000) {
|
||||
ElMessage.success(res.msg)
|
||||
} else {
|
||||
ElMessage.error(res.msg)
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@@ -1,285 +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"
|
||||
@select="handleSelect"
|
||||
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 {ElMessage, ElMessageBox} from "element-plus";
|
||||
import {Search, Refresh, Delete, Plus, Edit, Download} from '@element-plus/icons-vue'
|
||||
import Paging from "@/components/pagination/index.vue";
|
||||
import {useCacheStore} from "@/stores/cache";
|
||||
import {useRouter} from "vue-router";
|
||||
|
||||
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)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
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,107 +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";
|
||||
|
||||
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=>{
|
||||
let data = res.data
|
||||
tableData.value = data.rows
|
||||
total.value = data.total
|
||||
tableLoading.value = false
|
||||
})
|
||||
}
|
||||
//重置搜索
|
||||
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,316 +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
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
/**
|
||||
* @author: clay
|
||||
* @data: 2021/5/11 17:28
|
||||
* @email: clay@hchyun.com
|
||||
* @description: node 节点收缩和放大
|
||||
*/
|
||||
export default function(e){
|
||||
const {
|
||||
graph
|
||||
} = this;
|
||||
const item = e.item;
|
||||
const shape = e.shape;
|
||||
if (!item) {
|
||||
return;
|
||||
}
|
||||
|
||||
//收缩
|
||||
if (shape.get("name") === "collapse") {
|
||||
graph.updateItem(item, {
|
||||
collapsed: true,
|
||||
size: [300, 50],
|
||||
});
|
||||
setTimeout(() => graph.layout(), 100);
|
||||
//展开
|
||||
} else if (shape.get("name") === "expand") {
|
||||
graph.updateItem(item, {
|
||||
collapsed: false,
|
||||
size: [300, 500],
|
||||
});
|
||||
setTimeout(() => graph.layout(), 100);
|
||||
}
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
//时间转换为String类型
|
||||
const simpleDateFormat=(pattern)=> {
|
||||
const fmt = new Object();
|
||||
fmt.pattern = pattern;
|
||||
fmt.parse = function (source) {
|
||||
try {
|
||||
return new Date(source);
|
||||
} catch (e) {
|
||||
console.log("字符串 " + source + " 转时间格式失败!");
|
||||
return null;
|
||||
}
|
||||
};
|
||||
fmt.format = function (date) {
|
||||
if (typeof (date) == "undefined" || date == null || date == "") {
|
||||
return "";
|
||||
}
|
||||
try {
|
||||
date = new Date(date);
|
||||
} catch (e) {
|
||||
console.log("时间 " + date + " 格式化失败!");
|
||||
return "";
|
||||
}
|
||||
let strTime = this.pattern;//时间表达式的正则
|
||||
|
||||
const o = {
|
||||
"M+": date.getMonth() + 1, //月份
|
||||
"d+": date.getDate(), //日
|
||||
"H+": date.getHours(), //小时
|
||||
"m+": date.getMinutes(), //分
|
||||
"s+": date.getSeconds(), //秒
|
||||
"q+": Math.floor((date.getMonth() + 3) / 3), //季度
|
||||
"S": date.getMilliseconds() //毫秒
|
||||
};
|
||||
if (/(y+)/.test(strTime)) {
|
||||
strTime = strTime
|
||||
.replace(RegExp.$1, (date.getFullYear() + "")
|
||||
.substr(4 - RegExp.$1.length));
|
||||
}
|
||||
for (const k in o) {
|
||||
if (new RegExp("(" + k + ")").test(strTime)) {
|
||||
strTime = strTime.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
|
||||
}
|
||||
}
|
||||
return strTime;
|
||||
};
|
||||
return fmt;
|
||||
}
|
||||
|
||||
//用于一个函数有多个时间格式转换
|
||||
export const simpleDateMoreFormat=(date, formatStr) =>{
|
||||
console.log(date,formatStr)
|
||||
const fmt = simpleDateFormat(formatStr);
|
||||
date = fmt.parse(date)
|
||||
return fmt.format(date)
|
||||
}
|
||||
|
||||
//时间格式化为yyyy.MM
|
||||
const simpleDateFormatByDot=(date) =>{
|
||||
const fmt = simpleDateFormat("yyyy.MM");
|
||||
date = fmt.parse(date)
|
||||
return fmt.format(date)
|
||||
}
|
||||
|
||||
//时间格式化为yyyy-MM
|
||||
const simpleDateFormatByLine=(date) =>{
|
||||
const fmt = simpleDateFormat("yyyy-MM");
|
||||
date = fmt.parse(date)
|
||||
return fmt.format(date)
|
||||
}
|
||||
|
||||
//时间格式化为yyyy-MM-dd
|
||||
const simpleDateFormatByMoreLine=(date) =>{
|
||||
const fmt = simpleDateFormat("yyyy-MM-dd");
|
||||
date = fmt.parse(date)
|
||||
return fmt.format(date)
|
||||
}
|
||||
|
||||
//用于list表里每条记录中的startDate,endDate,格式化为yyyy.MM
|
||||
const converListDateByDot=(list) =>{
|
||||
for (const item of list) {
|
||||
item.startDate = simpleDateFormatByDot(item.startDate);
|
||||
item.endDate = simpleDateFormatByDot(item.endDate);
|
||||
}
|
||||
}
|
||||
|
||||
//用于data.startDate,data.endDate,格式化为yyyy-MM
|
||||
const converListDateByLine=(date) =>{
|
||||
data.startDate = simpleDateFormatByLine(data.startDate);
|
||||
data.endDate = simpleDateFormatByLine(data.endDate);
|
||||
}
|
||||
|
||||
|
||||
export default {
|
||||
simpleDateFormat,
|
||||
simpleDateMoreFormat,
|
||||
simpleDateFormatByDot,
|
||||
simpleDateFormatByLine,
|
||||
simpleDateFormatByMoreLine,
|
||||
converListDateByDot,
|
||||
converListDateByLine
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
/**
|
||||
* @author: clay
|
||||
* @data: 2019/08/15
|
||||
* @description: edge
|
||||
*/
|
||||
|
||||
import setState from './set-state'
|
||||
|
||||
export default {
|
||||
setState
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
/**
|
||||
* @author: clay
|
||||
* @data: 2019/08/15
|
||||
* @description: set edge state
|
||||
*/
|
||||
|
||||
import theme from '@/views/custom-query/topo/top/theme'
|
||||
|
||||
export default function(name, value, item) {
|
||||
const group = item.getContainer()
|
||||
const shape = group.get('children')[0] // 顺序根据 draw 时确定
|
||||
const themeStyle = theme.defaultStyle // todo...先使用默认主题,后期可能增加其它风格的主体
|
||||
if (name === 'selected') {
|
||||
if (value) {
|
||||
shape.attr(themeStyle.edgeStyle.selected)
|
||||
} else {
|
||||
shape.attr(themeStyle.edgeStyle.unselected)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,117 +0,0 @@
|
||||
/**
|
||||
* Created by clay on 2019/10/14
|
||||
* Description: common utils
|
||||
*/
|
||||
|
||||
/**
|
||||
* This is just a simple version of deep copy
|
||||
* Has a lot of edge cases bug
|
||||
* If you want to use a perfect deep copy, use lodash's _.cloneDeep
|
||||
* @param {Object} source
|
||||
* @returns {Object} targetObj
|
||||
*/
|
||||
const deepClone = function(source) {
|
||||
if (!source && typeof source !== 'object') {
|
||||
throw new Error('error arguments: deepClone')
|
||||
}
|
||||
let targetObj = source.constructor === Array ? [] : {}
|
||||
Object.keys(source).forEach(key => {
|
||||
if (source[key] && typeof source[key] === 'object') {
|
||||
targetObj[key] = deepClone(source[key])
|
||||
} else {
|
||||
targetObj[key] = source[key]
|
||||
}
|
||||
})
|
||||
return targetObj
|
||||
}
|
||||
|
||||
/**
|
||||
* Randomly extract one or more elements from an array
|
||||
* If you want to use a perfect solution, use lodash's _.sample or _.sampleSize
|
||||
* @param {Array} arr
|
||||
* @param {number} count
|
||||
* @returns {Array} arr
|
||||
*/
|
||||
const getRandomArrayElements = function(arr, count = 1) {
|
||||
if (count > arr.length) {
|
||||
throw new Error('error arguments: count is greater than length of array')
|
||||
}
|
||||
let shuffled = arr.slice(0), i = arr.length, min = i - count, temp, index
|
||||
while (i-- > min) {
|
||||
index = Math.floor((i + 1) * Math.random())
|
||||
temp = shuffled[index]
|
||||
shuffled[index] = shuffled[i]
|
||||
shuffled[i] = temp
|
||||
}
|
||||
return shuffled.slice(min)
|
||||
}
|
||||
|
||||
/**
|
||||
* @author: clay
|
||||
* @data: 2019/08/15
|
||||
* @description: graph utils
|
||||
*/
|
||||
|
||||
import node from './node'
|
||||
import anchor from './anchor'
|
||||
import edge from './edge'
|
||||
import collapse from './collapse'
|
||||
|
||||
/**
|
||||
* 比较两个对象的内容是否相同(两个对象的键值都相同)
|
||||
* @param obj1
|
||||
* @param obj2
|
||||
* @returns {*}
|
||||
*/
|
||||
const isObjectValueEqual = function(obj1, obj2) {
|
||||
let o1 = obj1 instanceof Object
|
||||
let o2 = obj2 instanceof Object
|
||||
// 不是对象的情况
|
||||
if (!o1 || !o2) {
|
||||
return obj1 === obj2
|
||||
}
|
||||
// 对象的属性(key值)个数不相等
|
||||
if (Object.keys(obj1).length !== Object.keys(obj2).length) {
|
||||
return false
|
||||
}
|
||||
// 判断每个属性(如果属性值也是对象则需要递归)
|
||||
for (let attr in obj1) {
|
||||
let t1 = obj1[attr] instanceof Object
|
||||
let t2 = obj2[attr] instanceof Object
|
||||
if (t1 && t2) {
|
||||
return isObjectValueEqual(obj1[attr], obj2[attr])
|
||||
} else if (obj1[attr] !== obj2[attr]) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 生成uuid算法,碰撞率低于1/2^^122
|
||||
* @returns {string}
|
||||
*/
|
||||
const generateUUID = function() {
|
||||
let d = new Date().getTime()
|
||||
// x 是 0-9 或 a-f 范围内的一个32位十六进制数
|
||||
let uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
||||
let r = (d + Math.random() * 16) % 16 | 0
|
||||
d = Math.floor(d / 16)
|
||||
return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16)
|
||||
})
|
||||
return uuid
|
||||
}
|
||||
|
||||
export default {
|
||||
node,
|
||||
anchor,
|
||||
edge,
|
||||
collapse,
|
||||
// 通用工具类函数
|
||||
isObjectValueEqual,
|
||||
generateUUID,
|
||||
deepClone,
|
||||
getRandomArrayElements
|
||||
}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
/**
|
||||
* @author: clay
|
||||
* @data: 2019/08/15
|
||||
* @description: node
|
||||
*/
|
||||
|
||||
import setState from './set-state'
|
||||
|
||||
export default {
|
||||
setState
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
/**
|
||||
* @author: clay
|
||||
* @data: 2019/08/15
|
||||
* @description: set node state
|
||||
*/
|
||||
|
||||
import theme from '@/views/custom-query/topo/top/theme'
|
||||
|
||||
export default function(name, value, item) {
|
||||
const group = item.getContainer()
|
||||
const themeStyle = theme.defaultStyle // todo...先使用默认主题,后期可能增加其它风格的主体
|
||||
let children = group.get('children')
|
||||
for (let i = 0; i < children.length; i++) {
|
||||
let child = children[i]
|
||||
//判断是否为er图的外围,是则改变样式
|
||||
if (child.attrs.name === 'border') {
|
||||
if (name === 'selected') {
|
||||
if (value) {
|
||||
child.attr(themeStyle.nodeStyle.selected)
|
||||
} else {
|
||||
child.attr(themeStyle.nodeStyle.default)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-table v-if="showTable" :data="formData.tableData" style="width: 100%">
|
||||
<el-table-column prop="projectId" label="项目名称" width="230">
|
||||
<el-table-column prop="projectId" label="项目名称" min-width="230">
|
||||
<template #default="scope">
|
||||
<el-form-item prop="time" :rules="scope.row.projectId?'1':rules.projectId">
|
||||
<el-select v-model="scope.row.projectId" placeholder="请选择项目名称" clearable>
|
||||
@@ -36,7 +36,7 @@
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="researchPersonnelId" label="研发人员" width="230">
|
||||
<el-table-column prop="researchPersonnelId" label="研发人员" min-width="180">
|
||||
<template #default="scope">
|
||||
<el-form-item prop="researchPersonnelId">
|
||||
{{ scope.row.researchPersonnel }}
|
||||
@@ -46,56 +46,56 @@
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="wagesPayable" label="应发工资" width="175">
|
||||
<el-table-column prop="wagesPayable" label="应发工资" min-width="175">
|
||||
<template #default="scope">
|
||||
<el-form-item prop="time" :rules="scope.row.wagesPayable?'1':rules.wagesPayable">
|
||||
<el-input-number v-model="scope.row.wagesPayable" placeholder="请输入应发工资" :controls="false"/>
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="performance" label="绩效" width="175">
|
||||
<el-table-column prop="performance" label="绩效" min-width="175">
|
||||
<template #default="scope">
|
||||
<el-form-item prop="time">
|
||||
<el-input-number v-model="scope.row.performance" placeholder="请输入绩效" :controls="false"/>
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="reserveFund" label="公积金" width="175">
|
||||
<el-table-column prop="reserveFund" label="公积金" min-width="175">
|
||||
<template #default="scope">
|
||||
<el-form-item prop="time" :rules="scope.row.reserveFund?'1':rules.reserveFund">
|
||||
<el-input-number v-model="scope.row.reserveFund" placeholder="请输入公积金" :controls="false"/>
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="socialSecurity" label="社保" width="175">
|
||||
<el-table-column prop="socialSecurity" label="社保" min-width="175">
|
||||
<template #default="scope">
|
||||
<el-form-item prop="time" :rules="scope.row.socialSecurity?'1':rules.socialSecurity">
|
||||
<el-input-number v-model="scope.row.socialSecurity" placeholder="请输入社保" :controls="false"/>
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="annuity" label="年金" width="175">
|
||||
<el-table-column prop="annuity" label="年金" min-width="175">
|
||||
<template #default="scope">
|
||||
<el-form-item prop="time" :rules="scope.row.annuity?'1':rules.annuity">
|
||||
<el-input-number v-model="scope.row.annuity" placeholder="请输入年金" :controls="false"/>
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="workday" label="工作日(天)" width="175">
|
||||
<el-table-column prop="workday" label="工作日(天)" min-width="175">
|
||||
<template #default="scope">
|
||||
<el-form-item prop="time" :rules="scope.row.workday?'1':rules.workday">
|
||||
<el-input-number v-model="scope.row.workday" placeholder="请输入工作日" :controls="false"/>
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="researchDuration" label="研发时长(天)" width="175">
|
||||
<el-table-column prop="researchDuration" label="研发时长(天)" min-width="175">
|
||||
<template #default="scope">
|
||||
<el-form-item prop="time" :rules="scope.row.researchDuration?'1':rules.researchDuration">
|
||||
<el-input-number v-model="scope.row.researchDuration" placeholder="请输入研发时长" :controls="false"/>
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="oper" label="操作">
|
||||
<el-table-column prop="oper" label="操作" min-width="130">
|
||||
<template #default="scope">
|
||||
<el-button type="primary" @click="handleCopy(scope.row)" link style="font-size: 18px">复制</el-button>
|
||||
<el-button type="primary" @click="handleDelete(scope.$index)" link style="font-size: 18px">删除</el-button>
|
||||
@@ -411,6 +411,12 @@ const getDetailList = async () => {
|
||||
if (code === 1000) {
|
||||
data.rows.forEach(item => {
|
||||
item.researchPersonnelId = Number(item.researchPersonnelId)
|
||||
let userObj = {
|
||||
id: item.researchPersonnelId,
|
||||
name: item.researchPersonnel,
|
||||
companyName: item.companyName,
|
||||
}
|
||||
userList.value.push(userObj)
|
||||
})
|
||||
formData.value.tableData = data.rows
|
||||
nextTick(() => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template>
|
||||
<!-- <el-button color="#DED0B2" style="float: right;margin: 0 10px 10px 0" @click="exportTable">导出</el-button>-->
|
||||
<el-button color="#DED0B2" style="float: right;margin: 0 10px 10px 0" @click="exportTable">导出</el-button>
|
||||
<el-table ref="table" :data="tableData" style="width: 100%;height: 479px" :show-summary="true" border
|
||||
:summary-method="getSummaries" v-loading="loading" :header-cell-style="{background:'#f5f7fa'}">
|
||||
<el-table-column type="index" label="序号" align="center" width="60"/>
|
||||
@@ -16,7 +16,7 @@
|
||||
<template #default="scope">
|
||||
<div
|
||||
v-if="scope.row.researchStage !== null && scope.row.researchStage !== null && scope.row.researchStage !== undefined">
|
||||
<Tag dictType="research_stage" :value="scope.row.researchStage"/>
|
||||
<el-tag effect="plain">{{scope.row.researchStage==1?'开发阶段':'研究阶段'}}</el-tag>
|
||||
</div>
|
||||
<div v-else>--</div>
|
||||
</template>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
:rules="rules"
|
||||
label-width="70px"
|
||||
>
|
||||
<!-- <h2>科研管理平台</h2>-->
|
||||
<h2>科研管理平台</h2>
|
||||
<el-form-item prop="username" label="账号">
|
||||
<el-input v-model="loginForm.username" :prefix-icon="User"></el-input>
|
||||
</el-form-item>
|
||||
|
||||
@@ -382,9 +382,11 @@ const getOtherFile = (val) => {
|
||||
showTable.value = true
|
||||
})
|
||||
}
|
||||
watch(() => otherFileList.value, (newVal) => {
|
||||
showTable.value = newVal.length !== 0;
|
||||
}, {deep: true})
|
||||
// watch(() => otherFileList.value, (newVal) => {
|
||||
// console.log('newVal',newVal)
|
||||
// showTable.value = newVal.length !== 0;
|
||||
// console.log('showTable.value',showTable.value)
|
||||
// }, {deep: true})
|
||||
watch(() => singleList.value, (newVal) => {
|
||||
showSingleTable.value = newVal.length !== 0;
|
||||
}, {deep: true})
|
||||
|
||||
@@ -50,7 +50,7 @@ const formDataArray = ref([
|
||||
},
|
||||
{
|
||||
label: '项目负责人',
|
||||
prop: 'projectChargePerson',
|
||||
prop: 'projectChargePersonName',
|
||||
colProps: {
|
||||
span: 8
|
||||
}
|
||||
@@ -101,11 +101,11 @@ const formDataArray = ref([
|
||||
])
|
||||
const tableData = ref({})
|
||||
const schema = computed(() => {
|
||||
if (JSON.stringify(tableData.value) !== '{}') {
|
||||
// if (JSON.stringify(tableData.value) !== '{}') {
|
||||
return formDataArray.value
|
||||
} else {
|
||||
return formArray.value
|
||||
}
|
||||
// } else {
|
||||
// return formArray.value
|
||||
// }
|
||||
})
|
||||
const baseForm = ref()
|
||||
const tableIns = ref()
|
||||
@@ -263,8 +263,7 @@ const getBaseInfo = async () => {
|
||||
}
|
||||
const init = async () => {
|
||||
const {code, msg, data} = await searchUpdateLedgerData(route.query.id)
|
||||
console.log('data',data)
|
||||
if (data) {
|
||||
if (code===1000) {
|
||||
tableData.value = data
|
||||
baseForm.value.setValues(data)
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<baseTitle title="基础信息"></baseTitle>
|
||||
<fvForm :schema="schema" @getInstance="(e)=>baseForm = e" style="margin-left:27px"></fvForm>
|
||||
<baseTitle title="阶段变更详情" style="margin-top: -10px"></baseTitle>
|
||||
<div style="color: #606266;font-size: 14px;height:25px;"><span style="display:inline-block;width: 84px;text-align: right;margin-right: 14px">抄送人</span>{{copyName}}</div>
|
||||
<div style="color: #606266;font-size: 14px;height:25px;"><span style="display:inline-block;width: 84px;text-align: right;margin-right: 14px">抄送人</span>{{copyName?copyName:'--'}}</div>
|
||||
<ApprovalDetail :formData="summaryData.formData" :data="summaryData" type="phase"
|
||||
:processViewer="summaryProcessViewer" :loading="loading" :fileListShow="fileListShow" v-model:value="auditOpinion"/>
|
||||
<opinion v-if="summaryData.taskId" :formData="summaryData.formData" :taskId="summaryData.taskId" v-model:value="auditOpinion"></opinion>
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<el-form-item prop="projectChargePerson" label="项目负责人">
|
||||
{{tableForm.projectChargePersonName}}
|
||||
{{ tableForm.projectChargePersonName }}
|
||||
<el-button @click="showPersonnelPicker">
|
||||
{{ tableForm.projectChargePersonName ? '更改' : '请选择研发人员' }}
|
||||
{{ tableForm.projectChargePersonName ? '更改' : '请选择项目负责人' }}
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
@@ -55,7 +55,8 @@
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item prop="projectCompletionRate" label="项目总体完成率(%)">
|
||||
<el-input-number v-model="tableForm.projectCompletionRate" placeholder="请输入项目总体完成率" min="0" max="100" :controls="false" style="width: 200px">
|
||||
<el-input-number v-model="tableForm.projectCompletionRate" placeholder="请输入项目总体完成率" min="0" max="100"
|
||||
:controls="false" style="width: 200px">
|
||||
</el-input-number>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
@@ -67,7 +68,7 @@
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
<user-picker :multiple="false" ref="userPicker" title="请选择项目负责人" @ok="selected"/>
|
||||
<user-picker :multiple="false" ref="userPicker" title="请选择项目负责人" @ok="selected" v-model:value="userList"/>
|
||||
<div class="oper-page-btn">
|
||||
<el-button color="#DED0B2" @click="handleSubmit">提交</el-button>
|
||||
<el-button @click="handleBack">返回</el-button>
|
||||
@@ -94,13 +95,14 @@ const tableForm = ref({
|
||||
endTime: '',
|
||||
projectBudgetDescription: '',
|
||||
projectChargePerson: '',
|
||||
projectChargePersonName:'',
|
||||
projectChargePersonName: '',
|
||||
projectCompletionRate: '',
|
||||
projectDevelopmentWay: '',
|
||||
projectId: '',
|
||||
startTime: ''
|
||||
})
|
||||
const userPicker = ref()
|
||||
const userList = ref([])
|
||||
|
||||
const showPersonnelPicker = () => {
|
||||
userPicker.value.showUserPicker()
|
||||
@@ -113,6 +115,7 @@ const selected = (select) => {
|
||||
tableForm.value.projectChargePerson = selectElement.id
|
||||
tableForm.value.projectChargePersonName = selectElement.name
|
||||
}
|
||||
userList.value = select
|
||||
}
|
||||
const disabledDate = (time) => {
|
||||
return time.getTime() < new Date(tableForm.value.startTime).getTime();
|
||||
@@ -151,6 +154,12 @@ getBaseInfo()
|
||||
const init = async () => {
|
||||
const {code, msg, data} = await searchUpdateLedgerData(route.query.id)
|
||||
tableForm.value = data
|
||||
let userObj = {
|
||||
id: data.projectChargePerson,
|
||||
name: data.projectChargePersonName,
|
||||
companyName: data.companyName,
|
||||
}
|
||||
userList.value.push(userObj)
|
||||
if (code !== 1000) {
|
||||
ElNotification({
|
||||
title: '提示',
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<fvForm :schema="schema" @getInstance="(e)=>baseForm = e"></fvForm>
|
||||
<el-form :model="tableForm" ref="form" class="query-form">
|
||||
<el-table :data="tableForm.tableData">
|
||||
<el-table-column prop="time" label="时间" width="180">
|
||||
<el-table-column prop="time" label="时间" min-width="180">
|
||||
<template #default="scope">
|
||||
<el-form-item prop="time" :rules="scope.row.time?'1':rules.time">
|
||||
<el-date-picker
|
||||
@@ -17,7 +17,7 @@
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="projectCost" label="项目费用" width="220">
|
||||
<el-table-column prop="projectCost" label="项目费用" min-width="220">
|
||||
<template #default="scope">
|
||||
<el-form-item prop="projectCost" :rules="scope.row.projectCost?'1':rules.projectCost">
|
||||
<el-select v-model="scope.row.projectCost" placeholder="请选择费用性质" clearable filterable>
|
||||
@@ -31,7 +31,7 @@
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="researchStage" label="研发阶段" width="220">
|
||||
<el-table-column prop="researchStage" label="研发阶段" min-width="220">
|
||||
<template #default="scope">
|
||||
<el-form-item prop="researchStage" :rules="scope.row.researchStage?'1':rules.researchStage">
|
||||
<el-select v-model="scope.row.researchStage" placeholder="请选择研发阶段" clearable filterable>
|
||||
@@ -45,7 +45,7 @@
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="digest" label="摘要" width="220">
|
||||
<el-table-column prop="digest" label="摘要" min-width="220">
|
||||
<template #default="scope">
|
||||
<el-form-item prop="digest" :rules="scope.row.digest?'1':rules.digest">
|
||||
<el-input v-model="scope.row.digest" placeholder="请输入摘要" clearable>
|
||||
@@ -53,7 +53,7 @@
|
||||
</el-form-item>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="afterTax" label="税后余额(元)" width="220">
|
||||
<el-table-column prop="afterTax" label="税后余额(元)" min-width="220">
|
||||
<template #default="scope">
|
||||
<el-form-item prop="afterTax" :rules="scope.row.afterTax?'1':rules.afterTax">
|
||||
<el-input-number v-model="scope.row.afterTax" placeholder="请输入税后余额" :controls="false">
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<template #default="scope">
|
||||
<div
|
||||
v-if="scope.row.researchStage !== null && scope.row.researchStage !== null && scope.row.researchStage !== undefined">
|
||||
<Tag dictType="research_stage" :value="scope.row.researchStage"/>
|
||||
<el-tag effect="plain">{{scope.row.researchStage==1?'开发阶段':'研究阶段'}}</el-tag>
|
||||
</div>
|
||||
<div v-else>--</div>
|
||||
</template>
|
||||
|
||||
@@ -153,7 +153,7 @@ const fileTable = reactive({
|
||||
type: 'index',
|
||||
label: '序号',
|
||||
align: 'center',
|
||||
width: '80',
|
||||
width: 85,
|
||||
},
|
||||
{
|
||||
prop: 'originalFileName',
|
||||
@@ -169,6 +169,7 @@ const fileTable = reactive({
|
||||
prop: 'size',
|
||||
label: '文件大小',
|
||||
align: 'center',
|
||||
width: 150,
|
||||
currentRender: ({row, index}) => (parseInt(row.size / 1024) + 'KB')
|
||||
},
|
||||
{
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<template>
|
||||
<baseTitle title="基础信息"></baseTitle>
|
||||
<fvForm :schema="schema" @getInstance="(e)=>baseForm = e"></fvForm>
|
||||
<baseTitle title="各流程信息"></baseTitle>
|
||||
<div class="steps-box">
|
||||
<el-steps :active="localActive" finish-status="success">
|
||||
<el-step
|
||||
@@ -22,6 +21,7 @@
|
||||
|
||||
<!-- 步骤内容 -->
|
||||
<div>
|
||||
<baseTitle title="各流程信息"></baseTitle>
|
||||
<slot name="content" :localActive="localActive"></slot>
|
||||
<!-- <template v-for="(item, index) in stepList" :key="item.key">
|
||||
<component v-if="localActive == index" v-bind="item.props || {}" :is="item.component" />
|
||||
@@ -101,28 +101,28 @@ const schema = computed(() => {
|
||||
label: '征集名称',
|
||||
prop: 'requirementName',
|
||||
colProps: {
|
||||
span: 12
|
||||
}
|
||||
},
|
||||
{
|
||||
label: '项目名称',
|
||||
prop: 'projectName',
|
||||
colProps: {
|
||||
span: 12
|
||||
span: 24
|
||||
}
|
||||
},
|
||||
{
|
||||
label: '征集描述',
|
||||
prop: 'collectExplain',
|
||||
colProps: {
|
||||
span: 12
|
||||
span: 24
|
||||
}
|
||||
},
|
||||
{
|
||||
label: '项目名称',
|
||||
prop: 'projectName',
|
||||
colProps: {
|
||||
span: 24
|
||||
}
|
||||
},
|
||||
{
|
||||
label: '所属公司',
|
||||
prop: 'affiliatedCompany',
|
||||
colProps: {
|
||||
span: 12
|
||||
span: 24
|
||||
}
|
||||
},
|
||||
]
|
||||
|
||||
@@ -240,12 +240,24 @@ const _value = computed({
|
||||
const filterDict = (data, value) => {
|
||||
if (data === undefined || value === undefined) return;
|
||||
let label = ''
|
||||
if (data instanceof Array) {
|
||||
data.find(item => {
|
||||
if (item.value == value) {
|
||||
label = item.label
|
||||
}
|
||||
let result = []
|
||||
if (JSON.parse(value) instanceof Array) {
|
||||
JSON.parse(value).forEach(item1 => {
|
||||
data.find(item => {
|
||||
if (item.value == item1) {
|
||||
result.push(item.label)
|
||||
}
|
||||
})
|
||||
})
|
||||
label = result.map(item => item).join(',')
|
||||
} else {
|
||||
if (data instanceof Array) {
|
||||
data.find(item => {
|
||||
if (item.value == value) {
|
||||
label = item.label
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
return label
|
||||
}
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
<template>
|
||||
<el-form ref="basicInfoForm" :model="info" :rules="rules" label-width="150px">
|
||||
<el-row>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="表名称" prop="tableName">
|
||||
<el-input placeholder="请输入仓库名称" v-model="info.tableName"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="表描述" prop="tableComment">
|
||||
<el-input placeholder="请输入" v-model="info.tableComment"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="12">
|
||||
<el-form-item label="实体类名称" prop="className">
|
||||
<el-input placeholder="请输入" v-model="info.className"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="作者" prop="functionAuthor">
|
||||
<el-input placeholder="请输入" v-model="info.functionAuthor"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="24">
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input type="textarea" :rows="3" v-model="info.remark"></el-input>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {defineExpose, defineProps} from "vue";
|
||||
|
||||
const props = defineProps({
|
||||
info: {
|
||||
type: Object,
|
||||
default: null
|
||||
}
|
||||
})
|
||||
const basicInfoForm = ref()
|
||||
const rules = ref({
|
||||
tableName: [
|
||||
{required: true, message: "请输入表名称", trigger: "blur"}
|
||||
],
|
||||
tableComment: [
|
||||
{required: true, message: "请输入表描述", trigger: "blur"}
|
||||
],
|
||||
className: [
|
||||
{required: true, message: "请输入实体类名称", trigger: "blur"}
|
||||
],
|
||||
functionAuthor: [
|
||||
{required: true, message: "请输入作者", trigger: "blur"}
|
||||
]
|
||||
})
|
||||
defineExpose({
|
||||
basicInfoForm
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
|
||||
</style>
|
||||
@@ -1,234 +0,0 @@
|
||||
<template>
|
||||
<el-card style="margin-top: 15px">
|
||||
<el-tabs v-model="activeName">
|
||||
<el-tab-pane label="基本信息" name="info">
|
||||
<basic-info-form :info="info" ref="infoRef"/>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="字段信息" name="column">
|
||||
<el-table ref="columnRef" :data="columns" row-key="columnId" :max-height="tableHeight">
|
||||
<el-table-column label="序号" type="index" min-width="5%" class-name="allowDrag"/>
|
||||
<el-table-column
|
||||
label="字段列名"
|
||||
prop="columnName"
|
||||
min-width="10%"
|
||||
:show-overflow-tooltip="true"
|
||||
/>
|
||||
<el-table-column label="字段描述" min-width="10%">
|
||||
<template #default="scope">
|
||||
<el-input v-model="scope.row.columnComment"></el-input>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="物理类型"
|
||||
prop="columnType"
|
||||
min-width="10%"
|
||||
:show-overflow-tooltip="true"
|
||||
/>
|
||||
<el-table-column label="Java类型" min-width="11%">
|
||||
<template #default="scope">
|
||||
<el-select v-model="scope.row.javaType" filterable>
|
||||
<el-option label="Long" value="Long"/>
|
||||
<el-option label="String" value="String"/>
|
||||
<el-option label="Integer" value="Integer"/>
|
||||
<el-option label="Double" value="Double"/>
|
||||
<el-option label="BigDecimal" value="BigDecimal"/>
|
||||
<el-option label="Date" value="Date"/>
|
||||
<el-option label="Boolean" value="Boolean"/>
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="java属性" min-width="10%">
|
||||
<template #default="scope">
|
||||
<el-input v-model="scope.row.javaField"></el-input>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column label="插入" min-width="5%">
|
||||
<template #default="scope">
|
||||
<el-checkbox true-label="1" false-label="0" v-model="scope.row.isInsert"></el-checkbox>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="编辑" min-width="5%">
|
||||
<template #default="scope">
|
||||
<el-checkbox true-label="1" false-label="0" v-model="scope.row.isEdit"></el-checkbox>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="列表" min-width="5%">
|
||||
<template #default="scope">
|
||||
<el-checkbox true-label="1" false-label="0" v-model="scope.row.isList"></el-checkbox>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="查询" min-width="5%">
|
||||
<template #default="scope">
|
||||
<el-checkbox true-label="1" false-label="0" v-model="scope.row.isQuery"></el-checkbox>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="查询方式" min-width="10%">
|
||||
<template #default="scope">
|
||||
<el-select v-model="scope.row.queryType" filterable>
|
||||
<el-option label="=" value="EQ"/>
|
||||
<el-option label="!=" value="NE"/>
|
||||
<el-option label=">" value="GT"/>
|
||||
<el-option label=">=" value="GE"/>
|
||||
<el-option label="<" value="LT"/>
|
||||
<el-option label="<=" value="LE"/>
|
||||
<el-option label="LIKE" value="LIKE"/>
|
||||
<el-option label="BETWEEN" value="BETWEEN"/>
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="是否正则" min-width="10%">
|
||||
<template #default="scope">
|
||||
<el-select v-model="scope.row.isRegular" filterable>
|
||||
<el-option v-for="item in regularOptions"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"/>
|
||||
<span></span>
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="必填" min-width="5%">
|
||||
<template #default="scope">
|
||||
<el-checkbox true-label="1" false-label="0" v-model="scope.row.isRequired"></el-checkbox>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="显示类型" min-width="12%">
|
||||
<template #default="scope">
|
||||
<el-select v-model="scope.row.htmlType" filterable>
|
||||
<el-option label="文本框" value="input"/>
|
||||
<el-option label="文本域" value="textarea"/>
|
||||
<el-option label="下拉框" value="select"/>
|
||||
<el-option label="单选框" value="radio"/>
|
||||
<el-option label="复选框" value="checkbox"/>
|
||||
<el-option label="日期控件" value="datetime"/>
|
||||
<el-option label="图片上传" value="imageUpload"/>
|
||||
<el-option label="文件上传" value="fileUpload"/>
|
||||
<el-option label="富文本控件" value="editor"/>
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="字典类型" min-width="12%">
|
||||
<template #default="scope">
|
||||
<el-select v-model="scope.row.dictType" clearable filterable placeholder="请选择" >
|
||||
<el-option
|
||||
v-for="dict in dictOption"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value">
|
||||
<span style="float: left">{{ dict.value }}</span>
|
||||
<span style="float: right; color: #8492a6; font-size: 13px">{{ dict.label }}</span>
|
||||
</el-option>
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="生成信息" name="table">
|
||||
<table-info :table="tables" :info="info" :columns="columns" :option-info="optionInfo" :dict-options="dictOption" ref="tableRef"/>
|
||||
</el-tab-pane>
|
||||
<el-form label-width="100px">
|
||||
<el-form-item style="text-align: center;margin-left:-100px;margin-top:10px;">
|
||||
<el-button type="primary" @click="submitForm()">提交</el-button>
|
||||
<el-button @click="close()">返回</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-tabs>
|
||||
</el-card>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {getTableDetail, editCodeGen} from "@/api/rapid/code-gen";
|
||||
import {getRegularOpt} from "@/api/rapid/regular";
|
||||
import {getDictOption} from "@/api/system/dict-type";
|
||||
import BasicInfoForm from "./basicInfoForm.vue"
|
||||
import TableInfo from './tableInfo.vue'
|
||||
import {ElMessage} from "element-plus";
|
||||
|
||||
const router = useRouter()
|
||||
const params = reactive(router.currentRoute.value.params)
|
||||
|
||||
const activeName = ref("column")
|
||||
const columns = ref([])
|
||||
const info = ref([])
|
||||
const regularOptions = ref([])
|
||||
const tables = ref([])
|
||||
const dictOption = ref([])
|
||||
const optionInfo = ref()
|
||||
const tableHeight = ref(document.documentElement.scrollHeight - 245 + 'px')
|
||||
|
||||
const getRegularOption = async () => {
|
||||
getRegularOpt().then(res => {
|
||||
if (res.code === 1000) {
|
||||
let def = [{
|
||||
value: 0,
|
||||
label: "无"
|
||||
}]
|
||||
def.push(...res.data)
|
||||
regularOptions.value = def
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const getInfo = async () => {
|
||||
getDictOption().then(res => {
|
||||
if (res.code === 1000) {
|
||||
dictOption.value = res.data
|
||||
getDetail()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const submitForm = async () => {
|
||||
const infoData = {...info.value}
|
||||
infoData.optionInfo = {...optionInfo.value}
|
||||
const obj = {
|
||||
...infoData,
|
||||
columns: [...columns.value]
|
||||
}
|
||||
await editCodeGen(obj).then(res => {
|
||||
if (res.code === 1000) {
|
||||
ElMessage.success(res.msg)
|
||||
return
|
||||
}
|
||||
ElMessage.error(res.msg)
|
||||
})
|
||||
}
|
||||
const getDetail = async () => {
|
||||
getTableDetail(params.tableId).then(res => {
|
||||
if (res.code === 1000) {
|
||||
columns.value = res.data.columns
|
||||
info.value = res.data.info
|
||||
tables.value = res.data.tables
|
||||
optionInfo.value = res.data.optionInfo
|
||||
}else {
|
||||
ElMessage.error(res.msg)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
const close = async () => {
|
||||
router.push({
|
||||
path: '/rapid/gen',
|
||||
})
|
||||
}
|
||||
|
||||
const getFormPromise = async (form) => {
|
||||
return new Promise(resolve => {
|
||||
form.validate(res => {
|
||||
resolve(res);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
getRegularOption()
|
||||
|
||||
getInfo()
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@@ -1,185 +0,0 @@
|
||||
<template>
|
||||
<el-dialog v-model="isVisited" title="导入表" width="1000px">
|
||||
<el-form :model="queryParams" inline class="query-form" ref="dataSourceFrom" style="margin: 0">
|
||||
<el-form-item label="数据源" prop="businessType">
|
||||
<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="title">
|
||||
<el-input v-model="queryParams.tableName" placeholder="请输入表名称" clearable></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item label="表备注" prop="title">
|
||||
<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="queryParams"
|
||||
type="daterange"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
value-format="YYYY-MM-DD"
|
||||
/>
|
||||
</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="operId"
|
||||
:lazy="true"
|
||||
ref="singleTable"
|
||||
v-loading="loading"
|
||||
@select="handleSelect"
|
||||
>
|
||||
<el-table-column type="selection" width="80"/>
|
||||
<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-column label="操作">
|
||||
<template #default="scope">
|
||||
<el-button type="primary" size="mini" @click="handleImport(scope.row)" link>导入</el-button>
|
||||
</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>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import {getDynamicTable, importTable} from "@/api/rapid/code-gen";
|
||||
import {Search, Refresh, View} from '@element-plus/icons-vue'
|
||||
import {ElMessage, ElMessageBox} from 'element-plus'
|
||||
import {defineExpose, defineProps} from "vue";
|
||||
import Paging from "@/components/pagination/index.vue";
|
||||
|
||||
const emit = defineEmits(['importSuccess'])
|
||||
|
||||
const queryParams = reactive({
|
||||
dataSourceId: null,
|
||||
tableName: '',
|
||||
tableComment: '',
|
||||
startTime: '',
|
||||
endTime: ''
|
||||
})
|
||||
|
||||
const pageInfo = reactive({
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
})
|
||||
const list = ref([])
|
||||
const dataSourceIds = ref()
|
||||
const loading = ref(true)
|
||||
const total = ref(0)
|
||||
const isVisited = ref(false)
|
||||
|
||||
const props = defineProps({
|
||||
dataSourceOption: {
|
||||
type: Array,
|
||||
default: []
|
||||
},
|
||||
queryId: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
})
|
||||
|
||||
const searchTableSearch = async () => {
|
||||
let params = {
|
||||
...queryParams,
|
||||
pageNum: pageInfo.pageNum,
|
||||
pageSize: pageInfo.pageSize
|
||||
}
|
||||
loading.value = true
|
||||
getDynamicTable(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)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
const handleImportTable = async (data) => {
|
||||
importTable(data).then(res => {
|
||||
if (res.code === 1000) {
|
||||
ElMessage.success(res.msg)
|
||||
isVisited.value = false
|
||||
emit("importSuccess")
|
||||
} else {
|
||||
ElMessage.error(res.msg)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const handleImport = (item) => {
|
||||
let data = {
|
||||
dataSourceId: queryParams.dataSourceId,
|
||||
tables: [item.tableName]
|
||||
}
|
||||
handleImportTable(data)
|
||||
}
|
||||
|
||||
|
||||
//勾选table数据行的 Checkbox
|
||||
const handleSelect = async (selection, row) => {
|
||||
if (selection.length !== 0) {
|
||||
disabled.value = false
|
||||
if (selection.length > 1) {
|
||||
const del_row = selection.shift();
|
||||
dataSourceIds.value.toggleRowSelection(del_row, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//重置功能
|
||||
const handleReset = () => {
|
||||
queryParams.dataSourceId = props.dataSourceOption[0].value
|
||||
queryParams.tableName = ''
|
||||
queryParams.tableComment = ''
|
||||
queryParams.startTime = ''
|
||||
queryParams.endTime = ''
|
||||
searchTableSearch()
|
||||
}
|
||||
//切换每页显示条数
|
||||
const handleSizeChange = async (val) => {
|
||||
pageInfo.pageSize = val
|
||||
await searchTableSearch()
|
||||
}
|
||||
|
||||
//点击页码进行分页功能
|
||||
const handleCurrentChange = async (val) => {
|
||||
pageInfo.pageNum = val
|
||||
await searchTableSearch()
|
||||
}
|
||||
|
||||
const show = () => {
|
||||
isVisited.value = true
|
||||
if (props.queryId !== null) {
|
||||
queryParams.dataSourceId = props.queryId
|
||||
} else {
|
||||
queryParams.dataSourceId = props.dataSourceOption[0].value
|
||||
}
|
||||
searchTableSearch()
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
show
|
||||
})
|
||||
</script>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user