wangjuncheng
2025-04-22 5caf72a91b204c78cdc91ce116beae5d445dc73d
src/views/left/CitySim.vue
@@ -107,34 +107,6 @@
        <el-button type="primary" @click="openSaveDialog">保存方案</el-button>
        <el-button type="success" @click="startPlay">开始模拟</el-button>
      </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>
  </div>
</template>
@@ -145,15 +117,12 @@
import Papa from "papaparse";
import { ElMessage, ElMessageBox } from "element-plus";
import { initeWaterPrimitiveView } from "@/utils/water";
import { createSimData } from "@/api/trApi";
import { SimAPIStore } from "@/store/simAPI";
import { useSimStore } from "@/store/simulation";
const simStore = useSimStore();
const simStore = SimAPIStore();
// 注入父组件提供的方法
const { startSimulate, endSimulate } = inject("simulateActions");
const saveDialogVisible = ref(false); // 控制保存方案对话框的显示状态(接口版本删除)
// 表单数据
const forms = reactive({
  name: "",
@@ -205,43 +174,11 @@
  return forms.fileList.map((file) => file.name).join(", ") || "无";
});
////////////////////////////////////// 接口版本需删除//////////////////////////////////////
// 打开保存方案对话框
const openSaveDialog = () => {
  if (
    !forms.rainfall ||
    !forms.duration ||
    !forms.intensity ||
    (simStore.selectTab === "行政区划仿真" && !forms.eare) ||
    (simStore.selectTab === "重点区域仿真" && !forms.eares)
  ) {
    ElMessage.warning("请先填写所有必填项");
    return;
  }
  saveDialogVisible.value = true;
}
const handleClose = () => {
  saveDialogVisible.value = false;
};
// 确认保存
const confirmSave = () => {
  console.log("保存方案成功", {
    模拟类型: dialogTitle.value,
    行政区域: simStore.selectTab === "行政区划仿真" ? forms.eare : null,
    重点区域: simStore.selectTab === "重点区域仿真" ? forms.eares : null,
    降雨量: `${forms.rainfall} mm`,
    降雨时长: `${forms.duration} h`,
    降雨强度: `${forms.intensity} mm/h`,
    上传文件: forms.fileList.map((file) => file.name),
  });
  ElMessage.success("方案已保存");
  saveDialogVisible.value = false;
  resetForm();
};
////////////////////////////////////// 结束删除//////////////////////////////////////
//////////////////////////////////接口版本启用//////////////////////////////////
const openSaveDialog = async () => {
  await simStore.openSaveDialog(forms);
};
// const isLoading = ref(false);
// // 保存方案
// const openSaveDialog = () => {
@@ -412,7 +349,6 @@
  }
  return true;
};
// 开始模拟
function startPlay() {