diff --git a/nezha-fronted/src/components/chart/panelChart.vue b/nezha-fronted/src/components/chart/panelChart.vue index a0ee60cfc..d5161842d 100644 --- a/nezha-fronted/src/components/chart/panelChart.vue +++ b/nezha-fronted/src/components/chart/panelChart.vue @@ -194,7 +194,7 @@ export default { }, // 参数 isRefresh 标识是否是刷新操作 getChartData (isRefresh, params) { // 获取chart的数据前的准备 主要用于处理时间参数 - if (!this.variablesInit) { // 变量未加载完成 不请求数据 + if (!this.variablesInit || !this.timerInit) { // 变量未加载完成 不请求数据 return } this.chartData = window.dataJson ? this.chartData : [] diff --git a/nezha-fronted/src/components/common/bottomBox/tabs/dashboardTab.vue b/nezha-fronted/src/components/common/bottomBox/tabs/dashboardTab.vue index ca73f23bc..9b245b335 100644 --- a/nezha-fronted/src/components/common/bottomBox/tabs/dashboardTab.vue +++ b/nezha-fronted/src/components/common/bottomBox/tabs/dashboardTab.vue @@ -618,6 +618,10 @@ export default { this.$set(this.searchTime, 2, val + 'd') } this.$refs.pickTime.$refs.timePicker.searchTime = this.searchTime + this.$store.dispatch('dispatchPanelTime', { + time: this.searchTime, + nowTimeType: this.nowTimeType + }) }, getVarType (from) { if (from === this.fromRoute.asset) { @@ -878,13 +882,15 @@ export default { }) }, setTimePickerRange () { - if (!this.timePickerLocked || !this.timePickerRange.nowTimeType) { - this.setDefaultTimeRange() - } - const nowTimeType = this.nowTimeType = this.timePickerRange.nowTimeType - this.searchTime = this.timePickerRange.time - this.$refs.pickTime.$refs.timePicker.setTimeRange(this.nowTimeType, this.searchTime) - this.setSearchTime(nowTimeType.type, nowTimeType.value, nowTimeType) + this.$nextTick(() => { + if (!this.timePickerLocked || !this.timePickerRange.nowTimeType) { + this.setDefaultTimeRange() + } + const nowTimeType = this.nowTimeType = this.timePickerRange.nowTimeType + this.searchTime = this.timePickerRange.time + this.$refs.pickTime && this.$refs.pickTime.$refs.timePicker.setTimeRange(this.nowTimeType, this.searchTime) + this.setSearchTime(nowTimeType.type, nowTimeType.value, nowTimeType) + }) }, // 设置默认刷新 setDefaultRefresh () { diff --git a/nezha-fronted/src/components/common/bottomBox/tabs/logBottomTab.vue b/nezha-fronted/src/components/common/bottomBox/tabs/logBottomTab.vue index 1a7aeb9b7..9cc2e7edb 100644 --- a/nezha-fronted/src/components/common/bottomBox/tabs/logBottomTab.vue +++ b/nezha-fronted/src/components/common/bottomBox/tabs/logBottomTab.vue @@ -137,13 +137,15 @@ export default { 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) + this.$nextTick(() => { + if (!this.timePickerLocked || !this.timePickerRange.nowTimeType) { + return + } + const nowTimeType = this.nowTimeType = this.timePickerRange.nowTimeType + this.filterTime = this.timePickerRange.time + this.$refs.pickTime && this.$refs.pickTime.$refs.timePicker.setTimeRange(this.nowTimeType, this.filterTime) + this.setSearchTime(nowTimeType.type, nowTimeType.value, nowTimeType) + }) }, setSearchTime (type, val) { // 设置searchTime if (type === 'minute') { diff --git a/nezha-fronted/src/components/common/timePicker.vue b/nezha-fronted/src/components/common/timePicker.vue index 992170925..e59f6e609 100644 --- a/nezha-fronted/src/components/common/timePicker.vue +++ b/nezha-fronted/src/components/common/timePicker.vue @@ -28,7 +28,7 @@