diff --git a/nezha-fronted/src/components/common/bottomBox/tabs/dashboardTab.vue b/nezha-fronted/src/components/common/bottomBox/tabs/dashboardTab.vue
index 903caadc0..ca73f23bc 100644
--- a/nezha-fronted/src/components/common/bottomBox/tabs/dashboardTab.vue
+++ b/nezha-fronted/src/components/common/bottomBox/tabs/dashboardTab.vue
@@ -878,7 +878,7 @@ export default {
})
},
setTimePickerRange () {
- if (!this.timePickerRange.nowTimeType) {
+ if (!this.timePickerLocked || !this.timePickerRange.nowTimeType) {
this.setDefaultTimeRange()
}
const nowTimeType = this.nowTimeType = this.timePickerRange.nowTimeType
diff --git a/nezha-fronted/src/components/common/bottomBox/tabs/logBottomTab.vue b/nezha-fronted/src/components/common/bottomBox/tabs/logBottomTab.vue
index e24178ad2..1a7aeb9b7 100644
--- a/nezha-fronted/src/components/common/bottomBox/tabs/logBottomTab.vue
+++ b/nezha-fronted/src/components/common/bottomBox/tabs/logBottomTab.vue
@@ -30,7 +30,7 @@
-
+
{{$t('overall.query')}}
@@ -73,7 +73,16 @@ export default {
matchContent: '',
loading: true,
endpointLoading: false,
- limit: 100
+ limit: 100,
+ nowTimeType: {}
+ }
+ },
+ computed: {
+ timePickerLocked () {
+ return this.$store.getters.getTimePickerLocked
+ },
+ timePickerRange () {
+ return this.$store.getters.getTimePickerRange
}
},
methods: {
@@ -119,8 +128,45 @@ export default {
this.$refs.pickTime && this.$refs.pickTime.$refs.timePicker.refresh()
},
getData () {
+ const nowTimeType = this.$refs.pickTime.$refs.timePicker.nowTimeType
+ this.setSearchTime(nowTimeType.type, nowTimeType.value)
+ this.$store.dispatch('dispatchTimePickerRange', {
+ time: this.searchTime,
+ nowTimeType: this.nowTimeType
+ })
this.queryLogData()
},
+ setTimePickerRange () {
+ if (!this.timePickerLocked || !this.timePickerRange.nowTimeType) {
+ return
+ }
+ const nowTimeType = this.nowTimeType = this.timePickerRange.nowTimeType
+ this.filterTime = this.timePickerRange.time
+ this.$refs.pickTime.$refs.timePicker.setTimeRange(this.nowTimeType, this.filterTime)
+ this.setSearchTime(nowTimeType.type, nowTimeType.value, nowTimeType)
+ },
+ setSearchTime (type, val) { // 设置searchTime
+ if (type === 'minute') {
+ const startTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())).setMinutes(new Date(bus.computeTimezone(new Date().getTime())).getMinutes() - val))
+ const endTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())))
+ this.$set(this.filterTime, 0, startTime)
+ this.$set(this.filterTime, 1, endTime)
+ this.$set(this.filterTime, 2, val + 'm')
+ } else if (type === 'hour') {
+ const startTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())).setHours(new Date(bus.computeTimezone(new Date().getTime())).getHours() - val))
+ const endTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())))
+ this.$set(this.filterTime, 0, startTime)
+ this.$set(this.filterTime, 1, endTime)
+ this.$set(this.filterTime, 2, val + 'h')
+ } else if (type === 'date') {
+ const startTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())).setDate(new Date(bus.computeTimezone(new Date().getTime())).getDate() - val))
+ const endTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())))
+ this.$set(this.filterTime, 0, startTime)
+ this.$set(this.filterTime, 1, endTime)
+ this.$set(this.filterTime, 2, val + 'd')
+ }
+ this.$refs.pickTime.$refs.timePicker.searchTime = this.filterTime
+ },
queryLogData (limit) { // log的chart和table是一个请求
this.loading = true
if (limit) {
@@ -162,6 +208,7 @@ export default {
} else if (this.from === fromRoute.asset) {
this.expressions = [`{asset="${this.obj.name}"}`]
}
+ this.setTimePickerRange()
this.$nextTick(() => {
this.queryLogData()
})
diff --git a/nezha-fronted/src/components/page/dashboard/dashboard.vue b/nezha-fronted/src/components/page/dashboard/dashboard.vue
index c6467e209..6b0a2a47c 100644
--- a/nezha-fronted/src/components/page/dashboard/dashboard.vue
+++ b/nezha-fronted/src/components/page/dashboard/dashboard.vue
@@ -1171,7 +1171,8 @@ export default {
})
},
setTimePickerRange () {
- if (!this.timePickerRange.nowTimeType) {
+ if (this.$route.query.searchTime) return
+ if (!this.timePickerLocked || !this.timePickerRange.nowTimeType) {
this.setDefaultTimeRange()
}
const nowTimeType = this.nowTimeType = this.timePickerRange.nowTimeType
@@ -1202,6 +1203,10 @@ export default {
mode: { target: this, propertyName: 'mode', type: 'string' }
}
this.initQueryFromPath(searchKeys)
+ this.$store.dispatch('dispatchTimePickerRange', {
+ time: this.searchTime,
+ nowTimeType: this.nowTimeType
+ })
this.showPanel.id = this.dashboardId
this.filter.dashboardId = this.dashboardId
// 设置查看模式