From abb9f456987a48e506f2b8dbf8772ff82aeead50 Mon Sep 17 00:00:00 2001 From: wangjiahao <1522128093@qq.com> Date: Wed, 1 Dec 2021 17:39:27 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E8=A7=86=E5=9B=BE=E6=96=B0?= =?UTF-8?q?=E5=BB=BA=E8=BF=BD=E5=8A=A0=E8=87=AA=E5=8A=A8=E7=82=B9=E5=87=BB?= =?UTF-8?q?=E4=BA=8B=E4=BB=B6=EF=BC=8C=E5=BD=93=E5=89=8D=E6=96=B0=E5=8A=A0?= =?UTF-8?q?=E8=A7=86=E5=9B=BE=E9=AB=98=E4=BA=AE=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/views/chart/group/Group.vue | 25 ++++++++++++++++++--- frontend/src/views/chart/index.vue | 7 ++++-- frontend/src/views/chart/view/ChartEdit.vue | 1 + 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/frontend/src/views/chart/group/Group.vue b/frontend/src/views/chart/group/Group.vue index 1f837baf53..998c0eb391 100644 --- a/frontend/src/views/chart/group/Group.vue +++ b/frontend/src/views/chart/group/Group.vue @@ -422,7 +422,9 @@ export default { searchMap: { all: this.$t('commons.all'), folder: this.$t('commons.folder') - } + }, + currentNodeData: {}, + currentKey: null } }, watch: { @@ -626,16 +628,28 @@ export default { }) }, + initCurrentNode() { + if (this.currentKey) { + this.$nextTick(() => { + this.$refs.chartTreeRef.setCurrentKey(this.currentKey) + this.$nextTick(() => { + document.querySelector('.is-current').firstChild.click() + }) + }) + } + }, treeNode(cache = false) { const modelInfo = localStorage.getItem('chart-tree') const userCache = (modelInfo && cache) if (userCache) { this.tData = JSON.parse(modelInfo) + this.initCurrentNode() } queryAuthModel({ modelType: 'chart' }, !userCache).then(res => { localStorage.setItem('chart-tree', JSON.stringify(res.data)) if (!userCache) { this.tData = res.data + this.initCurrentNode() } }) }, @@ -655,6 +669,7 @@ export default { }, nodeClick(data, node) { + this.currentNodeData = data if (data.modelInnerType !== 'group') { this.$emit('switchComponent', { name: 'ChartEdit', param: data }) } @@ -767,8 +782,7 @@ export default { this.$emit('newViewInfo', { 'id': response.data.id }) } else { _this.expandedArray.push(response.data.sceneId) - _this.$refs.chartTreeRef.setCurrentKey(response.data.id) - _this.$emit('switchComponent', { name: 'ChartEdit', param: response.data }) + _this.currentKey = response.data.id _this.treeNode() } }) @@ -923,6 +937,11 @@ export default { }, searchTypeClick(searchTypeInfo) { this.searchType = searchTypeInfo + }, + nodeTypeChange(newType) { + if (this.currentNodeData) { + this.currentNodeData.modelInnerType = newType + } } } } diff --git a/frontend/src/views/chart/index.vue b/frontend/src/views/chart/index.vue index 7e5d0b43ad..8d605050c1 100644 --- a/frontend/src/views/chart/index.vue +++ b/frontend/src/views/chart/index.vue @@ -2,12 +2,12 @@ - + - + @@ -49,6 +49,9 @@ export default { }, saveSuccess(val) { this.saveStatus = val + }, + typeChange(newType) { + this.$refs.group.nodeTypeChange(newType) } } } diff --git a/frontend/src/views/chart/view/ChartEdit.vue b/frontend/src/views/chart/view/ChartEdit.vue index fcaf2844a9..ec346f9900 100644 --- a/frontend/src/views/chart/view/ChartEdit.vue +++ b/frontend/src/views/chart/view/ChartEdit.vue @@ -1100,6 +1100,7 @@ export default { if (newVal === 'map' && newVal !== oldVal) { this.initAreas() } + this.$emit('typeChange', newVal) } }, created() {