支持删除  合并处理  点击合并后禁止键盘事件 排除继续监听事件重新组合数组
已修改2个文件
43 ■■■■■ 文件已修改
src/utils/components/init-map.vue 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/system/shootPoint/components/shootPointDialog.vue 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/components/init-map.vue
@@ -901,6 +901,7 @@
          grouped[index][type] = item.position;
        }
      })
      console.log(grouped)
      const result = Object.keys(grouped).map((key, idx) => {
        const group = grouped[key];
        const positionGround = group.groundPoiId.getValue(Cesium.JulianDate.now())
@@ -909,14 +910,14 @@
        const aerialPos = Cesium.Cartographic.fromCartesian(positionAerialPo);
        return {
          id: this.genId(),
          label: `地面点${idx}`,
          label: `地面点${key}`,
          longitude: Cesium.Math.toDegrees(groundPos.longitude),
          latitude: Cesium.Math.toDegrees(groundPos.latitude),
          height: groundPos.height,
          children: [
            {
              id: this.genId(),
              label: `空中点${idx}`,
              label: `空中点${key}`,
              longitude: Cesium.Math.toDegrees(aerialPos.longitude),
              latitude: Cesium.Math.toDegrees(aerialPos.latitude),
              height: aerialPos.height,
@@ -950,14 +951,14 @@
        const aerialPos = Cesium.Cartographic.fromCartesian(positionAerialPo);
        return {
          id: this.genId(),
          label: `地面点${idx}`,
          label: `地面点${key}`,
          longitude: Cesium.Math.toDegrees(groundPos.longitude),
          latitude: Cesium.Math.toDegrees(groundPos.latitude),
          height: groundPos.height,
          children: [
            {
              id: this.genId(),
              label: `空中点${idx}`,
              label: `空中点${key}`,
              longitude: Cesium.Math.toDegrees(aerialPos.longitude),
              latitude: Cesium.Math.toDegrees(aerialPos.latitude),
              height: aerialPos.height
@@ -966,6 +967,8 @@
        };
      });
      this.$emit('mergePoint',result,this.mergeNumber,viewerM)
      window.removeEventListener("keydown", this.onKeyDown);
      window.removeEventListener("keyup", this.onKeyUp);
    },
    genId() {
      return (Date.now().toString(16) + Math.random().toString(16).slice(2, 10)).slice(0, 16);
src/views/system/shootPoint/components/shootPointDialog.vue
@@ -55,6 +55,10 @@
                              <i 
                                class="el-icon-success" 
                              ></i>
                              <i
                                class="el-icon-delete"
                                @click.stop="deleteItem(wp)"
                              ></i>
                              <div class="waypoint-contnet">
                                <span class="waypoint-index">{{ wp.label +'----'  +wp.children[0].label }}</span>
                                <span v-for="(action, aIndex) in wp.children[0].actions" 
@@ -800,6 +804,7 @@
      console.log(this.treeData)
      console.log(this.waypoints)
      console.log(data)
      console.log(this.lastTableArr)
      const byLabel = this.addOrUpdate(this.lastTableArr, data, 'label', this)
      this.waypoints  = this.lastTableArr
      console.log(byLabel)
@@ -822,6 +827,33 @@
    },
    clickItem(value){
        this.$refs.initMap.editAction(value);  
    },
    extractNumberFromLabel(label){
      const match = label.match(/(\d+)/); // 获取标签中的数字
      return match ? match[0] : null;
    },
    deleteItem(item){
      this.treeData = this.treeData.filter(obj=>obj.id != item.id)
      this.lastTableArr = this.lastTableArr.filter(obj=>obj.id != item.id)
      const data1LabelNumber = this.extractNumberFromLabel(item.label);
      // 创建一个新的EntityCollection,只保留不匹配的实体
      const filteredEntities = window.viewerM.entities.values.filter(entity => {
        const entityIdNumber =  this.extractNumberFromLabel(entity.id); // 提取实体的id中的数字
        return entityIdNumber !== data1LabelNumber; // 如果数字不一致,保留该实体
      });
      // 清空原来的entities集合并重新添加过滤后的实体
      window.viewerM.entities.removeAll(); // 清空所有实体
      filteredEntities.forEach(entity => window.viewerM.entities.add(entity))
      console.log(item)
      console.log(this.treeData)
       console.log(this.lastTableArr)
      console.log(window.viewerM.entities.values)
      // console.log(window.viewerM.entities.values[0].id)
      // console.log(window.viewerM.entities.values[1].id)
      // console.log(window.viewerM.entities.values[2].id)
      // console.log(window.viewerM.entities.values[3].id)
    }
  }
}