无人机管理后台前端(已迁走)
罗广辉
2025-11-21 b5e2aaaba43d7456ab6ffedefa16c97a22cbe479
src/views/layerManagement/index.vue
@@ -23,6 +23,7 @@
          @update:editFolder="handleFolder"
          :activeName="activeName"
          @newFencesMethods="newFencesMethods"
          :reset-check="resetCheck"
        ></leftList>
        <rightEdit
          v-if="layerParams.addNest || layerParams.editNest"
@@ -97,19 +98,23 @@
  editFolderData: null,
  editingIsProhibited: false, //禁止编辑
  isDetailShow: false,
  isSingleLocating:false
  isSingleLocating:false , //是否是单个定位
  currentLocationFolderId:null,
});
const resetCheck = ref(false);
const handleClick = tab => {
  const clickedTab = tabData.value.find(item => item.type === tab.paneName);
  activeType.value = clickedTab.type;
  activeName.value = clickedTab.name;
  getdataFolderApi();
  parentMethod();
  handleCoverDataUpdate([])
  layerParams.value.addNest = false
    layerParams.value.editNest = false
     layerParams.value.addFolder = false
    layerParams.value.editFolder = false
    resetCheck.value = !resetCheck.value;
};
const refreshMethod = () => {
  getdataFolderApi();
@@ -170,8 +175,7 @@
// 点击显示区域
const handleCoverDataUpdate = data => {
  selectDataList.value = data;
  if (selectDataList.value.length > 0) {
  if (selectDataList.value?.length > 0) {
    loadDataToMap(selectDataList.value);
  } else {
    viewer.entities.removeAll();
@@ -218,7 +222,7 @@
        : item.category_id === 3 
          ? colorMap.border3 
          : Cesium.Color.YELLOW;
    viewer.entities.add({
      viewer.entities.add({
      id: `polygon_${item.id}`,
      customType: 'fence_polygon',
      customInfo: item,
@@ -241,9 +245,7 @@
      },
      zIndex: 99, 
    });
  });
  });
 if (!layerParams.value.isSingleLocating) {
    focusOnAllFeatures(); 
  }
@@ -251,16 +253,44 @@
};
const focusOnAllFeatures = () => {
  if (tbJwdList.length === 0 || !viewer) return;
  // 判断是否有指定定位的文件夹
  if (layerParams.value.currentLocationFolderId) {
    // 筛选当前文件夹下的所有子节点坐标
    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; // 仅聚焦当前文件夹,结束方法
    }
  }
  // 无指定文件夹时,聚焦所有选中数据
  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
  });
};
// 区域点击显示详细信息
@@ -348,7 +378,7 @@
      let cartographic = Cesium.Cartographic.fromCartesian(item);
      let lng = Cesium.Math.toDegrees(cartographic.longitude); // 经度
      let lat = Cesium.Math.toDegrees(cartographic.latitude); // 纬度
      let height = Cesium.Math.toDegrees(cartographic.height); //高度
      let height = Cesium.Math.toDegrees(cartographic.height); //高度
      return {
        lng: _.round(lng, 6),
        lat: _.round(lat, 6),
@@ -409,14 +439,6 @@
  }
};
provide('layerParams', layerParams);
// onMounted(() => {
//   initMap();
//   cesiumContextMenu();
//   getdataFolderApi();
//   EventBus.on('deleteMapEntityById', deleteMapEntityById);
//   EventBus.on('deleteMapEntitiesByFolderId', deleteMapEntitiesByFolderId);
// });
onMounted(() => {
  initMap();
  cesiumContextMenu();
@@ -431,22 +453,23 @@
//定位到指定节点
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();