NEZ-1832 f ix:修改asset logs 二级页面 时间参数错误

This commit is contained in:
zhangyu
2022-04-22 10:04:59 +08:00
parent bd1b87a601
commit ca432d5962
3 changed files with 50 additions and 46 deletions

View File

@@ -61,8 +61,8 @@ export default {
return { return {
logData: null, logData: null,
filterTime: [ filterTime: [
bus.timeFormate(bus.getOffsetTimezoneData(-1), this.timeFormatMain), bus.timeFormate(bus.getOffsetTimezoneData(-1)),
bus.timeFormate(bus.getOffsetTimezoneData(), this.timeFormatMain) bus.timeFormate(bus.getOffsetTimezoneData())
], ],
expressions: [''], expressions: [''],
matchSymbol: '|=', matchSymbol: '|=',
@@ -75,8 +75,8 @@ export default {
exportLog ({ limit, descending }) { exportLog ({ limit, descending }) {
const params = { const params = {
logql: this.expressions, logql: this.expressions,
start: this.$stringTimeParseToUnix(this.filterTime[0]), start: this.$stringTimeParseToUnix(bus.formateTimeToTime(this.filterTime[0])),
end: this.$stringTimeParseToUnix(this.filterTime[1]), end: this.$stringTimeParseToUnix(bus.formateTimeToTime(this.filterTime[1])),
direction: descending ? 'backward' : 'forward', direction: descending ? 'backward' : 'forward',
limit limit
} }
@@ -118,7 +118,9 @@ export default {
if (item != '') { if (item != '') {
let expr = item let expr = item
this.matchContent && (expr = `${item} ${this.matchSymbol} "${this.matchContent}"`) this.matchContent && (expr = `${item} ${this.matchSymbol} "${this.matchContent}"`)
requestArr.push(this.$get('/logs/loki/api/v1/query_range?format=1&query=' + encodeURIComponent(expr) + '&start=' + this.$stringTimeParseToUnix(this.filterTime[0]) + '&end=' + this.$stringTimeParseToUnix(this.filterTime[1]) + '&limit=' + limit)) const statTime = bus.formateTimeToTime(this.filterTime[0])
const endTime = bus.formateTimeToTime(this.filterTime[1])
requestArr.push(this.$get('/logs/loki/api/v1/query_range?format=1&query=' + encodeURIComponent(expr) + '&start=' + this.$stringTimeParseToUnix(statTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&limit=' + limit))
} }
}) })
axios.all(requestArr).then(res => { axios.all(requestArr).then(res => {

View File

@@ -289,8 +289,8 @@ export default {
this.getData(this.filter) this.getData(this.filter)
}, },
refreshTime (st, et) { refreshTime (st, et) {
const startTime = bus.timeFormate(st, 'yyyy-MM-dd hh:mm') const startTime = bus.timeFormate(st)
const endTime = bus.timeFormate(et, 'yyyy-MM-dd hh:mm') const endTime = bus.timeFormate(et)
this.searchTime = [startTime, endTime] this.searchTime = [startTime, endTime]
}, },
panelReloadForDel () { panelReloadForDel () {
@@ -494,9 +494,10 @@ export default {
if (this.$refs.pickTime) { if (this.$refs.pickTime) {
const nowTimeType = this.$refs.pickTime.$refs.timePicker.nowTimeType const nowTimeType = this.$refs.pickTime.$refs.timePicker.nowTimeType
this.nowTimeType = this.$refs.pickTime.$refs.timePicker.nowTimeType this.nowTimeType = this.$refs.pickTime.$refs.timePicker.nowTimeType
console.log(nowTimeType, this.nowTimeType)
this.setSearchTime(nowTimeType.type, nowTimeType.value) this.setSearchTime(nowTimeType.type, nowTimeType.value)
this.filter.start_time = bus.timeFormate(this.searchTime[0], 'YYYY-MM-DD HH:mm:ss') this.filter.start_time = bus.timeFormate(this.searchTime[0])
this.filter.end_time = bus.timeFormate(this.searchTime[1], 'YYYY-MM-DD HH:mm:ss') this.filter.end_time = bus.timeFormate(this.searchTime[1])
this.filter.panelId = this.showPanel.id this.filter.panelId = this.showPanel.id
this.getData(this.filter) this.getData(this.filter)
this.$store.dispatch('dispatchPanelTime', { this.$store.dispatch('dispatchPanelTime', {
@@ -508,20 +509,21 @@ export default {
/* 时间条件查询--end */ /* 时间条件查询--end */
setSearchTime (type, val) { // 设置searchTime setSearchTime (type, val) { // 设置searchTime
if (type === 'minute') { if (type === 'minute') {
const startTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())).setMinutes(new Date(bus.computeTimezone(new Date().getTime())).getMinutes() - val), 'YYYY-MM-DD HH:mm:ss') 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())), 'YYYY-MM-DD HH:mm:ss') const endTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())))
this.$set(this.searchTime, 0, startTime) this.$set(this.searchTime, 0, startTime)
this.$set(this.searchTime, 1, endTime) this.$set(this.searchTime, 1, endTime)
this.$set(this.searchTime, 2, val + 'm') this.$set(this.searchTime, 2, val + 'm')
} else if (type === 'hour') { } 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), 'YYYY-MM-DD HH:mm:ss') 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())), 'YYYY-MM-DD HH:mm:ss') const endTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())))
this.$set(this.searchTime, 0, startTime) this.$set(this.searchTime, 0, startTime)
this.$set(this.searchTime, 1, endTime) this.$set(this.searchTime, 1, endTime)
this.$set(this.searchTime, 2, val + 'h') this.$set(this.searchTime, 2, val + 'h')
console.log(this.searchTime)
} else if (type === 'date') { } 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), 'YYYY-MM-DD HH:mm:ss') 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())), 'YYYY-MM-DD HH:mm:ss') const endTime = bus.timeFormate(new Date(bus.computeTimezone(new Date().getTime())))
this.$set(this.searchTime, 0, startTime) this.$set(this.searchTime, 0, startTime)
this.$set(this.searchTime, 1, endTime) this.$set(this.searchTime, 1, endTime)
this.$set(this.searchTime, 2, val + 'd') this.$set(this.searchTime, 2, val + 'd')

View File

@@ -255,7 +255,7 @@ export default {
this.getRangeHistoryArr() this.getRangeHistoryArr()
}, },
methods: { methods: {
changeDropdownFlag(){ changeDropdownFlag () {
if (this.dropdownFlag) { if (this.dropdownFlag) {
this.dropdownFlag = false this.dropdownFlag = false
} }
@@ -269,27 +269,27 @@ export default {
}, },
myDatePickerShow (item) { myDatePickerShow (item) {
this.whoChoose = item this.whoChoose = item
this.isCustom = true this.isCustom = true
this.$refs.calendar.focus() this.$refs.calendar.focus()
this.$refs.calendar.pickerVisible = true this.$refs.calendar.pickerVisible = true
if (document.getElementById('viewGraphDialog')) { if (document.getElementById('viewGraphDialog')) {
// 处理 多弹出的z-index的问题 当前为 alertMessage的处理 // 处理 多弹出的z-index的问题 当前为 alertMessage的处理
const viewGraphDialogStyle = window.getComputedStyle( const viewGraphDialogStyle = window.getComputedStyle(
document.getElementById('viewGraphDialog', null) document.getElementById('viewGraphDialog', null)
) )
setTimeout(() => { setTimeout(() => {
if (viewGraphDialogStyle['z-index'] !== 'auto') { if (viewGraphDialogStyle['z-index'] !== 'auto') {
const dom = const dom =
document.getElementsByClassName('el-picker-panel') document.getElementsByClassName('el-picker-panel')
Array.prototype.forEach.call(dom, function (element) { Array.prototype.forEach.call(dom, function (element) {
element.style['z-index'] = element.style['z-index'] =
viewGraphDialogStyle['z-index'] + 1 viewGraphDialogStyle['z-index'] + 1
}) })
this.$refs.calendar.$el.style['z-index'] = this.$refs.calendar.$el.style['z-index'] =
viewGraphDialogStyle['z-index'] + 1 viewGraphDialogStyle['z-index'] + 1
} }
}) })
} }
}, },
historyChange (item) { historyChange (item) {
this.searchTime[0] = item.start this.searchTime[0] = item.start
@@ -389,27 +389,27 @@ export default {
// } // }
// this.$set(this.searchTime, 0, bus.timeFormate(time[0])) // this.$set(this.searchTime, 0, bus.timeFormate(time[0]))
// this.$set(this.searchTime, 1, bus.timeFormate(time[1])) // this.$set(this.searchTime, 1, bus.timeFormate(time[1]))
this.$set(this.searchTime, 0, bus.timeFormate(timeGroup.start_time)); this.$set(this.searchTime, 0, bus.timeFormate(timeGroup.start_time))
this.$set(this.searchTime, 1, bus.timeFormate(timeGroup.end_time)); this.$set(this.searchTime, 1, bus.timeFormate(timeGroup.end_time))
this.showTime = this.nowTimeType = { this.showTime = this.nowTimeType = {
id: 4, id: 4,
text: this.$t("dashboard.panel.lastOneHour"), text: this.$t('dashboard.panel.lastOneHour'),
type: "hour", type: 'hour',
value: 1, value: 1
}; }
const time = bus.getTimezontDateRange(); const time = bus.getTimezontDateRange()
if (timeGroup.start_time) { if (timeGroup.start_time) {
this.$set( this.$set(
this.searchTime, this.searchTime,
0, 0,
bus.timeFormate(timeGroup.start_time) bus.timeFormate(timeGroup.start_time)
); )
this.$set(this.searchTime, 1, bus.timeFormate(timeGroup.end_time)); this.$set(this.searchTime, 1, bus.timeFormate(timeGroup.end_time))
} else { } else {
this.$set(this.searchTime, 0, bus.timeFormate(time[0])); this.$set(this.searchTime, 0, bus.timeFormate(time[0]))
this.$set(this.searchTime, 1, bus.timeFormate(time[1])); this.$set(this.searchTime, 1, bus.timeFormate(time[1]))
} }
this.$set(this.searchTime, 0, bus.timeFormate(time[0])); this.$set(this.searchTime, 0, bus.timeFormate(time[0]))
} }
} else { } else {
this.showTime = this.nowTimeType = { this.showTime = this.nowTimeType = {
@@ -463,7 +463,7 @@ export default {
} }
} }
} else { } else {
this.isCustom = false; this.isCustom = false
this.showDropdown() this.showDropdown()
if (this.showEmpty && id === 12) { if (this.showEmpty && id === 12) {
this.searchTime = [] this.searchTime = []