NEZ-3289 fix: alertMessage 刷新时 清空路由参数

This commit is contained in:
zhangyu
2023-10-27 19:14:12 +08:00
parent 6bf3e6bc9d
commit 245cef19b8
2 changed files with 73 additions and 4 deletions

View File

@@ -406,7 +406,9 @@ export default {
], ],
errorContent: '', errorContent: '',
isError: false, isError: false,
defaultPick: 10 defaultPick: 10,
defaultPickType: 'date',
defaultPickVal: 7,
} }
}, },
computed: { computed: {
@@ -450,6 +452,12 @@ export default {
}, },
methods: { methods: {
renderDefaultParams () { 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
}
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) : ''
@@ -461,46 +469,74 @@ export default {
switch (this.searchTime[2]) { switch (this.searchTime[2]) {
case '5m' : case '5m' :
this.defaultPick = 1 this.defaultPick = 1
this.defaultPickType = 'minute'
this.defaultPickVal = 5
break break
case '15m' : case '15m' :
this.defaultPick = 2 this.defaultPick = 2
this.defaultPickType = 'minute'
this.defaultPickVal = 15
break break
case '30m' : case '30m' :
this.defaultPick = 3 this.defaultPick = 3
this.defaultPickType = 'minute'
this.defaultPickVal = 30
break break
case '1h' : case '1h' :
this.defaultPick = 4 this.defaultPick = 4
this.defaultPickType = 'hour'
this.defaultPickVal = 1
break break
case '3h' : case '3h' :
this.defaultPick = 5 this.defaultPick = 5
this.defaultPickType = 'hour'
this.defaultPickVal = 3
break break
case '6h' : case '6h' :
this.defaultPick = 6 this.defaultPick = 6
this.defaultPickType = 'hour'
this.defaultPickVal = 6
break break
case '12h' : case '12h' :
this.defaultPick = 7 this.defaultPick = 7
this.defaultPickType = 'hour'
this.defaultPickVal = 12
break break
case '1d' : // case '1d' :
this.defaultPick = 8 // this.defaultPick = 8
break // this.defaultPickType = 'hour'
// break
case '24h' : case '24h' :
this.defaultPick = 8 this.defaultPick = 8
this.defaultPickType = 'hour'
this.defaultPickVal = 24
break break
case '2d' : case '2d' :
this.defaultPick = 9 this.defaultPick = 9
this.defaultPickType = 'date'
this.defaultPickVal = 2
break break
case '7d' : case '7d' :
this.defaultPick = 10 this.defaultPick = 10
this.defaultPickType = 'date'
this.defaultPickVal = 7
break break
case '30d' : case '30d' :
this.defaultPick = 11 this.defaultPick = 11
this.defaultPickType = 'date'
this.defaultPickVal = 30
break break
case 'all' : case 'all' :
this.defaultPick = 12 this.defaultPick = 12
this.defaultPickType = 'all'
this.defaultPickVal = 'all'
break break
default: default:
this.defaultPick = 0 this.defaultPick = 0
} }
if (this.defaultPick && this.defaultPick !== 12) {
this.setDefaultSearchTime('')
}
// this.defaultPick = 11 // this.defaultPick = 11
}, },
batchAck () { batchAck () {
@@ -825,6 +861,30 @@ export default {
this.setSearchTime('searchTime') this.setSearchTime('searchTime')
this.getTableData() this.getTableData()
}, },
setDefaultSearchTime () {
const type = this.defaultPickType
const val = this.defaultPickVal
const key = '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))
const endTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())))
this.$set(this[key], 0, startTime)
this.$set(this[key], 1, endTime)
this.$set(this[key], 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))
const endTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())))
this.$set(this[key], 0, startTime)
this.$set(this[key], 1, endTime)
this.$set(this[key], 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))
const endTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())))
this.$set(this[key], 0, startTime)
this.$set(this[key], 1, endTime)
this.$set(this[key], 2, val + 'd')
}
},
getTableData (state) { getTableData (state) {
if (state) { if (state) {
this.state = state this.state = state
@@ -873,6 +933,7 @@ export default {
...this.searchLabel, ...this.searchLabel,
body: encodeURIComponent(JSON.stringify(this.searchLabel.body)) body: encodeURIComponent(JSON.stringify(this.searchLabel.body))
} }
console.log(this.searchLabel.body)
this.$get('/alert/message/query', { ...queryParams }).then(response => { this.$get('/alert/message/query', { ...queryParams }).then(response => {
this.tools.loading = false this.tools.loading = false
if (response.code == 200) { if (response.code == 200) {

View File

@@ -39,6 +39,14 @@ export default {
if (window.outerWidth <= defaultWindowWidth) { // outerWidth 获取设备宽度 if (window.outerWidth <= defaultWindowWidth) { // outerWidth 获取设备宽度
document.querySelector('meta[name=viewport]').setAttribute('content', `width=device-width, initial-scale=${window.outerWidth / (defaultWindowWidth * window.devicePixelRatio)}, maximum-scale=1.0, user-scalable=0`) document.querySelector('meta[name=viewport]').setAttribute('content', `width=device-width, initial-scale=${window.outerWidth / (defaultWindowWidth * window.devicePixelRatio)}, maximum-scale=1.0, user-scalable=0`)
} }
window.addEventListener('unload', this.clearUrl)
},
methods: {
clearUrl () {
sessionStorage.setItem('nz-reload', 1)
}
},
beforeDestroy () {
} }
} }
</script> </script>