wangjuncheng
2025-04-15 d5b4f923a873820d0ba01b73da629e4ca8456457
change
已修改5个文件
405 ■■■■■ 文件已修改
src/views/left/CitySim.vue 301 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/left/KGSim.vue 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/left/KGSimOption/HistorySimulation.vue 13 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/left/KGSimOption/PredictiveSimulation.vue 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/left/KGSimOption/RealTimeSimulation.vue 56 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/left/CitySim.vue
@@ -8,20 +8,6 @@
    </div>
    <div class="forms">
      <el-form :model="forms" label-width="auto" style="max-width: 600px">
        <el-form-item label="行政区域:" v-if="disForm == '行政区划仿真'">
          <el-select
            v-model="forms.eare"
            placeholder="Select"
            style="max-width: 600px"
          >
            <el-option
              v-for="item in cityOptions"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="上传参数">
          <el-upload
            v-model:file-list="forms.fileList"
@@ -40,6 +26,21 @@
            <template #append>mm/h</template>
          </el-upload>
        </el-form-item>
        <el-form-item label="行政区域:" v-if="disForm == '行政区划仿真'">
          <el-select
            v-model="forms.eare"
            placeholder="Select"
            style="max-width: 600px"
          >
            <el-option
              v-for="item in cityOptions"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="重点区域" v-if="disForm == '重点区域仿真'">
          <el-select
            v-model="forms.eares"
@@ -85,133 +86,149 @@
        <el-form-item label="仿真参数:"> </el-form-item>
      </el-form>
      <div style="display: flex; justify-content: flex-end">
        <el-button>保存方案</el-button>
        <el-button @click="startPlay">开始模拟</el-button>
        <el-button type="primary" @click="openSaveDialog">保存方案</el-button>
        <el-button type="success" @click="startPlay">开始模拟</el-button>
      </div>
    </div>
    <!-- 保存方案对话框 -->
    <el-dialog
      v-model="saveDialogVisible"
      :title="dialogTitle"
      width="50%"
      :before-close="handleClose"
      custom-class="custom-dialog"
    >
      <div class="dialog-content">
        <p><strong>模拟类型:</strong>{{ dialogTitle }}</p>
        <p v-if="disForm === '行政区划仿真'"><strong>行政区域:</strong>{{ forms.eare }}</p>
        <p v-if="disForm === '重点区域仿真'"><strong>重点区域:</strong>{{ forms.eares }}</p>
        <p><strong>降雨量:</strong>{{ forms.rainfall }} mm</p>
        <p><strong>降雨时长:</strong>{{ forms.duration }} h</p>
        <p><strong>降雨强度:</strong>{{ forms.intensity }} mm/h</p>
        <p><strong>上传文件:</strong>{{ uploadedFilesText }}</p>
      </div>
      <template #footer>
        <span class="dialog-footer">
          <el-button @click="saveDialogVisible = false">取消</el-button>
          <el-button type="primary" @click="confirmSave">确定保存</el-button>
        </span>
      </template>
    </el-dialog>
  </div>
</template>
<script setup>
import { reactive, ref, watch, inject } from "vue";
import { initeWaterPrimitiveView } from "@/utils/water";
import { reactive, ref, computed ,watch} from "vue";
import { ElMessage, ElMessageBox } from "element-plus";
// 注入父组件提供的方法
const { startSimulate, endSimulate } = inject("simulateActions");
// const emit = defineEmits(["start", "end"]);
// function endPlay() {
//   emit("end");
// }
function startPlay() {
  initeWaterPrimitiveView();
  startSimulate();
}
const value = ref("");
const cityOptions = [
  {
    value: "北京市",
    label: "北京市",
  },
  {
    value: "东城区",
    label: "东城区",
  },
  {
    value: "西城区",
    label: "西城区",
  },
  {
    value: "朝阳区",
    label: "朝阳区",
  },
  {
    value: "海淀区",
    label: "海淀区",
  },
  {
    value: "丰台区",
    label: "丰台区",
  },
  {
    value: "石景山区",
    label: "石景山区",
  },
  {
    value: "门头沟区",
    label: "门头沟区",
  },
  {
    value: "房山区",
    label: "房山区",
  },
  {
    value: "通州区",
    label: "通州区",
  },
  {
    value: "顺义区",
    label: "顺义区",
  },
  {
    value: "昌平区",
    label: "昌平区",
  },
  {
    value: "大兴区",
    label: "大兴区",
  },
  {
    value: "怀柔区",
    label: "怀柔区",
  },
  {
    value: "平谷区",
    label: "平谷区",
  },
  {
    value: "密云区",
    label: "密云区",
  },
  {
    value: "延庆区",
    label: "延庆区",
  },
];
const earesOptions = [
  {
    value: "孙胡沟",
    label: "孙胡沟",
  },
  {
    value: "鱼水洞后沟",
    label: "鱼水洞后沟",
  },
  {
    value: "于家西沟",
    label: "于家西沟",
  },
  {
    value: "北河沟",
    label: "北河沟",
  },
  {
    value: "龙泉峪村",
    label: "龙泉峪村",
  },
];
const forms = reactive({
  eare: "北京市",
  eares: "孙胡沟",
  rainfall: "50",
  duration: "5",
  intensity: "70",
  fileList: [],
// 定义 Props
const props = defineProps({
  clickValue: String,
});
// 数据绑定
const disForm = ref(""); // 当前显示的表单类型
const saveDialogVisible = ref(false); // 控制保存方案对话框的显示状态
const forms = reactive({
  eare: "北京市", // 行政区域
  eares: "孙胡沟", // 重点区域
  rainfall: "50", // 降雨量
  duration: "5", // 降雨时长
  intensity: "70", // 降雨强度
  fileList: [], // 上传的文件列表
});
// 行政区域选项
const cityOptions = [
  { value: "北京市", label: "北京市" },
  { value: "东城区", label: "东城区" },
  { value: "西城区", label: "西城区" },
  { value: "朝阳区", label: "朝阳区" },
  { value: "海淀区", label: "海淀区" },
  { value: "丰台区", label: "丰台区" },
  { value: "石景山区", label: "石景山区" },
  { value: "门头沟区", label: "门头沟区" },
  { value: "房山区", label: "房山区" },
  { value: "通州区", label: "通州区" },
  { value: "顺义区", label: "顺义区" },
  { value: "昌平区", label: "昌平区" },
  { value: "大兴区", label: "大兴区" },
  { value: "怀柔区", label: "怀柔区" },
  { value: "平谷区", label: "平谷区" },
  { value: "密云区", label: "密云区" },
  { value: "延庆区", label: "延庆区" },
];
// 重点区域选项
const earesOptions = [
  { value: "孙胡沟", label: "孙胡沟" },
  { value: "鱼水洞后沟", label: "鱼水洞后沟" },
  { value: "于家西沟", label: "于家西沟" },
  { value: "北河沟", label: "北河沟" },
  { value: "龙泉峪村", label: "龙泉峪村" },
];
// 计算属性:获取对话框标题
const dialogTitle = computed(() => {
  return disForm.value === "行政区划仿真" ? "行政区划仿真" : "重点区域仿真";
});
// 计算属性:获取上传文件的名称列表
const uploadedFilesText = computed(() => {
  return forms.fileList.map(file => file.name).join(", ") || "无";
});
// 监听 Props 变化,更新当前表单类型
watch(
  () => props.clickValue,
  (newValue) => {
    disForm.value = newValue || "行政区划仿真";
  },
  { immediate: true, deep: true }
);
// 打开保存方案对话框
const openSaveDialog = () => {
  if (
    !forms.rainfall ||
    !forms.duration ||
    !forms.intensity ||
    (disForm.value === "行政区划仿真" && !forms.eare) ||
    (disForm.value === "重点区域仿真" && !forms.eares)
  ) {
    ElMessage.warning("请先填写所有必填项");
    return;
  }
  saveDialogVisible.value = true;
};
// 关闭保存方案对话框
const handleClose = () => {
  saveDialogVisible.value = false;
};
// 确认保存
const confirmSave = () => {
  console.log('保存方案成功', {
    模拟类型: dialogTitle.value,
    行政区域: disForm.value === "行政区划仿真" ? forms.eare : null,
    重点区域: disForm.value === "重点区域仿真" ? forms.eares : null,
    降雨量: `${forms.rainfall} mm`,
    降雨时长: `${forms.duration} h`,
    降雨强度: `${forms.intensity} mm/h`,
    // 上传文件: forms.fileList.map(file => file.name),
  });
  ElMessage.success('方案已保存');
  saveDialogVisible.value = false;
};
// 开始模拟
function startPlay() {
  console.log("开始模拟按钮被点击");
}
// 文件上传相关方法
function handleRemove(file, uploadFiles) {
  console.log(file, uploadFiles);
}
@@ -227,6 +244,7 @@
    } totally`
  );
}
const beforeUpload = (file) => {
  const allowedTypes = [
    "application/vnd.ms-excel",
@@ -259,23 +277,8 @@
    () => false
  );
}
const disForm = ref("");
// 定义 Props
const props = defineProps({
  clickValue: String,
});
// 监听 Props 变化
watch(
  () => props.clickValue,
  (newValue) => {
    disForm.value = newValue || "行政区划仿真";
  },
  { immediate: true, deep: true }
);
</script>
<style lang="less" scoped>
.forms {
  background: url("@/assets/img/screen/leftbg.png");
src/views/left/KGSim.vue
@@ -1,6 +1,6 @@
<template>
  <div class="simulation-module">
    <!-- 模拟区域郭楠 -->
    <!-- 模拟区域 -->
    <div class="simulation-area">
      <p>模拟区域</p>
      <el-select
@@ -35,11 +35,6 @@
        <el-radio label="预测模拟">预测模拟</el-radio>
      </el-radio-group>
      <div v-if="selectedSimulation === '历史模拟'">
        <!-- <HistorySimulation
          :selectedArea="selectedArea"
          @start="start"
          @end="end"
        /> -->
        <HistorySimulation :selectedArea="selectedArea" />
      </div>
      <div v-if="selectedSimulation === '实时模拟'">
@@ -57,17 +52,6 @@
import HistorySimulation from "./KGSimOption/HistorySimulation.vue";
import PredictiveSimulation from "./KGSimOption/PredictiveSimulation.vue";
import RealTimeSimulation from "./KGSimOption/RealTimeSimulation.vue";
// const emit = defineEmits(["start", "end"]);
// function end() {
//   emit("end");
// }
// function start() {
//   // initeWaterPrimitiveView();
//   emit("start");
// }
const selectedSimulation = ref("历史模拟");
const selectedArea = ref("孙胡沟");
@@ -102,7 +86,6 @@
</script>
<style scoped>
/* 样式保持不变 */
</style>
<style scoped>
src/views/left/KGSimOption/HistorySimulation.vue
@@ -93,16 +93,12 @@
import { ref, computed, inject } from "vue";
import { ElMessage } from "element-plus";
import { initeWaterPrimitiveView } from "@/utils/water";
// const emit = defineEmits(["start", "end"]);
const { startSimulate, endSimulate } = inject("simulateActions");
// function endPlay() {
//   emit("end");
// }
function startPlay() {
  console.log("开始模拟按钮被点击");
  console.log("当前选中的区域:", props.selectedArea);
  initeWaterPrimitiveView();
  // emit("start");
  startSimulate();
}
// 定义 Props
@@ -175,11 +171,6 @@
  });
  ElMessage.success("方案已保存");
  saveDialogVisible.value = false;
};
// 开始模拟
const startSimulation = () => {
  console.log("开始模拟按钮被点击");
  console.log("当前选中的区域:", props.selectedArea);
};
</script>
src/views/left/KGSimOption/PredictiveSimulation.vue
@@ -84,15 +84,13 @@
import { ref, computed } from 'vue';
import { ElMessage } from 'element-plus';
import { initeWaterPrimitiveView } from "@/utils/water";
const emit = defineEmits(["start", "end"]);
function endPlay() {
  emit("end");
}
const { startSimulate, endSimulate } = inject("simulateActions");
function startPlay() {
  console.log("开始模拟按钮被点击");
  console.log("当前选中的区域:", props.selectedArea);
    initeWaterPrimitiveView();
    emit("start");
  startSimulate();
}
// 定义 Props
const props = defineProps({
@@ -176,12 +174,6 @@
// 打开方案
const openPlan = () => {
  console.log('打开方案按钮被点击');
};
// 开始模拟
const startSimulation = () => {
  console.log('开始模拟按钮被点击');
  console.log('当前选中的区域:', props.selectedArea);
};
</script>
src/views/left/KGSimOption/RealTimeSimulation.vue
@@ -66,15 +66,19 @@
import { ref, watch, defineProps, computed } from 'vue';
import { ElMessage } from 'element-plus';
import { initeWaterPrimitiveView } from "@/utils/water";
const emit = defineEmits(["start", "end"]);
function endPlay() {
  emit("end");
}
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();
    emit("start");
  startSimulate();
}
// 工具函数:深拷贝并设置默认选中状态
function deepCloneAndSetSelected(data) {
@@ -109,12 +113,12 @@
    ],
    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' }
      ]
    }
  },
@@ -125,12 +129,12 @@
    ],
    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' }
      ]
    }
  },
@@ -141,12 +145,12 @@
    ],
    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' }
      ]
    }
  }
@@ -214,25 +218,9 @@
  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('未来预测按钮被点击');
};