From a57caa72a54efe9de3fe26a6c36d3e8038267377 Mon Sep 17 00:00:00 2001
From: guonan <guonan201020@163.com>
Date: 星期四, 17 七月 2025 09:09:49 +0800
Subject: [PATCH] 修改x按钮

---
 src/components/tools/DebuffDetail.vue |  360 +++++++++++++++++++++++++++++++++++++-----------------------
 1 files changed, 222 insertions(+), 138 deletions(-)

diff --git a/src/components/tools/DebuffDetail.vue b/src/components/tools/DebuffDetail.vue
index 4bc9239..5a4ca4f 100644
--- a/src/components/tools/DebuffDetail.vue
+++ b/src/components/tools/DebuffDetail.vue
@@ -1,151 +1,235 @@
 <template>
-	<div class="detail">
-		<div class="detail-top">缁熻鍒嗘瀽缁撴灉</div>
-		<div class="detail-btn" @click="showMsg">鏌ョ湅璇︽儏</div>
-		<div class="detail-close" @click="closeMsg"></div>
-		<div class="detail-context">
-			<div v-for="(item, key) in detailList" :key="key" class="detail-item">
-				<div class="detail-name">{{ item.name }}</div>
-				<div class="detail-value">{{ item.value }}</div>
-			</div>
-		</div>
-	</div>
+  <div class="detail">
+    <div class="detail-top">缁熻鍒嗘瀽缁撴灉</div>
+    <!-- <div class="detail-btn" @click="showMsg">鏌ョ湅璇︽儏</div> -->
+    <div class="detail-close" @click="closeMsg"></div>
+    <div class="detail-context">
+      <div v-for="(item, key) in detailList" :key="key" class="detail-item">
+        <div class="detail-name">{{ item.name }}</div>
+        <div class="detail-value">{{ item.value }}</div>
+      </div>
+    </div>
+  </div>
 </template>
 
-<script>
-	export default {
-		name: "detail",
-		components: {},
-		props: {
-			areaName: {
-				type: String,
-				default: "灏瑰瑗挎矡",
-			},
-		},
-		data() {
-			return {
-				show: false,
-				detailList: [
-					{
-						name: "鏈�澶ч洦寮猴細",
-						value: Number(Math.random() * 100).toFixed(2) + " mm/h",
-					},
-					{
-						name: "骞冲潎闆ㄥ己锛�",
-						value: Number(Math.random() * 10).toFixed(2) + " mm/h",
-					},
-					{
-						name: "鏈�澶ф按娣憋細",
-						value: "1.86 m",
-					},
-					{
-						name: "骞冲潎姘存繁锛�",
-						value: "0.29 m",
-					},
-					{
-						name: "鏈�澶ф祦閫燂細",
-						value: "7 m/s",
-					},
-					{
-						name: "濞佽儊鎴垮眿锛�",
-						value: "406 闂�",
-					},
-					{
-						name: "濞佽儊浜哄彛锛�",
-						value: "145 鎴�",
-					},
-					{
-						name: "濞佽儊璐骇锛�",
-						value: "4872 涓囧厓",
-					},
-				],
-			}
-		},
-		methods: {
-			closeMsg() {
-				this.$emit("close")
-			},
-			showMsg() {
-				this.$emit("open")
-			},
-		},
-	}
+<script setup>
+import { ref, onMounted } from "vue";
+import { useSimStore } from "@/store/simulation";
+import { storeToRefs } from "pinia";
+
+const simStore = useSimStore();
+const { selectedScheme, schemWaterInfo } = storeToRefs(simStore);
+// schemWaterInfo
+// 闅愭偅鐐�
+const filteredData = simStore.DangerPoint.filter((item) =>
+  item.position?.includes("瀛欒儭娌�")
+);
+
+// 鍝嶅簲寮忔暟鎹�
+const detailList = ref([
+  {
+    name: "鏈�澶ч洦寮猴細",
+    value: (Math.random() * 100).toFixed(2) + " mm/h",
+  },
+  {
+    name: "骞冲潎闆ㄥ己锛�",
+    value: (Math.random() * 10).toFixed(2) + " mm/h",
+  },
+  {
+    name: "鏈�澶ф按娣憋細",
+    value: "1.86 m",
+  },
+  // {
+  //   name: "鏈�澶ф祦閫燂細",
+  //   value: "7 m/s",
+  // },
+  {
+    name: "濞佽儊鎴挎暟锛�",
+    value: "406 闂�",
+  },
+  {
+    name: "濞佽儊鎴锋暟锛�",
+    value: "145 鎴�",
+  },
+  {
+    name: "濞佽儊浜哄彛锛�",
+    value: "145 浜�",
+  },
+  {
+    name: "濞佽儊璐骇锛�",
+    value: "4872 涓囧厓",
+  },
+]);
+
+const updateThreatData = () => {
+  // 绛涢�� position 鍖呭惈 "瀛欒儭娌�" 鐨勬暟鎹�
+  const filteredData = simStore.DangerPoint.filter((item) =>
+    item.position?.includes("瀛欒儭娌�")
+  );
+
+  if (filteredData.length === 0) {
+    console.warn("鏈壘鍒� position 鍖呭惈 '瀛欒儭娌�' 鐨勬暟鎹�");
+    return;
+  }
+
+  // 鍒濆鍖栫疮鍔犲��
+  let totalHousehold = 0; // 濞佽儊鎴锋暟
+  let totalPerson = 0; // 濞佽儊浜烘暟
+  let totalRoom = 0; // 濞佽儊鎴挎暟
+
+  // 閬嶅巻骞剁疮鍔�
+  filteredData.forEach((item) => {
+    totalHousehold += Number(item.threatHouseNum) || 0;
+    totalPerson += Number(item.threatPersonNum) || 0;
+    totalRoom += Number(item.threatRoomNum) || 0;
+  });
+
+  // 鏇存柊 detailList
+  detailList.value[5].value = `${totalHousehold} 鎴穈;
+  detailList.value[6].value = `${totalPerson} 浜篳;
+  detailList.value[4].value = `${totalRoom} 闂碻;
+
+  console.log("濞佽儊鎴锋暟:", totalHousehold);
+  console.log("濞佽儊浜烘暟:", totalPerson);
+  console.log("濞佽儊鎴挎暟:", totalRoom);
+};
+// 鏂规硶瀹氫箟
+const getRainfallData = () => {
+  if (!selectedScheme.value || !selectedScheme.value.data) {
+    console.warn("selectedScheme 鎴� data 涓嶅瓨鍦�");
+    return;
+  }
+
+  let data = selectedScheme.value.data;
+
+  // 濡傛灉鏄瓧绗︿覆锛屽垯灏濊瘯瑙f瀽鎴愬璞�
+  if (typeof data === "string") {
+    try {
+      data = JSON.parse(data);
+    } catch (e) {
+      console.error("data 涓嶆槸鏈夋晥鐨� JSON 瀛楃涓�");
+      return;
+    }
+  }
+
+  if (selectedScheme.value.type !== 2) {
+    // console.log(schemWaterInfo.value,'杩欓噷鏄墍鏈夌殑鏂规鏁版嵁');
+    
+    
+    // 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 涓殑鈥滄渶澶ч洦寮衡�濆拰鈥滃钩鍧囬洦寮衡��
+    detailList.value[0].value = schemWaterInfo.value[1].toFixed(2) + " mm/h"; // 鏈�澶ч洦寮�
+    detailList.value[1].value = schemWaterInfo.value[2].toFixed(2) + " mm/h"; // 骞冲潎闆ㄥ己
+    detailList.value[2].value = schemWaterInfo.value[0].toFixed(2) + " m"; // 鏈�澶ф按娣�
+
+    console.log(
+      "褰撳墠鏂规涓嬫渶澶ф按娣便�佹渶澶ч洦閲忋�佸钩鍧囬洦閲忥細",
+      schemWaterInfo.value[0].toFixed(2),
+      schemWaterInfo.value[1].toFixed(2),
+      schemWaterInfo.value[2].toFixed(2)
+    );
+  }
+};
+
+const closeMsg = () => {
+  // 浣跨敤 defineEmits 瀹氫箟 emit
+  emit("close");
+};
+
+const showMsg = () => {
+  emit("open");
+};
+
+// 瀹氫箟 emit
+const emit = defineEmits(["close", "open"]);
+
+// 鐢熷懡鍛ㄦ湡閽╁瓙
+onMounted(() => {
+  // console.log(filteredData);
+  updateThreatData();
+  getRainfallData();
+});
 </script>
+
 <style lang="less" scoped>
-	.detail {
-		background: url("@/assets/img/tools/messagebg.png");
-		background-size: 100% 100%;
-		width: 391px;
-		height: 420px;
-		position: absolute;
-		top: 50%;
-		left: 50%;
-		transform: translate(-50%, -50%);
-		z-index: 99;
-	}
+.detail {
+  background: url("@/assets/img/tools/messagebg.png");
+  background-size: 100% 100%;
+  width: 391px;
+  height: 420px;
+  position: absolute;
+  top: 50%;
+  left: 50%;
+  transform: translate(-50%, -50%);
+  z-index: 99;
+}
 
-	.detail-top {
-		position: absolute;
-		top: 5px;
-		left: 20px;
-		font-weight: 700;
-		font-size: 18px;
-		font-weight: 700;
-		color: #fff;
-		line-height: 40px;
-		width: 270px;
-		cursor: pointer;
-	}
+.detail-top {
+  position: absolute;
+  top: 5px;
+  left: 20px;
+  font-weight: 700;
+  font-size: 18px;
+  color: #fff;
+  line-height: 40px;
+  width: 270px;
+  cursor: pointer;
+}
 
-	.detail-close {
-		position: absolute;
-		right: 3px;
-		top: 10px;
-		width: 20px;
-		height: 20px;
-		text-align: center;
-		line-height: 20px;
-		text-align: center;
+.detail-close {
+  position: absolute;
+  right: 3px;
+  top: 10px;
+  width: 20px;
+  height: 20px;
+  text-align: center;
+  line-height: 20px;
+  font-weight: 700;
+  font-size: 18px;
+  color: #fff;
+  cursor: pointer;
+}
 
-		font-weight: 700;
-		font-size: 18px;
-		font-weight: 700;
-		color: #fff;
-		cursor: pointer;
-	}
+.detail-context {
+  position: absolute;
+  top: 40px;
+  left: 20px;
+  width: 350px;
+}
 
-	.detail-context {
-		position: absolute;
-		top: 40px;
-		left: 20px;
-		width: 350px;
-	}
+.detail-item {
+  height: 23px;
+  margin-top: 15px;
+  margin-left: 10px;
+}
 
-	.detail-item {
-		height: 23px;
-		margin-top: 15px;
-		margin-left: 10px;
-	}
-	.detail-name {
-		float: left;
-		font-weight: 700;
-		color: #94e0c4;
-	}
+.detail-name {
+  float: left;
+  font-weight: 700;
+  color: #94e0c4;
+}
 
-	.detail-value {
-		float: left;
-		color: #e1eee9;
-	}
+.detail-value {
+  float: left;
+  color: #e1eee9;
+}
 
-	.detail-btn {
-		background: url("@/assets/img/tools/messagebtn.png") no-repeat;
-		position: absolute;
-		bottom: 60px;
-		right: 60px;
-		width: 105px;
-		height: 26px;
-		text-align: center;
-		color: #fff;
-		cursor: pointer;
-	}
+.detail-btn {
+  background: url("@/assets/img/tools/messagebtn.png") no-repeat;
+  position: absolute;
+  bottom: 60px;
+  right: 60px;
+  width: 105px;
+  height: 26px;
+  text-align: center;
+  color: #fff;
+  cursor: pointer;
+}
 </style>

--
Gitblit v1.9.3