import { Component, ViewChild, Input, EventEmitter, Output, OnInit, Inject, LOCALE_ID, HostBinding } from '@angular/core'; import { TreeTableComponent, TreeNode } from '@farris/ui-treetable'; import { FilterExpression, ExpressionItem } from '../filter-expression-entity'; import { ExpressionService } from '@gsp-svc/expression'; import { VarEntity } from '@gsp-svc/expression'; import { Schema } from '@gsp-svc/expression'; import { GspCommonDataType } from '@gsp-bef/gsp-cm-metadata'; import { InjectedEntity } from '@gsp-svc/expression'; import { ExpressTypeEnum, RelationTypeEnum, CompareTypeEnum } from '../typeinfo'; import { FilterProperty, PropertyDataType } from '../property-entity'; import { FieldType } from '../field-type'; import { FilterEntitySchema } from '../schema'; import { FilterInjectedEntity } from '../injected-entity'; import { ViewEncapsulation } from '@angular/core'; import { NotifyService } from '@farris/ui-notify'; import { FilterConditionLocalePipe } from '../filter-condition-locale.pipe'; import { NewSchema } from '../NewSchema'; @Component({ selector: 'app-filter-condition', templateUrl: './filter-condition.component.html', styleUrls: ['./filter-condition.component.css'], providers: [ExpressionService], encapsulation: ViewEncapsulation.None }) /** * 过滤条件弹出框逻辑类 */ export class FilterConditionComponent implements OnInit { @HostBinding("class.f-utils-flex-column") cls = true; @HostBinding("class.h-100") cls1 = true; @ViewChild('tt') tt: TreeTableComponent; //获得树列表组件柄 @Output() closed = new EventEmitter(); //关闭窗口事件 @Output() result = new EventEmitter(); @Input() contextEntity: VarEntity[] = []; //预置计算表达式上下文实体 @Input() expressionText: string = ""; //预置计算默认表达式显示 @Input() expressionSchema: Array<{ name: string, schema: Schema }> = []; //预置计算表达式中的schema @Input() expressionNewSchema: Array<{ name: string, newSchema: NewSchema }> = []; //预置计算表达式中的NewSchema @Input() expressionInjectedEntities: InjectedEntity[] = []; //预置计算表达式中的注入实体 @Input() expressionCDT: GspCommonDataType[] = []; //预置计算表达式cdt集 @Input() propertyList: Array = []; //预置属性列表 @Input() filterExpressionString: string = null; //预置过滤表达式串 @Input() schemaMap = new Map(); //预置过滤表达式schema @Input() newSchemaMap = new Map(); //预置过滤表达式newSchema @Input() injectedEntity = new FilterInjectedEntity(); //预置过滤表达式注入实体 @Input() exprWinWidth: number = 850; //预置计算表达式弹出框宽度 constructor(private expr: ExpressionService, private notifyservice: NotifyService, @Inject(LOCALE_ID) localeId: string) { this.notifyservice = this.expr.getInjector().get(NotifyService); let languageCode = localeId != null ? localeId : localStorage.getItem('languageCode'); this.locale = new FilterConditionLocalePipe(languageCode); } locale: FilterConditionLocalePipe; //关系运算符 operators = []; private AllOperator = []; //全部 private StringOperator = []; //字符 private NumberOperator = []; //数字 private DateOperator = []; //日期 //频繁使用的,定义为变量 AND: string; OR: string; VALUE: string; EXPRESSION: string; DATE: string; DATETIME: string; columns: any[]; //列信息 relations = []; //逻辑运算符 types = []; //值类型 private notifies = {}; //消息提示 //默认属性 RelationView: string; //逻辑显示值 PropertyView: string; //属性显示值 OperatorView: string; //关系符显示值 ValueTypeView: string; //表达式类型显示值 //判断是否保存编辑后的过滤表达式 isEdited: boolean = false; displayPopup: boolean = false; OriginText: FilterExpression; //原始的表达式文本,记录用于取消 filterExpression: FilterExpression; treeData: TreeNode[] = []; treeDataTemp: TreeNode[]; //初始化,复制treeData值,treeDataTemp用于转换为FilterExpression实体 ngOnInit() { this.initResource(); if (this.filterExpressionString == null || this.filterExpressionString == "") { this.treeData = this.baseTree(); } else { let conditions = JSON.parse(this.filterExpressionString) as FilterExpression; this.treeData.push(this.unConvert(conditions)); this.treeData[0].data.id = 1; } this.treeDataTemp = this.treeData; } /** * Farris-Tree的节点选中事件 * @param $event 选中的元素 */ nodeSelected($event) { //隐藏所有节点的编辑框 this.hideNodeEditor(this.treeData); //将所选节点比较项、表达式类型项、值编辑框显示,并将所选对应数据赋给默认项进行显示 this.OperatorView = $event.node.data.operator; this.ValueTypeView = $event.node.data.expressType; if ($event.node.data.item == this.AND || $event.node.data.item == this.OR) { this.RelationView = $event.node.data.item; } else if ($event.node.data.item !== this.locale.transform("SelectProperty")) { let properties = this.propertyList.filter(x => x.text == $event.node.data.item); this.PropertyView = properties[0].id; if (properties[0].propertyDataType == PropertyDataType.String) { this.operators = this.StringOperator; } else if (properties[0].propertyDataType == PropertyDataType.Int16 || properties[0].propertyDataType == PropertyDataType.Int32 || properties[0].propertyDataType == PropertyDataType.Int64 || properties[0].propertyDataType == PropertyDataType.Decimal || properties[0].propertyDataType == PropertyDataType.Double) { this.operators = this.NumberOperator; } else if (properties[0].propertyDataType == PropertyDataType.DateTime || properties[0].propertyDataType == PropertyDataType.Date) { this.operators = this.DateOperator; } else { this.operators = this.AllOperator; } } $event.node.data.displayOperator = true; $event.node.data.displayExpressType = true; $event.node.data.displayValue = true; $event.node.data.displaySelect = true; }; /** * 隐藏所有节点的编辑框 * @param treeNodes 页面展示树结构 */ hideNodeEditor(treeNodes: TreeNode[]) { treeNodes.forEach(element => { element.data.displayOperator = false; element.data.displayExpressType = false; element.data.displayValue = false; element.data.displaySelect = false; //若有子节点,则将其子节点的编辑选择框隐藏 if ((element.children) && element.children.length != 0) { this.hideNodeEditor(element.children); } }); }; /** * 选择结束后隐藏该字段选择框 * @param tree 树形表绑定结构 * @param type 所选字段 */ hideFieldEditor(tree: TreeNode[], type: FieldType) { //找到所操作的节点,根据所选择的字段将对应选择编辑框隐藏 tree.forEach(treeNode => { if (this.tt.isSelected(treeNode)) { switch (type) { case FieldType.Item: treeNode.data.displaySelect = false; break; case FieldType.Operation: treeNode.data.displayOperator = false; break; case FieldType.Valuetype: treeNode.data.displayExpressType = false; break; } return; } else if ((treeNode.children) && treeNode.children.length != 0) { //若未找到所选节点,则找其子节点 this.hideFieldEditor(treeNode.children, type); } }); } //选择逻辑符 selectGroup($event) { this.propertyNodeOperate($event, this.treeData, FieldType.Group); } //选择项时 selectItem($event) { this.propertyNodeOperate($event, this.treeData, FieldType.Item); } //选择比较操作符时 selectOperator($event) { this.propertyNodeOperate($event, this.treeData, FieldType.Operation); } //选择值类型时 selectExpressType($event) { this.propertyNodeOperate($event, this.treeData, FieldType.Valuetype) }; /** * * @param event 选中内容 * @param tree 页面树形结构 * @param type 类型 */ private propertyNodeOperate(event: any, tree: TreeNode[], type: FieldType) { tree.forEach(node => { if (this.tt.isSelected(node)) { //对所选节点进行赋值操作 switch (type) { case FieldType.Group: { node.data.item = event.data.id; this.RelationView = event.data.id; } break; case FieldType.Item: { node.data.item = event.data.text; this.PropertyView = event.data.id; node.data.parentItem = event.data.parentItem; node.data.propertyDataType = event.data.propertyDataType; if (node.data.propertyDataType == PropertyDataType.String) { this.operators = this.StringOperator; } else if (node.data.propertyDataType == PropertyDataType.Int16 || node.data.propertyDataType == PropertyDataType.Int32 || node.data.propertyDataType == PropertyDataType.Int64 || node.data.propertyDataType == PropertyDataType.Decimal || node.data.propertyDataType == PropertyDataType.Double) { this.operators = this.NumberOperator; } else if (node.data.propertyDataType == PropertyDataType.DateTime || node.data.propertyDataType == PropertyDataType.Date) { this.operators = this.DateOperator; } else { this.operators = this.AllOperator; } } break; case FieldType.Operation: { node.data.operator = event.data.id; this.OperatorView = event.data.id; } break; case FieldType.Valuetype: { node.data.expressType = event.data.id; this.ValueTypeView = event.data.id; } break; } return; } else if ((node.children) && node.children.length != 0) { //否则对其子节点进行赋值操作 this.propertyNodeOperate(event, node.children, type); } }); } /** * 选中节点选择 * @param treeNodes 关系组 * @returns */ isSelected(treeNodes: TreeNode[]): any { let treeNode: TreeNode; for (var i = 0; i < treeNodes.length; i++) { if (this.tt.isSelected(treeNodes[i])) { treeNode = treeNodes[i]; break; } else if ((treeNodes[i].children) && treeNodes[i].children.length != 0) { //若在该层节点中未找到所选节点,则找其子节点 treeNode = this.isSelected(treeNodes[i].children); if ((treeNode)) break; } } return treeNode; } /** * 打开高级表达式 */ openAdvancedExpression() { let that = this; //添加预置上下文变量 if (this.contextEntity && this.contextEntity.length != 0) { this.contextEntity.forEach(element => { this.expr.addContext(element); }); } //添加预置表达式文本 let selectNode = this.isSelected(this.treeData); if ((selectNode) && (selectNode.data.value != "") && (selectNode.data.value != null)) { this.expr.addExpressionText(selectNode.data.value); } else this.expr.addExpressionText(this.expressionText); //添加注入实体 this.expressionInjectedEntities.forEach(element => { this.expr.addInjectedEntity(element.name, element.schemaName, element.injectedName, element.injectedType); }); //添加schema this.expressionSchema.forEach(element => { this.expr.addSchema(element.name, element.schema); }); //添加NewSchema this.expressionNewSchema.forEach(element => { this.expr.addNewSchema(element.name, element.newSchema); }); //添加cdt this.expr.addCDT(this.expressionCDT); //打开表达式编辑器并返回编辑结果 this.expr.buildExpression().then(info => { let expressInfo: any = info; this.displayExpressResult(that.treeData, expressInfo); }); } /** * 将计算表达式结果展示到对应节点 * @param treeNodes 树表绑定结构 * @param expressInfo 计算表达式得到结果 */ displayExpressResult(treeNodes: TreeNode[], expressInfo: string) { //找到所选节点实体,并将计算表达式所得结果赋给对应属性进行显示 treeNodes.forEach(treeNode => { if (this.tt.isSelected(treeNode)) { treeNode.data.value = expressInfo; return; } //若在该层节点中未找到所选节点,则找其子节点 else if ((treeNode.children) && treeNode.children.length != 0) { this.displayExpressResult(treeNode.children, expressInfo); } //若仍未找到,则不进行任何操作 }); } /** * 删除节点 * @param treeNode 要删除的节点 */ delete($event) { this.onDelete(this.treeData, $event); } /** * 删除节点具体实现类 * @param treeNodes 树形表绑定结构 */ onDelete(treeNodes: TreeNode[], id: number) { treeNodes.forEach(treeNode => { if (treeNode.data.id == id) { if (treeNode.data.id == 1) { this.notifyservice[this.notifies['6'].type]({ msg: this.notifies['6'].msg }); this.treeData = this.baseTree(); return; } //所选节点所在数 let index = treeNodes.indexOf(treeNode); //将所选节点剔除 treeNodes.splice(index, 1); } else if ((treeNode.children) && treeNode.children.length != 0) { treeNode.children = this.onDelete(treeNode.children, id); } }); this.tt.updateSerializedValue(); return treeNodes; } /** * 保存生成过滤条件串 */ public confirm() { this.treeDataTemp = this.treeData; let isNull = true; let isMatch = true; if (this.checkNull(this.treeDataTemp[0].children, isNull) && this.checkMatch(this.treeDataTemp[0].children, isMatch)) { //根据树形数据结构转化为过滤表达式实体 this.filterExpression = this.convert(this.treeDataTemp[0]); this.isEdited = true; this.notifyservice[this.notifies['1'].type]({ msg: this.notifies['1'].msg }); this.close(); this.closed.emit("close"); } } /** * 重置清空过滤条件 */ public reset() { this.treeData = this.baseTree(); this.filterExpressionString = null; //置空页面数据 } /** * 关闭过滤表达式设计页面 */ public cancel() { this.closed.emit("close"); } /** * 关闭窗口 */ close() { if (this.isEdited == true) { //若只包含关系项则返回空 if (this.filterExpression.expressItems.length == 0) this.result.next(null); //若最后一次点了确定,则将过滤表达式JSON序列化输出 else this.result.next(JSON.stringify(this.filterExpression)); } //若未点确定,默认无任何编辑文本,则输出空串 else this.result.next(this.filterExpressionString); } /** * 递归检查整个过滤表达式是否有漏填的项 * @param treeNodes * @param isNull * @returns */ checkNull(treeNodes: TreeNode[], isNull: boolean): boolean { for (var i = 0; i < treeNodes.length; i++) { if (treeNodes[i].data.item == this.AND || treeNodes[i].data.item == this.OR) { if (!(treeNodes[i].children) || treeNodes[i].children.length == 0) { this.notifyservice[this.notifies['3'].type]({ msg: this.notifies['3'].msg }); isNull = false; break; } else if (!this.checkNull(treeNodes[i].children, isNull)) { isNull = false; break; } } else { if (!(treeNodes[i].data.item) || treeNodes[i].data.item == this.locale.transform("SelectProperty") || !(treeNodes[i].data.operator) || !(treeNodes[i].data.expressType) || treeNodes[i].data.value == null || treeNodes[i].data.value == undefined) { this.notifyservice[this.notifies['4'].type]({ msg: this.notifies['4'].msg }); isNull = false; break; } } } return isNull; } /** * 校验节点数值类型是否填写正确 * @param treeNodes * @param isMatch * @returns */ checkMatch(treeNodes: TreeNode[], isMatch: boolean) { for (var i = 0; i < treeNodes.length; i++) { if (treeNodes[i].data.item != this.AND && treeNodes[i].data.item != this.OR) { if (treeNodes[i].data.expressType == this.locale.transform("Value")) { if ((treeNodes[i].data.propertyDataType == PropertyDataType.Int16 || treeNodes[i].data.propertyDataType == PropertyDataType.Int32 || treeNodes[i].data.propertyDataType == PropertyDataType.Int64) && isNaN(treeNodes[i].data.value)) { this.notifyservice[this.notifies['5'].type]({ msg: this.notifies['5'].msg }); isMatch = false; break; } } } else isMatch = this.checkMatch(treeNodes[i].children, isMatch); } return isMatch; } /** * 页面展示的树结构解析为过滤条件 * @param tree 页面展示树结构 * @returns 过滤条件 */ private convert(tree: TreeNode): FilterExpression { let conditions: FilterExpression = new FilterExpression(); //得到最外层的关系符 conditions.relationOperator = this.toValue(tree.data.item); //若其子项不为空 if (tree.children.length != 0) { //对其每一个子项进行转化操作 tree.children.forEach(child => { if (this.toValue(child.data.item) == RelationTypeEnum.And || this.toValue(child.data.item) == RelationTypeEnum.Or) { //若子项为并且、或者 conditions.expressItems.push(this.convert(child)); } else { //若子项为属性 //根据属性名展示值找到其在预置列表中的语义化值,将语义化值赋给实体保存 let properties = this.propertyList.filter(x => x.text == child.data.item); let item: ExpressionItem = { "propertyName": properties[0] != null ? properties[0].value : null, "propertyDataType": child.data.propertyDataType, "operator": this.toValue(child.data.operator), "expressType": this.toValue(child.data.expressType), "value": child.data.value, "parentItem": child.data.parentItem }; //若为数值型比较,则将value值强制转换为数字 if (item.expressType == ExpressTypeEnum.Value && (item.operator == CompareTypeEnum.GreaterThan || item.operator == CompareTypeEnum.GreaterThanOrEqual || item.operator == CompareTypeEnum.LessThan || item.operator == CompareTypeEnum.LessThanOrEqual)) { item.value = Number(child.data.value); } if (item.expressType == ExpressTypeEnum.Value && (item.operator == CompareTypeEnum.Equal || item.operator == CompareTypeEnum.NotEqual)) { if (item.propertyDataType == PropertyDataType.Decimal || item.propertyDataType == PropertyDataType.Double || item.propertyDataType == PropertyDataType.Int16 || item.propertyDataType == PropertyDataType.Int32 || item.propertyDataType == PropertyDataType.Int64) { item.value = Number(child.data.value); } } //将子项放入父项的字段中 conditions.expressItems.push(item); } }); } return conditions; } /** * 将过滤条件转换为树形结构,用于页面展示 * @param conditions 过滤条件实体 * @returns 树形结构 */ private unConvert(conditions: FilterExpression): TreeNode { let tree: TreeNode = { data: { "id": Math.random(), //树形结构中每个节点的id "item": this.relationToView(conditions.relationOperator), //属性 "propertyDataType": null, //属性数据类型 "operator": null, //属性操作符 "expressType": null, //值类型 "value": null, //值 "displaySelect": false, //选择项显示 "displayOperator": false, //操作符项显示 "displayExpressType": false, //表达式类型显示 "displayValue": false, //值显示 "parentItem": null //父项 }, children: [], //子节点集合 expanded: true //是否展开 }; //对于每一个子项 conditions.expressItems.forEach(cond => { let item = cond as any; //此处类型转换受限,通过relationOperator判断字段类型 if (item.relationOperator == RelationTypeEnum.And || item.relationOperator == RelationTypeEnum.Or) { //存在relationOperator属性,则子项为FilterExpression,递归 let child = this.unConvert(item); child.data.parent = tree;//添加父节点 tree.children.push(child); } else { //不存在relationOperator属性,则子项为ExpressionItem类型,赋值 let properties = this.propertyList.filter(x => x.value == item.propertyName); let child: TreeNode = { data: { "id": Math.random(), //树形结构中每个节点的id "item": properties[0] != null ? properties[0].text : null, //属性 "propertyDataType": item.propertyDataType, //属性数据类型 "operator": this.operatorToView(item.operator), //操作比较符 "expressType": this.valueTypeToView(item.expressType), //表达式类型 "value": item.value, //值 "parentItem": item.parentItem //父项 }, parent: tree, //添加父节点 children: [], //子节点集合 expanded: true //是否展开 } tree.children.push(child); } }); return tree; } /** * 添加条件 */ addItem(treeId: number) { this.hideNodeEditor(this.treeData); this.addNode(this.treeData, this.locale.transform("SelectProperty"), this.locale.transform("Equal"), this.locale.transform("Value"), treeId); this.OperatorView = this.locale.transform("SelectProperty"); //默认显示 } /** * 添加分组 */ addGroup(treeId: number) { this.addNode(this.treeData, this.AND, null, null, treeId); } /** * 根据所选为关系或者属性对新节点进行初始化 * @param treeNodes 树形表绑定结构 * @param defaultString 新节点显示默认值 */ addNode(treeNodes: TreeNode[], defaultString: any, defaultOperator: string, defalutExpressType: string, treeId: number) { treeNodes.forEach(node => { if (node.data.id == treeId) { //若关系值为空 if (!(node.data.item)) { this.notifyservice[this.notifies['2'].type]({ msg: this.notifies['2'].msg }); return; } //若为所选的关系节点,则在其子项里添加新子节点 let newNode: TreeNode = { data: { "item": defaultString, "propertyDataType": null, //属性数据类型 "operator": defaultOperator, "expressType": defalutExpressType, "value": null, "id": Math.random(), "parentItem": null }, parent: node, children: [], expanded: true }; //向该所选节点的子项添加新节点 node.children.push(newNode); return; } else if ((node.children) && node.children.length != 0) { //若未找到所选节点,且该节点子项不为空,则在其子项中查找所选节点 this.addNode(node.children, defaultString, defaultOperator, defalutExpressType, treeId); } }); this.tt.updateSerializedValue(); } /** * 返回过滤条件树的第一个结点 * @returns id = 1的结点 */ private baseTree(): any { let tree = []; tree.push( { data: { "id": 1, //树形结构中每个节点的id "item": this.AND, //属性项(默认为And) "propertyDataType": null, //属性数据类型 "operator": null, //操作比较符 "expressType": null, //表达式类型 "value": null, //值 "displaySelect": false, //选择项显示 "displayOperator": false, //操作符项显示 "displayExpressType": false, //表达式类型显示 "displayValue": false, //值显示 "parentItem": null //父项 }, children: [], //子节点集合 expanded: true //是否展开 } ); return tree; } /** * 初始化资源 */ private initResource() { this.columns = [ { field: 'item', title: this.locale.transform("Item"), width: 271 }, { field: 'operator', title: this.locale.transform("Operator"), width: 140 }, { field: 'expressType', title: this.locale.transform("ExpressType"), width: 140 }, { field: 'value', title: this.locale.transform("Value"), width: 235 }, { field: 'operation', title: this.locale.transform("Operation"), width: 200, align: "center" } ]; this.relations = [ { id: this.AND = this.locale.transform("And") }, { id: this.OR = this.locale.transform("Or") } ]; this.types = [ { id: this.VALUE = this.locale.transform("Value") }, { id: this.EXPRESSION = this.locale.transform("Expression") }, // { id: this.DATE = this.locale.transform("Date") }, // { id: this.DATETIME = this.locale.transform("DateTime") } ]; this.notifies = { 1: { type: 'success', msg: this.locale.transform("Success") }, 2: { type: 'warning', msg: this.locale.transform("Warning_SelectRelation") }, 3: { type: 'warning', msg: this.locale.transform("Warning_ContainsFilters") }, 4: { type: 'warning', msg: this.locale.transform("Warning_ConditionsComplete") }, 5: { type: 'warning', msg: this.locale.transform("Warning_NumericMatch") }, 6: { type: 'warning', msg: this.locale.transform("Warning_DeteleFirst") } }; this.AllOperator = [ { id: this.locale.transform("Equal") }, { id: this.locale.transform("NotEqual") }, { id: this.locale.transform("GreaterThan") }, { id: this.locale.transform("GreaterThanOrEqual") }, { id: this.locale.transform("LessThan") }, { id: this.locale.transform("LessThanOrEqual") }, { id: this.locale.transform("Contains") }, { id: this.locale.transform("NotContains") }, { id: this.locale.transform("StartsWith") }, { id: this.locale.transform("NotStartsWith") }, { id: this.locale.transform("EndsWith") }, { id: this.locale.transform("NotEndsWith") }, { id: this.locale.transform("IsNull") }, { id: this.locale.transform("IsNotNull") }, { id: this.locale.transform("In") }, { id: this.locale.transform("NotIn") }, { id: this.locale.transform("Date_Earlier") }, { id: this.locale.transform("Date_Equal") }, { id: this.locale.transform("Date_Later") } ]; this.NumberOperator = [ { id: this.locale.transform("Equal") }, { id: this.locale.transform("NotEqual") }, { id: this.locale.transform("GreaterThan") }, { id: this.locale.transform("GreaterThanOrEqual") }, { id: this.locale.transform("LessThan") }, { id: this.locale.transform("LessThanOrEqual") }, { id: this.locale.transform("IsNull") }, { id: this.locale.transform("IsNotNull") } ]; this.StringOperator = [ { id: this.locale.transform("Equal") }, { id: this.locale.transform("NotEqual") }, { id: this.locale.transform("Contains") }, { id: this.locale.transform("NotContains") }, { id: this.locale.transform("StartsWith") }, { id: this.locale.transform("EndsWith") }, { id: this.locale.transform("NotStartsWith") }, { id: this.locale.transform("NotEndsWith") }, { id: this.locale.transform("IsNull") }, { id: this.locale.transform("IsNotNull") }, { id: this.locale.transform("In") }, { id: this.locale.transform("NotIn") } ]; this.DateOperator = [ { id: this.locale.transform("Date_Earlier") }, { id: this.locale.transform("Date_Equal") }, { id: this.locale.transform("Date_Later") } ]; this.RelationView = this.locale.transform("And"); this.PropertyView = this.locale.transform("SelectProperty"); this.OperatorView = this.locale.transform("GreaterThan"); this.ValueTypeView = this.locale.transform("Value"); } /** * 逻辑操作符、值类型、操作符的视图值转为真实值 * @param value 视图值 * @returns 真实值 */ private toValue(value: string): any { switch (value) { case this.AND: return RelationTypeEnum.And; case this.OR: return RelationTypeEnum.Or; case this.VALUE: return ExpressTypeEnum.Value; case this.EXPRESSION: return ExpressTypeEnum.Expression; case this.DATE: return ExpressTypeEnum.Date; case this.DATETIME: return ExpressTypeEnum.DateTime; case this.locale.transform("GreaterThan"): return CompareTypeEnum.GreaterThan; case this.locale.transform("GreaterThanOrEqual"): return CompareTypeEnum.GreaterThanOrEqual; case this.locale.transform("LessThan"): return CompareTypeEnum.LessThan; case this.locale.transform("LessThanOrEqual"): return CompareTypeEnum.LessThanOrEqual; case this.locale.transform("Equal"): return CompareTypeEnum.Equal; case this.locale.transform("NotEqual"): return CompareTypeEnum.NotEqual; case this.locale.transform("Contains"): return CompareTypeEnum.Contains; case this.locale.transform("NotContains"): return CompareTypeEnum.NotContains; case this.locale.transform("StartsWith"): return CompareTypeEnum.StartsWith; case this.locale.transform("NotStartsWith"): return CompareTypeEnum.NotStartsWith; case this.locale.transform("EndsWith"): return CompareTypeEnum.EndsWith; case this.locale.transform("NotEndsWith"): return CompareTypeEnum.NotEndsWith; case this.locale.transform("IsNull"): return CompareTypeEnum.IsNull; case this.locale.transform("IsNotNull"): return CompareTypeEnum.IsNotNull; case this.locale.transform("In"): return CompareTypeEnum.In; case this.locale.transform("NotIn"): return CompareTypeEnum.NotIn; case this.locale.transform("Date_Earlier"): return CompareTypeEnum.Date_Earlier; case this.locale.transform("Date_Equal"): return CompareTypeEnum.Date_Equal; case this.locale.transform("Date_Later"): return CompareTypeEnum.Date_Later; } } /** * 逻辑操作符转为视图值 * @param type 逻辑操作符 * @returns 视图值 */ private relationToView(type: RelationTypeEnum): string { switch (type) { case RelationTypeEnum.And: return this.AND; case RelationTypeEnum.Or: return this.OR; } } /** * 值类型转为视图值 * @param type 值类型 * @returns 视图值 */ private valueTypeToView(type: ExpressTypeEnum): string { switch (type) { case ExpressTypeEnum.Value: return this.VALUE; case ExpressTypeEnum.Expression: return this.EXPRESSION; case ExpressTypeEnum.Date: return this.DATE; case ExpressTypeEnum.DateTime: return this.DATETIME; } } /** * 操作符转为视图值 * @param type 操作符 * @returns 视图值 */ private operatorToView(type: CompareTypeEnum): string { switch (type) { case CompareTypeEnum.GreaterThan: return this.locale.transform("GreaterThan"); case CompareTypeEnum.GreaterThanOrEqual: return this.locale.transform("GreaterThanOrEqual"); case CompareTypeEnum.LessThan: return this.locale.transform("LessThan"); case CompareTypeEnum.LessThanOrEqual: return this.locale.transform("LessThanOrEqual"); case CompareTypeEnum.Equal: return this.locale.transform("Equal"); case CompareTypeEnum.NotEqual: return this.locale.transform("NotEqual"); case CompareTypeEnum.Contains: return this.locale.transform("Contains"); case CompareTypeEnum.NotContains: return this.locale.transform("NotContains"); case CompareTypeEnum.StartsWith: return this.locale.transform("StartsWith"); case CompareTypeEnum.NotStartsWith: return this.locale.transform("NotStartsWith"); case CompareTypeEnum.EndsWith: return this.locale.transform("EndsWith"); case CompareTypeEnum.NotEndsWith: return this.locale.transform("NotEndsWith"); case CompareTypeEnum.IsNull: return this.locale.transform("IsNull"); case CompareTypeEnum.IsNotNull: return this.locale.transform("IsNotNull"); case CompareTypeEnum.In: return this.locale.transform("In"); case CompareTypeEnum.NotIn: return this.locale.transform("NotIn"); case CompareTypeEnum.Date_Earlier: return this.locale.transform("Date_Earlier"); case CompareTypeEnum.Date_Equal: return this.locale.transform("Date_Equal"); case CompareTypeEnum.Date_Later: return this.locale.transform("Date_Later"); } } }