From 880a26cd0a47207103f3078a184ca542d8c05610 Mon Sep 17 00:00:00 2001 From: fit2cloud-chenyw Date: Tue, 8 Jun 2021 16:03:49 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BB=AA=E8=A1=A8=E6=9D=BF=E8=BF=87?= =?UTF-8?q?=E6=BB=A4=20=E5=B1=80=E9=83=A8=E5=88=B7=E6=96=B0=20=E5=9F=BA?= =?UTF-8?q?=E6=9C=AC=E5=8A=9F=E8=83=BD=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/Editor/ComponentWrapper.vue | 1 - .../canvas/components/Editor/index.vue | 7 +++- .../canvas/custom-component/UserView.vue | 42 ++++++++++++------- frontend/src/layout/components/Topbar.vue | 4 +- frontend/src/store/index.js | 24 ++++------- frontend/src/utils/conditionUtil.js | 32 ++++++++++++++ frontend/src/views/login/index.vue | 2 +- frontend/src/views/panel/edit/index.vue | 15 +++++-- frontend/src/views/panel/list/PanelList.vue | 6 ++- 9 files changed, 93 insertions(+), 40 deletions(-) create mode 100644 frontend/src/utils/conditionUtil.js diff --git a/frontend/src/components/canvas/components/Editor/ComponentWrapper.vue b/frontend/src/components/canvas/components/Editor/ComponentWrapper.vue index e6058d1c83..57ec8b0c8e 100644 --- a/frontend/src/components/canvas/components/Editor/ComponentWrapper.vue +++ b/frontend/src/components/canvas/components/Editor/ComponentWrapper.vue @@ -17,7 +17,6 @@ :style="getStyle(config.style)" :prop-value="config.propValue" :element="config" - :filter="config.filters" /> diff --git a/frontend/src/components/canvas/components/Editor/index.vue b/frontend/src/components/canvas/components/Editor/index.vue index 374cef2f84..1f0bd7ecd9 100644 --- a/frontend/src/components/canvas/components/Editor/index.vue +++ b/frontend/src/components/canvas/components/Editor/index.vue @@ -40,7 +40,6 @@ :style="getComponentStyle(item.style)" :prop-value="item.propValue" :element="item" - :filter="item.filters" :out-style="getShapeStyleInt(item.style)" />
- - + +
{ - 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 - const viewIds = component.options.attrs.viewIds - const condition = new Condition(component.id, fieldId, operator, value, viewIds) - return condition -} const data = { state: { ...animation.state, @@ -137,19 +127,21 @@ const data = { const vidMatch = viewIdMatch(condition.viewIds, element.propValue.viewId) let j = currentFilters.length - let filterExist = false + // let filterExist = false while (j--) { const filter = currentFilters[j] if (filter.componentId === filterComponentId) { - filterExist = true + // filterExist = true // 已存在该条件 且 条件值有效 直接替换原体检 - vidMatch && vValid && (currentFilters[j] = condition) + // vidMatch && vValid && (currentFilters[j] = condition) // 已存在该条件 且 条件值无效 直接删除原条件 - vidMatch && !vValid && (currentFilters.splice(j, 1)) + // vidMatch && !vValid && (currentFilters.splice(j, 1)) + currentFilters.splice(j, 1) } } // 不存在该条件 且 条件有效 直接保存该条件 - !filterExist && vValid && currentFilters.push(condition) + // !filterExist && vValid && currentFilters.push(condition) + vidMatch && vValid && currentFilters.push(condition) element.filters = currentFilters state.componentData[index] = element } diff --git a/frontend/src/utils/conditionUtil.js b/frontend/src/utils/conditionUtil.js new file mode 100644 index 0000000000..0e010b8665 --- /dev/null +++ b/frontend/src/utils/conditionUtil.js @@ -0,0 +1,32 @@ + +import { Condition } from '@/components/widget/bean/Condition' +/** + * 判断两个conditions数组是否相同 + * @param {*} conditions1 + * @param {*} conditions2 + * @returns + */ +export const isChange = (conditions1, conditions2) => { + // 两个都null + if (!conditions1 && !conditions2) return false + if (!conditions1 || !conditions2) return true + // 数组长度不一样 肯定发生了改变 + if (conditions1.length !== conditions2.length) return true + let arr1 = JSON.parse(JSON.stringify(conditions1)) + let arr2 = JSON.parse(JSON.stringify(conditions2)) + arr1 = arr1.sort((s1, s2) => s1.componentId > s2.componentId) + arr2 = arr2.sort((s1, s2) => s1.componentId > s2.componentId) + return JSON.stringify(arr1) !== JSON.stringify(arr2) +} + +export const valueValid = condition => { + return condition && condition.value && condition.value.length > 0 && condition.value[0] +} + +export const formatCondition = obj => { + const { component, value, operator } = obj + const fieldId = component.options.attrs.fieldId + const viewIds = component.options.attrs.viewIds + const condition = new Condition(component.id, fieldId, operator, value, viewIds) + return condition +} diff --git a/frontend/src/views/login/index.vue b/frontend/src/views/login/index.vue index a8e7f68b4a..dcae4b81be 100644 --- a/frontend/src/views/login/index.vue +++ b/frontend/src/views/login/index.vue @@ -5,7 +5,7 @@