|
@@ -191,7 +191,7 @@
|
|
|
:visible.sync="showRelationEdit" title="过滤器结构编辑" width="600px" custom-class="filter-relation-dialog"
|
|
|
append-to-body
|
|
|
>
|
|
|
- <filter-node :node="relationNode" :level="1" type="where"></filter-node>
|
|
|
+ <filter-node :node="relationNode" :level="1" type="where"></filter-node>
|
|
|
</el-dialog>
|
|
|
</div>
|
|
|
</template>
|
|
@@ -256,6 +256,7 @@ export default {
|
|
|
onNodeDrag: this.onNodeDrag,
|
|
|
onNodeDrop: this.onNodeDrop,
|
|
|
onDelFilter: this.onDelFilter,
|
|
|
+ filterChange: this.clomunRelationChange,
|
|
|
maxLevel: this.maxLevel,
|
|
|
};
|
|
|
},
|
|
@@ -340,19 +341,18 @@ export default {
|
|
|
},
|
|
|
// 结构编辑面板点击编辑过滤器时
|
|
|
editFilterByUniqId(uniqId) {
|
|
|
- // 遍历 filter 中的每个对象
|
|
|
- this.config.filter.forEach(item => {
|
|
|
- // 检查 conditions 是否存在且不为空
|
|
|
- if (item.conditions && item.conditions.length > 0) {
|
|
|
- // 遍历 conditions 数组中的每个对象
|
|
|
- item.conditions.forEach(condition => {
|
|
|
- // 将 uniqId 添加到 uniqIds 数组中
|
|
|
- if (condition.uniqId === uniqId){
|
|
|
- this.onEditFilter(item, 2);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
+ let filter = this.config.filter.find((i) => i.uniqId === uniqId);
|
|
|
+ this.onEditFilter(filter, 2);
|
|
|
+ },
|
|
|
+ // 修改连接方式
|
|
|
+ clomunRelationChange(value){
|
|
|
+ if (value && value.conditions && value.conditions.length === 1){
|
|
|
+ this.config.filter.forEach((item)=>{
|
|
|
+ if (item.uniqId === value.conditions[0].uniqId){
|
|
|
+ this.$set(item, 'connectType', value.relation === 'OR' ? 'or' : 'and')
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
},
|
|
|
// 编辑结构时
|
|
|
onEditRelation() {
|
|
@@ -443,22 +443,24 @@ export default {
|
|
|
// });
|
|
|
// }
|
|
|
// });
|
|
|
- // this.relationNode?.conditions?.forEach((node, index) => {
|
|
|
- // this.updateNullNode(this.relationNode, node,itemUniqId, index);
|
|
|
- // });
|
|
|
- // if (this.config.filterRelation){
|
|
|
- // this.config.filterRelation = JSON.stringify(this.relationNode)
|
|
|
- // }
|
|
|
+ this.relationNode?.conditions?.forEach((node, index) => {
|
|
|
+ this.updateNullNode(this.relationNode, node, index,this.nowFilter);
|
|
|
+ });
|
|
|
+ if (this.config.filterRelation){
|
|
|
+ this.config.filterRelation = JSON.stringify(this.relationNode)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 更新节点连接方式
|
|
|
+ updateNullNode(parent, item, index,nowFilter) {
|
|
|
+ if (item?.conditions && item.conditions.length){
|
|
|
+ if ( item.conditions.length === 1 && item.conditions[0].uniqId === nowFilter.uniqId){
|
|
|
+ item.relation = nowFilter.connectType === 'and' ? 'AND' : 'OR'
|
|
|
+ }else {
|
|
|
+ item.conditions.forEach((node, i) => this.updateNullNode(item, node, i,nowFilter));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
},
|
|
|
- // 清除空节点
|
|
|
- // updateNullNode(parent, item,itemUniqId, index) {
|
|
|
- // if (item?.conditions && item.conditions.length){
|
|
|
- // item.conditions.forEach((node, i) => this.updateNullNode(item, node, itemUniqId, i));
|
|
|
- // }
|
|
|
- // if (!item.conditions && !itemUniqId.includes(item.uniqId)) {
|
|
|
- // parent.conditions.splice(index, 1);
|
|
|
- // }
|
|
|
- // },
|
|
|
// 过滤器删除条件
|
|
|
onConditionDel(i) {
|
|
|
this.nowFilter.conditions.splice(i, 1);
|