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