| | |
| | | <el-select |
| | | @change="handleChange1" |
| | | v-model="selectValue1" |
| | | placeholder="Select" |
| | | placeholder="请选择行政区" |
| | | size="mini" |
| | | style="width: 240px" |
| | | > |
| | |
| | | <el-select |
| | | @change="handleChange" |
| | | v-model="selectValue" |
| | | placeholder="Select" |
| | | placeholder="请选择重点沟" |
| | | size="mini" |
| | | style="width: 240px" |
| | | > |
| | |
| | | <el-tree |
| | | v-show="!isLoading" |
| | | :data="deviceTree" |
| | | default-expand-all |
| | | node-key="deviceId" |
| | | :props="treeProps" |
| | | @node-click="handleTreeNodeClick" |
| | |
| | | import { useRoute, onBeforeRouteUpdate } from "vue-router"; |
| | | import { createPoint, removeEntities, clearAllPoints } from "@/utils/map"; |
| | | import { deviceDictList, getDictName } from "@/constant/dict.js"; |
| | | import { getDeviceInfoShg, getDeviceInfo } from "@/api/hpApi"; |
| | | import { initeWaterPrimitiveView } from "@/utils/water"; //相机flyTo函数,后续options列表中有对应经纬度后弃用 |
| | | import { useSimStore } from "@/store/simulation"; |
| | | import { Loading } from "@element-plus/icons-vue"; |
| | | import { getDeviceInfoByPage } from "@/api/hpApi"; |
| | | |
| | | const simStore = useSimStore(); |
| | | |
| | |
| | | } |
| | | }); |
| | | |
| | | // onBeforeRouteUpdate((to, from, next) => { |
| | | // if (to.path !== "/zhjc") { |
| | | // handleCleanup(); |
| | | // } |
| | | // next(); |
| | | // }); |
| | | const route = useRoute(); |
| | | |
| | | onBeforeUnmount(() => { |
| | |
| | | } |
| | | }); |
| | | |
| | | // watch( |
| | | // () => simStore.DeviceShowSwitch, |
| | | // (newValue, oldValue) => { |
| | | // if (newValue) { |
| | | // initializeDevicePoints(); |
| | | // } else { |
| | | // clearAllPoints(); |
| | | // } |
| | | // } |
| | | // ); |
| | | const selectValue1 = ref(""); |
| | | |
| | | const BJoptions = ref([ |
| | | { label: "密云区", value: "110118000000" }, |
| | | { label: "房山区", value: "110111000000" }, |
| | | { label: "门头沟区", value: "110109000000" }, |
| | | { label: "延庆区", value: "110119000000" }, |
| | | { label: "怀柔区", value: "110116000000" }, |
| | | { label: "昌平区", value: "110114000000" }, |
| | | { label: "平谷区", value: "110117000000" }, |
| | | { label: "海淀区", value: "110108000000" }, |
| | | { label: "石景山区", value: "110107000000" }, |
| | | { label: "丰台区", value: "110106000000" }, |
| | | ]); |
| | | |
| | | const selectValue = ref("孙胡沟"); |
| | | |
| | | const options = ref([ |
| | | { value: "孙胡沟", label: "孙胡沟" }, |
| | | { value: "鱼水洞后沟", label: "鱼水洞后沟" }, |
| | | { value: "于家西沟", label: "于家西沟" }, |
| | | { value: "北河沟", label: "北河沟" }, |
| | | { value: "龙泉峪村", label: "龙泉峪村" }, |
| | | ]); |
| | | |
| | | const deviceListAll = ref([]); |
| | | |
| | | const initializeDevicePoints = () => { |
| | | const list = []; |
| | | // val.forEach((item, index) => { |
| | | deviceListAll.value.forEach((item, index) => { |
| | | // 根据需求可增删 |
| | | item.type = getDictName(deviceDictList, item.dictDeviceType); |
| | |
| | | // console.log(`设备名称: ${item.id}, 设备类型: ${item.name}`); |
| | | createPoint(item); |
| | | }); |
| | | }; |
| | | |
| | | const DevicePoints = async (item) => { |
| | | // 根据需求可增删 |
| | | item.type = getDictName(deviceDictList, item.dictDeviceType); |
| | | item.name = item.deviceName |
| | | // 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); |
| | | }; |
| | | |
| | | // 根据区域名称加载设备列表 |
| | |
| | | ElMessage("请选择一个区域"); |
| | | return; |
| | | } |
| | | selectValue1.value = ""; |
| | | selectValue.value = item; |
| | | // 根据新区域名重新加载设备列表 |
| | | loadDeviceList(item); |
| | | initializeDevicePoints(); |
| | | |
| | | // console.log(deviceListAll.value); |
| | | }; |
| | | |
| | | const selectValue1 = ref("北京市"); |
| | | // 处理区域变化事件 |
| | | const handleChange1 = async (item) => { |
| | | if (!item) { |
| | | ElMessage("请选择一个区域"); |
| | | return; |
| | | } |
| | | selectValue1.value = item; |
| | | selectValue.value = ""; |
| | | deviceListAll.value = []; |
| | | let pageNum = 1; |
| | | let hasMore = true; |
| | | |
| | | const BJoptions = ref([]); |
| | | try { |
| | | while (hasMore) { |
| | | const res = await getDeviceInfoByPage(item, pageNum); |
| | | |
| | | const selectValue = ref("孙胡沟"); |
| | | // 将新数据追加到列表中 |
| | | deviceListAll.value = [...deviceListAll.value, ...res.data.pageData]; |
| | | |
| | | const options = ref([ |
| | | { value: "孙胡沟", label: "孙胡沟" }, |
| | | { value: "鱼水洞后沟", label: "鱼水洞后沟" }, |
| | | { value: "于家西沟", label: "于家西沟" }, |
| | | { value: "北河沟", label: "北河沟" }, |
| | | { value: "龙泉峪村", label: "龙泉峪村" }, |
| | | ]); |
| | | // 判断是否还有下一页 |
| | | if (pageNum < res.data.pageCount) { |
| | | pageNum++; |
| | | await new Promise((resolve) => setTimeout(resolve, 300)); |
| | | } else { |
| | | hasMore = false; |
| | | } |
| | | } |
| | | } catch (err) { |
| | | console.error("获取监测设备失败", err); |
| | | deviceListAll.value = []; // 可选:清空或保留已加载部分 |
| | | } finally { |
| | | // 暂时先关闭加载状态,因为此处为分页请求数据,然后一点一点的渲染,最终会加载完成 |
| | | // 如果开启加载状态,最后还是会等所有数据都请求回来才会渲染 |
| | | // loading.value = false; // 关闭加载状态 |
| | | } |
| | | }; |
| | | |
| | | const treeProps = { |
| | | label: "deviceName", |
| | |
| | | }); |
| | | |
| | | function handleTreeNodeClick(data) { |
| | | initializeDevicePoints(); |
| | | if (selectValue.value) { |
| | | // 此处调用是因为GisView页面会在点击下一乡镇之前把上一个选择的区域的隐患点清除掉(如果刚好选择了孙胡沟,那么下一个点击将会清空孙胡沟的隐患点) |
| | | initializeDevicePoints(); |
| | | } else { |
| | | // 行政区划的点位太多了,只能选中哪个渲染哪个 |
| | | DevicePoints(data); |
| | | } |
| | | // 只有设备节点才处理点击事件 |
| | | if (!data.children) { |
| | | const entity = viewer.entities.getById(data.deviceId); |