From 97f930560577a493f781c6f3853b2d77a12a9d2b Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Mon, 16 Aug 2021 13:34:23 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20axios=E5=BC=82=E6=AD=A5=E6=89=A7?= =?UTF-8?q?=E8=A1=8C=E5=AF=BC=E8=87=B4=E5=9C=B0=E5=9B=BE=E5=88=87=E6=8D=A2?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../canvas/custom-component/UserView.vue | 2 + .../views/chart/components/ChartComponent.vue | 61 +++++++++---------- frontend/src/views/chart/view/ChartEdit.vue | 1 + 3 files changed, 32 insertions(+), 32 deletions(-) diff --git a/frontend/src/components/canvas/custom-component/UserView.vue b/frontend/src/components/canvas/custom-component/UserView.vue index 939be53126..c978f9e800 100644 --- a/frontend/src/components/canvas/custom-component/UserView.vue +++ b/frontend/src/components/canvas/custom-component/UserView.vue @@ -296,6 +296,8 @@ export default { this.drillClickDimensionList = [] if (this.chart.type === 'map') { this.backToParent(0, length) + const current = this.$refs[this.element.propValue.id] + current && current.registerDynamicMap && current.registerDynamicMap(null) } }, diff --git a/frontend/src/views/chart/components/ChartComponent.vue b/frontend/src/views/chart/components/ChartComponent.vue index 8a78a069d7..9368cb3129 100644 --- a/frontend/src/views/chart/components/ChartComponent.vue +++ b/frontend/src/views/chart/components/ChartComponent.vue @@ -48,7 +48,6 @@ export default { return { myChart: {}, chartId: uuid.v1(), - currentGeoJson: null, showTrackBar: true, trackBarStyle: { position: 'absolute', @@ -57,7 +56,7 @@ export default { }, pointParam: null, - downOrUp: false + dynamicAreaCode: null } }, @@ -144,52 +143,50 @@ export default { if (chart.type === 'map') { const customAttr = JSON.parse(chart.customAttr) if (!customAttr.areaCode) return - - if (this.$store.getters.geoMap[customAttr.areaCode]) { - const json = this.$store.getters.geoMap[customAttr.areaCode] + const cCode = this.dynamicAreaCode || customAttr.areaCode + if (this.$store.getters.geoMap[cCode]) { + const json = this.$store.getters.geoMap[cCode] this.initMapChart(json, chart) return } - geoJson(customAttr.areaCode).then(res => { - this.initMapChart(res, chart) - + geoJson(cCode).then(res => { this.$store.dispatch('map/setGeo', { - key: customAttr.areaCode, + key: cCode, value: res - // value: res.data + }).then(() => { + this.initMapChart(res, chart) }) - this.currentGeoJson = res }) return } this.myEcharts(chart_option) }, registerDynamicMap(areaCode) { - this.downOrUp = true - if (this.$store.getters.geoMap[areaCode]) { - const json = this.$store.getters.geoMap[areaCode] - this.$echarts.registerMap('MAP', json) - console.log('开始切换地图:' + areaCode) - return - } - geoJson(areaCode).then(res => { - this.$echarts.registerMap('MAP', res) - console.log('开始切换地图:' + areaCode) - this.$store.dispatch('map/setGeo', { - key: areaCode, - value: res - }) - }).catch(() => { - this.downOrUp = true - }) + this.dynamicAreaCode = areaCode + // if (this.$store.getters.geoMap[areaCode]) { + // const json = this.$store.getters.geoMap[areaCode] + // this.myChart.dispose() + // this.myChart = this.$echarts.getInstanceByDom(document.getElementById(this.chartId)) + // this.$echarts.registerMap('MAP', json) + // return + // } + // geoJson(areaCode).then(res => { + // this.$store.dispatch('map/setGeo', { + // key: areaCode, + // value: res + // }).then(() => { + // this.myChart.dispose() + // this.myChart = this.$echarts.getInstanceByDom(document.getElementById(this.chartId)) + // this.$echarts.registerMap('MAP', res) + // }) + // }).catch(() => { + // this.downOrUp = true + // }) }, initMapChart(geoJson, chart) { - if (!this.$echarts.getMap('MAP') || !this.downOrUp) { - console.log('开始初始化地图:') - this.$echarts.registerMap('MAP', geoJson) - } + this.$echarts.registerMap('MAP', geoJson) // this.$echarts.getMap('MAP') || this.$echarts.registerMap('MAP', geoJson) const base_json = JSON.parse(JSON.stringify(BASE_MAP)) const chart_option = baseMapOption(base_json, chart) diff --git a/frontend/src/views/chart/view/ChartEdit.vue b/frontend/src/views/chart/view/ChartEdit.vue index abf33cb007..ea8f148a89 100644 --- a/frontend/src/views/chart/view/ChartEdit.vue +++ b/frontend/src/views/chart/view/ChartEdit.vue @@ -1418,6 +1418,7 @@ export default { if (this.chart.type === 'map') { this.backToParent(0, length) this.currentAcreaNode = null + this.$refs.dynamicChart && this.$refs.dynamicChart.registerDynamicMap && this.$refs.dynamicChart.registerDynamicMap(null) } }, drillJump(index) {