fix: chart 时间回显错误
This commit is contained in:
@@ -170,7 +170,15 @@ export default {
|
|||||||
const now = new Date(bus.computeTimezone(new Date().getTime()))
|
const now = new Date(bus.computeTimezone(new Date().getTime()))
|
||||||
const origin = new Date(bus.timeFormate(bus.formateTimeToTime(this.timeRange[1]), 'YYYY-MM-DD HH:mm:ss'))
|
const origin = new Date(bus.timeFormate(bus.formateTimeToTime(this.timeRange[1]), 'YYYY-MM-DD HH:mm:ss'))
|
||||||
const numInterval = now.getTime() - origin.getTime()
|
const numInterval = now.getTime() - origin.getTime()
|
||||||
if (numInterval >= 60000) { // 大于1分钟,则start、end均往后移numInterval,否则时间不变
|
let nowTimeType = this.$route.query.nowTimeType
|
||||||
|
if (!nowTimeType) {
|
||||||
|
nowTimeType = {
|
||||||
|
value: 1
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
nowTimeType = JSON.parse(nowTimeType)
|
||||||
|
}
|
||||||
|
if (numInterval >= 6 && nowTimeType.value !== -1) { // 大于1分钟,则start、end均往后移numInterval,否则时间不变
|
||||||
startTime = bus.getNewTime(bus.formateTimeToTime(this.timeRange[0]), numInterval, 'YYYY-MM-DD HH:mm:ss')
|
startTime = bus.getNewTime(bus.formateTimeToTime(this.timeRange[0]), numInterval, 'YYYY-MM-DD HH:mm:ss')
|
||||||
endTime = bus.timeFormate(now, 'YYYY-MM-DD HH:mm:ss')
|
endTime = bus.timeFormate(now, 'YYYY-MM-DD HH:mm:ss')
|
||||||
} else {
|
} else {
|
||||||
@@ -306,6 +314,7 @@ export default {
|
|||||||
} else {
|
} else {
|
||||||
if (r.status === 'success') {
|
if (r.status === 'success') {
|
||||||
r.data.result.forEach(item => {
|
r.data.result.forEach(item => {
|
||||||
|
item.elements = elements[rIndex - elements.length]
|
||||||
this.allDataLength++
|
this.allDataLength++
|
||||||
item.values.forEach(values => {
|
item.values.forEach(values => {
|
||||||
values[0] = values[0] + this.minusTime / 1000
|
values[0] = values[0] + this.minusTime / 1000
|
||||||
@@ -470,7 +479,13 @@ export default {
|
|||||||
case 'logs': {
|
case 'logs': {
|
||||||
this.chartData = []
|
this.chartData = []
|
||||||
elements.forEach((element, index) => {
|
elements.forEach((element, index) => {
|
||||||
this.chartData.push(this.dataJson[this.chartInfo.id + '_' + index].data.result)
|
const data = this.dataJson[this.chartInfo.id + '_' + index].data.result.map(item => {
|
||||||
|
return {
|
||||||
|
...item,
|
||||||
|
elements: element
|
||||||
|
}
|
||||||
|
})
|
||||||
|
this.chartData.push(data)
|
||||||
})
|
})
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,7 +106,7 @@
|
|||||||
<div class="date-range-title">{{$t('timepicker.relatime')}}</div>
|
<div class="date-range-title">{{$t('timepicker.relatime')}}</div>
|
||||||
<ul class="date-range-item">
|
<ul class="date-range-item">
|
||||||
<li
|
<li
|
||||||
v-for="(item, key) in timeData"
|
v-for="(item, key) in timeShowData"
|
||||||
@click="timeChange(item)"
|
@click="timeChange(item)"
|
||||||
:class="showTime.id === item.id ? 'activeLi' : ''"
|
:class="showTime.id === item.id ? 'activeLi' : ''"
|
||||||
:key="key"
|
:key="key"
|
||||||
@@ -182,11 +182,11 @@ export default {
|
|||||||
text: this.$t('dashboard.panel.lastOneHour')
|
text: this.$t('dashboard.panel.lastOneHour')
|
||||||
},
|
},
|
||||||
timeData: [
|
timeData: [
|
||||||
// {
|
{
|
||||||
// id: 0,
|
id: 0,
|
||||||
// text: this.$t("dashboard.panel.customTimeRange"),
|
text: this.$t('dashboard.panel.customTimeRange'),
|
||||||
// value: -1,
|
value: -1
|
||||||
// },
|
},
|
||||||
{
|
{
|
||||||
id: 12,
|
id: 12,
|
||||||
text: this.$t('dashboard.panel.noDate'),
|
text: this.$t('dashboard.panel.noDate'),
|
||||||
@@ -259,6 +259,7 @@ export default {
|
|||||||
value: 30
|
value: 30
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
timeShowData: [],
|
||||||
nowTimeType: {
|
nowTimeType: {
|
||||||
id: 4,
|
id: 4,
|
||||||
text: this.$t('dashboard.panel.lastOneHour'),
|
text: this.$t('dashboard.panel.lastOneHour'),
|
||||||
@@ -273,6 +274,8 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted () {
|
mounted () {
|
||||||
|
this.timeShowData = JSON.parse(JSON.stringify(this.timeData))
|
||||||
|
this.timeShowData.shift()
|
||||||
this.getItem()
|
this.getItem()
|
||||||
this.getUtcStr()
|
this.getUtcStr()
|
||||||
this.getRangeHistoryArr()
|
this.getRangeHistoryArr()
|
||||||
@@ -419,10 +422,14 @@ export default {
|
|||||||
this.oldSearchTimeError[1] = false
|
this.oldSearchTimeError[1] = false
|
||||||
},
|
},
|
||||||
setCustomTime (timeGroup, timeRange) {
|
setCustomTime (timeGroup, timeRange) {
|
||||||
|
console.log(timeGroup)
|
||||||
if (timeGroup) {
|
if (timeGroup) {
|
||||||
this.showTime = this.nowTimeType = this.timeData.find(
|
this.showTime = this.nowTimeType = this.timeData.find(
|
||||||
(item) => item.id == timeGroup.id
|
(item) => item.id == timeGroup.id
|
||||||
)
|
)
|
||||||
|
if (timeGroup.value == -1) {
|
||||||
|
this.isCustom = true
|
||||||
|
}
|
||||||
if (this.showTime) {
|
if (this.showTime) {
|
||||||
this.showTime = Object.assign({}, this.showTime)
|
this.showTime = Object.assign({}, this.showTime)
|
||||||
this.$set(this.searchTime, 0, timeGroup.start_time)
|
this.$set(this.searchTime, 0, timeGroup.start_time)
|
||||||
|
|||||||
Reference in New Issue
Block a user