wangjuncheng
2025-05-16 b1398528bd9f5245f580285681cca6abc192c651
src/components/tools/DebuffDetail.vue
@@ -13,6 +13,12 @@
</template>
<script>
// 状态管理器
import { useSimStore } from "@/store/simulation";
import { storeToRefs } from "pinia";
const simStore = useSimStore();
const { selectedScheme } = storeToRefs(simStore);
   export default {
      name: "detail",
      components: {},
@@ -39,10 +45,6 @@
                  value: "1.86 m",
               },
               {
                  name: "平均水深:",
                  value: "0.29 m",
               },
               {
                  name: "最大流速:",
                  value: "7 m/s",
               },
@@ -61,7 +63,43 @@
            ],
         }
      },
   mounted() {
      this.getRainfallData(); // 组件挂载后执行获取雨量数据
   },
      methods: {
      getRainfallData() {
         if (!selectedScheme.value || !selectedScheme.value.data) {
            console.warn("selectedScheme 或 data 不存在");
            return;
         }
         let data = selectedScheme.value.data;
         // 如果是字符串,则尝试解析成对象
         if (typeof data === 'string') {
            try {
               data = JSON.parse(data);
            } catch (e) {
               console.error("data 不是有效的 JSON 字符串");
               return;
            }
         }
         const rainfallList = data.rainfalls;
         // 提取 intensity 值
         const rainValues = rainfallList.map(r => r.intensity);
         const minRain = Math.min(...rainValues);
         const maxRain = Math.max(...rainValues);
         const avgRain = rainValues.reduce((sum, val) => sum + val, 0) / rainValues.length;
         // 更新 detailList 中的“最大雨强”和“平均雨强”
         this.detailList[0].value = maxRain.toFixed(2) + " mm/h";       // 最大雨强
         this.detailList[1].value = avgRain.toFixed(2) + " mm/h";       // 平均雨强
         console.log('当前方案下最小雨量、最大雨量、平均雨量:',
            minRain.toFixed(2),
            maxRain.toFixed(2),
            avgRain.toFixed(2)
         );
      },
         closeMsg() {
            this.$emit("close")
         },
@@ -126,6 +164,7 @@
      margin-top: 15px;
      margin-left: 10px;
   }
   .detail-name {
      float: left;
      font-weight: 700;