wangjuncheng
2025-04-15 8792be67cf5791a4a3afc2f72fd8d7cfc3cff353
src/views/left/KGSimOption/HistorySimulation.vue
@@ -90,19 +90,17 @@
</template>
<script setup>
import { ref, computed } from "vue";
import { ref, computed, inject } from "vue";
import { ElMessage } from "element-plus";
import { initeWaterPrimitiveView } from "@/utils/water";
const emit = defineEmits(["start", "end"]);
import { useSimStore } from "@/store/simulation.js"; // 引入 Store
function endPlay() {
  emit("end");
}
// 获取 Store 实例
const simStore = useSimStore();
function startPlay() {
  initeWaterPrimitiveView();
  emit("start");
}
// 注入模拟操作方法
const { startSimulate, endSimulate } = inject("simulateActions");
// 定义 Props
const props = defineProps({
  selectedArea: {
@@ -163,22 +161,31 @@
// 确认保存
const confirmSave = () => {
  console.log("保存方案成功", {
    区域: props.selectedArea,
    模拟类型: "历史模拟",
    历史雨情: selectedRainfallName.value,
    降雨总量: `${totalRainfall.value} mm`,
    降雨强度: `${rainfallIntensity.value} mm/h`,
    降雨时长: `${rainfallDuration.value} h`,
  });
  // 构造新的方案对象
  const newScheme = {
    id: Date.now().toString(), // 唯一 ID
    area: props.selectedArea, // 区域
    name: selectedRainfallName.value, // 方案名称
    createTime: new Date().toISOString(), // 创建时间
    taskStatus: 1, // 初始状态为未开始
    totalRainfall: totalRainfall.value, // 降雨总量
    rainfallIntensity: rainfallIntensity.value, // 降雨强度
    rainfallDuration: rainfallDuration.value, // 降雨时长
  };
  simStore.addSchemCard(newScheme);
  ElMessage.success("方案已保存");
  // 关闭对话框
  saveDialogVisible.value = false;
};
// 开始模拟
const startSimulation = () => {
function startPlay() {
  console.log("开始模拟按钮被点击");
  console.log("当前选中的区域:", props.selectedArea);
};
  initeWaterPrimitiveView();
  startSimulate();
}
</script>
<style scoped>