From 0bfae138a46f36629ed2491c5d65fc70a4c0b1ce Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 7 Apr 2020 16:24:11 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=86=E5=9B=BE=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E8=BF=87=E6=BB=A4=E5=85=81=E8=AE=B8=E8=BF=94=E5=9B=9E=E9=80=89?= =?UTF-8?q?=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../source/x_component_query_Query/Viewer.js | 111 ++++++++++++++---- 1 file changed, 89 insertions(+), 22 deletions(-) diff --git a/o2web/source/x_component_query_Query/Viewer.js b/o2web/source/x_component_query_Query/Viewer.js index ef32116aff..0479a5de0b 100644 --- a/o2web/source/x_component_query_Query/Viewer.js +++ b/o2web/source/x_component_query_Query/Viewer.js @@ -850,32 +850,90 @@ MWF.xApplication.query.Query.Viewer = MWF.QViewer = new Class({ var option = this.viewSearchCustomPathListNode.options[idx]; var entry = option.retrieve("entry"); if (entry){ + var selectableList = this.getCustomSelectScriptResult(entry); switch (entry.formatType){ case "numberValue": this.loadComparisonSelect(this.lp.numberFilter); - this.loadViewSearchCustomValueNumberInput(); + if( selectableList.length > 0 ){ + this.loadViewSerchCustomSelectByScript(selectableList) + }else{ + this.loadViewSearchCustomValueNumberInput(); + } break; case "dateTimeValue": this.loadComparisonSelect(this.lp.dateFilter); - this.loadViewSearchCustomValueDateTimeInput(); + if( selectableList.length > 0 ){ + this.loadViewSerchCustomSelectByScript(selectableList) + }else { + this.loadViewSearchCustomValueDateTimeInput(); + } break; case "dateValue": this.loadComparisonSelect(this.lp.dateFilter); - this.loadViewSearchCustomValueDateInput(); + if( selectableList.length > 0 ){ + this.loadViewSerchCustomSelectByScript(selectableList) + }else { + this.loadViewSearchCustomValueDateInput(); + } break; case "timeValue": this.loadComparisonSelect(this.lp.dateFilter); - this.loadViewSearchCustomValueTimeInput(); + if( selectableList.length > 0 ){ + this.loadViewSerchCustomSelectByScript(selectableList) + }else { + this.loadViewSearchCustomValueTimeInput(); + } break; case "booleanValue": this.loadComparisonSelect(this.lp.booleanFilter); - this.loadViewSearchCustomValueBooleanInput(); + if( selectableList.length > 0 ){ + this.loadViewSerchCustomSelectByScript(selectableList) + }else { + this.loadViewSearchCustomValueBooleanInput(); + } break; default: this.loadComparisonSelect(this.lp.textFilter); - this.loadViewSearchCustomValueTextInput(); + if( selectableList.length > 0 ){ + this.loadViewSerchCustomSelectByScript(selectableList) + }else { + this.loadViewSearchCustomValueTextInput(); + } + } + } + }, + getCustomSelectScriptResult : function( entry ){ + var scriptResult = []; + if( entry.valueType === "script" ){ + if( entry.valueScript && entry.valueScript.code ){ + var result = this.Macro.exec(entry.valueScript.code, this); + var array = typeOf( result ) === "array" ? result : [result]; + for( var i=0; i -1 ){ + var arr = array[i].split("|"); + scriptResult.push({ "text" : arr[0], "value" : arr[1] }) + }else{ + scriptResult.push({ "text" : array[i], "value" : array[i] }) + } + } } } + return scriptResult; + }, + loadViewSerchCustomSelectByScript: function( array ){ + this.viewSearchCustomValueContentNode.empty(); + this.viewSearchCustomValueNode = new Element("select", { + "styles": this.css.viewFilterSearchCustomComparisonListNode, + "multiple": true + }).inject(this.viewSearchCustomValueContentNode); + array.each(function( v ){ + var option = new Element("option", { + "style": this.css.viewFilterSearchOptionNode, + "value": v.value, + "text": v.text, + "selected" : array.length === 1 + }).inject(this.viewSearchCustomValueNode); + }.bind(this)); }, loadViewSearchCustomValueNumberInput: function(){ this.viewSearchCustomValueContentNode.empty(); @@ -1001,23 +1059,32 @@ MWF.xApplication.query.Query.Viewer = MWF.QViewer = new Class({ var comparisonTitle = this.viewSearchCustomComparisonListNode.options[comparisonIdx].get("text"); var value = ""; - switch (entry.formatType){ - case "numberValue": - value = this.viewSearchCustomValueNode.get("value"); - break; - case "dateTimeValue": - value = this.viewSearchCustomValueNode.get("value"); - break; - case "booleanValue": - var idx = this.viewSearchCustomValueNode.selectedIndex; - if (idx!==-1){ - var v = this.viewSearchCustomValueNode.options[idx].get("value"); - value = (v==="true"); - } - break; - default: - value = this.viewSearchCustomValueNode.get("value"); + if( entry.valueType === "script" && entry.valueScript && entry.valueScript.code ){ + var idx = this.viewSearchCustomValueNode.selectedIndex; + if (idx!==-1){ + var v = this.viewSearchCustomValueNode.options[idx].get("value"); + value = entry.formatType === "booleanValue" ? (v==="true") : v; + } + }else{ + switch (entry.formatType){ + case "numberValue": + value = this.viewSearchCustomValueNode.get("value"); + break; + case "dateTimeValue": + value = this.viewSearchCustomValueNode.get("value"); + break; + case "booleanValue": + var idx = this.viewSearchCustomValueNode.selectedIndex; + if (idx!==-1){ + var v = this.viewSearchCustomValueNode.options[idx].get("value"); + value = (v==="true"); + } + break; + default: + value = this.viewSearchCustomValueNode.get("value"); + } } + if (value===""){ MWF.xDesktop.notice("error", {"x": "left", "y": "top"}, this.lp.filterErrorValue, this.viewSearchCustomValueContentNode, {"x": 0, "y": 85}); return false; -- GitLab