guonan
2025-06-19 d3e7a1953618d73ffb1a480cb7c6afda42246460
src/views/left/CitySim.vue
@@ -10,7 +10,11 @@
    <div class="left-top" v-if="simStore.selectTab == '重点区域仿真'">
      重点区域仿真(10m精度)
    </div>
    <div class="forms">
    <div class="left-top" v-if="simStore.selectTab == '重点沟仿真'">
      历史模拟
    </div>
    <div class="forms" :class="{ 'no-background': !showBackground }">
      <el-form
        :rules="rules"
        :model="forms"
@@ -106,7 +110,7 @@
            v-if="forms.fileList.length !== 0"
            v-model="forms.hours"
            type="datetime"
            placeholder="Select date and time"
            placeholder="请选择开始时间"
          />
          <el-date-picker
            v-if="forms.fileList.length == 0"
@@ -169,9 +173,18 @@
const options = reactive([]);
// 历史模拟选中区域
const props = defineProps({
  selectedArea: {
    type: Object,
    required: true,
  },
});
const intensityOptions = ref([
  { value: "mm/h", label: "mm/h" },
  { value: "mm/5min", label: "mm/5min" },
  { value: "mm/1min", label: "mm/1min" },
]);
// 定义一个方法,用于根据 type 获取区域数据
@@ -193,6 +206,8 @@
  fetchRegionData(1);
});
const showBackground = ref(true); // 默认显示背景图
// 监听 selectTab 的变化
watch(selectTab, (newVal) => {
  let type;
@@ -203,10 +218,21 @@
    case "重点区域仿真":
      type = 2;
      break;
    case "重点沟仿真":
      type = 3;
      break;
    default:
      type = 1; // 默认值
  }
  // 根据 type 设置是否显示背景图(因为历史模拟中表单带了背景图)
  if (type == 3) {
    showBackground.value = false;
  } else {
    showBackground.value = true;
  }
  fetchRegionData(type);
  // Tab切换的时候清空表单
  resetForm();
});
// 注入父组件提供的方法
@@ -245,6 +271,9 @@
const addSimCheme = async () => {
  try {
    if (selectTab.value == "重点沟仿真") {
      forms.geom = props.selectedArea;
    }
    await simStore.addSimCheme(forms);
    resetForm(); // 只有在保存成功后才重置表单
    EventBus.emit("close-selectArea");
@@ -378,10 +407,6 @@
  console.log(intensityColumn, "intensityColumnintensityColumnintensityColumn");
  // 3. 提取第二列的单位(如 "(mm/h)" → "mm/h")
  const intensityUnit = extractUnitFromHeader(intensityColumn);
  console.log(
    intensityUnit,
    "intensityUnitintensityUnitintensityUnitintensityUnit"
  );
  forms.intensityUnit = intensityUnit; // 存储单位(可选)
  // 4. 如果校验通过,继续处理数据
@@ -392,6 +417,7 @@
  const firstTime = parseDateTime(data[0][timeColumn]);
  const lastTime = parseDateTime(data[data.length - 1][timeColumn]);
  const timeDuration = Math.floor((lastTime - firstTime) / 1000);
  console.log(firstTime,lastTime,timeDuration,'aaaaaaaaaaaaaaaaaaaaaaaaaaaa')
  forms.duration = (timeDuration / 3600).toFixed(2);
  const maxValue = Math.max(
@@ -475,6 +501,9 @@
async function startPlay() {
  try {
    // 保存方案
    if (selectTab.value == "重点沟仿真") {
      forms.geom = props.selectedArea;
    }
    const res = await simStore.addSimCheme(forms);
    const schemeId = res.data?.data?.id;
@@ -485,21 +514,22 @@
    // 调用求解器
    const simStartRes = await getSimStart(schemeId);
    console.log(simStartRes, "getSimStart 返回结果");
    // 关闭选择区域窗口、初始化视图并开始模拟
    EventBus.emit("close-selectArea");
    simStore.shouldPoll = true;
    // 暂时不在此处开始模拟,模拟都在方案列表中进行模拟
    // initeWaterPrimitiveView();
    // startSimulate();
    ElMessage.warning({
      message: "请返回方案列表开始模拟!",
      message: "请返回方案列表等待模拟结果!",
      duration: 10000, // 提示框显示时长,单位为毫秒,默认是3000毫秒
    });
  } catch (error) {
    console.error("启动模拟过程中发生错误:", error);
    ElMessage.error("启动模拟失败,请稍后再试");
    // ElMessage.error("启动模拟失败,请稍后再试");
  }
}
</script>
@@ -512,6 +542,12 @@
  height: 100%;
  padding: 10px 10px 0px 0px;
  box-sizing: border-box;
  transition: background 0.3s ease; // 可选过渡效果
}
.forms.no-background {
  margin-top: 0px;
  background-image: none;
}
/deep/ .el-input-group__append,
.el-input-group__prepend {