fix: 修复画布中组件加载多次

This commit is contained in:
fit2cloud-chenyw
2021-05-20 16:45:27 +08:00
parent 39a282dd65
commit df8413731e
12 changed files with 46 additions and 16 deletions

View File

@@ -89,6 +89,7 @@ export default {
deleteCurCondition() {
if (this.curComponent.type === 'custom') {
this.$store.dispatch('conditions/delete', { componentId: this.curComponent.id })
bus.$emit('delete-condition', { componentId: this.curComponent.id })
}
},

View File

@@ -92,6 +92,10 @@ export default {
})
})
},
created() {
// 先清除查询条件
this.$store.dispatch('conditions/clear')
},
methods: {
changeStyleWithScale,
getStyle,
@@ -105,7 +109,7 @@ export default {
resetID(data) {
if (data) {
data.forEach(item => {
item.id = uuid.v1()
item.type !== 'custom' && (item.id = uuid.v1())
})
}
return data

View File

@@ -118,7 +118,7 @@ export default {
resetID(data) {
if (data) {
data.forEach(item => {
item.id = uuid.v1()
item.type !== 'custom' && (item.id = uuid.v1())
})
}
return data

View File

@@ -29,7 +29,6 @@
class="component"
:style="item.style"
:element="item"
@set-condition-value="setConditionValue"
/>
<component
@@ -109,7 +108,7 @@ export default {
height: this.changeStyleWithScale(this.canvasStyleData.height) + 'px'
}
if (this.canvasStyleData.openCommonStyle) {
if (this.canvasStyleData.panel.backgroundType === 'image'&&this.canvasStyleData.panel.imageUrl) {
if (this.canvasStyleData.panel.backgroundType === 'image' && this.canvasStyleData.panel.imageUrl) {
style = {
width: this.changeStyleWithScale(this.canvasStyleData.width) + 'px',
height: this.changeStyleWithScale(this.canvasStyleData.height) + 'px',
@@ -148,6 +147,9 @@ export default {
this.deleteCondition(condition)
})
},
created() {
this.$store.dispatch('conditions/clear')
},
methods: {
changeStyleWithScale,

View File

@@ -69,9 +69,9 @@ export default {
},
resetID(data) {
if( data ) {
if (data) {
data.forEach(item => {
item.id = uuid.v1()
item.type !== 'custom' && (item.id = uuid.v1())
})
}

View File

@@ -44,6 +44,7 @@ export default {
created() {
this.options = this.element.options
this.setCondition()
},
mounted() {
this.$nextTick(() => {
@@ -52,8 +53,12 @@ export default {
},
methods: {
changeValue(value) {
this.inDraw && this.$store.dispatch('conditions/add', { component: this.element, value: [this.options.value], operator: this.operator })
this.setCondition()
this.inDraw && this.$emit('set-condition-value', { component: this.element, value: [value], operator: this.operator })
},
setCondition() {
this.inDraw && this.$store.dispatch('conditions/add', { component: this.element, value: [this.options.value], operator: this.operator })
}
}
}