From c1ec061127464ded8107dd0762af02a96eefc6d3 Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Fri, 18 Feb 2022 17:44:16 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=AE=8C=E5=96=84=E8=A7=86?= =?UTF-8?q?=E5=9B=BE=E6=8F=92=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/AsyncComponent/index.vue | 6 ++- .../canvas/custom-component/UserView.vue | 50 +++++++++++++++---- frontend/src/views/chart/view/ChartEdit.vue | 47 ++++++++++------- .../src/views/system/plugin/PluginCom.vue | 5 +- 4 files changed, 76 insertions(+), 32 deletions(-) diff --git a/frontend/src/components/AsyncComponent/index.vue b/frontend/src/components/AsyncComponent/index.vue index 67779ffafb..7c0b613372 100644 --- a/frontend/src/components/AsyncComponent/index.vue +++ b/frontend/src/components/AsyncComponent/index.vue @@ -65,8 +65,12 @@ export default { this.refId = uuid.v1 }, methods: { - chartResize() { + /* chartResize() { this.$refs[this.refId] && this.$refs[this.refId].chartResize && this.$refs[this.refId].chartResize() + }, */ + callPluginInner(param) { + const { methodName, methodParam } = param + this.$refs[this.refId] && this.$refs[this.refId][methodName] && this.$refs[this.refId][methodName](methodParam) } } } diff --git a/frontend/src/components/canvas/custom-component/UserView.vue b/frontend/src/components/canvas/custom-component/UserView.vue index 947e4d7d89..a17634a791 100644 --- a/frontend/src/components/canvas/custom-component/UserView.vue +++ b/frontend/src/components/canvas/custom-component/UserView.vue @@ -298,7 +298,9 @@ export default { } // 如果gap有变化刷新 if (this.preCanvasPanel && this.preCanvasPanel.gap !== newVal.panel.gap) { - this.$refs[this.element.propValue.id].chartResize() + this.chart.isPlugin + ? this.$refs[this.element.propValue.id].callPluginInner({ methodName: 'chartResize' }) + : this.$refs[this.element.propValue.id].chartResize() } this.preCanvasPanel = deepCopy(newVal.panel) }, @@ -313,7 +315,9 @@ export default { this.changeIndex++ this.chartResize(this.changeIndex) } else { - this.$refs[this.element.propValue.id].chartResize() + this.chart.isPlugin + ? this.$refs[this.element.propValue.id].callPluginInner({ methodName: 'chartResize' }) + : this.$refs[this.element.propValue.id].chartResize() } } }, @@ -333,7 +337,7 @@ export default { }, 'chartType': function(newVal, oldVal) { // this.isPlugin = this.plugins.some(plugin => plugin.value === this.chart.type) - if (newVal === 'map' && newVal !== oldVal) { + if ((newVal === 'map' || newVal === 'buddle-map') && newVal !== oldVal) { this.initAreas() } }, @@ -360,6 +364,10 @@ export default { bindPluginEvent() { bus.$on('plugin-chart-click', this.chartClick) bus.$on('plugin-jump-click', this.jumpClick) + bus.$on('plugin-add-view-track-filter', this.addViewTrackFilter) + }, + addViewTrackFilter(linkageParam) { + this.$store.commit('addViewTrackFilter', linkageParam) }, // 根据仪表板的缩放比例,修改视图内部参数 mergeScale() { @@ -477,7 +485,7 @@ export default { chartClick(param) { if (this.drillClickDimensionList.length < this.chart.drillFields.length - 1) { - this.chart.type === 'map' && this.sendToChildren(param) + (this.chart.type === 'map' || this.chart.type === 'buddle-map') && this.sendToChildren(param) this.drillClickDimensionList.push({ dimensionList: param.data.dimensionList }) this.getData(this.element.propValue.viewId) } else if (this.chart.drillFields.length > 0) { @@ -547,17 +555,22 @@ export default { resetDrill() { const length = this.drillClickDimensionList.length this.drillClickDimensionList = [] - if (this.chart.type === 'map') { + if (this.chart.type === 'map' || this.chart.type === 'buddle-map') { this.backToParent(0, length) const current = this.$refs[this.element.propValue.id] - current && current.registerDynamicMap && current.registerDynamicMap(null) + + if (this.chart.isPlugin) { + current && current.callPluginInner({ methodName: 'registerDynamicMap', methodParam: null }) + } else { + current && current.registerDynamicMap && current.registerDynamicMap(null) + } } }, drillJump(index) { const length = this.drillClickDimensionList.length this.drillClickDimensionList = this.drillClickDimensionList.slice(0, index) - if (this.chart.type === 'map') { + if (this.chart.type === 'map' || this.chart.type === 'buddle-map') { this.backToParent(index, length) } this.getData(this.element.propValue.viewId) @@ -576,7 +589,11 @@ export default { this.currentAcreaNode = tempNode const current = this.$refs[this.element.propValue.id] - current && current.registerDynamicMap && current.registerDynamicMap(this.currentAcreaNode.code) + if (this.chart.isPlugin) { + current && current.callPluginInner({ methodName: 'registerDynamicMap', methodParam: this.currentAcreaNode.code }) + } else { + current && current.registerDynamicMap && current.registerDynamicMap(this.currentAcreaNode.code) + } }, // 切换下一级地图 @@ -593,7 +610,11 @@ export default { const nextNode = currentNode.children.find(item => item.name === name) this.currentAcreaNode = nextNode const current = this.$refs[this.element.propValue.id] - nextNode && current && current.registerDynamicMap && current.registerDynamicMap(nextNode.code) + if (this.chart.isPlugin) { + nextNode && current && current.callPluginInner({ methodName: 'registerDynamicMap', methodParam: nextNode.code }) + } else { + nextNode && current && current.registerDynamicMap && current.registerDynamicMap(nextNode.code) + } } }, @@ -622,7 +643,12 @@ export default { const areaNode = this.findEntityByname(name, []) if (!areaNode) return const current = this.$refs[this.element.propValue.id] - current && current.registerDynamicMap && current.registerDynamicMap(areaNode.code) + + if (this.chart.isPlugin) { + current && current.callPluginInner({ methodName: 'registerDynamicMap', methodParam: areaNode.code }) + } else { + current && current.registerDynamicMap && current.registerDynamicMap(areaNode.code) + } }, // 根据地名获取areaCode findEntityByname(name, array) { @@ -650,7 +676,9 @@ export default { if (this.$refs[this.element.propValue.id]) { this.timeMachine = setTimeout(() => { if (index === this.changeIndex) { - this.$refs[this.element.propValue.id].chartResize() + this.chart.isPlugin + ? this.$refs[this.element.propValue.id].callPluginInner({ methodName: 'chartResize' }) + : this.$refs[this.element.propValue.id].chartResize() } this.destroyTimeMachine() }, 50) diff --git a/frontend/src/views/chart/view/ChartEdit.vue b/frontend/src/views/chart/view/ChartEdit.vue index 916aa15627..600bf77536 100644 --- a/frontend/src/views/chart/view/ChartEdit.vue +++ b/frontend/src/views/chart/view/ChartEdit.vue @@ -829,6 +829,7 @@
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++) { diff --git a/frontend/src/views/system/plugin/PluginCom.vue b/frontend/src/views/system/plugin/PluginCom.vue index 040863b621..e75548225c 100644 --- a/frontend/src/views/system/plugin/PluginCom.vue +++ b/frontend/src/views/system/plugin/PluginCom.vue @@ -79,8 +79,11 @@ export default { const { eventName, eventParam } = param bus.$emit(eventName, eventParam) }, - chartResize() { + /* chartResize() { this.$refs[this.refId] && this.$refs[this.refId].chartResize && this.$refs[this.refId].chartResize() + }, */ + callPluginInner(param) { + this.$refs[this.refId] && this.$refs[this.refId].callPluginInner && this.$refs[this.refId].callPluginInner(param) } } }