fix(仪表板): 删除Tab画布时同时清理对应画布的组件

This commit is contained in:
wangjiahao 2022-12-20 15:24:42 +08:00
parent 246da34880
commit 8cfee501fe
2 changed files with 14 additions and 1 deletions

View File

@ -640,7 +640,7 @@ export default {
while (len--) {
if (this.element.options.tabList[len].name === param.name) {
this.element.options.tabList.splice(len, 1)
this.$store.commit('deleteComponentsWithCanvasId', this.element.id + '-' + param.name)
const activeIndex = (len - 1 + this.element.options.tabList.length) % this.element.options.tabList.length
this.activeTabName = this.element.options.tabList[activeIndex].name
}

View File

@ -503,6 +503,9 @@ const data = {
const element = state.componentData[index]
if (element.id && element.id === id) {
state.componentData.splice(index, 1)
if (element.type === 'de-tabs') {
this.commit('deleteComponentsWithCanvasId', element.id)
}
break
}
}
@ -811,6 +814,16 @@ const data = {
state.mousePointShadowMap.mouseY = mousePoint.mouseY
state.mousePointShadowMap.width = mousePoint.width
state.mousePointShadowMap.height = mousePoint.height
},
deleteComponentsWithCanvasId(state, canvasId) {
if (canvasId && canvasId.length > 10) {
for (let index = 0; index < state.componentData.length; index++) {
const element = state.componentData[index]
if (element.canvasId && element.canvasId.includes(canvasId)) {
state.componentData.splice(index, 1)
}
}
}
}
},
modules: {