diff --git a/frontend/src/components/canvas/custom-component/UserView.vue b/frontend/src/components/canvas/custom-component/UserView.vue index c39624a67d..50c444cd92 100644 --- a/frontend/src/components/canvas/custom-component/UserView.vue +++ b/frontend/src/components/canvas/custom-component/UserView.vue @@ -141,7 +141,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 }, @@ -327,18 +333,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++) { @@ -360,6 +355,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 + }) }) },