fix:修改 block 刷新无效的问题

This commit is contained in:
zhangyu
2022-01-26 18:34:38 +08:00
parent a8e0bc1795
commit b5a7ed482b
4 changed files with 24 additions and 16 deletions

View File

@@ -31,6 +31,7 @@
<chart-block
v-else-if="isBlock"
ref="chart"
:timeFilter="queryParams"
:chart-info="chartInfo"
:chart-data="chartData"
:entity="entity"
@@ -38,6 +39,7 @@
<chart-group
v-else-if="isGroup"
:timeFilter="queryParams"
:chart-info="chartInfo"
:chart-data="chartData"
:entity="entity"

View File

@@ -184,6 +184,7 @@ export default {
},
dateTimeRangeChange (s, e, v) {
this.chartTimeFilter = { startTime: s, endTime: e, dateRangeValue: v }
this.$emit('refresh', this.chartTimeFilter)
},
tableLimitChange () {
this.$emit('tableChange')

View File

@@ -165,13 +165,15 @@ export default {
},
methods: {
/* 参数 extraParams 额外请求参数isRefresh 是否是刷新 */
getChartData (url, extraParams = {}, isRefresh) {
getChartData (url, extraParams = {}, isRefresh, chartTimeFilter) {
const vm = this
this.loading = true
this.standaloneTimeRange.use = !!isRefresh
try {
// 单个图表刷新时,使用单独的时间
if (this.standaloneTimeRange.use) {
if (chartTimeFilter) {
this.queryTimeRange = { startTime: getSecond(chartTimeFilter.startTime), endTime: getSecond(chartTimeFilter.endTime) }
} else if (this.standaloneTimeRange.use) {
this.queryTimeRange = { startTime: getSecond(this.standaloneTimeRange.startTime), endTime: getSecond(this.standaloneTimeRange.endTime) }
} else if (this.timeFilter) {
this.queryTimeRange = { startTime: getSecond(this.timeFilter.startTime), endTime: getSecond(this.timeFilter.endTime) }
@@ -227,6 +229,12 @@ export default {
})
} else if (this.chartInfo.type === 94) {
this.chartInfo.children = [...this.chartInfo.children]
} else if (this.chartInfo.type === 95) {
if (!this.chartInfo.firstShow) {
this.chartInfo.firstShow = true
} else {
this.$refs.chart.$refs.chart.reload()
}
}
} catch (e) {
console.error(e)
@@ -253,14 +261,14 @@ export default {
resize () {
this.$refs.chart.resize()
},
refresh () {
refresh (chartTimeFilter) {
const myEndTime = window.$dayJs.tz().valueOf()
const myStartTime = myEndTime - this.chartTimeFilter.dateRangeValue * 60 * 1000
this.standaloneTimeRange.use = true
this.standaloneTimeRange.startTime = myStartTime
this.standaloneTimeRange.endTime = myEndTime
this.emitter.emit('chart-pageNo')
this.getChartData(null, {}, true)
this.getChartData(null, {}, true, chartTimeFilter)
},
showFullscreen (show) {
this.$emit('showFullscreen', show, this.chartInfo)

View File

@@ -20,24 +20,21 @@ export default {
data () {
return {
dataList: [],
time: {},
firstShow: false
}
},
watch: {
// 'chartInfo.children': {
// immediate: true,
// deep: true,
// handle (n) {
// if (!this.firstShow) {
// this.dataList = JSON.parse(JSON.stringify(this.chartInfo.children))
// this.firstShow = true
// }
// }
// }
},
mounted () {
this.dataList = JSON.parse(JSON.stringify(this.chartInfo.children))
// this.time = JSON.parse(JSON.stringify(this.timeFilter))
this.firstShow = true
},
methods: {
reload () {
console.log(123132)
this.dataList = JSON.parse(JSON.stringify(this.chartInfo.children))
// this.time = JSON.parse(JSON.stringify(this.timeFilter))
}
}
}
</script>