| | |
| | | import { defineStore } from 'pinia' |
| | | import { ref } from 'vue' |
| | | import { ElMessage, ElMessageBox, formMetaProps } from 'element-plus' |
| | | import { ElMessage, ElMessageBox } from 'element-plus' |
| | | import { createSimData } from '@/api/trApi'; |
| | | import dayjs from 'dayjs' |
| | | |
| | | export const SimAPIStore = defineStore('SimAPI', () => { |
| | | const selectTab = ref("行政区划仿真") |
| | |
| | | |
| | | try { |
| | | const params = { |
| | | geom: forms.geom, |
| | | geom: forms.geom.value, |
| | | areaName: forms.geom.label, |
| | | areaType: getAreaType(selectTab.value), |
| | | createTime: Date.now(), |
| | | name: forms.name, |
| | | type: forms.type, |
| | | status: 0, |
| | | data: JSON.stringify({ |
| | | startTime: Array.isArray(forms.hours) |
| | | ? dayjs(forms.hours[0]).format("YYYY-MM-DD HH:mm:ss") |
| | | : dayjs(forms.hours).format("YYYY-MM-DD HH:mm:ss"), |
| | | type: forms.type, |
| | | total: forms.rainfall, |
| | | duration: forms.duration, |
| | | intensity: forms.intensity, |
| | | total: parseFloat(forms.rainfall), |
| | | duration: parseFloat(forms.duration), |
| | | intensity: parseFloat(forms.intensity), |
| | | prediction: forms.prediction, |
| | | history: forms.history, |
| | | mode: forms.mode, |
| | | gauges: forms.gauges |
| | | gauges: forms.gauges, |
| | | rainfalls: forms.rainFallList, |
| | | intensityUnit: forms.intensityUnit |
| | | }) |
| | | } |
| | | console.log(params) |
| | | const res = await createSimData(params) |
| | | ElMessage.success('方案保存成功') |
| | | return res |
| | |
| | | |
| | | // 保存方案弹窗 |
| | | const addSimCheme = async (forms) => { |
| | | if (!validateForm(forms)) return |
| | | // 表单验证 |
| | | if (!validateForm(forms)) { |
| | | throw new Error('表单验证未通过'); // 抛出错误,阻止继续执行 |
| | | } |
| | | |
| | | try { |
| | | await ElMessageBox.confirm('确定要保存当前方案吗?', '新建方案', { |
| | |
| | | } else { |
| | | ElMessage.info('已取消保存') |
| | | } |
| | | throw error // 保证外部能捕获到错误 |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | return { |
| | | selectTab, |
| | | isLoading, |