提交 20d33343 编写于 作者: JunZai's avatar JunZai

update

上级 b9caefaf
......@@ -119,7 +119,34 @@ FilterTree,
if(this.filterItems.length === 0) {
return null;
}
return { ...this.transformAnd(this.filterItems) };
let ands: any[] = this.transformAnd(this.filterItems);
this.transformResult(ands, '$and');
return { '$and': ands };
}
/**
* 处理结果集
*
* @return {*}
* @memberof ${srfclassname('${ctrl.codeName}')}Base
*/
public transformResult(datas: any[], pName: string) {
let items: any[] = [];
for(let i = datas.length - 1; i >= 0; i--) {
let data: any = datas[i];
let field: string = Object.is(pName, '$and') ? '$or' : '$and';
if(data.hasOwnProperty(field)) {
items.push(data);
datas.splice(i, 1);
this.transformResult(data[field], field);
}
}
if(items.length > 0) {
let item: any = {};
item[pName] = items;
datas.push(item);
}
}
/**
......@@ -138,8 +165,8 @@ FilterTree,
item[field.prop][data.mode] = (data[data.field] == null ? '' : data[data.field]);
result.push(item)
} else if(Object.is(data.label, '$and')) {
item[data.label] = this.transformAnd(data.children);
result.push(item)
let items: any[] = this.transformAnd(data.children);
result = [...result, ...items];
} else if(Object.is(data.label, '$or')) {
item[data.label] = this.transformOr(data.children);
result.push(item)
......@@ -165,7 +192,7 @@ FilterTree,
result.push(item);
} else if(Object.is(data.label, '$and')) {
item[data.label] = this.transformAnd(data.children);
result.push(item);
result.push(item)
} else if(Object.is(data.label, '$or')) {
item[data.label] = this.transformOr(data.children);
result.push(item);
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册