wangjuncheng
2025-07-08 f373e0c0797e1800bf066fdfbb748bb9242230f6
泥位计
已修改3个文件
67 ■■■■ 文件已修改
src/components/menu/flowRate_waterLevel.vue 48 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/monifangzhen/WaterDepthContent.vue 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/monifangzhen/WaterVelocityContent.vue 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/menu/flowRate_waterLevel.vue
@@ -53,7 +53,7 @@
import { useSimStore } from "@/store/simulation";
import { storeToRefs } from "pinia";
const simStore = useSimStore();
const { selectedScheme, currentInfo } = storeToRefs(simStore);
const { selectedScheme, currentInfo, selectNWJ } = storeToRefs(simStore); // 新增监听 selectNWJ
import { EventBus } from "@/eventBus";
const pickedPoints = ref([]);
@@ -61,7 +61,7 @@
const isPickingActive = ref(false);
const currentTime = ref(0);
let serviceInfo = ref(null);
const isCurrentInfoFromSelectNWJ = ref(false);
const props = defineProps({
    playingTime: {
        type: String,
@@ -70,6 +70,7 @@
});
const viewer = window.viewer;
serviceInfo = selectedScheme.value.serviceName;
function getPickPosition(windowPosition) {
    if (!viewer) return null;
@@ -85,10 +86,9 @@
        height: cartographic.height
    };
}
function addPointToViewer(point, index) {
    const displayTime = currentTime.value || "未设置时间";
    const schemeInfo = selectedScheme.value;
    serviceInfo = schemeInfo.serviceName;
    // 如果已有选中点,则先清除
    if (pickedPoints.value.length >= 1) {
@@ -139,7 +139,8 @@
    currentInfo.value = {
        longitude: point.longitude,
        latitude: point.latitude,
        serviceInfo: serviceInfo
        serviceInfo: serviceInfo,
        deviceName: null
    };
    // 请求数据并更新 label
    getFlowRateInfo(point.longitude, point.latitude, displayTime).then(result => {
@@ -169,7 +170,6 @@
        if (position) {
            const index = pickedPoints.value.length;
            addPointToViewer(position, index);
        }
    }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
}
@@ -181,6 +181,7 @@
    isPickingActive.value = true;
    ElMessage.success(`开始--流量流速--拾取坐标功能,请点击地图选择点位!选取完请及时关闭,避免影响其他功能!`);
}
function stopPicking() {
    if (handler.value) {
        handler.value.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK);
@@ -189,6 +190,7 @@
    }
    isPickingActive.value = false;
}
function togglePick() {
    if (isPickingActive.value) {
        stopPicking();
@@ -199,6 +201,7 @@
        isPickingActive.value = true;
    }
}
watch(
    () => props.playingTime,
    async (newVal, oldVal) => {
@@ -229,6 +232,7 @@
`.trim();
    }
}
function endCalculation() {
    pickedPoints.value.forEach(pointInfo => {
        if (pointInfo.labelEntity) viewer.entities.remove(pointInfo.labelEntity);
@@ -237,13 +241,13 @@
    pickedPoints.value = [];
    EventBus.emit("clear-water-depth");
    EventBus.emit("clear-water-velocity");
}
defineExpose({
    endCalculation,
    stopPicking
});
function getFlowRateInfo(lon, lat, time) {
    const params = {
        lon: lon,
@@ -252,7 +256,6 @@
        serviceName: serviceInfo
    };
    return getFlowRate(params).then(data => {
        // console.log('获取到的数据:', data);
        if (data && data.code === 200) {
            return {
                depth: data.data.depth.toFixed(2),
@@ -266,5 +269,34 @@
        return { depth: 'N/A', velocity: 'N/A' };
    });
}
// 👇 监听 simStore.selectNWJ,当其有值时执行清除操作
watch(() => selectNWJ.value, (newVal) => {
    if (newVal != null && newVal !== '') {
        // 👇 有值时自动停止拾取并清除实体
        if (isPickingActive.value) stopPicking();
        if (pickedPoints.value.length > 0) endCalculation();
        console.log(newVal,'asdasdasdads');
        const { longitude, latitude ,deviceName} = newVal;
        currentInfo.value = {
            longitude,
            latitude,
            serviceInfo: serviceInfo,
            deviceName
        };
        console.log(currentInfo.value, '这里进行数据的打印');
        isCurrentInfoFromSelectNWJ.value = true;
        // 👇 可选:调用一次分析函数来加载数据(根据你的业务需要决定是否启用)
        // getFlowRateInfo(longitude, latitude, currentTime.value).then(...)
    } else {
        // 👇 如果 selectNWJ 被清空,恢复手动选择能力
        isCurrentInfoFromSelectNWJ.value = false;
    }
},
    { immediate: true });
</script>
<style lang="less" scoped></style>
src/components/monifangzhen/WaterDepthContent.vue
@@ -7,7 +7,10 @@
    <div v-else>
      <div class="location-info">
        <h3>位置信息</h3>
        <p class="coordinates">
        <p v-if="deviceName" class="coordinates">
          {{ deviceName }}
        </p>
        <p v-if="!deviceName" class="coordinates">
          经度: <strong>{{ safeCurrentInfo.longitude.toFixed(3) }}&nbsp;&nbsp;&nbsp;&nbsp;</strong>
          纬度:<strong>{{ safeCurrentInfo.latitude.toFixed(3) }}</strong>
        </p>
@@ -38,7 +41,9 @@
const simStore = useSimStore();
const { currentInfo } = storeToRefs(simStore);
const deviceName = computed(() => {
  return currentInfo.value?.deviceName;
});
// 图表 DOM 引用
const chartDom = ref(null);
let myChart = null;
@@ -96,7 +101,6 @@
async function fetchDataAndUpdateChart(chart) {
  const info = currentInfo.value;
  if (!info || showSelectPrompt.value || !chartDom.value) return;
  const { longitude, latitude, serviceInfo } = info;
  const result = await getFlowRateInfo(longitude, latitude, serviceInfo);
src/components/monifangzhen/WaterVelocityContent.vue
@@ -7,7 +7,10 @@
    <div v-else>
      <div class="location-info">
        <h3>位置信息</h3>
        <p class="coordinates">
        <p v-if="deviceName" class="coordinates">
          {{ deviceName }}
        </p>
        <p v-if="!deviceName" class="coordinates">
          经度: <strong>{{ safeCurrentInfo.longitude.toFixed(3) }}&nbsp;&nbsp;&nbsp;&nbsp;</strong>
          纬度:<strong>{{ safeCurrentInfo.latitude.toFixed(3) }}</strong>
        </p>
@@ -38,7 +41,9 @@
const simStore = useSimStore();
const { currentInfo } = storeToRefs(simStore);
const deviceName = computed(() => {
  return currentInfo.value?.deviceName;
});
// 图表 DOM 引用
const chartDom = ref(null);
let myChart = null;