|
@@ -281,15 +281,15 @@ export default {
|
|
|
this.$set( field, 'conditions', [{function: "eq", values: ["", ""], timeType: "absolute", countType: "left",connectType:"and",asFilter:true,uniqId: util.getRandomStr(7)}])
|
|
|
this.config.filter.push(field);
|
|
|
document.body.click()
|
|
|
- field.conditions.forEach((item,i)=>{
|
|
|
- this.relationNode.conditions.push({uniqId: item.uniqId, columnTitle: field.columnTitle,})
|
|
|
- this.config.filterRelation = JSON.stringify(this.relationNode)
|
|
|
- })
|
|
|
- // if (this.config.filterRelation){
|
|
|
- // let filterRelation = JSON.parse(this.config.filterRelation)
|
|
|
- // filterRelation.conditions.push({uniqId: field.uniqId, columnTitle: field.columnTitle,})
|
|
|
- // this.config.filterRelation = JSON.stringify(filterRelation)
|
|
|
- // }
|
|
|
+ // field.conditions.forEach((item,i)=>{
|
|
|
+ // this.relationNode.conditions.push({uniqId: item.uniqId, columnTitle: field.columnTitle,})
|
|
|
+ // this.config.filterRelation = JSON.stringify(this.relationNode)
|
|
|
+ // })
|
|
|
+ if (this.config.filterRelation){
|
|
|
+ let filterRelation = JSON.parse(this.config.filterRelation)
|
|
|
+ filterRelation.conditions.push({uniqId: field.uniqId, columnTitle: field.columnTitle,})
|
|
|
+ this.config.filterRelation = JSON.stringify(filterRelation)
|
|
|
+ }
|
|
|
},
|
|
|
countCanAggregation(filter) {
|
|
|
if (filter.connectTime == 'where') return false;
|
|
@@ -371,15 +371,17 @@ export default {
|
|
|
},
|
|
|
// 初始化过滤器结构
|
|
|
initRelation() {
|
|
|
- let filterRelation = this.config.filter.filter((i) => i.connectTime === "where");
|
|
|
+ // let filterRelation = this.config.filter.filter((i) => i.connectTime === "where");
|
|
|
// 遍历 filterRelation 定义filterRelation下每个对象为item,如果item下conditions 存在且有长度的 遍历item的 conditions map出来 {uniqId: i.uniqId, columnTitle: item.columnTitle}
|
|
|
- let conditionsList = []
|
|
|
- filterRelation.forEach((item) => {
|
|
|
- let filterItem = item.conditions.map((i) => ({uniqId: i.uniqId, columnTitle: item.columnTitle,}));
|
|
|
- conditionsList = [...conditionsList,...filterItem]
|
|
|
- });
|
|
|
+ // let conditionsList = []
|
|
|
+ // filterRelation.forEach((item) => {
|
|
|
+ // let filterItem = item.conditions.map((i) => ({uniqId: i.uniqId, columnTitle: item.columnTitle,}));
|
|
|
+ // conditionsList = [...conditionsList,...filterItem]
|
|
|
+ // });
|
|
|
this.relationNode = {
|
|
|
- conditions: conditionsList,
|
|
|
+ conditions: this.config.filter
|
|
|
+ .filter((i) => i.connectTime === "where")
|
|
|
+ .map((i) => ({uniqId: i.uniqId, columnTitle: i.columnTitle,})),
|
|
|
relation: "AND",
|
|
|
};
|
|
|
},
|
|
@@ -422,47 +424,38 @@ export default {
|
|
|
onConditionAdd() {
|
|
|
let addItem = {function: "eq", values: ["", ""], timeType: "absolute", countType: "left",uniqId: util.getRandomStr(7)}
|
|
|
this.nowFilter.conditions.push(addItem);
|
|
|
- if (this.config.filterRelation){
|
|
|
- this.relationNode.conditions.push({uniqId: addItem.uniqId, columnTitle: this.nowFilter.columnTitle,})
|
|
|
- this.config.filterRelation = JSON.stringify(this.relationNode)
|
|
|
- }
|
|
|
+ // if (this.config.filterRelation){
|
|
|
+ // this.relationNode.conditions.push({uniqId: addItem.uniqId, columnTitle: this.nowFilter.columnTitle,})
|
|
|
+ // this.config.filterRelation = JSON.stringify(this.relationNode)
|
|
|
+ // }
|
|
|
},
|
|
|
onConditionUpdate() {
|
|
|
this.showEditFilter = false
|
|
|
- let itemUniqId = [];
|
|
|
- // 遍历 filter 中的每个对象
|
|
|
- this.config.filter.forEach(item => {
|
|
|
- // 检查 conditions 是否存在且不为空
|
|
|
- if (item.conditions && item.conditions.length > 0) {
|
|
|
- // 遍历 conditions 数组中的每个对象
|
|
|
- item.conditions.forEach(condition => {
|
|
|
- // 将 uniqId 添加到 uniqIds 数组中
|
|
|
- itemUniqId.push(condition.uniqId);
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
- this.relationNode?.conditions?.forEach((node, index) => {
|
|
|
- this.updateNullNode(this.relationNode, node,itemUniqId, index);
|
|
|
- });
|
|
|
- if (this.config.filterRelation){
|
|
|
- this.config.filterRelation = JSON.stringify(this.relationNode)
|
|
|
- }
|
|
|
- },
|
|
|
- // 清除空节点
|
|
|
- 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);
|
|
|
- }
|
|
|
+ // let itemUniqId = [];
|
|
|
+ // // 遍历 filter 中的每个对象
|
|
|
+ // this.config.filter.forEach(item => {
|
|
|
+ // // 检查 conditions 是否存在且不为空
|
|
|
+ // if (item.conditions && item.conditions.length > 0) {
|
|
|
+ // // 遍历 conditions 数组中的每个对象
|
|
|
+ // item.conditions.forEach(condition => {
|
|
|
+ // // 将 uniqId 添加到 uniqIds 数组中
|
|
|
+ // itemUniqId.push(condition.uniqId);
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // this.relationNode?.conditions?.forEach((node, index) => {
|
|
|
+ // this.updateNullNode(this.relationNode, node,itemUniqId, index);
|
|
|
+ // });
|
|
|
+ // if (this.config.filterRelation){
|
|
|
+ // this.config.filterRelation = JSON.stringify(this.relationNode)
|
|
|
+ // }
|
|
|
},
|
|
|
// 清除空节点
|
|
|
- // clearNullNode(parent, item, index) {
|
|
|
- // if (item.conditions && item.conditions.length){
|
|
|
- // item.conditions.forEach((node, i) => this.clearNullNode(item, node, i));
|
|
|
+ // 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 && !item.conditions.length) {
|
|
|
+ // if (!item.conditions && !itemUniqId.includes(item.uniqId)) {
|
|
|
// parent.conditions.splice(index, 1);
|
|
|
// }
|
|
|
// },
|
|
@@ -476,17 +469,6 @@ export default {
|
|
|
this.$nextTick(() => {
|
|
|
this.nowFilter = field;
|
|
|
this.toggleType = toggleType;
|
|
|
- let relation = this.config.filterRelation;
|
|
|
- if (relation) {
|
|
|
- let where = JSON.parse(relation);
|
|
|
- if (where.conditions && where.conditions.length) {
|
|
|
- this.relationNode = where;
|
|
|
- } else {
|
|
|
- this.initRelation();
|
|
|
- }
|
|
|
- } else {
|
|
|
- this.initRelation();
|
|
|
- }
|
|
|
})
|
|
|
// let func = this.nowFilter.conditions[0].function;
|
|
|
// if (func === "in" || func === "notIn" || func === "indexIn") {
|
|
@@ -497,21 +479,19 @@ export default {
|
|
|
},
|
|
|
onFieldDel(index) {
|
|
|
let item = this.config.filter.splice(index, 1)[0];
|
|
|
- item.conditions.forEach((item1) => {
|
|
|
- let uniqId = item1.uniqId;
|
|
|
- if (this.config.filterRelation){
|
|
|
- let where = JSON.parse(this.config.filterRelation);
|
|
|
- let node = this.getIncludeNode(where, uniqId);
|
|
|
- let index2 = node.conditions.findIndex((i) => i.uniqId === uniqId);
|
|
|
- node.conditions.splice(index2, 1);
|
|
|
- where.conditions.forEach((node, index) => {
|
|
|
- this.clearNullNode(where, node, index);
|
|
|
- });
|
|
|
- this.config.filterRelation = JSON.stringify(where);
|
|
|
- this.relationNode = where;
|
|
|
- this.$forceUpdate();
|
|
|
- }
|
|
|
- })
|
|
|
+ let uniqId = item.uniqId;
|
|
|
+ if (this.config.filterRelation){
|
|
|
+ let where = JSON.parse(this.config.filterRelation);
|
|
|
+ let node = this.getIncludeNode(where, uniqId);
|
|
|
+ let index2 = node.conditions.findIndex((i) => i.uniqId === uniqId);
|
|
|
+ node.conditions.splice(index2, 1);
|
|
|
+ where.conditions.forEach((node, index) => {
|
|
|
+ this.clearNullNode(where, node, index);
|
|
|
+ });
|
|
|
+ this.config.filterRelation = JSON.stringify(where);
|
|
|
+ this.relationNode = where;
|
|
|
+ this.$forceUpdate();
|
|
|
+ }
|
|
|
},
|
|
|
getIncludeNode(node, uniqId) {
|
|
|
if (node.conditions && node.conditions.length){
|