NEZ-3289 fix: 修改浏览器刷新 不清空所有参数 只更新时间参数

This commit is contained in:
zhangyu
2023-10-30 10:58:51 +08:00
parent 245cef19b8
commit 2639604e43
3 changed files with 22 additions and 18 deletions

View File

@@ -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)

View File

@@ -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 = ['', '']
}
}
}

View File

@@ -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)