diff --git a/vue-fastapi-frontend/src/views/dataAsset/assetDetail/index.vue b/vue-fastapi-frontend/src/views/dataAsset/assetDetail/index.vue index 38f7e55..66708d1 100644 --- a/vue-fastapi-frontend/src/views/dataAsset/assetDetail/index.vue +++ b/vue-fastapi-frontend/src/views/dataAsset/assetDetail/index.vue @@ -81,7 +81,15 @@ - + + + @@ -201,22 +209,50 @@ import { getSearch, batch, deptTreeSelect } from "@/api/dataAsset/assetDetail"; const { proxy } = getCurrentInstance() const defaultProps = { children: 'children', - label: 'name', -} + label: 'label', +}; + + +import useUserStore from '@/store/modules/user'; // 注意路径是否正确 + +const userStore = useUserStore(); // 正确调用 +const dsSysList = userStore.dsSysList; // 访问属性 const currentNode = ref({}) const treeData = ref([]) const treeDataChildren = ref([]); +const getSrcSysName = (id) => { + if (id === null || id === undefined) return ''; + + const getName = (val) => { + const match = dsSysList.find(item => item.id == String(val).trim()); + return match ? match.name : val; + }; + + return getName(id); +}; +function addLabel(nodes) { + if (!nodes) return; + nodes.forEach(node => { + node.label = getSrcSysName(node.name); // 给每个节点加 label + if (node.children && node.children.length > 0) { + addLabel(node.children); // 递归处理子节点 + } + }); +} /** 查询部门下拉树结构 */ function getDeptTree() { deptTreeSelect().then(response => { - treeData.value = response.data; - if (response.data && response.data[0] && response.data[0].children) { - treeDataChildren.value = response.data[0].children + const data = response.data || []; + addLabel(data); // 先给所有节点加 label + treeData.value = data; + if (data[0] && data[0].children) { + treeDataChildren.value = data[0].children; } }); }; + /** 节点单击事件 */ function handleNodeClick(data) { queryParams.value.dataAstSrc = data.name; @@ -234,7 +270,7 @@ watch(filterText, val => { /** 通过条件过滤节点 */ const filterNode = (value, data) => { if (!value) return true; - return data.name.indexOf(value) !== -1; + return data.label.indexOf(value) !== -1; }; const columns = ref([