From df8413731e77cce7b7cabff34ec6fec8524045fc Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Thu, 20 May 2021 16:45:27 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E7=94=BB=E5=B8=83?= =?UTF-8?q?=E4=B8=AD=E7=BB=84=E4=BB=B6=E5=8A=A0=E8=BD=BD=E5=A4=9A=E6=AC=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../canvas/components/Editor/ContextMenu.vue | 1 + .../canvas/components/Editor/Preview.vue | 6 +++++- .../canvas/components/Editor/PreviewEject.vue | 2 +- .../canvas/components/Editor/index.vue | 6 ++++-- frontend/src/components/canvas/index.vue | 4 ++-- .../components/widget/DeWidget/DeSelect.vue | 7 ++++++- frontend/src/store/modules/conditions.js | 21 +++++++++++++++++-- frontend/src/views/link/view/index.vue | 2 +- .../src/views/panel/GrantAuth/shareTree.vue | 4 ++-- frontend/src/views/panel/edit/index.vue | 4 ++-- frontend/src/views/panel/enshrine/index.vue | 2 +- frontend/src/views/panel/list/PanelList.vue | 3 ++- 12 files changed, 46 insertions(+), 16 deletions(-) diff --git a/frontend/src/components/canvas/components/Editor/ContextMenu.vue b/frontend/src/components/canvas/components/Editor/ContextMenu.vue index 18f3fdb6a8..9083d20a57 100644 --- a/frontend/src/components/canvas/components/Editor/ContextMenu.vue +++ b/frontend/src/components/canvas/components/Editor/ContextMenu.vue @@ -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 }) } }, diff --git a/frontend/src/components/canvas/components/Editor/Preview.vue b/frontend/src/components/canvas/components/Editor/Preview.vue index 0d2e07ce34..86ce8259df 100644 --- a/frontend/src/components/canvas/components/Editor/Preview.vue +++ b/frontend/src/components/canvas/components/Editor/Preview.vue @@ -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 diff --git a/frontend/src/components/canvas/components/Editor/PreviewEject.vue b/frontend/src/components/canvas/components/Editor/PreviewEject.vue index 9e84d2b3eb..a236d7eb00 100644 --- a/frontend/src/components/canvas/components/Editor/PreviewEject.vue +++ b/frontend/src/components/canvas/components/Editor/PreviewEject.vue @@ -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 diff --git a/frontend/src/components/canvas/components/Editor/index.vue b/frontend/src/components/canvas/components/Editor/index.vue index c1ad0e8f8f..ba74062db1 100644 --- a/frontend/src/components/canvas/components/Editor/index.vue +++ b/frontend/src/components/canvas/components/Editor/index.vue @@ -29,7 +29,6 @@ class="component" :style="item.style" :element="item" - @set-condition-value="setConditionValue" /> { - item.id = uuid.v1() + item.type !== 'custom' && (item.id = uuid.v1()) }) } diff --git a/frontend/src/components/widget/DeWidget/DeSelect.vue b/frontend/src/components/widget/DeWidget/DeSelect.vue index 213e9bf73d..1fc694bb0a 100644 --- a/frontend/src/components/widget/DeWidget/DeSelect.vue +++ b/frontend/src/components/widget/DeWidget/DeSelect.vue @@ -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 }) } } } diff --git a/frontend/src/store/modules/conditions.js b/frontend/src/store/modules/conditions.js index 965b239c8f..908f94ad9f 100644 --- a/frontend/src/store/modules/conditions.js +++ b/frontend/src/store/modules/conditions.js @@ -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 diff --git a/frontend/src/views/link/view/index.vue b/frontend/src/views/link/view/index.vue index 24b6088f65..c92b5fc478 100644 --- a/frontend/src/views/link/view/index.vue +++ b/frontend/src/views/link/view/index.vue @@ -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 diff --git a/frontend/src/views/panel/GrantAuth/shareTree.vue b/frontend/src/views/panel/GrantAuth/shareTree.vue index 4cd9348234..acc3747ce4 100644 --- a/frontend/src/views/panel/GrantAuth/shareTree.vue +++ b/frontend/src/views/panel/GrantAuth/shareTree.vue @@ -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()) }) } diff --git a/frontend/src/views/panel/edit/index.vue b/frontend/src/views/panel/edit/index.vue index 6eb9dd3a68..3467328e9f 100644 --- a/frontend/src/views/panel/edit/index.vue +++ b/frontend/src/views/panel/edit/index.vue @@ -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() } } } diff --git a/frontend/src/views/panel/enshrine/index.vue b/frontend/src/views/panel/enshrine/index.vue index 7e944638c5..f2b10f89ba 100644 --- a/frontend/src/views/panel/enshrine/index.vue +++ b/frontend/src/views/panel/enshrine/index.vue @@ -53,7 +53,7 @@ export default { resetID(data) { if (data) { data.forEach(item => { - item.id = uuid.v1() + item.type !== 'custom' && (item.id = uuid.v1()) }) } diff --git a/frontend/src/views/panel/list/PanelList.vue b/frontend/src/views/panel/list/PanelList.vue index d655410501..9b3ac90d28 100644 --- a/frontend/src/views/panel/list/PanelList.vue +++ b/frontend/src/views/panel/list/PanelList.vue @@ -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()) }) }