From 53202d7b0c18abf980e38165207c1988f8f3d5b7 Mon Sep 17 00:00:00 2001 From: "@changcode" Date: Wed, 19 Jan 2022 16:18:11 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=BC=95=E5=85=A5=20tiny-emitter=20?= =?UTF-8?q?=E6=8F=92=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/charts/ChartTablePagination.vue | 4 ++++ src/main.js | 4 ++++ src/views/charts/PanelChart.vue | 2 ++ 3 files changed, 10 insertions(+) diff --git a/src/components/charts/ChartTablePagination.vue b/src/components/charts/ChartTablePagination.vue index 945a2fc8..521d861c 100644 --- a/src/components/charts/ChartTablePagination.vue +++ b/src/components/charts/ChartTablePagination.vue @@ -45,6 +45,10 @@ export default { } }, mounted () { + const _this = this + this.emitter.on('chart-pageNo', function () { + _this.resetPageNo() + }) this.$el.querySelector('.el-pagination__jump').childNodes[0].nodeValue = '' } } diff --git a/src/main.js b/src/main.js index e837fc6a..f7887aa1 100644 --- a/src/main.js +++ b/src/main.js @@ -13,6 +13,8 @@ import 'highlight.js/styles/color-brewer.css' import '@/assets/css/main.scss' // 样式入口 import VueGridLayout from 'vue-grid-layout' import ElementPlus from 'element-plus' +import bus from 'tiny-emitter' +const emitter = new bus() import dayjs from 'dayjs' import utc from 'dayjs/plugin/utc' // dependent on utc plugin import timezone from 'dayjs/plugin/timezone' @@ -54,4 +56,6 @@ app.component('time-refresh', TimeRefresh) app.component('panel-chart-list', PanelChartList) app.mount('#app') + +app.config.globalProperties.emitter = emitter export default app diff --git a/src/views/charts/PanelChart.vue b/src/views/charts/PanelChart.vue index e1b7cf96..a6775668 100644 --- a/src/views/charts/PanelChart.vue +++ b/src/views/charts/PanelChart.vue @@ -232,6 +232,7 @@ export default { this.standaloneTimeRange.use = true this.standaloneTimeRange.startTime = myStartTime this.standaloneTimeRange.endTime = myEndTime + this.emitter.emit('chart-pageNo') this.getChartData(null, {}, true) }, showFullscreen (show) { @@ -288,6 +289,7 @@ export default { this.loading = show }, tableChange () { + this.emitter.emit('chart-pageNo') this.getChartData() }, getTargetPageData (pageNum, pageSize, tableData) {