| | |
| | | </template> |
| | | |
| | | <script setup> |
| | | import { ref, defineEmits } from "vue"; |
| | | import { ref, defineEmits, provide } from "vue"; |
| | | import citySim from "./CitySim.vue"; |
| | | import kgSim from "./KGSim.vue"; |
| | | import dayjs from 'dayjs'; |
| | | |
| | | import { useSimStore } from "@/store/simulation"; |
| | | import { SimAPIStore } from "@/store/simAPI"; |
| | | |
| | | const simStore = useSimStore(); |
| | | const simStore = SimAPIStore(); |
| | | |
| | | // 定义返回事件 |
| | | const emits = defineEmits(["back"]); |
| | |
| | | const goBack = () => { |
| | | emits("back", clickValue.value); |
| | | }; |
| | | |
| | | // 计算累计时长 |
| | | 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; |
| | | }; |
| | | |
| | | provide("calculateHours", { calculateHoursDifference }); |
| | | </script> |
| | | |
| | | <style lang="less" scoped> |