forked from github/dataease
fix: 修复画布中组件加载多次
This commit is contained in:
parent
39a282dd65
commit
df8413731e
@ -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 })
|
||||
}
|
||||
},
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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,
|
||||
|
||||
|
@ -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())
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -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 })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,11 +5,13 @@ const state = {
|
||||
|
||||
const mutations = {
|
||||
ADD_CONDITION: (state, condition) => {
|
||||
!condition && (condition = [])
|
||||
state.conditions.push(condition)
|
||||
condition && valueValid(condition) && state.conditions.push(condition)
|
||||
},
|
||||
REDUCE_CONDITION: (state, index) => {
|
||||
state.conditions && state.conditions.length > index && state.conditions.splice(index, 1)
|
||||
},
|
||||
CLEAR: (state) => {
|
||||
state.conditions = []
|
||||
}
|
||||
}
|
||||
|
||||
@ -30,6 +32,17 @@ const actions = {
|
||||
},
|
||||
reduce({ commit }, index) {
|
||||
commit('ADD_CONDITION', index)
|
||||
},
|
||||
delete({ commit }, component) {
|
||||
for (let index = 0; index < state.conditions.length; index++) {
|
||||
const element = state.conditions[index]
|
||||
if (element.componentId === component.componentId) {
|
||||
commit('REDUCE_CONDITION', index)
|
||||
}
|
||||
}
|
||||
},
|
||||
clear({ commit }) {
|
||||
commit('CLEAR')
|
||||
}
|
||||
|
||||
}
|
||||
@ -61,6 +74,10 @@ const isValid = condition => {
|
||||
return validResult
|
||||
}
|
||||
|
||||
const valueValid = condition => {
|
||||
return condition && condition.value && condition.value.length > 0 && condition.value[0]
|
||||
}
|
||||
|
||||
const formatCondition = obj => {
|
||||
const { component, value, operator } = obj
|
||||
const fieldId = component.options.attrs.fieldId
|
||||
|
@ -38,7 +38,7 @@ export default {
|
||||
resetID(data) {
|
||||
if (data) {
|
||||
data.forEach(item => {
|
||||
item.id = uuid.v1()
|
||||
item.type !== 'custom' && (item.id = uuid.v1())
|
||||
})
|
||||
}
|
||||
return data
|
||||
|
@ -51,9 +51,9 @@ export default {
|
||||
})
|
||||
},
|
||||
resetID(data) {
|
||||
if( data ) {
|
||||
if (data) {
|
||||
data.forEach(item => {
|
||||
item.id = uuid.v1()
|
||||
item.type !== 'custom' && (item.id = uuid.v1())
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -270,7 +270,7 @@ export default {
|
||||
resetID(data) {
|
||||
if (data) {
|
||||
data.forEach(item => {
|
||||
item.id = uuid.v1()
|
||||
item.type !== 'custom' && (item.id = uuid.v1())
|
||||
})
|
||||
}
|
||||
return data
|
||||
@ -372,7 +372,7 @@ export default {
|
||||
},
|
||||
closeLeftPanel() {
|
||||
this.show = false
|
||||
this.beforeDestroy()
|
||||
// this.beforeDestroy()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ export default {
|
||||
resetID(data) {
|
||||
if (data) {
|
||||
data.forEach(item => {
|
||||
item.id = uuid.v1()
|
||||
item.type !== 'custom' && (item.id = uuid.v1())
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -486,6 +486,7 @@ export default {
|
||||
// 加载视图数据
|
||||
get('panel/group/findOne/' + data.id).then(response => {
|
||||
this.$store.commit('setComponentData', this.resetID(JSON.parse(response.data.panelData)))
|
||||
// this.$store.commit('setComponentData', sourceInfo.type === 'custom' ? sourceInfo : this.resetID(sourceInfo))
|
||||
const temp = JSON.parse(response.data.panelStyle)
|
||||
this.$store.commit('setCanvasStyle', temp)
|
||||
this.$store.dispatch('panel/setPanelInfo', data)
|
||||
@ -535,7 +536,7 @@ export default {
|
||||
resetID(data) {
|
||||
if (data) {
|
||||
data.forEach(item => {
|
||||
item.id = uuid.v1()
|
||||
item.type !== 'custom' && (item.id = uuid.v1())
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user