fix:CN-1518 Network Overview流量曲线图的交互逻辑优化,减少请求次数
This commit is contained in:
@@ -408,9 +408,18 @@ export default {
|
|||||||
},
|
},
|
||||||
metricChange (value) {
|
metricChange (value) {
|
||||||
const { query } = this.$route
|
const { query } = this.$route
|
||||||
const newUrl = urlParamsHandler(window.location.href, query, {
|
const rangeParam = query.range
|
||||||
metric: value
|
let params = { metric: value }
|
||||||
})
|
// 优先级:url > config.js > 默认值。
|
||||||
|
const dateRangeValue = rangeParam ? parseInt(rangeParam) : (DEFAULT_TIME_FILTER_RANGE.dashboard || 60)
|
||||||
|
if (dateRangeValue !== -1) {
|
||||||
|
const { startTime, endTime } = getNowTime(dateRangeValue)
|
||||||
|
this.timeFilter = { startTime: getSecond(startTime), endTime: getSecond(endTime), dateRangeValue: dateRangeValue }
|
||||||
|
this.$store.commit('setTimeRangeArray', [this.timeFilter.startTime, this.timeFilter.endTime])
|
||||||
|
this.$store.commit('setTimeRangeFlag', dateRangeValue.value)
|
||||||
|
params = { metric: value, startTime: this.timeFilter.startTime, endTime: this.timeFilter.endTime, range: dateRangeValue }
|
||||||
|
}
|
||||||
|
const newUrl = urlParamsHandler(window.location.href, query, params)
|
||||||
overwriteUrl(newUrl)
|
overwriteUrl(newUrl)
|
||||||
},
|
},
|
||||||
// 动态查询评分基准
|
// 动态查询评分基准
|
||||||
|
|||||||
@@ -191,7 +191,7 @@ export default {
|
|||||||
this.toggleLoading(true)
|
this.toggleLoading(true)
|
||||||
axios.get(url, { params: params }).then(response => {
|
axios.get(url, { params: params }).then(response => {
|
||||||
const res = response.data
|
const res = response.data
|
||||||
|
this.chartDateObject = response
|
||||||
if (response.status === 200) {
|
if (response.status === 200) {
|
||||||
this.isNoData = res.data.result.length === 0
|
this.isNoData = res.data.result.length === 0
|
||||||
this.showError = false
|
this.showError = false
|
||||||
@@ -214,6 +214,33 @@ export default {
|
|||||||
this.toggleLoading(false)
|
this.toggleLoading(false)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
initTabData (val, show, active, n) {
|
||||||
|
const newVal = val ? _.clone(val) : this.metric
|
||||||
|
this.toggleLoading(true)
|
||||||
|
try {
|
||||||
|
const res = this.chartDateObject.data
|
||||||
|
if (this.chartDateObject.status === 200) {
|
||||||
|
this.isNoData = res.data.result.length === 0
|
||||||
|
this.showError = false
|
||||||
|
if (!active) {
|
||||||
|
this.tabs = _.cloneDeep(this.tabsTemplate)
|
||||||
|
}
|
||||||
|
if (this.isNoData) {
|
||||||
|
this.lineTab = ''
|
||||||
|
this.tabs = _.cloneDeep(this.tabsTemplate)
|
||||||
|
} else {
|
||||||
|
this.initData(res.data.result, newVal, active, show, n)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.httpError(res)
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e)
|
||||||
|
this.httpError(e)
|
||||||
|
} finally {
|
||||||
|
this.toggleLoading(false)
|
||||||
|
}
|
||||||
|
},
|
||||||
echartsInit (echartsData, show) {
|
echartsInit (echartsData, show) {
|
||||||
// echarts内容在单元测试时不执行
|
// echarts内容在单元测试时不执行
|
||||||
if (!this.isUnitTesting) {
|
if (!this.isUnitTesting) {
|
||||||
@@ -360,7 +387,7 @@ export default {
|
|||||||
this.legendSelectChange(item, index, 'active')
|
this.legendSelectChange(item, index, 'active')
|
||||||
this.showMarkLine = !item.invertTab
|
this.showMarkLine = !item.invertTab
|
||||||
}
|
}
|
||||||
this.init(this.metric, this.showMarkLine, 'active')
|
this.initTabData(this.metric, this.showMarkLine, 'active')
|
||||||
},
|
},
|
||||||
mouseenter (item) {
|
mouseenter (item) {
|
||||||
if (this.isNoData) return
|
if (this.isNoData) return
|
||||||
|
|||||||
Reference in New Issue
Block a user