| | |
| | | v-for="item in HistoricalRainData" |
| | | :key="item.id" |
| | | :label="item.name" |
| | | :value="item.id" |
| | | :value="item.name" |
| | | ></el-option> |
| | | </el-select> |
| | | </div> |
| | |
| | | <span>mm/h</span> |
| | | </div> |
| | | <div class="input-item"> |
| | | <label>选择时间:</label> |
| | | <el-date-picker |
| | | v-model="hours" |
| | | type="datetimerange" |
| | | start-placeholder="开始时间" |
| | | end-placeholder="结束时间" |
| | | format="YYYY-MM-DD HH:mm:ss" |
| | | date-format="YYYY/MM/DD ddd" |
| | | time-format="A hh:mm:ss" |
| | | @change="change" |
| | | /> |
| | | <span>h</span> |
| | | </div> |
| | | <div class="input-item"> |
| | | <label>降雨时长:</label> |
| | | <el-input |
| | | disabled |
| | | v-model="rainfallDuration" |
| | | type="number" |
| | | placeholder="请输入" |
| | |
| | | </div> |
| | | |
| | | <!-- 保存方案对话框 --> |
| | | <el-dialog |
| | | <!-- <el-dialog |
| | | v-model="saveDialogVisible" |
| | | title="保存方案" |
| | | width="50%" |
| | |
| | | <el-button type="primary" @click="confirmSave">确定保存</el-button> |
| | | </span> |
| | | </template> |
| | | </el-dialog> |
| | | </el-dialog> --> |
| | | </div> |
| | | </template> |
| | | |
| | |
| | | import { initeWaterPrimitiveView } from "@/utils/water"; |
| | | import { useSimStore } from "@/store/simulation.js"; // 引入 Store |
| | | import { getRainfallData } from "@/api/hpApi.js"; |
| | | import { SimAPIStore } from "@/store/simAPI"; |
| | | import { EventBus } from "@/eventBus"; // 引入事件总线 |
| | | |
| | | // 获取 Store 实例 |
| | | const simStore = useSimStore(); |
| | | const simStore = SimAPIStore(); |
| | | |
| | | // 测试获取雨量数据 |
| | | // const getRainData = () => { |
| | | // getRainfallData() |
| | |
| | | // 定义 Props |
| | | const props = defineProps({ |
| | | selectedArea: { |
| | | type: String, |
| | | type: Object, |
| | | required: true, |
| | | }, |
| | | }); |
| | | |
| | | // 数据绑定 |
| | | const rainfallHistory = ref("2"); // 默认选中第二项 |
| | | const rainfallHistory = ref("XX年50mm降雨"); // 默认选中第二项 |
| | | const totalRainfall = ref(50); // 降雨总量 |
| | | const schemeName = ref("方案名称"); // 方案名称 |
| | | const rainfallIntensity = ref(70); // 降雨强度 |
| | | const rainfallDuration = ref(5); // 降雨时长 |
| | | const hours = ref(null); |
| | | const rainfallDuration = ref(null); // 降雨时长 |
| | | const isCollapsed = ref(false); // 控制详情的展开/收起状态 |
| | | const saveDialogVisible = ref(false); // 控制保存方案对话框的显示状态 |
| | | |
| | |
| | | // 获取当前选中的历史雨情名称 |
| | | const selectedRainfallName = computed(() => { |
| | | const selected = HistoricalRainData.find( |
| | | (item) => item.id === rainfallHistory.value |
| | | (item) => item.name === rainfallHistory.value |
| | | ); |
| | | return selected ? selected.name : ""; |
| | | }); |
| | |
| | | isCollapsed.value = !isCollapsed.value; |
| | | }; |
| | | |
| | | const { calculateHoursDifference } = inject("calculateHours"); |
| | | |
| | | const change = (val) => { |
| | | rainfallDuration.value = calculateHoursDifference(val); |
| | | }; |
| | | |
| | | // 打开保存方案对话框 |
| | | const openSaveDialog = () => { |
| | | if ( |
| | | !props.selectedArea || |
| | | !rainfallHistory.value || |
| | | !totalRainfall.value || |
| | | !schemeName.value || |
| | | !rainfallIntensity.value || |
| | | !rainfallDuration.value |
| | | ) { |
| | | ElMessage.warning("请先填写所有必填项"); |
| | | return; |
| | | } |
| | | ElMessageBox.confirm("确定要保存当前方案吗?", { |
| | | confirmButtonText: "确定", |
| | | cancelButtonText: "取消", |
| | | type: "warning", |
| | | }) |
| | | .then(confirmSave) |
| | | .catch(() => { |
| | | ElMessage({ |
| | | type: "info", |
| | | message: "已取消保存", |
| | | }); |
| | | }); |
| | | // saveDialogVisible.value = true; |
| | | }; |
| | | const params = { |
| | | name: schemeName.value, |
| | | |
| | | type: "历史模拟", |
| | | data: { |
| | | |
| | | rainFall: totalRainfall.value, |
| | | rainfallIntensity: rainfallIntensity.value, |
| | | rainfallDuration: rainfallDuration.value, |
| | | rainfallHistory: rainfallHistory.value, |
| | | }, |
| | | }; |
| | | const isLoading = ref(false); |
| | | const confirmSave = async () => { |
| | | if (isLoading.value) { |
| | | ElMessage.warning("正在保存,请稍候..."); |
| | | return; // 防止重复提交 |
| | | } |
| | | isLoading.value = true; // 开始加载状态 |
| | | console.log("当前选中的区域 (selectedArea):", props.selectedArea); |
| | | |
| | | const params = { |
| | | const openSaveDialog = async () => { |
| | | const forms = { |
| | | name: schemeName.value, |
| | | type: "历史模拟", |
| | | eares: props.selectedArea, |
| | | data: { |
| | | rainFall: totalRainfall.value, |
| | | rainfallIntensity: rainfallIntensity.value, |
| | | rainfallDuration: rainfallDuration.value, |
| | | rainfallHistory: rainfallHistory.value, |
| | | }, |
| | | geom: props.selectedArea, |
| | | type: 3, |
| | | rainfall: totalRainfall.value, |
| | | intensity: rainfallIntensity.value, |
| | | duration: rainfallDuration.value, |
| | | history: rainfallHistory.value, |
| | | }; |
| | | |
| | | try { |
| | | await simStore.createSimulation(params); // 调用 Store 中的保存方法 |
| | | ElMessage.success("保存成功"); |
| | | saveDialogVisible.value = false; // 关闭保存对话框 |
| | | } catch (error) { |
| | | console.error("保存失败:", error); |
| | | ElMessage.error("保存失败,请稍后重试"); |
| | | } finally { |
| | | isLoading.value = false; // 结束加载状态 |
| | | } |
| | | await simStore.addSimCheme(forms); |
| | | EventBus.emit("close-selectArea"); |
| | | }; |
| | | |
| | | // 关闭保存方案对话框 |
| | | const handleClose = () => { |
| | | saveDialogVisible.value = false; |
| | | }; |
| | | |
| | | // // 确认保存 |
| | | // const confirmSave = () => { |
| | | // // 构造新的方案对象 |
| | | // const newScheme = { |
| | | // id: Date.now().toString(), // 唯一 ID |
| | | // area: props.selectedArea, // 区域 |
| | | // name: selectedRainfallName.value, // 方案名称 |
| | | // createTime: new Date().toISOString(), // 创建时间 |
| | | // taskStatus: 1, // 初始状态为未开始 |
| | | // totalRainfall: totalRainfall.value, // 降雨总量 |
| | | // schemeName: schemeName.value, // 降雨总量 |
| | | // rainfallIntensity: rainfallIntensity.value, // 降雨强度 |
| | | // rainfallDuration: rainfallDuration.value, // 降雨时长 |
| | | // }; |
| | | |
| | | // simStore.addSchemCard(newScheme); |
| | | // ElMessage.success("方案已保存"); |
| | | // // 关闭对话框 |
| | | // saveDialogVisible.value = false; |
| | | // }; |
| | | |
| | | // 开始模拟 |
| | | function startPlay() { |