| | |
| | | </div> |
| | | <div class="buttons"> |
| | | <el-button type="primary" @click="openSaveDialog">保存方案</el-button> |
| | | <el-button type="success" @click="startSimulation">开始模拟</el-button> |
| | | <el-button type="success" @click="startPlay">开始模拟</el-button> |
| | | <el-button type="success" @click="futurePredictions">未来预测</el-button> |
| | | </div> |
| | | |
| | |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { ref, watch, defineProps, computed } from 'vue'; |
| | | import { ref, watch, defineProps, computed, inject } from 'vue'; |
| | | import { ElMessage } from 'element-plus'; |
| | | import { initeWaterPrimitiveView } from "@/utils/water"; |
| | | import { useSimStore } from "@/store/simulation.js"; // 引入 Store |
| | | |
| | | // 获取 Store 实例 |
| | | const simStore = useSimStore(); |
| | | |
| | | // 注入模拟操作方法 |
| | | const { startSimulate, endSimulate } = inject("simulateActions"); |
| | | |
| | | function startPlay() { |
| | | const selectedItems = filteredTableData.value.filter(item => item.selected); |
| | | if (selectedItems.length > 0) { |
| | | console.log('选中的项:', selectedItems.map(item => item.name)); |
| | | } else { |
| | | console.log('未选中任何项'); |
| | | } |
| | | console.log('当前选中的区域:', props.selectedArea); |
| | | console.log('当前选中的雨量数据:', selectedRainfall.value); |
| | | initeWaterPrimitiveView(); |
| | | startSimulate(); |
| | | } |
| | | |
| | | // 工具函数:深拷贝并设置默认选中状态 |
| | | function deepCloneAndSetSelected(data) { |
| | |
| | | ], |
| | | tableData: { |
| | | '1': [ |
| | | { id: '001', name: '孙胡沟气象站001' }, // 默认未勾选 |
| | | { id: '002', name: '孙胡沟气象站002' } // 默认未勾选 |
| | | { id: '001', name: '孙胡沟气象站001' }, |
| | | { id: '002', name: '孙胡沟气象站002' } |
| | | ], |
| | | '2': [ |
| | | { id: '003', name: '孙胡沟雨量计003' }, // 默认未勾选 |
| | | { id: '004', name: '孙胡沟雨量计004' } // 默认未勾选 |
| | | { id: '003', name: '孙胡沟雨量计003' }, |
| | | { id: '004', name: '孙胡沟雨量计004' } |
| | | ] |
| | | } |
| | | }, |
| | |
| | | ], |
| | | tableData: { |
| | | '1': [ |
| | | { id: '005', name: '鱼水洞后沟气象站005' }, // 默认未勾选 |
| | | { id: '006', name: '鱼水洞后沟气象站006' } // 默认未勾选 |
| | | { id: '005', name: '鱼水洞后沟气象站005' }, |
| | | { id: '006', name: '鱼水洞后沟气象站006' } |
| | | ], |
| | | '2': [ |
| | | { id: '007', name: '鱼水洞后沟雨量计007' }, // 默认未勾选 |
| | | { id: '008', name: '鱼水洞后沟雨量计008' } // 默认未勾选 |
| | | { id: '007', name: '鱼水洞后沟雨量计007' }, |
| | | { id: '008', name: '鱼水洞后沟雨量计008' } |
| | | ] |
| | | } |
| | | }, |
| | |
| | | ], |
| | | tableData: { |
| | | '1': [ |
| | | { id: '009', name: '于家西沟气象站009' }, // 默认未勾选 |
| | | { id: '010', name: '于家西沟气象站010' } // 默认未勾选 |
| | | { id: '009', name: '于家西沟气象站009' }, |
| | | { id: '010', name: '于家西沟气象站010' } |
| | | ], |
| | | '2': [ |
| | | { id: '011', name: '于家西沟雨量计011' }, // 默认未勾选 |
| | | { id: '012', name: '于家西沟雨量计012' } // 默认未勾选 |
| | | { id: '011', name: '于家西沟雨量计011' }, |
| | | { id: '012', name: '于家西沟雨量计012' } |
| | | ] |
| | | } |
| | | } |
| | |
| | | |
| | | // 确认保存 |
| | | const confirmSave = () => { |
| | | console.log('保存方案成功', { |
| | | 区域: props.selectedArea, |
| | | 模拟类型: '实时模拟', |
| | | 雨量数据: selectedRainfallName.value, |
| | | 设备信息: selectedDevices.value.map(item => item.name) |
| | | }); |
| | | ElMessage.success('方案已保存'); |
| | | // 构造新的方案对象 |
| | | const newScheme = { |
| | | id: Date.now().toString(), // 唯一 ID |
| | | area: props.selectedArea, // 区域 |
| | | name: selectedRainfallName.value, // 方案名称(雨量数据类型) |
| | | createTime: new Date().toISOString(), // 创建时间 |
| | | taskStatus:1, // 初始状态为未开始 |
| | | rainfallType: selectedRainfallName.value, // 雨量数据类型 |
| | | devices: selectedDevices.value.map((item) => item.name), // 设备信息 |
| | | }; |
| | | |
| | | // 调用 Store 的方法添加方案 |
| | | simStore.addSchemCard(newScheme); |
| | | |
| | | console.log("保存方案成功", newScheme); |
| | | ElMessage.success("方案已保存"); |
| | | |
| | | // 关闭对话框 |
| | | saveDialogVisible.value = false; |
| | | }; |
| | | |
| | | // 切换详情显示 |
| | | const toggleDetails = () => { |
| | | isCollapsed.value = !isCollapsed.value; |
| | | }; |
| | | |
| | | // 开始模拟 |
| | | const startSimulation = () => { |
| | | const selectedItems = filteredTableData.value.filter(item => item.selected); |
| | | if (selectedItems.length > 0) { |
| | | console.log('选中的项:', selectedItems.map(item => item.name)); |
| | | } else { |
| | | console.log('未选中任何项'); |
| | | } |
| | | |
| | | console.log('当前选中的区域:', props.selectedArea); |
| | | console.log('当前选中的雨量数据:', selectedRainfall.value); |
| | | }; |
| | | |
| | | // 未来预测 |
| | | const futurePredictions = () => { |
| | | console.log('未来预测按钮被点击'); |
| | | }; |