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 @@