Commit 3a2c2257 by ningjihai

tree

parent edbc8bba
...@@ -141,7 +141,7 @@ import { ref, reactive, watch, computed, nextTick,toRaw } from 'vue' ...@@ -141,7 +141,7 @@ import { ref, reactive, watch, computed, nextTick,toRaw } from 'vue'
import { ElMessage,ElMessageBox } from 'element-plus' import { ElMessage,ElMessageBox } from 'element-plus'
import DesensitizationRuleDialog from './DesensitizationRuleDialog.vue' import DesensitizationRuleDialog from './DesensitizationRuleDialog.vue'
import useAppStore from '@/store/modules/app'
import { import {
desensitizationruleQuery, desensitizationruleQuery,
queryversion, queryversion,
...@@ -158,6 +158,9 @@ queryDesensitizationTables ...@@ -158,6 +158,9 @@ queryDesensitizationTables
import { queryTables,query } from '@/api/classification/classification.js' import { queryTables,query } from '@/api/classification/classification.js'
import TreeFilter from './TreeFilter.vue' import TreeFilter from './TreeFilter.vue'
const appStore = useAppStore()
const props = defineProps({ const props = defineProps({
title: { title: {
type: String, type: String,
...@@ -553,7 +556,9 @@ const handleRuleConfirm = (str,data) =>{ ...@@ -553,7 +556,9 @@ const handleRuleConfirm = (str,data) =>{
} }
const getNodeIcon = (type) => {
return appStore.DATABASE_ICONS[type]
}
// 生成唯一标识符 // 生成唯一标识符
function uuid() { function uuid() {
...@@ -564,54 +569,68 @@ function uuid() { ...@@ -564,54 +569,68 @@ function uuid() {
} }
// 树节点点击处理 // 树节点点击处理
const handleNodeClick = async (data) => { const handleNodeClick = async (data) => {
currentNodeData.value = data currentNodeData.value = data
// 2. 点击一层系统数据,查 schemas // 点击一层系统数据,查 schemas
if (data.type === 'system') { if (data.type === 'system') {
const res = await queryShemas({ const res = await queryShemas({
dataSystemId: data.tid, dataSystemId: data.tid,
dataType: data.dbtype, dataType: data.dbtype,
projectid: sessionStorage.getItem('projectId') projectid: sessionStorage.getItem('projectId') || ''
}) })
if (res && res.data) { if (res && res.data) {
data.children = res.data.map(schema => ({ data.children = res.data.map(schema => ({
id: uuid(),
dataSystemId: data.tid,
dbtype: data.dbtype,
projectid: sessionStorage.getItem('projectId') || '',
schema: schema.text,
type: 'database',
label: schema.text,
parent: data,
icon: getNodeIcon('DATABASE'),
children: []
}))
treeData.value = [...treeData.value] // 触发视图更新
}
}
// 点击二层数据库,构造一层
if(data.type === 'database'){
data.children = [
{
id: uuid(), id: uuid(),
...schema, label: '表',
type: 'database', type: 'category',
label: schema.text, dataSystemId: data.dataSystemId,
parent: data, dbtype: data.dbtype,
children: [ projectid: data.projectid,
{ schema: data.schema,
id: uuid(), parent: data,
label: '表', icon: getNodeIcon('queryTables'),
type: 'category', children: []
parent: { }
...schema, ]
type: 'database',
label: schema.text,
parent: data,
tid: data.tid,
dbservername: schema.text
},
children: []
}
]
}))
treeData.value = [...treeData.value] // 触发视图更新
}
} }
// 3. 点击三层 category,查表
if (data.type === 'category' && data.parent) {
const parentDb = data.parent // 点击三层 category,查表
if (data.type === 'category') {
const res = await queryTables({ const res = await queryTables({
dataSystemId: parentDb.tid, dataSystemId: data.dataSystemId,
schema: parentDb.dbservername schema: data.schema
}) })
if (res && res.data) { if (res && res.data) {
data.children = res.data.map(table => ({ data.children = res.data.map(table => ({
...table, dataSystemId: data.dataSystemId,
id: uuid(), dbtype: data.dbtype,
projectid: data.projectid,
schema: data.schema,
realName: table.realName,
showName: table.showName,
id: uuid(),
label: table.showName, label: table.showName,
type: 'table', type: 'table',
icon: getNodeIcon('TABLE'),
parent: data parent: data
})) }))
treeData.value = [...treeData.value] treeData.value = [...treeData.value]
...@@ -689,6 +708,7 @@ const openDialog = async (mode, strategyData = null) => { ...@@ -689,6 +708,7 @@ const openDialog = async (mode, strategyData = null) => {
...item, ...item,
label: item.sysname, label: item.sysname,
type: 'system', type: 'system',
icon: getNodeIcon(item.dbtype),
children: [ children: [
] ]
})) }))
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
> >
<template #default="{ node, data }"> <template #default="{ node, data }">
<span class="custom-tree-node"> <span class="custom-tree-node">
<i :class="getNodeIcon(data.type)" class="node-icon"></i> <i class="iconfont node-icon" v-html="data.icon.text" :style="`color: ${data.icon.color};`"></i>
<span>{{ node.label }}</span> <span>{{ node.label }}</span>
<template v-if="data.type === 'category'"> <template v-if="data.type === 'category'">
<i class="el-icon-collection icon-category" style="margin-left:6px;color:#F7BA2A;font-size:16px;"></i> <i class="el-icon-collection icon-category" style="margin-left:6px;color:#F7BA2A;font-size:16px;"></i>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论