| | |
| | | ></el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="选择时间:"> |
| | | <el-form-item label="选择时间:" v-show="forms.prediction != '降雨场次'"> |
| | | <el-date-picker |
| | | v-model="forms.hours" |
| | | type="datetimerange" |
| | |
| | | date-format="YYYY/MM/DD ddd" |
| | | time-format="A hh:mm:ss" |
| | | @change="change" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="选择时间:" v-show="forms.prediction == '降雨场次'"> |
| | | <el-date-picker |
| | | v-model="forms.hours" |
| | | type="datetime" |
| | | placeholder="请选择开始时间" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="预计时长:"> |
| | |
| | | <div class="buttons"> |
| | | <el-button type="primary" @click="openPlan">打开方案</el-button> |
| | | <el-button type="primary" @click="openSaveDialog">保存方案</el-button> |
| | | <el-button type="success" @click="startPlay">开始模拟</el-button> |
| | | <el-button type="success" @click="startPlay">保存并开始模拟</el-button> |
| | | </div> |
| | | </div> |
| | | </template> |
| | |
| | | .slice(1) |
| | | .reduce((acc, curr, i) => acc + parseInt(curr, 10) / (i === 0 ? 1 : 60), 0) |
| | | .toFixed(1); |
| | | console.log(parseFloat(decimalHours)); // 输出: 2.6 |
| | | // console.log(parseFloat(decimalHours)); // 输出: 2.6 |
| | | forms.duration = decimalHours; |
| | | forms.intensity = val.rainIntensityHour; |
| | | forms.rainfall = val.rainfallTotalValue; |
| | |
| | | // 打开保存方案对话框 |
| | | const openSaveDialog = async () => { |
| | | // 在 setup 内部更新 geom 的值 |
| | | printDamEntities(); |
| | | try { |
| | | forms.geom = props.selectedArea; |
| | | await simStore.addSimCheme(forms); |
| | | // 打印拦挡坝所需要的数据 |
| | | resetForm(); |
| | | EventBus.emit("close-selectArea"); |
| | | } catch (err) {} |
| | |
| | | // 开始模拟 |
| | | async function startPlay() { |
| | | try { |
| | | formData.geom = props.selectedArea; |
| | | forms.geom = props.selectedArea; |
| | | // 保存方案 |
| | | const res = await simStore.addSimCheme(forms); |
| | | const schemeId = res.data?.data?.id; |
| | |
| | | |
| | | // 关闭选择区域窗口、初始化视图并开始模拟 |
| | | EventBus.emit("close-selectArea"); |
| | | |
| | | simStore.shouldPoll = true; |
| | | // 暂时不在此处开始模拟,模拟都在方案列表中进行模拟 |
| | | // initeWaterPrimitiveView(); |
| | | // startSimulate(); |
| | | |
| | | ElMessage.warning({ |
| | | message: "请返回方案列表开始模拟!", |
| | | message: "请返回方案列表等待模拟结果!", |
| | | duration: 10000, // 提示框显示时长,单位为毫秒,默认是3000毫秒 |
| | | }); |
| | | } catch (error) { |
| | | ElMessage.error("启动模拟失败,请稍后再试"); |
| | | console.log(error); |
| | | } |
| | | } |
| | | |
| | |
| | | const openPlan = () => { |
| | | console.log("打开方案按钮被点击"); |
| | | }; |
| | | // ========================================拦挡坝=============================================================== |
| | | // 获取拦挡坝数据 |
| | | function printDamEntities() { |
| | | const entities = viewer.entities.values; |
| | | const damDataList = []; |
| | | |
| | | for (let i = 0; i < entities.length; i++) { |
| | | const entity = entities[i]; |
| | | |
| | | if (entity.name && (entity.name === '栏档坝1' || entity.name === '栏档坝2')) { |
| | | let position = entity.position?._value; |
| | | |
| | | // 如果有位置信息,就将其从笛卡尔坐标转为经纬度和高度 |
| | | let cartographic = undefined; |
| | | if (position) { |
| | | cartographic = Cesium.Cartographic.fromCartesian(position); |
| | | } |
| | | |
| | | damDataList.push({ |
| | | name: entity.name, |
| | | position: position ? { |
| | | x: position.x, |
| | | y: position.y, |
| | | z: position.z |
| | | } : null, |
| | | cartographic: cartographic ? { |
| | | longitude: Cesium.Math.toDegrees(cartographic.longitude), // 经度(度) |
| | | latitude: Cesium.Math.toDegrees(cartographic.latitude), // 纬度(度) |
| | | height: cartographic.height // 高度(米) |
| | | } : null, |
| | | heading: entity.heading?._value ?? entity.heading, |
| | | pitch: entity.pitch?._value ?? entity.pitch, |
| | | roll: entity.roll?._value ?? entity.roll, |
| | | modelScale: entity.model?.scale?._value ?? entity.model?.scale |
| | | }); |
| | | } |
| | | } |
| | | |
| | | if (damDataList.length > 0) { |
| | | console.log("【栏档坝实体数据列表】:", damDataList); |
| | | deleteDamEntitiesAfterDelay(); |
| | | } else { |
| | | console.log("未找到任何名为 '栏档坝1' 或 '栏档坝2' 的实体"); |
| | | } |
| | | } |
| | | // 保存方案后定时清除新建的拦挡坝数据 |
| | | function deleteDamEntitiesAfterDelay() { |
| | | setTimeout(() => { |
| | | const entities = Array.from(viewer.entities.values); |
| | | const damsToDelete = entities.filter( |
| | | entity => entity.name === '栏档坝1' || entity.name === '栏档坝2' |
| | | ); |
| | | |
| | | damsToDelete.forEach(entity => { |
| | | viewer.entities.remove(entity); |
| | | }); |
| | | |
| | | if (damsToDelete.length > 0) { |
| | | console.log(`【已删除】共 ${damsToDelete.length} 个栏档坝实体`); |
| | | } else { |
| | | console.log("未找到任何可删除的栏档坝实体"); |
| | | } |
| | | }, 5000); |
| | | } |
| | | </script> |
| | | |
| | | <style lang="less" scoped> |