diff --git a/o2web/source/x_component_query_StatementDesigner/$Statement/statementDesigner.html b/o2web/source/x_component_query_StatementDesigner/$Statement/statementDesigner.html index 45e74323a3bc78d784271b49441ad81f6ceb4083..e3af09028464be54d74dec9c5c8b4eb8f976c6a4 100644 --- a/o2web/source/x_component_query_StatementDesigner/$Statement/statementDesigner.html +++ b/o2web/source/x_component_query_StatementDesigner/$Statement/statementDesigner.html @@ -11,7 +11,7 @@ diff --git a/o2web/source/x_component_query_StatementDesigner/$Statement/view.html b/o2web/source/x_component_query_StatementDesigner/$Statement/view.html index 334a86ee77457460faf410f2a053d824fc131dfd..ee37177afdec0ac56e36ce4d9e7c735df4cb1f5e 100644 --- a/o2web/source/x_component_query_StatementDesigner/$Statement/view.html +++ b/o2web/source/x_component_query_StatementDesigner/$Statement/view.html @@ -100,10 +100,23 @@
+ + + + + + + + diff --git a/o2web/source/x_component_query_StatementDesigner/Property.js b/o2web/source/x_component_query_StatementDesigner/Property.js index da77ab491b2d2a7a66e1af0c8bcedcf59fdec246..434b4237c1b0fc67594948e540c16b3019467eb0 100644 --- a/o2web/source/x_component_query_StatementDesigner/Property.js +++ b/o2web/source/x_component_query_StatementDesigner/Property.js @@ -63,7 +63,7 @@ MWF.xApplication.query.StatementDesigner.Property = MWF.SDProperty = new Class({ nodes.each(function (node) { MWF.xDesktop.requireApp("query.StatementDesigner", "widget.ViewFilter", function () { var _slef = this; - new MWF.xApplication.query.StatementDesigner.widget.ViewFilter(node, this.view.designer, { + this.viewFilter = new MWF.xApplication.query.StatementDesigner.widget.ViewFilter(node, this.view.designer, { "filtrData": filtrData, "customData": customData }, { diff --git a/o2web/source/x_component_query_StatementDesigner/Statement.js b/o2web/source/x_component_query_StatementDesigner/Statement.js index 8b77a06b20f76406bb2cb2585a532d6c540595ca..5c614d375e6ee59217e4772b6d8fe260114d9c9a 100644 --- a/o2web/source/x_component_query_StatementDesigner/Statement.js +++ b/o2web/source/x_component_query_StatementDesigner/Statement.js @@ -576,28 +576,7 @@ MWF.xApplication.query.StatementDesigner.Statement = new Class({ debugger; var entityClassName = e.target.options[e.target.selectedIndex].value; this.json.entityClassName = entityClassName; - if (this.json.format == "jpql") { - if (this.editor) { - var re = /(.*from\s*)/ig; - if (this.json.type == "update") re = /(.*update\s*)/ig; - - //if (this.json.type=="select" && this.editor){ - var v = this.json.data; - - var re2 = /(\s+)/ig; - var arr = re.exec(v); - if (arr && arr[0]) { - var left = arr[0] - v = v.substring(left.length, v.length); - //var ar = re2.exec(v); - var right = v.substring(v.indexOf(" "), v.length); - this.json.data = left + entityClassName + right; - this.editor.editor.setValue(this.json.data); - } - //} - } - - } + this.changeEditorEntityClassName( entityClassName.split(".").getLast() ); // var className = e.target.options[e.target.selectedIndex].value; @@ -649,6 +628,47 @@ MWF.xApplication.query.StatementDesigner.Statement = new Class({ } }.bind(this)); }, + changeEditorEntityClassName : function( entityClassName ){ + if (this.json.format == "jpql") { + if (this.editor) { + var re = /(.*from\s*)/ig; + if (this.json.type == "update") re = /(.*update\s*)/ig; + + //if (this.json.type=="select" && this.editor){ + var v = this.json.data; + + var re2 = /(\s+)/ig; + var arr = re.exec(v); + if (arr && arr[0]) { + var left = arr[0] + v = v.substring(left.length, v.length); + //var ar = re2.exec(v); + var right = v.substring(v.indexOf(" "), v.length); + this.json.data = left + entityClassName + right; + this.editor.editor.setValue(this.json.data); + } + + //} + } + + if( this.countEditor ){ + var re = /(.*from\s*)/ig; + var v = this.json.countData; + + var re2 = /(\s+)/ig; + var arr = re.exec(v); + if (arr && arr[0]) { + var left = arr[0] + v = v.substring(left.length, v.length); + //var ar = re2.exec(v); + var right = v.substring(v.indexOf(" "), v.length); + this.json.countData = left + entityClassName + right; + this.countEditor.editor.setValue(this.json.countData); + } + } + + } + }, selectTable: function () { new MWF.O2Selector(this.designer.content, { @@ -663,9 +683,12 @@ MWF.xApplication.query.StatementDesigner.Statement = new Class({ this.dynamicTableContent.set("text", name); this.json.table = name; this.json.tableObj = items[0].data; + this.changeEditorEntityClassName( name ); + if(this.view && this.view.property && this.view.property.viewFilter)this.view.property.viewFilter.setPathInputSelectOptions(); } else { this.dynamicTableContent.set("text", ""); this.json.table = ""; + if(this.view && this.view.property && this.view.property.viewFilter)this.view.property.viewFilter.setPathInputSelectOptions(); } }.bind(this) }); diff --git a/o2web/source/x_component_query_StatementDesigner/widget/ViewFilter.js b/o2web/source/x_component_query_StatementDesigner/widget/ViewFilter.js index d3d0706aa43cb2a672b3d42f73f03c4160d7a985..968858852a2836336385985e02ce2a9032043fa2 100644 --- a/o2web/source/x_component_query_StatementDesigner/widget/ViewFilter.js +++ b/o2web/source/x_component_query_StatementDesigner/widget/ViewFilter.js @@ -124,7 +124,9 @@ MWF.xApplication.query.StatementDesigner.widget.ViewFilter = new Class({ this.titleInput = this.inputAreaNode.getElement(".titleInput_vf"); this.pathInput = this.inputAreaNode.getElement(".pathInput_vf"); + this.pathInputSelect = this.inputAreaNode.getElement(".pathInputSelect_vf"); this.parameterInput = this.inputAreaNode.getElement(".parameterInput_vf"); + this.parameterInputSelect = this.inputAreaNode.getElement(".parameterInputSelect_vf"); this.datatypeInput = this.inputAreaNode.getElement(".datatypeInput_vf"); this.restrictFilterInput = this.inputAreaNode.getElement(".restrictFilterInput_vf"); @@ -199,6 +201,84 @@ MWF.xApplication.query.StatementDesigner.widget.ViewFilter = new Class({ if (e.code == 13) this.modifyOrAddFilterItem(); }.bind(this)); + this.pathInputSelect.addEvent("change", function ( ev ) { + var option = ev.target.options[ev.target.selectedIndex]; + debugger; + var type = option.retrieve("type"); + var d = this.app.statement.data; + if( type === "dynamic" ){ + var field = option.retrieve("field"); + if( field ){ + this.titleInput.set("value", field.description || field.name); + if( field.name ){ + var path = this.pathInput.get("value"); + if( path.indexOf(".") > -1 ){ + path = path.split(".")[0] +"."+ field.name; + }else{ + var alias; + var tableName = option.retrieve("tableName"); + if( d.data.indexOf(tableName) > -1){ + var str = d.data.split(tableName)[1].trim(); + if( str.indexOf(" ") )alias = str.split(" ")[0]; + } + path = alias ? ( alias +"."+ field.name ) : field.name; + } + this.pathInput.set("value", path); + } + if( field.type ){ + var t; + switch (field.type) { + case "string": + case "stringList": + case "stringLob": + case "stringMap": + t = "textValue"; + break; + case "integer": + case "long": + case "double": + case "integerList": + case "longList": + case "doubleList": + t = "numberValue"; + break; + case "dateTime": + t = "dateTimeValue"; + break; + case "date": + t = "dateValue"; + break; + case "time": + t = "timeValue"; + break; + case "boolean": + case "booleanList": + t = "booleanValue"; + break; + default: + t = "textValue"; + break; + } + for (var i = 0; i < this.datatypeInput.options.length; i++) { + if (this.datatypeInput.options[i].value === t) { + this.datatypeInput.options[i].set("selected", true); + this.switchInputDisplay(); + if (this.datatypeInput.onchange) this.datatypeInput.onchange(); + break; + } + } + } + }else{ + this.titleInput.set("value", ""); + this.pathInput.set("value", ""); + this.datatypeInput.options[0].set("selected", true); + this.switchInputDisplay(); + if (this.datatypeInput.onchange)this.datatypeInput.onchange(); + } + } + }.bind(this)) + this.setPathInputSelectOptions() + //if (this.app.statement.view){ // var id = this.app.view.data.id; // var div = this.node.getElement("#"+id+"viewFilterValueArea2"); @@ -246,6 +326,38 @@ MWF.xApplication.query.StatementDesigner.widget.ViewFilter = new Class({ // } // } }, + setPathInputSelectOptions : function(){ + debugger; + var d = this.app.statement.data; + this.pathInputSelect.empty(); + if( d.entityCategory ==='dynamic' && d.table ){ + o2.Actions.load("x_query_assemble_designer").TableAction.get( d.table, function(json){ + if( json.data.data ){ + + var ps = this.pathInput.get("value").split("."); + var p = ps[1] ? ps[1] : ps[0]; + + var option = new Element("option", { "text": "", "value": "" }).inject(this.pathInputSelect); + option.store("type", "dynamic"); + option.store("tableName", json.data.name); + + var fieldJson = JSON.parse( json.data.data ); + fieldJson.fieldList.each( function ( field ) { + var option = new Element("option", { + "text": field.name + ( field.description ? ("-" + field.description) : "" ), + "value": field.name, + "selected": (field.name===p) + }).inject(this.pathInputSelect); + option.store("field", field); + option.store("type", "dynamic"); + option.store("tableName", json.data.name); + }.bind(this)) + } + }.bind(this)) + }else if( d.entityCategory ==='official' ){ + + } + }, switchInputDisplay: function () { var id = ""; if (this.app.statement.view) { @@ -591,6 +703,18 @@ MWF.xApplication.query.StatementDesigner.widget.ViewFilter = new Class({ } } + var ps = this.pathInput.get("value").split("."); + var p = ps[1] ? ps[1] : ps[0]; + var flag = true; + for (var i = 0; i < this.pathInputSelect.options.length; i++) { + if (this.pathInputSelect.options[i].value === p) { + this.pathInputSelect.options[i].set("selected", true); + flag = false; + break; + } + } + if(flag)this.pathInputSelect.options[0].set("selected", true); + switch (data.formatType) { case "textValue": this.valueTextInput.set("value", data.value);
选择: + + +
标题: