无人机管理后台前端(已迁走)
张含笑
2025-11-07 f754a1f2f47ea24c9c74e54c011fb2e33aaa72c8
feat:编辑文件夹清除区域
2 files modified
22 ■■■■■ changed files
src/views/layerManagement/components/leftList.vue 8 ●●●● patch | view | raw | blame | history
src/views/layerManagement/index.vue 14 ●●●● patch | view | raw | blame | history
src/views/layerManagement/components/leftList.vue
@@ -170,9 +170,9 @@
    } else {
      // 全选:仅设置 level 3 节点的 id
      treeRef.value.setCheckedKeys(allFenceKeys);
      checkedKeys.value = allFenceKeys; // 同步更新 checkedKeys
      checkedNodes.value = allFenceNodes; // 存储 level 3 数据
      coverData.value = allFenceNodes; // 同步 coverData
      checkedKeys.value = allFenceKeys;
      checkedNodes.value = allFenceNodes;
      coverData.value = allFenceNodes;
    }
    emit('update:coverData', coverData.value);
  }
@@ -358,7 +358,7 @@
  left: 0;
  height: 95%;
  z-index: 99;
  width: 392px;
  width: 382px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.8);
  border-radius: 8px 8px 8px 8px;
src/views/layerManagement/index.vue
@@ -53,12 +53,11 @@
import { flyVisual } from '@/utils/cesium/mapUtil';
import rightEdit from '@/views/layerManagement/components/rightEdit.vue';
import leftList from '@/views/layerManagement/components/leftList.vue';
import nationalSpatialPlanning from '@/views/layerManagement/components/nationalSpatialPlanning.vue';
import { DrawPolygon } from '@/views/layerManagement/components/utils';
import * as Cesium from 'cesium';
import { PublicCesium } from '@/utils/cesium/publicCesium';
import _, { cloneDeep, throttle } from 'lodash';
import { ElButton } from 'element-plus';
import { provide } from 'vue';
import { useStore } from 'vuex';
const store = useStore();
@@ -157,6 +156,7 @@
};
// 编辑文件夹
const handleFolder = val => {
parentMethod()
  layerParams.value.editFolderData = val;
};
// 新增开启绘制
@@ -273,7 +273,6 @@
let publicCesiumInstance = null;
let viewer = null;
const viewInstance = shallowRef(null);
const homeViewer = shallowRef(null);
const drawPolygonExample = new DrawPolygon();
// 地图初始化
const initMap = () => {
@@ -284,10 +283,8 @@
    layerMode: 4,
    contour: false,
  });
  viewer = publicCesiumInstance.getViewer();
  viewInstance.value = publicCesiumInstance;
  const nanChangPosition = Cesium.Cartesian3.fromDegrees(
    115.892151, // 经度
    28.676493, // 纬度
@@ -328,22 +325,17 @@
  let polygonString = JSON.stringify(polygon);
  layerParams.value.polygonPosition = polygon.length > 0 ? polygonString : null;
  if (polygon.length >= 3) {
    //  确保多边形闭合:最后一个点与第一个点一致(避免计算偏差)
    //  确保多边形闭合:最后一个点与第一个点一致
    const firstPoint = polygon[0];
    const lastPoint = polygon[polygon.length - 1];
    const isClosed =
      _.round(firstPoint[0], 6) === _.round(lastPoint[0], 6) &&
      _.round(firstPoint[1], 6) === _.round(lastPoint[1], 6);
    // 若未闭合,手动添加闭合点
    const closedPolygon = isClosed ? polygon : [...polygon, firstPoint];
    //  转换为 turf 支持的 GeoJSON 格式(Polygon 类型需外层嵌套数组)
    const turfPolygon = turf.polygon([closedPolygon]);
    //  计算面积(turf.area() 返回平方米,保留2位小数)
    const area = _.round(turf.area(turfPolygon), 2);
    //  赋值给 layerParams,
    layerParams.value.fenceArea = area;
  } else {
    // 坐标点不足3个时,清空面积
    layerParams.value.fenceArea = 0;
  }
};