| | |
| | | node-key="id" |
| | | default-expand-all |
| | | :expand-on-click-node="false" |
| | | :check-on-click-node="false" |
| | | |
| | | :check-on-click-node="false" |
| | | :filter-node-method="filterNode" |
| | | @check="handleCheck" |
| | | :props="{ |
| | | label: 'name', |
| | |
| | | <template #default="{ node }"> |
| | | <div class="tree-node"> |
| | | <!-- 节点名称 --> |
| | | <span class="nodeName" :class="{ 'search-highlight': isNodeMatched(node.data.id) }">{{ node.label }}</span> |
| | | <span class="nodeName">{{ node.label }}</span> |
| | | <!-- 操作按钮组 --> |
| | | <div class="tree-node-actions"> |
| | | <el-button |
| | |
| | | dkbh: '', |
| | | patchesName: '', |
| | | }); |
| | | const matchedNodeIds = ref([]); |
| | | const loading = ref(false); |
| | | const treeData = ref([]); |
| | | const treeAllData = ref([]); |
| | |
| | | layerParams.value.fileType = 1; |
| | | } else if (props.activeName === '自定义禁飞区') { |
| | | layerParams.value.fileType = 2; |
| | | } |
| | | } |
| | | emit('update:editFolder', node.data); |
| | | } else if (node.data.level === 3) { |
| | | checkedKeys.value = []; |
| | |
| | | } |
| | | |
| | | function search() { |
| | | const keyword = formData.value.dkbh.trim(); |
| | | matchedNodeIds.value = []; |
| | | |
| | | if (!keyword) return; |
| | | |
| | | // 递归查找匹配的节点 |
| | | const findMatches = (nodes) => { |
| | | nodes.forEach(node => { |
| | | if (node.name && node.name.includes(keyword)) { |
| | | matchedNodeIds.value.push(node.id); |
| | | } |
| | | if (node.children && node.children.length) { |
| | | findMatches(node.children); |
| | | } |
| | | }); |
| | | }; |
| | | |
| | | findMatches(treeData.value); |
| | | treeRef.value?.filter(formData.value.dkbh); |
| | | } |
| | | // 重置搜索 |
| | | function reset() { |
| | | formData.value.dkbh = ''; |
| | | matchedNodeIds.value = []; |
| | | treeRef.value?.filter(''); |
| | | } |
| | | |
| | | // 判断节点是否匹配搜索关键词 |
| | | const isNodeMatched = (nodeId) => { |
| | | return matchedNodeIds.value.includes(nodeId); |
| | | }; |
| | | function filterNode(value, data) { |
| | | if (props.activeName === '国土空间规划') { |
| | | if (!value) return data.level === 2 || data.level === 1; |
| | |
| | | display: flex; |
| | | flex-direction: column; |
| | | } |
| | | .search-highlight { |
| | | color: #409eff !important; // 蓝色高亮,可以根据需要修改 |
| | | font-weight: bold; |
| | | } |
| | | |
| | | .searchBox { |
| | | display: flex; |
| | | margin-top: 10px; |