NEZ-1334 fix:Panel设置时间查询后,刷新单个图表,内容出错

This commit is contained in:
zhangyu
2021-11-24 09:38:06 +08:00
parent 42c7d6ae7d
commit 5ced7cb068
5 changed files with 16 additions and 8 deletions

View File

@@ -304,7 +304,8 @@ export default {
obj: Object, obj: Object,
panelLock: { type: Boolean, default: false }, panelLock: { type: Boolean, default: false },
hasGroup: { type: Boolean, default: true }, hasGroup: { type: Boolean, default: true },
panelDataList: Array panelDataList: Array,
nowTimeType: {}
}, },
components: { components: {
@@ -973,7 +974,12 @@ export default {
let startTime = '' let startTime = ''
let endTime = '' let endTime = ''
if (filterType === 'refresh') { // 刷新 if (filterType === 'refresh') { // 刷新
const now = new Date(bus.computeTimezone(new Date().getTime())) let now = null
if (this.nowTimeType.id === 0 && this.nowTimeType.value === -1) {
now = new Date(this.filter.start_time)
} else {
now = new Date(bus.computeTimezone(new Date().getTime()))
}
const origin = new Date(this.filter.end_time) const origin = new Date(this.filter.end_time)
const numInterval = now.getTime() - origin.getTime() const numInterval = now.getTime() - origin.getTime()
if (numInterval >= 60000) { // 大于1分钟则start、end均往后移numInterval否则时间不变 if (numInterval >= 60000) { // 大于1分钟则start、end均往后移numInterval否则时间不变

View File

@@ -681,7 +681,7 @@ export default {
resolve({ data: '', status: 'no query' }) resolve({ data: '', status: 'no query' })
}) })
} }
query += '&nullType=' + 'connected' query += '&nullType=' + 'null'
return this.$get('/prom/api/v1/query_range?query=' + query + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step) return this.$get('/prom/api/v1/query_range?query=' + query + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step)
}) })
} }

View File

@@ -74,7 +74,7 @@ export default {
data () { data () {
return { return {
tempDom: { height: 250, width: '' }, tempDom: { height: 250, width: '' },
chartDataTemp: { id: 8832, prev: null, next: null, panelId: 0, title: '123', span: 12, height: 0, createAt: '2021-01-27 07:36:19', unit: 2, weight: 0, pid: null, buildIn: null, seq: null, param: { last: 0, legendValue: { total: 'off', min: 'off', avg: 'off', last: 'off', max: 'off' }, threshold: '', url: '', nullType: 'connected' }, sync: null, asset: null, isLoaded: true, from: '__vue_devtool_undefined__', draggable: true, resizable: true, editable: true }, chartDataTemp: { id: 8832, prev: null, next: null, panelId: 0, title: '123', span: 12, height: 0, createAt: '2021-01-27 07:36:19', unit: 2, weight: 0, pid: null, buildIn: null, seq: null, param: { last: 0, legendValue: { total: 'off', min: 'off', avg: 'off', last: 'off', max: 'off' }, threshold: '', url: '', nullType: 'null' }, sync: null, asset: null, isLoaded: true, from: '__vue_devtool_undefined__', draggable: true, resizable: true, editable: true },
chartData: {}, chartData: {},
filter: { filter: {
end_time: bus.timeFormate(bus.getOffsetTimezoneData(), 'yyyy-MM-dd hh:mm:ss'), end_time: bus.timeFormate(bus.getOffsetTimezoneData(), 'yyyy-MM-dd hh:mm:ss'),
@@ -108,7 +108,7 @@ export default {
chartData.param = { chartData.param = {
legendValue: { total: 'off', min: 'off', avg: 'off', last: 'off', max: 'off' }, legendValue: { total: 'off', min: 'off', avg: 'off', last: 'off', max: 'off' },
last: 0, last: 0,
nullType: 'connected', nullType: 'null',
threshold: '', threshold: '',
url: '', url: '',
valueMapping: { mapping: [{ color: { bac: '#fff', text: '#000' }, text: '', value: '' }], type: 'text' }, valueMapping: { mapping: [{ color: { bac: '#fff', text: '#000' }, text: '', value: '' }], type: 'text' },

View File

@@ -686,7 +686,7 @@ export default {
resolve({ data: '', status: 'no query' }) resolve({ data: '', status: 'no query' })
}) })
} }
query += '&nullType=' + 'connected' query += '&nullType=' + 'null'
return this.$get('/prom/api/v1/query_range?query=' + query + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step) return this.$get('/prom/api/v1/query_range?query=' + query + '&start=' + this.$stringTimeParseToUnix(startTime) + '&end=' + this.$stringTimeParseToUnix(endTime) + '&step=' + step)
}) })
} }

View File

@@ -82,7 +82,7 @@
<div id="tableList" class="table-list"> <div id="tableList" class="table-list">
<div ref="dashboardScrollbar" id="dashboardScrollbar" class="border-t-1-de" style="height: calc(100% - 20px); overflow: auto;"> <div ref="dashboardScrollbar" id="dashboardScrollbar" class="border-t-1-de" style="height: calc(100% - 20px); overflow: auto;">
<div class="box-content" v-loading="chartListLoading"> <div class="box-content" v-loading="chartListLoading">
<chart-list ref="chartList" :class="{'show-top':showTopBtn}" :from="fromRoute.panel" :panel-lock="panelLock" @on-edit-chart="editChart" @on-refresh-time="refreshTime" @on-remove-chart="delChart" @panel-list-loading="load" @on-add-group-item-chart="addGroupItem"></chart-list> <chart-list :nowTimeType="nowTimeType" ref="chartList" :class="{'show-top':showTopBtn}" :from="fromRoute.panel" :panel-lock="panelLock" @on-edit-chart="editChart" @on-refresh-time="refreshTime" @on-remove-chart="delChart" @panel-list-loading="load" @on-add-group-item-chart="addGroupItem"></chart-list>
</div> </div>
</div> </div>
</div> </div>
@@ -215,7 +215,8 @@ export default {
filterPanel: '', filterPanel: '',
// ---图表相关参数--end // ---图表相关参数--end
scrollbarWrap: null, scrollbarWrap: null,
batchDeleteObjs: [] batchDeleteObjs: [],
nowTimeType: {}
} }
}, },
components: { components: {
@@ -470,6 +471,7 @@ export default {
// 选择日期变化 // 选择日期变化
dateChange (val) { dateChange (val) {
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.setSearchTime(nowTimeType.type, nowTimeType.value, nowTimeType) this.setSearchTime(nowTimeType.type, nowTimeType.value, nowTimeType)
this.filter.start_time = bus.timeFormate(this.searchTime[0], 'yyyy-MM-dd hh:mm:ss') 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.end_time = bus.timeFormate(this.searchTime[1], 'yyyy-MM-dd hh:mm:ss')