wangjuncheng
2025-05-19 e98dee8d702092a88610c3e3ae08bbf4a9c4d494
src/components/tools/LayerTree.vue
@@ -13,18 +13,26 @@
</template>
<script setup>
import { ref, onMounted, watch, nextTick, onUnmounted } from "vue";
import {
  ref,
  onMounted,
  watch,
  nextTick,
  onUnmounted,
  computed,
  watchEffect,
} from "vue";
import { createPoint, removeEntities, addTileset } from "@/utils/map";
import { deviceDictList, getDictName } from "@/constant/dict.js";
import { useRoute } from "vue-router";
import { loadAreaPolygon, clearAreaPolygon } from "@/utils/area";
import { checkedKeys } from "@/store/index";
import {
  getDuanMainData,
  getDevicetListData,
  getDistrictListData,
} from "@/api/index.js";
import { init } from "echarts";
import { getDuanMainData, getDistrictListData } from "@/api/index.js";
import { getDeviceInfo, getDangerPoint } from "@/api/hpApi";
import { useSimStore } from "@/store/simulation";
const simStore = useSimStore();
const route = useRoute();
@@ -34,7 +42,7 @@
    label: "三维服务",
    children: [
      { label: "模型数据" },
      { label: "地形数据" },
      { label: "地形数据" },
      { label: "影像数据" },
    ],
  },
@@ -85,7 +93,6 @@
//   // });
//   // treeMap.set("影像数据", ImageryLayer);
// }
// 地形数据
let TerrainLayer = null;
@@ -177,6 +184,18 @@
    }
    return;
  }
  if (label === "综合监测设备信息") {
    simStore.DeviceShowSwitch = checked;
    if (checked) {
    if (!treeMap.get("综合监测设备信息")) {
    } else {
      toggleLayerVisible("综合监测设备信息", true);
    }
  } else {
    toggleLayerVisible("综合监测设备信息", false);
  }
  return;
}
  // 其他图层的处理逻辑
  const list = treeMap.get(label);
@@ -216,24 +235,23 @@
  }
}
// 设备列表
// 监测设备列表
const devicetList = ref([]);
/**
 * 获取设备列表并初始化设备点
 */
// 监测设备列表
const getDevicetList = async () => {
  await getDevicetListData().then((res) => {
    devicetList.value = res.data;
  });
  const res = await getDeviceInfo(); // 调整getDeviceInfo以接受动态参数,如果需要的话
  devicetList.value = res.data.pageData.filter((item) =>
    item.deviceName?.includes("孙胡沟")
  );
};
// 默认加载部分已替换至Device.vue中,逻辑修改为根据当前选择地形切换设备点显示
async function initDevicePoint() {
  let list = [];
  await getDevicetList();
  devicetList.value.forEach((item) => {
    item.type = getDictName(deviceDictList, item.dictDeviceType);
    item.name = item.type;
    item.name = item.deviceName.split("孙胡沟")[1];
    item.id = item.deviceId;
    item.className = "device";
    item.showLabel = true;
@@ -245,34 +263,34 @@
  treeMap.set("综合监测设备信息", list);
}
// 区域列表
const districtList = ref([]);
// 隐患点列表
watchEffect(() => {
  const dangerPoints = simStore.DangerPoint.filter((item) =>
    item.position?.includes("孙胡沟")
  );
/**
 * 获取区域列表并初始化区域点
 */
const getDistrictList = async () => {
  await getDistrictListData().then((res) => {
    districtList.value = res.data;
  });
};
  if (dangerPoints && dangerPoints.length > 0) {
    const list = [];
async function initDistrictPoint() {
  let list = [];
  await getDistrictList();
  districtList.value.forEach((item) => {
    item.showBillboard = true;
    item.className = "district";
    // item.type = "泥石流";        //数据icon设置
    const entity = createPoint(item);
    entity.show = false;
    list.push(entity);
  });
  treeMap.set("孙胡沟隐患点", list);
}
    dangerPoints.forEach((item) => {
      // console.log(item, "item");
      item.id = item.hdId;
      item.name = item.hdName;
      item.latitude = item.lat;
      item.longitude = item.lon;
      item.showBillboard = true;
      item.type = item.disasterType;
      item.className = "district";
      const entity = createPoint(item);
      entity.show = false;
      list.push(entity);
    });
    treeMap.set("孙胡沟隐患点", list);
  }
});
let divPointList = [];
/**
 * 初始化断面点
 */
@@ -319,8 +337,8 @@
 * 初始化所有数据
 */
function getData() {
  initDevicePoint();
  initDistrictPoint();
  // initDevicePoint();
  // initDistrictPoint();
  initDuanmianPoint();
  addTetrahedron();
}
@@ -384,6 +402,7 @@
</script>
<style lang="less" scoped>
@import url("../../assets/css/infobox.css");
.layer-tree {
  background: url("@/assets/img/tools/plotting_new.png");
  width: 200px;
@@ -392,6 +411,6 @@
  overflow: hidden;
}
/deep/ .el-tree {
    overflow: hidden !important;
  overflow: hidden !important;
}
</style>