无人机管理后台前端(已迁走)
张含笑
2025-11-18 9b065363dcff37fddd179375c6f1b7e5ad64df58
feat:恢复选中效果
1 files modified
41 ■■■■ changed files
src/views/layerManagement/components/leftList.vue 41 ●●●● patch | view | raw | blame | history
src/views/layerManagement/components/leftList.vue
@@ -57,8 +57,8 @@
        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',
@@ -69,7 +69,7 @@
        <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
@@ -117,7 +117,6 @@
  dkbh: '',
  patchesName: '',
});
const matchedNodeIds = ref([]);
const loading = ref(false);
const treeData = ref([]);
const treeAllData = ref([]);
@@ -239,7 +238,7 @@
      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 = [];
@@ -326,35 +325,12 @@
}
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;
@@ -435,10 +411,7 @@
  display: flex;
  flex-direction: column;
}
.search-highlight {
  color: #409eff !important; // 蓝色高亮,可以根据需要修改
  font-weight: bold;
}
.searchBox {
  display: flex;
  margin-top: 10px;