无人机管理后台前端(已迁走)
张含笑
2025-11-14 b0827f4c098e9507ce1d5dc490111421ebdea29a
feat:11
2 files modified
120 ■■■■ changed files
src/views/layerManagement/components/leftList.vue 29 ●●●●● patch | view | raw | blame | history
src/views/layerManagement/index.vue 91 ●●●● patch | view | raw | blame | history
src/views/layerManagement/components/leftList.vue
@@ -188,37 +188,44 @@
};
// 定位按钮事件
const handleLocation = node => {
 if (node.data.level === 2) {
    layerParams.value.isSingleLocating = false;
  if (node.data.level === 2) {
    layerParams.value.isSingleLocating = false;
    // 新增:标记当前定位的文件夹ID
    layerParams.value.currentLocationFolderId = node.data.id;
  } else if (node.data.level === 3) {
    layerParams.value.isSingleLocating = true;
    layerParams.value.isSingleLocating = true;
    // 清空文件夹定位标识
    layerParams.value.currentLocationFolderId = null;
  }
  const currentCheckedKeys = [...checkedKeys.value];
  const currentCheckedNodes = [...checkedNodes.value];
  EventBus.emit('focusOnNode', node.data);
  if (node.data.level === 2) {
    const folderChildren = node.data.children || [];
    const childrenIds = folderChildren.map(child => child.id);
    // 合并已选中的节点和当前文件夹的子节点
    const newCheckedKeys = [...new Set([...currentCheckedKeys, ...childrenIds])];
    const newCheckedNodes = [...currentCheckedNodes, ...folderChildren];
    const newChildrenIds = childrenIds.filter(id => !currentCheckedKeys.includes(id));
    const newChildrenNodes = folderChildren.filter(child => newChildrenIds.includes(child.id));
    const newCheckedKeys = [...new Set([...currentCheckedKeys, ...newChildrenIds])];
    const newCheckedNodes = [...currentCheckedNodes, ...newChildrenNodes];
    treeRef.value.setCheckedKeys(newCheckedKeys);
    checkedKeys.value = newCheckedKeys;
    checkedNodes.value = newCheckedNodes;
    coverData.value = newCheckedNodes;
  }
  // 如果是单个节点(level 3),仅添加到选中列表(如果未选中)
  else if (!currentCheckedKeys.includes(node.data.id)) {
  layerParams.value.isSingleLocating = true
    emit('update:coverData', coverData.value);
  } else if (!currentCheckedKeys.includes(node.data.id)) {
    layerParams.value.isSingleLocating = true;
    currentCheckedKeys.push(node.data.id);
    currentCheckedNodes.push(node.data);
    treeRef.value.setCheckedKeys(currentCheckedKeys);
    checkedKeys.value = currentCheckedKeys;
    checkedNodes.value = currentCheckedNodes;
    coverData.value = currentCheckedNodes;
    emit('update:coverData', coverData.value);
  }
  emit('update:coverData', coverData.value);
};
// 编辑按钮事件
const handleEdit = node => {
src/views/layerManagement/index.vue
@@ -97,7 +97,8 @@
  editFolderData: null,
  editingIsProhibited: false, //禁止编辑
  isDetailShow: false,
  isSingleLocating:false
  isSingleLocating:false ,
  currentLocationFolderId:null,
});
const handleClick = tab => {
@@ -169,6 +170,8 @@
};
// 点击显示区域
const handleCoverDataUpdate = data => {
console.log('daa',data);
  selectDataList.value = data;
  if (selectDataList.value.length > 0) {
  
@@ -243,6 +246,7 @@
    });
  });
  console.log('layerParams.value.isSingleLocating',layerParams.value.isSingleLocating);
  
 if (!layerParams.value.isSingleLocating) {
    focusOnAllFeatures(); 
@@ -251,16 +255,46 @@
};
const focusOnAllFeatures = () => {
  if (tbJwdList.length === 0 || !viewer) return;
  // 判断是否有指定定位的文件夹
  if (layerParams.value.currentLocationFolderId) {
  console.log('11111111');
    // 筛选当前文件夹下的所有子节点坐标
    const targetFolderPositions = selectDataList.value
      .filter(item => item.folder_id === layerParams.value.currentLocationFolderId)
      .flatMap(item => {
        const positions = parseGeoDataToPositions(item.geo_data, item.altitude);
        return positions.length >= 3 ? positions : [];
      });
    if (targetFolderPositions.length > 0) {
      const positionsData = targetFolderPositions.map(pos => [
        pos.lng,
        pos.lat,
        pos.height || 0
      ]);
      flyVisual({
        positionsData,
        viewer,
        multiple: activeName.value === '国土空间规划' ? 13 : 10,
        pitch: -90
      });
      return; // 仅聚焦当前文件夹,结束方法
    }
  }
 console.log('333333');
  // 无指定文件夹时,聚焦所有选中数据(保持原有逻辑)
  const positionsData = tbJwdList.map(pos => [
    pos.lng,
    pos.lat,
    pos.height || 0
    pos.height || 0
  ]);
  flyVisual({
    positionsData,
    viewer,
      multiple:activeName.value == '国土空间规划' ? 13 :4, // 缩放倍数
    pitch: -90
    multiple: activeName.value === '国土空间规划' ? 13 : 4,
    pitch: -90
  });
};
// 区域点击显示详细信息
@@ -409,14 +443,6 @@
  }
};
provide('layerParams', layerParams);
// onMounted(() => {
//   initMap();
//   cesiumContextMenu();
//   getdataFolderApi();
//   EventBus.on('deleteMapEntityById', deleteMapEntityById);
//   EventBus.on('deleteMapEntitiesByFolderId', deleteMapEntitiesByFolderId);
// });
onMounted(() => {
  initMap();
  cesiumContextMenu();
@@ -430,23 +456,42 @@
});
//定位到指定节点
const focusOnNode = (nodeData) => {
// const focusOnNode = (nodeData) => {
//   if (!viewer || !nodeData?.geo_data) return;
//   // 解析节点坐标
//   const positions = parseGeoDataToPositions(nodeData.geo_data, nodeData.altitude);
// if (positions.length < 3) {
//     return;
//   }
//   flyVisual({
//     positionsData: positions.map(pos => [pos.lng, pos.lat, pos.height || 0]),
//     viewer,
//       multiple:activeName.value == '国土空间规划' ? 13 :7, // 缩放倍数
//     pitch: -90
//   });
// };
// 父组件中修改 focusOnNode 方法
const focusOnNode = (nodeData) => {
  if (!viewer || !nodeData?.geo_data) return;
  // 解析节点坐标
  const positions = parseGeoDataToPositions(nodeData.geo_data, nodeData.altitude);
if (positions.length < 3) {
    return;
  }
  flyVisual({
    positionsData: positions.map(pos => [pos.lng, pos.lat, pos.height || 0]),
    viewer,
      multiple:activeName.value == '国土空间规划' ? 13 :7, // 缩放倍数
    pitch: -90
  });
  if (positions.length < 3) return;
  // level 2 节点走全量聚焦,level 3 节点走单个聚焦
  if (nodeData.level === 2) {
    focusOnAllFeatures();
  } else {
    flyVisual({
      positionsData: positions.map(pos => [pos.lng, pos.lat, pos.height || 0]),
      viewer,
      multiple: activeName.value === '国土空间规划' ? 13 : 7, // 缩放倍数
      pitch: -90
    });
  }
};
onBeforeUnmount(() => {
  destroyMap();