NEZ-3005 fix:APM Explorer的query按钮不能自动更新Relative Time Range

This commit is contained in:
zhangyu
2023-07-21 10:31:56 +08:00
parent 45abd4ac95
commit 84aaaf4db7
7 changed files with 42 additions and 1 deletions

View File

@@ -531,6 +531,7 @@ export default {
}) })
}, },
getAlertList () { getAlertList () {
this.setSearchTime('searchTime')
this.tableData = [] this.tableData = []
this.loading = true this.loading = true
this.$set(this.searchLabel, 'pageNo', this.pageObj.pageNo) this.$set(this.searchLabel, 'pageNo', this.pageObj.pageNo)

View File

@@ -382,6 +382,7 @@ export default {
}) })
}, },
dateChange () { dateChange () {
this.setSearchTime('searchTimeHeader')
this.getTableData() this.getTableData()
}, },
getTableData (state) { getTableData (state) {

View File

@@ -431,6 +431,7 @@ export default {
}) })
}, },
queryChartDate () { queryChartDate () {
this.setSearchTime('searchTime')
const start = this.searchTime[0] ? this.searchTime[0] : this.getTime(-1, 'h') const start = this.searchTime[0] ? this.searchTime[0] : this.getTime(-1, 'h')
const end = this.searchTime[1] ? this.searchTime[1] : this.getTime(0, 'h') const end = this.searchTime[1] ? this.searchTime[1] : this.getTime(0, 'h')
this.searchTime = [start, end] this.searchTime = [start, end]

View File

@@ -152,6 +152,38 @@ export default {
} }
return aliasExpression return aliasExpression
} }
},
/* 时间条件查询--end */
setSearchTime (key, cb) { // 设置searchTime
if (this.$refs.pickTime) {
const nowTimeType = this.$refs.pickTime.$refs.timePicker.nowTimeType
this.nowTimeType = this.$refs.pickTime.$refs.timePicker.nowTimeType
const type = nowTimeType.type
const val = nowTimeType.value
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')
}
this.$refs.pickTime.$refs.timePicker.searchTime = this[key]
}
if (cb) {
this.cb()
}
} }
} }
} }

View File

@@ -881,6 +881,7 @@ export default {
}, },
dateChange () { dateChange () {
this.setSearchTime('searchTime')
this.getTableData() this.getTableData()
}, },
getTableData (state) { getTableData (state) {

View File

@@ -3988,6 +3988,11 @@ export default {
} }
}, },
expressionChange () { expressionChange () {
if (this.$refs.pickTime) {
const nowTimeType = this.$refs.pickTime.$refs.timePicker.nowTimeType
this.nowTimeType = this.$refs.pickTime.$refs.timePicker.nowTimeType
this.setSearchTime(nowTimeType.type, nowTimeType.value)
}
if (this.expressions && this.expressions.length >= 1) { if (this.expressions && this.expressions.length >= 1) {
if (this.showMetrics) { if (this.showMetrics) {
this.queryTableData() this.queryTableData()

View File

@@ -1,7 +1,7 @@
const timePicker = { const timePicker = {
state: { state: {
timePickerLocked: localStorage.getItem('nz-time-picker-locked') ? JSON.parse(localStorage.getItem('nz-time-picker-locked')) : false, timePickerLocked: localStorage.getItem('nz-time-picker-locked') ? JSON.parse(localStorage.getItem('nz-time-picker-locked')) : false,
timePickerRange: localStorage.getItem('nz-time-picker-range') ? JSON.parse(localStorage.getItem('nz-time-picker-range')) : {}, timePickerRange: localStorage.getItem('nz-time-picker-range') ? JSON.parse(localStorage.getItem('nz-time-picker-range')) : {}
}, },
mutations: { mutations: {
setTimePickerLocked (state, flag) { setTimePickerLocked (state, flag) {