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 {
logData: null,
filterTime: [
bus.timeFormate(bus.getOffsetTimezoneData(-1), this.timeFormatMain),
bus.timeFormate(bus.getOffsetTimezoneData(), this.timeFormatMain)
bus.timeFormate(bus.getOffsetTimezoneData(-1)),
bus.timeFormate(bus.getOffsetTimezoneData())
],
expressions: [''],
matchSymbol: '|=',
@@ -75,8 +75,8 @@ export default {
exportLog ({ limit, descending }) {
const params = {
logql: this.expressions,
start: this.$stringTimeParseToUnix(this.filterTime[0]),
end: this.$stringTimeParseToUnix(this.filterTime[1]),
start: this.$stringTimeParseToUnix(bus.formateTimeToTime(this.filterTime[0])),
end: this.$stringTimeParseToUnix(bus.formateTimeToTime(this.filterTime[1])),
direction: descending ? 'backward' : 'forward',
limit
}
@@ -118,7 +118,9 @@ export default {
if (item != '') {
let expr = item
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 => {

View File

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

View File

@@ -255,7 +255,7 @@ export default {
this.getRangeHistoryArr()
},
methods: {
changeDropdownFlag(){
changeDropdownFlag () {
if (this.dropdownFlag) {
this.dropdownFlag = false
}
@@ -389,27 +389,27 @@ export default {
// }
// this.$set(this.searchTime, 0, bus.timeFormate(time[0]))
// this.$set(this.searchTime, 1, bus.timeFormate(time[1]))
this.$set(this.searchTime, 0, bus.timeFormate(timeGroup.start_time));
this.$set(this.searchTime, 1, bus.timeFormate(timeGroup.end_time));
this.$set(this.searchTime, 0, bus.timeFormate(timeGroup.start_time))
this.$set(this.searchTime, 1, bus.timeFormate(timeGroup.end_time))
this.showTime = this.nowTimeType = {
id: 4,
text: this.$t("dashboard.panel.lastOneHour"),
type: "hour",
value: 1,
};
const time = bus.getTimezontDateRange();
text: this.$t('dashboard.panel.lastOneHour'),
type: 'hour',
value: 1
}
const time = bus.getTimezontDateRange()
if (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))
} else {
this.$set(this.searchTime, 0, bus.timeFormate(time[0]));
this.$set(this.searchTime, 1, bus.timeFormate(time[1]));
this.$set(this.searchTime, 0, bus.timeFormate(time[0]))
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 {
this.showTime = this.nowTimeType = {
@@ -463,7 +463,7 @@ export default {
}
}
} else {
this.isCustom = false;
this.isCustom = false
this.showDropdown()
if (this.showEmpty && id === 12) {
this.searchTime = []