From 2639604e438b8e33964a871d6b4b69a97728eb85 Mon Sep 17 00:00:00 2001 From: zhangyu Date: Mon, 30 Oct 2023 10:58:51 +0800 Subject: [PATCH] =?UTF-8?q?NEZ-3289=20=20fix=EF=BC=9A=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=B5=8F=E8=A7=88=E5=99=A8=E5=88=B7=E6=96=B0=20=E4=B8=8D?= =?UTF-8?q?=E6=B8=85=E7=A9=BA=E6=89=80=E6=9C=89=E5=8F=82=E6=95=B0=20?= =?UTF-8?q?=E5=8F=AA=E6=9B=B4=E6=96=B0=E6=97=B6=E9=97=B4=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/common/pickTime.vue | 6 ++--- .../src/components/common/timePicker.vue | 7 ++--- .../components/page/alert/alertMessage.vue | 27 ++++++++++--------- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/nezha-fronted/src/components/common/pickTime.vue b/nezha-fronted/src/components/common/pickTime.vue index dad9eb56c..4da1b1b0e 100644 --- a/nezha-fronted/src/components/common/pickTime.vue +++ b/nezha-fronted/src/components/common/pickTime.vue @@ -76,7 +76,7 @@ export default { }, data () { return { - searchTime: [], + searchTime: ['', ''], visible: false, intervalTimer: null, interval: -1, @@ -146,10 +146,10 @@ export default { }, timeFormate (timeRange) { if (timeRange && timeRange.length < 2) { - return [] + return ['', ''] } if (!timeRange[0]) { - return [] + return ['', ''] } const startTime = bus.timeFormate(timeRange[0], this.pickTimer) const endTime = bus.timeFormate(timeRange[1], this.pickTimer) diff --git a/nezha-fronted/src/components/common/timePicker.vue b/nezha-fronted/src/components/common/timePicker.vue index 9c099b0b2..9feb9b291 100644 --- a/nezha-fronted/src/components/common/timePicker.vue +++ b/nezha-fronted/src/components/common/timePicker.vue @@ -237,8 +237,9 @@ export default { this.getUtcStr() this.getRangeHistoryArr() const timeTemp = this.$lodash.cloneDeep(this.searchTime) - this.oldSearchTime[0] = timeTemp[0] - this.oldSearchTime[1] = timeTemp[1] + console.log(this.searchTime) + this.oldSearchTime[0] = timeTemp[0] || '' + this.oldSearchTime[1] = timeTemp[1] || '' // 监听dateFormat变化 改变日期格式 window.addEventListener('storage', this.watchDateFormat) }, @@ -606,7 +607,7 @@ export default { } } if (this.showEmpty && this.defaultPick === 12) { - this.searchTime = [] + this.searchTime = ['', ''] } } } diff --git a/nezha-fronted/src/components/page/alert/alertMessage.vue b/nezha-fronted/src/components/page/alert/alertMessage.vue index 015ef7b73..42a8f3e9d 100644 --- a/nezha-fronted/src/components/page/alert/alertMessage.vue +++ b/nezha-fronted/src/components/page/alert/alertMessage.vue @@ -408,7 +408,7 @@ export default { isError: false, defaultPick: 10, defaultPickType: 'date', - defaultPickVal: 7, + defaultPickVal: 7 } }, computed: { @@ -452,19 +452,16 @@ export default { }, methods: { renderDefaultParams () { - if (sessionStorage.getItem('nz-reload') == 1) { - this.searchTime = [bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())).setHours(new Date(bus.computeTimezone(new Date().getTime())).getHours() - 24 * 7)), bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime()))), '7d'] - this.searchLabel = {} - sessionStorage.setItem('nz-reload', 0) - return - } + sessionStorage.setItem('nz-reload', 0) const q = JSON.parse(this.$route.query.body) this.state = q.state this.searchTime[0] = q.startAt ? this.momentTz(q.startAt) : '' this.searchTime[1] = q.endAt ? this.momentTz(q.endAt) : '' this.searchTime[2] = q.timeType - if (!q.startAt) { - this.searchTime[2] = 'all' + if (!q.startAt && !q.timeType) { + this.searchTime = ['', '', 'all'] + } else if (q.timeType === 'all') { + this.searchTime = ['', '', 'all'] } switch (this.searchTime[2]) { case '5m' : @@ -922,10 +919,16 @@ export default { ...this.searchLabel } const path = this.fromRoute.alertMessage - const routePathParams = this.$lodash.cloneDeep(param) + const routePathParams = JSON.parse(JSON.stringify(param)) delete routePathParams.statistics - routePathParams.body.startAt = this.searchTime[0] ? this.momentStrToTimestamp(this.searchTime[0]) : '' - routePathParams.body.endAt = this.searchTime[1] ? this.momentStrToTimestamp(this.searchTime[1]) : '' + console.log(this.searchTime[2]) + if (!this.searchTime[2]) { + routePathParams.body.startAt = this.searchTime[0] ? this.momentStrToTimestamp(this.searchTime[0]) : '' + routePathParams.body.endAt = this.searchTime[1] ? this.momentStrToTimestamp(this.searchTime[1]) : '' + } else { + delete routePathParams.body.startAt + delete routePathParams.body.endAt + } routePathParams.body.timeType = this.searchTime[2] routePathParams.body = JSON.stringify(routePathParams.body) this.updatePath(routePathParams, path)