From 49441ace631ed834da009bc89745643eb74ea475 Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Thu, 12 Aug 2021 18:18:37 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=9C=B0=E5=9B=BE=E7=BC=93=E5=AD=98=20?= =?UTF-8?q?=E5=9C=B0=E5=9B=BE=E8=81=94=E5=8A=A8=E9=A2=84=E7=95=99=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../canvas/custom-component/UserView.vue | 45 +++++++++++++------ .../views/chart/components/ChartComponent.vue | 25 ++++++----- 2 files changed, 46 insertions(+), 24 deletions(-) diff --git a/frontend/src/components/canvas/custom-component/UserView.vue b/frontend/src/components/canvas/custom-component/UserView.vue index 4e91e732eb..bbf26ac74c 100644 --- a/frontend/src/components/canvas/custom-component/UserView.vue +++ b/frontend/src/components/canvas/custom-component/UserView.vue @@ -137,7 +137,13 @@ export default { }, linkageFilters: { handler(newVal, oldVal) { - isChange(newVal, oldVal) && this.getData(this.element.propValue.viewId) + // isChange(newVal, oldVal) && this.getData(this.element.propValue.viewId) + if (isChange(newVal, oldVal)) { + // if (this.chart.type === 'map') { + // this.doMapLink(newVal) + // } + this.getData(this.element.propValue.viewId) + } }, deep: true }, @@ -267,7 +273,6 @@ export default { } }, - resetDrill() { const length = this.drillClickDimensionList.length this.drillClickDimensionList = [] @@ -321,18 +326,7 @@ export default { current && current.registerDynamicMap && current.registerDynamicMap(nextNode.code) } }, - // 根据地名获取areaCode - // findEntityByname(name, array) { - // if (array === null || array.length === 0) array = this.places - // for (let index = 0; index < array.length; index++) { - // const node = array[index] - // if (node.name === name) return node - // if (node.children && node.children.length > 0) { - // const temp = this.findEntityByname(name, node.children) - // if (temp) return temp - // } - // } - // } + findEntityByCode(code, array) { if (array === null || array.length === 0) array = this.places for (let index = 0; index < array.length; index++) { @@ -354,6 +348,29 @@ export default { this.places = res.data localStorage.setItem('areaMapping', JSON.stringify(res.data)) }) + }, + doMapLink(linkFilters) { + if (!linkFilters && linkFilters.length === 0) return + const value = linkFilters[0].value + if (!value && value.length === 0) return + const name = value[0] + if (!name) return + const areaNode = this.findEntityByname(name, []) + if (!areaNode) return + const current = this.$refs[this.element.propValue.id] + current && current.registerDynamicMap && current.registerDynamicMap(areaNode.code) + }, + // 根据地名获取areaCode + findEntityByname(name, array) { + if (array === null || array.length === 0) array = this.places + for (let index = 0; index < array.length; index++) { + const node = array[index] + if (node.name === name) return node + if (node.children && node.children.length > 0) { + const temp = this.findEntityByname(name, node.children) + if (temp) return temp + } + } } } } diff --git a/frontend/src/views/chart/components/ChartComponent.vue b/frontend/src/views/chart/components/ChartComponent.vue index fa5728b0f4..e0b487b5f7 100644 --- a/frontend/src/views/chart/components/ChartComponent.vue +++ b/frontend/src/views/chart/components/ChartComponent.vue @@ -145,16 +145,11 @@ export default { const customAttr = JSON.parse(chart.customAttr) if (!customAttr.areaCode) return - // if (this.currentGeoJson) { - // this.initMapChart(this.currentGeoJson, chart) - // return - // } - - // if (this.$store.getters.geoMap[customAttr.areaCode]) { - // this.currentGeoJson = this.$store.getters.geoMap[customAttr.areaCode] - // this.initMapChart(this.currentGeoJson, chart) - // return - // } + if (this.$store.getters.geoMap[customAttr.areaCode]) { + const json = this.$store.getters.geoMap[customAttr.areaCode] + this.initMapChart(json, chart) + return + } geoJson(customAttr.areaCode).then(res => { this.initMapChart(res, chart) @@ -171,9 +166,19 @@ export default { this.myEcharts(chart_option) }, registerDynamicMap(areaCode) { + if (this.$store.getters.geoMap[areaCode]) { + this.downOrUp = true + const json = this.$store.getters.geoMap[areaCode] + this.$echarts.registerMap('MAP', json) + return + } geoJson(areaCode).then(res => { this.downOrUp = true this.$echarts.registerMap('MAP', res) + this.$store.dispatch('map/setGeo', { + key: areaCode, + value: res + }) }) },