guonan
2025-05-19 a9f6123da84523d2343cb9f838cf258d28997608
Merge branch 'master' of http://103.135.160.14:9034/r/NslWeb
已添加1个文件
已修改8个文件
284 ■■■■■ 文件已修改
public/images/poi/雨量计1.png 补丁 | 查看 | 原始文档 | blame | 历史
src/components/menu/Device.vue 97 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/menu/Location.vue 84 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/tools/LayerTree.vue 74 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/tools/Legend_yhgl.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/tools/Legend_zhjc.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/constant/dict.js 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/store/simulation.js 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/utils/map.js 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
public/images/poi/ÓêÁ¿¼Æ1.png
src/components/menu/Device.vue
@@ -6,28 +6,12 @@
    <div class="left-content device-content">
      <div style="margin-left: 5px">
        <span style="color: white">重点沟:</span>
        <el-select
          @change="handleChange"
          v-model="selectValue"
          placeholder="Select"
          size="large"
          style="width: 240px"
        >
          <el-option
            v-for="item in options"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        <el-select @change="handleChange" v-model="selectValue" placeholder="Select" size="large" style="width: 240px">
          <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
        </el-select>
      </div>
      <el-tree
        :data="deviceTree"
        node-key="deviceId"
        :props="treeProps"
        @node-click="handleTreeNodeClick"
        class="device-tree"
      >
      <el-tree :data="deviceTree" node-key="deviceId" :props="treeProps" @node-click="handleTreeNodeClick"
        class="device-tree">
        <template #default="{ node, data }">
          <span v-if="!data.children" class="device-tree-item">
            <!-- <div class="device-item-icon"></div> -->
@@ -43,30 +27,77 @@
</template>
<script setup>
import { ref, computed, onMounted } from "vue";
import { ref, computed, onMounted, watch, onBeforeUnmount, } from "vue";
import { useRoute, onBeforeRouteUpdate } from 'vue-router';
import { createPoint, removeEntities } from "@/utils/map";
import { deviceDictList, getDictName } from "@/constant/dict.js";
import { getDeviceInfo } from "@/api/hpApi";
// å®šä¹‰ä¸€ä¸ªå“åº”式引用存储设备列表
const deviceListAll = ref([]);
// ç»„件挂载时获取设备信息,默认过滤“孙胡沟”
import { initeWaterPrimitiveView } from "@/utils/water"; //相机flyTo函数,后续options列表中有对应经纬度后弃用
import { useSimStore } from "@/store/simulation";
const simStore = useSimStore();
onMounted(() => {
  loadDeviceList("孙胡沟");
  initeWaterPrimitiveView()
});
onBeforeRouteUpdate((to, from, next) => {
  if (to.path !== '/zhjc') {
    handleCleanup();
  }
  next();
});
const route = useRoute();
onBeforeUnmount(() => {
  if (route.path !== '/zhjc') {
    handleCleanup();
  }
});
watch(() => simStore.DeviceShowSwitch, (newValue, oldValue) => {
  if (newValue) {
    initializeDevicePoints();
  } else {
    handleCleanup()
  }
});
const deviceListAll = ref([]);
const deviceEntities = ref([]);
const handleCleanup = () => {
  deviceListAll.value.forEach(item => {
    removeEntities(item.deviceId);
  });
}
const initializeDevicePoints = () => {
  const list = [];
  deviceListAll.value.forEach((item, index) => {
    // æ ¹æ®éœ€æ±‚可增删
    item.type = getDictName(deviceDictList, item.dictDeviceType);
    item.name = item.deviceName.split(selectValue.value)[1] || item.deviceName;
    item.id = item.deviceId;
    item.className = "device";
    item.showLabel = true;
    // æ‰“印每个设备的名称和设备类型
    // console.log(`设备名称: ${item.id}, è®¾å¤‡ç±»åž‹: ${item.name}`);
    createPoint(item);
  });
  deviceEntities.value = list;
};
// æ ¹æ®åŒºåŸŸåç§°åŠ è½½è®¾å¤‡åˆ—è¡¨
const loadDeviceList = async (areaName) => {
  try {
    const res = await getDeviceInfo(); // è°ƒæ•´getDeviceInfo以接受动态参数,如果需要的话
    deviceListAll.value = res.data.pageData.filter((item) =>
    handleCleanup()
    const res = await getDeviceInfo();
    const allDevices = res.data.pageData;
    const devicesInArea = allDevices.filter((item) =>
      item.deviceName?.includes(areaName)
    );
    deviceListAll.value = devicesInArea;
    deviceListAll.length = 0;
    initializeDevicePoints();
  } catch (error) {
    console.error("加载设备信息失败", error);
  }
};
// å¤„理区域变化事件
const handleChange = (item) => {
  if (!item) {
@@ -75,7 +106,7 @@
  }
  // æ ¹æ®æ–°åŒºåŸŸåé‡æ–°åŠ è½½è®¾å¤‡åˆ—è¡¨
  loadDeviceList(item);
  console.log(deviceListAll.value);
  // console.log(deviceListAll.value);
};
const selectValue = ref("孙胡沟");
@@ -115,12 +146,10 @@
  // å…ˆæŒ‰è®¾å¤‡ç±»åž‹åˆ†ç»„
  deviceListAll.value.forEach((device) => {
    const typeName = getDictName(deviceDictList, device.dictDeviceType);
    if (!typeName) {
      console.warn("未找到设备类型:", device);
      return;
    }
    if (!typeMap[typeName]) {
      typeMap[typeName] = [];
    }
@@ -222,12 +251,14 @@
:deep(.el-select__placeholder) {
  color: white;
}
:deep(.el-select-dropdown__item.hover),
:deep(.el-select-dropdown__item:hover) {
  color: white !important;
  background-color: rgb(38, 124, 124, 0.5);
}
:deep(.el-tree-node__content) {
  padding-left: 0px !important ;
  padding-left: 0px !important;
}
</style>
src/components/menu/Location.vue
@@ -7,19 +7,8 @@
    <div class="left-content district-content">
      <div style="margin-left: 5px">
        <span style="color: white">重点沟:</span>
        <el-select
          @change="handleChange"
          v-model="selectValue"
          placeholder="Select"
          size="large"
          style="width: 240px"
        >
          <el-option
            v-for="item in options"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        <el-select @change="handleChange" v-model="selectValue" placeholder="Select" size="large" style="width: 240px">
          <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
        </el-select>
      </div>
@@ -29,13 +18,7 @@
        <div v-if="loading" class="loading-overlay">
          <div class="spinner"></div>
        </div>
        <div
          v-else
          v-for="(item, key) in districtList"
          :key="key"
          class="district-item"
          @click="handleClick(item)"
        >
        <div v-else v-for="(item, key) in districtList" :key="key" class="district-item" @click="handleClick(item)">
          <div class="district-item-icon"></div>
          <div class="district-item-text">{{ item.hdName }}</div>
        </div>
@@ -45,12 +28,25 @@
</template>
<script setup>
import { ref, onMounted, watch } from "vue";
import { createPoint } from "@/utils/map";
import { ref, onMounted, watch, onBeforeUnmount } from "vue";
import { createPoint, removeEntities } from "@/utils/map";
import { useSimStore } from "@/store/simulation";
import { initeWaterPrimitiveView } from "@/utils/water"; //相机flyTo函数,后续options列表中有对应经纬度后弃用
import { useRoute, onBeforeRouteUpdate } from 'vue-router';
const simStore = useSimStore();
onBeforeRouteUpdate((to, from, next) => {
  if (to.path !== '/yhgl') {
    handleCleanup();
  }
  next();
});
const route = useRoute();
onBeforeUnmount(() => {
  if (route.path !== '/yhgl') {
    handleCleanup();
  }
});
const selectValue = ref("孙胡沟");
const options = ref([
@@ -91,9 +87,27 @@
    });
  }
}
const handleCleanup = async () => {
  await Promise.all(districtList.value.map(item => removeEntities(item.hdId)));
}
const initializeDevicePoints = async () => {
  await Promise.all(districtList.value.map(async (item, index) => {
    // æ ¹æ®éœ€æ±‚可增删
    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";
    await createPoint(item);
    // æ‰“印每个设备的名称和设备类型
    // console.log(`设备名称: ${item.id}, è®¾å¤‡ç±»åž‹: ${item.name}`);
  }));
};
// æ ¹æ®åŒºåŸŸåç§°è¿‡æ»¤æ•°æ®
const filterDataByArea = (areaName) => {
const filterDataByArea = async (areaName) => {
  handleCleanup();
  if (!areaName || !simStore.DangerPoint || simStore.DangerPoint.length === 0) {
    districtList.value = [];
    return;
@@ -102,6 +116,7 @@
  districtList.value = simStore.DangerPoint.filter((item) =>
    item.position?.includes(areaName)
  );
  await initializeDevicePoints();
};
// å¤„理区域变化事件
@@ -111,10 +126,15 @@
    ElMessage.warning("请选择一个区域");
    return;
  }
  filterDataByArea(areaName);
};
watch(() => simStore.DangerShowSwitch, (newValue, oldValue) => {
  if (newValue) {
    initializeDevicePoints();
  } else {
    handleCleanup()
  }
});
// ç›‘听 simStore.DangerPoint å˜åŒ–
watch(
  () => simStore.DangerPoint,
@@ -123,6 +143,7 @@
      filterDataByArea(selectValue.value);
      loading.value = false; // æ•°æ®åŠ è½½å®Œæˆ
    } else {
      handleCleanup();
      districtList.value = [];
      loading.value = true; // æ•°æ®æœªå‡†å¤‡å°±ç»ª
    }
@@ -131,6 +152,8 @@
);
onMounted(() => {
  handleCleanup()
  initeWaterPrimitiveView()
  // é»˜è®¤å…ˆæ£€æŸ¥ä¸€éæ•°æ®
  if (simStore.DangerPoint && simStore.DangerPoint.length > 0) {
    filterDataByArea("孙胡沟");
@@ -148,7 +171,8 @@
  left: 0px;
  right: 0px;
  bottom: 10px;
  background-color: rgba(236, 233, 233, 0.5); /* åŠé€æ˜Žé®ç½© */
  background-color: rgba(236, 233, 233, 0.5);
  /* åŠé€æ˜Žé®ç½© */
  display: flex;
  align-items: center;
  justify-content: center;
@@ -169,6 +193,7 @@
    transform: rotate(360deg);
  }
}
.district {
  position: absolute;
  width: 345px;
@@ -183,10 +208,12 @@
  cursor: pointer;
  margin-top: 10px;
}
.district-content {
  padding: 10px;
  box-sizing: border-box;
}
.district-item-icon {
  background: url("@/assets/img/menu/locationicon.png") no-repeat;
  background-position: 5px 5px;
@@ -213,6 +240,7 @@
/deep/ .el-select__placeholder {
  color: white;
}
/deep/ .el-select-dropdown__item.hover,
.el-select-dropdown__item:hover {
  color: white !important;
src/components/tools/LayerTree.vue
@@ -184,6 +184,30 @@
    }
    return;
  }
  if (label === "综合监测设备信息") {
    simStore.DeviceShowSwitch = checked;
    if (checked) {
    if (!treeMap.get("综合监测设备信息")) {
    } else {
      toggleLayerVisible("综合监测设备信息", true);
    }
  } else {
    toggleLayerVisible("综合监测设备信息", false);
  }
  return;
}
if (label === "孙胡沟隐患点") {
    simStore.DangerShowSwitch = checked;
    if (checked) {
    if (!treeMap.get("孙胡沟隐患点")) {
    } else {
      toggleLayerVisible("孙胡沟隐患点", true);
    }
  } else {
    toggleLayerVisible("孙胡沟隐患点", false);
  }
  return;
}
  // å…¶ä»–图层的处理逻辑
  const list = treeMap.get(label);
@@ -219,7 +243,7 @@
  } else if (entityList && typeof entityList.show !== "undefined") {
    entityList.show = checked;
  } else {
    console.error(`无法设置图层 ${name} çš„可见性`);
    // console.error(`无法设置图层 ${name} çš„可见性`);
  }
}
@@ -233,7 +257,7 @@
    item.deviceName?.includes("孙胡沟")
  );
};
// é»˜è®¤åŠ è½½éƒ¨åˆ†å·²æ›¿æ¢è‡³Device.vue中,逻辑修改为根据当前选择地形切换设备点显示
async function initDevicePoint() {
  let list = [];
  await getDevicetList();
@@ -252,31 +276,31 @@
}
// é𐿂£ç‚¹åˆ—表
watchEffect(() => {
  const dangerPoints = simStore.DangerPoint.filter((item) =>
    item.position?.includes("孙胡沟")
  );
// watchEffect(() => {
//   const dangerPoints = simStore.DangerPoint.filter((item) =>
//     item.position?.includes("孙胡沟")
//   );
  if (dangerPoints && dangerPoints.length > 0) {
    const list = [];
//   if (dangerPoints && dangerPoints.length > 0) {
//     const 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);
    });
//     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);
  }
});
//     treeMap.set("孙胡沟隐患点", list);
//   }
// });
let divPointList = [];
/**
@@ -325,7 +349,7 @@
 * åˆå§‹åŒ–所有数据
 */
function getData() {
  initDevicePoint();
  // initDevicePoint();
  // initDistrictPoint();
  initDuanmianPoint();
  addTetrahedron();
src/components/tools/Legend_yhgl.vue
@@ -26,7 +26,7 @@
};
onMounted(() => {
  console.log("这里是图例集合!");
  // console.log("这里是图例集合!");
});
</script>
src/components/tools/Legend_zhjc.vue
@@ -31,7 +31,7 @@
};
onMounted(() => {
  console.log("这里是图例集合!");
  // console.log("这里是图例集合!");
});
</script>
src/constant/dict.js
@@ -8,6 +8,10 @@
        value: "1874719366287368194",
    },
    {
        label: "雨量计1",
        value: "1437295810",
    },
    {
        label: "摄像头",
        value: "1437295825",
    },
src/store/simulation.js
@@ -5,6 +5,8 @@
export const useSimStore = defineStore('simulation', () => {
    // é𐿂£ç‚¹åˆ—表
    const DeviceShowSwitch = ref(true)
    const DangerShowSwitch = ref(true)
    const DangerPoint = ref([])
    const navigationShow = ref(true)
    const leftShow = ref(false)
@@ -147,6 +149,8 @@
        backToHome,
        rainFalls,
        DangerPoint,
        DeviceShowSwitch,
        DangerShowSwitch,
        // æ–¹æ¡ˆç›¸å…³æ–¹æ³•
        setSchemCard,
src/utils/map.js
@@ -156,12 +156,19 @@
  return entity;
}
export function removeEntities() {
  entities.forEach(entity => {
    // viewer.entities.remove(entity)
    entity.show = false;
// export function removeEntities() {
//   entities.forEach(entity => {
//     viewer.entities.remove(entity)
//     entity.show = false;
//   });
//   // entities = []
// }
export function removeEntities(id) {
  entities.forEach((entity, index) => {
    if (entity.id === id) {
      viewer.entities.remove(entity);
    }
  });
  // entities = []
}
function removeHandler() {
  if (interativeHandler != null && Cesium.defined(interativeHandler)) {