| | |
| | | const forms = reactive({ |
| | | name: "", |
| | | geom: "", |
| | | rainfall: "", |
| | | duration: "", |
| | | intensity: "", |
| | | rainfall: null, |
| | | duration: null, |
| | | intensity: null, |
| | | fileList: [], |
| | | type: 3, |
| | | rainFallList: [], |
| | | hours: "", |
| | | hours: null, |
| | | }); |
| | | |
| | | // 计算累计时长 |
| | | const calculateHoursDifference = (val) => { |
| | | if (!val || val.length !== 2) return 0; |
| | | const [startDate, endDate] = val; |
| | | const diffInHours = dayjs(endDate).diff(dayjs(startDate), "hour", true); // true 表示返回浮点数 |
| | | return diffInHours; |
| | | }; |
| | | const { calculateHoursDifference } = inject("calculateHours"); |
| | | |
| | | const change = (val) => { |
| | | forms.duration = calculateHoursDifference(val); |
| | |
| | | const resetForm = () => { |
| | | forms.geom = ""; |
| | | forms.eares = "孙胡沟"; |
| | | forms.rainfall = ""; |
| | | forms.duration = ""; |
| | | forms.intensity = ""; |
| | | forms.rainfall = null; |
| | | forms.duration = null; |
| | | forms.intensity = null; |
| | | forms.fileList = []; |
| | | forms.rainFallList = []; |
| | | forms.hours = ""; |
| | | forms.hours = null; |
| | | }; |
| | | |
| | | // 计算属性:获取上传文件的名称列表 |
| | |
| | | const transformKeys = (data) => { |
| | | return data.map((item) => ({ |
| | | time: item["时间"], // "时间" → "time" |
| | | intensity: item["小时雨强mm/h"], // "小时雨强mm/h" → "intensity" |
| | | total: item["累计雨量"], // "累计雨量" → "total" |
| | | intensity: parseFloat(item["小时雨强mm/h"]), // 转为浮点数 |
| | | total: parseFloat(item["累计雨量"]), // 转为浮点数 |
| | | })); |
| | | }; |
| | | |