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() {