From 97e1a263d2ac7844ff06c09ed2cee57c82d80307 Mon Sep 17 00:00:00 2001 From: zhangyu Date: Tue, 9 Nov 2021 15:11:20 +0800 Subject: [PATCH] =?UTF-8?q?NEZ-1207=20fix=EF=BC=9A=20=E5=85=A8=E5=B1=8F?= =?UTF-8?q?=E5=90=8E=E8=87=AA=E5=8A=A8=E5=88=B7=E6=96=B0=E6=8C=89=E9=92=AE?= =?UTF-8?q?=E6=97=A0=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/charts/line-chart-block.vue | 26 +++++++++++++++++++ .../src/components/common/pickTime.vue | 1 - 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/nezha-fronted/src/components/charts/line-chart-block.vue b/nezha-fronted/src/components/charts/line-chart-block.vue index 42e0280a6..f938e07fe 100644 --- a/nezha-fronted/src/components/charts/line-chart-block.vue +++ b/nezha-fronted/src/components/charts/line-chart-block.vue @@ -1534,8 +1534,12 @@ export default { this.$emit('on-duplicate-chart-block', this.data.id) }, dateChange (time) { + const nowTimeType = this.$refs.pickTime.$refs.timePicker.nowTimeType + this.setSearchTime(nowTimeType.type, nowTimeType.value, nowTimeType) this.filter.start_time = bus.timeFormate(this.searchTime[0], 'yyyy-MM-dd hh:mm:ss') this.filter.end_time = bus.timeFormate(this.searchTime[1], 'yyyy-MM-dd hh:mm:ss') + this.filter.value = this.searchTime[2] + this.filter.id = this.$refs.pickTime.$refs.timePicker.showTime.id // this.echartModalStore.clear() this.showLegend = false this.$refs['localLoadingScreen' + this.chartIndex].startLoading() @@ -1545,6 +1549,28 @@ export default { this.getQueryChart('dashboard') } }, + setSearchTime (type, val, nowTimeType) { // 设置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), 'yyyy-MM-dd hh:mm:ss') + const endTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())), 'yyyy-MM-dd hh:mm:ss') + this.$set(this.searchTime, 0, startTime) + this.$set(this.searchTime, 1, endTime) + this.$set(this.searchTime, 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), 'yyyy-MM-dd hh:mm:ss') + const endTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())), 'yyyy-MM-dd hh:mm:ss') + this.$set(this.searchTime, 0, startTime) + this.$set(this.searchTime, 1, endTime) + this.$set(this.searchTime, 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), 'yyyy-MM-dd hh:mm:ss') + const endTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())), 'yyyy-MM-dd hh:mm:ss') + this.$set(this.searchTime, 0, startTime) + this.$set(this.searchTime, 1, endTime) + this.$set(this.searchTime, 2, val + 'd') + } + this.$refs.pickTime.$refs.timePicker.searchTime = this.searchTime + }, // 查询数据,修改日期查询全屏数据 getQueryChart (type) { /* diff --git a/nezha-fronted/src/components/common/pickTime.vue b/nezha-fronted/src/components/common/pickTime.vue index 6551f1a49..1ff8dba1c 100644 --- a/nezha-fronted/src/components/common/pickTime.vue +++ b/nezha-fronted/src/components/common/pickTime.vue @@ -38,7 +38,6 @@ import bus from '../../libs/bus' import timePicker from './timePicker' import multipleTime from './multipleTime' import chartUnit from './chartUnit' -let timeout export default { name: 'pickTime', components: {