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 () { data () {
return { return {
searchTime: [], searchTime: ['', ''],
visible: false, visible: false,
intervalTimer: null, intervalTimer: null,
interval: -1, interval: -1,
@@ -146,10 +146,10 @@ export default {
}, },
timeFormate (timeRange) { timeFormate (timeRange) {
if (timeRange && timeRange.length < 2) { if (timeRange && timeRange.length < 2) {
return [] return ['', '']
} }
if (!timeRange[0]) { if (!timeRange[0]) {
return [] return ['', '']
} }
const startTime = bus.timeFormate(timeRange[0], this.pickTimer) const startTime = bus.timeFormate(timeRange[0], this.pickTimer)
const endTime = bus.timeFormate(timeRange[1], this.pickTimer) const endTime = bus.timeFormate(timeRange[1], this.pickTimer)

View File

@@ -237,8 +237,9 @@ export default {
this.getUtcStr() this.getUtcStr()
this.getRangeHistoryArr() this.getRangeHistoryArr()
const timeTemp = this.$lodash.cloneDeep(this.searchTime) const timeTemp = this.$lodash.cloneDeep(this.searchTime)
this.oldSearchTime[0] = timeTemp[0] console.log(this.searchTime)
this.oldSearchTime[1] = timeTemp[1] this.oldSearchTime[0] = timeTemp[0] || ''
this.oldSearchTime[1] = timeTemp[1] || ''
// 监听dateFormat变化 改变日期格式 // 监听dateFormat变化 改变日期格式
window.addEventListener('storage', this.watchDateFormat) window.addEventListener('storage', this.watchDateFormat)
}, },
@@ -606,7 +607,7 @@ export default {
} }
} }
if (this.showEmpty && this.defaultPick === 12) { if (this.showEmpty && this.defaultPick === 12) {
this.searchTime = [] this.searchTime = ['', '']
} }
} }
} }

View File

@@ -408,7 +408,7 @@ export default {
isError: false, isError: false,
defaultPick: 10, defaultPick: 10,
defaultPickType: 'date', defaultPickType: 'date',
defaultPickVal: 7, defaultPickVal: 7
} }
}, },
computed: { computed: {
@@ -452,19 +452,16 @@ export default {
}, },
methods: { methods: {
renderDefaultParams () { renderDefaultParams () {
if (sessionStorage.getItem('nz-reload') == 1) { sessionStorage.setItem('nz-reload', 0)
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
}
const q = JSON.parse(this.$route.query.body) const q = JSON.parse(this.$route.query.body)
this.state = q.state this.state = q.state
this.searchTime[0] = q.startAt ? this.momentTz(q.startAt) : '' this.searchTime[0] = q.startAt ? this.momentTz(q.startAt) : ''
this.searchTime[1] = q.endAt ? this.momentTz(q.endAt) : '' this.searchTime[1] = q.endAt ? this.momentTz(q.endAt) : ''
this.searchTime[2] = q.timeType this.searchTime[2] = q.timeType
if (!q.startAt) { if (!q.startAt && !q.timeType) {
this.searchTime[2] = 'all' this.searchTime = ['', '', 'all']
} else if (q.timeType === 'all') {
this.searchTime = ['', '', 'all']
} }
switch (this.searchTime[2]) { switch (this.searchTime[2]) {
case '5m' : case '5m' :
@@ -922,10 +919,16 @@ export default {
...this.searchLabel ...this.searchLabel
} }
const path = this.fromRoute.alertMessage const path = this.fromRoute.alertMessage
const routePathParams = this.$lodash.cloneDeep(param) const routePathParams = JSON.parse(JSON.stringify(param))
delete routePathParams.statistics delete routePathParams.statistics
routePathParams.body.startAt = this.searchTime[0] ? this.momentStrToTimestamp(this.searchTime[0]) : '' console.log(this.searchTime[2])
routePathParams.body.endAt = this.searchTime[1] ? this.momentStrToTimestamp(this.searchTime[1]) : '' 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.timeType = this.searchTime[2]
routePathParams.body = JSON.stringify(routePathParams.body) routePathParams.body = JSON.stringify(routePathParams.body)
this.updatePath(routePathParams, path) this.updatePath(routePathParams, path)