diff --git a/src/components/Graph.vue b/src/components/Graph.vue index 5007305f..add9083b 100644 --- a/src/components/Graph.vue +++ b/src/components/Graph.vue @@ -49,12 +49,16 @@ import type { PropType } from "vue"; import { useI18n } from "vue-i18n"; import { EventParams } from "@/types/app"; import { useECharts } from "@/hooks/useEcharts"; +import { useAppStoreWithOut } from "@/store/modules/app"; import { addResizeListener, removeResizeListener } from "@/utils/event"; import Trace from "@/views/dashboard/controls/Trace.vue"; +import dateFormatStep from "@/utils/dateFormat"; +import getLocalTime from "@/utils/localtime"; /*global Nullable, defineProps, defineEmits*/ const emits = defineEmits(["select"]); const { t } = useI18n(); +const appStore = useAppStoreWithOut(); const chartRef = ref>(null); const menus = ref>(null); const visMenus = ref(false); @@ -156,8 +160,27 @@ function updateOptions() { } function viewTrace() { - console.log(currentParams.value); - const item = {}; + if (!currentParams.value) { + return; + } + const start = appStore.intervalUnix[currentParams.value.dataIndex]; + const end = start; + const { step } = appStore.durationRow; + const item = { + duration: { + start: dateFormatStep( + getLocalTime(appStore.utc, new Date(start)), + step, + true + ), + end: dateFormatStep( + getLocalTime(appStore.utc, new Date(end)), + step, + true + ), + step, + }, + }; traceOptions.value = { ...traceOptions.value, filters: item, diff --git a/src/store/modules/app.ts b/src/store/modules/app.ts index d5cc441f..3e17052f 100644 --- a/src/store/modules/app.ts +++ b/src/store/modules/app.ts @@ -71,7 +71,7 @@ export const appStore = defineStore({ step: this.duration.step, }; }, - intervalTime(): string[] { + intervalUnix(): number[] { let interval = 946080000000; switch (this.duration.step) { case "MINUTE": @@ -97,12 +97,17 @@ export const appStore = defineStore({ this.utcMin * 60000; const startUnix: number = this.duration.start.getTime(); const endUnix: number = this.duration.end.getTime(); - const timeIntervals: string[] = []; + const timeIntervals: number[] = []; for (let i = 0; i <= endUnix - startUnix; i += interval) { - const temp: string = dateFormatTime( - new Date(startUnix + i - utcSpace), - this.duration.step - ); + timeIntervals.push(startUnix + i - utcSpace); + } + return timeIntervals; + }, + intervalTime(): string[] { + const arr = this.intervalUnix; + const timeIntervals: string[] = []; + for (const item of arr) { + const temp: string = dateFormatTime(new Date(item), this.duration.step); timeIntervals.push(temp); } return timeIntervals; diff --git a/src/types/app.d.ts b/src/types/app.d.ts index d2001fda..e22444fd 100644 --- a/src/types/app.d.ts +++ b/src/types/app.d.ts @@ -45,4 +45,5 @@ export type EventParams = { value: number | Array; color: string; event: any; + dataIndex: number; };