Explorar o código

查询里增加了视图

unknown %!s(int64=5) %!d(string=hai) anos
pai
achega
5c2f5ea1be

+ 11 - 1
o2web/source/x_component_process_FormDesigner/Module/Statement.js

@@ -83,7 +83,11 @@ MWF.xApplication.process.FormDesigner.Module.Statement = MWF.FCStatement = new C
         }
 
         MWF.Actions.get("x_query_assemble_designer").getStatement(this.json["queryStatement"].id, function(json){
-            var viewData = JSON.decode(json.data.view);
+
+            var viewData = JSON.decode(json.data.view || "");
+            if( !viewData || !viewData.data ){
+                return;
+            }
 
             this.viewData = viewData;
             if( this.json.actionbar === "show" ){
@@ -113,11 +117,17 @@ MWF.xApplication.process.FormDesigner.Module.Statement = MWF.FCStatement = new C
             this._createViewNode(function(){
                 if (callback) callback();
             }.bind(this));
+            if( this.property && this.property.viewFilter ){
+                this.property.viewFilter.resetStatementData( this.json["queryStatement"].id );
+            }
         }else{
             this.iconNode.setStyle("display", "block");
             if (this.viewNode) this.viewNode.destroy();
             this.node.setStyles(this.css.moduleNode);
             if (callback) callback();
+            if( this.property && this.property.viewFilter ){
+                this.property.viewFilter.resetStatementData();
+            }
         }
     },
     _setEditStyle: function(name, input, oldValue){

+ 10 - 0
o2web/source/x_component_process_FormDesigner/Module/StatementSelector.js

@@ -21,5 +21,15 @@ MWF.xApplication.process.FormDesigner.Module.StatementSelector = MWF.FCStatement
 		this.form = form;
 		this.container = null;
 		this.containerNode = null;
+	},
+	_checkView: function(callback){
+		if( this.property && this.property.viewFilter ){
+			if (this.json["queryStatement"] && this.json["queryStatement"]!="none"){
+				this.property.viewFilter.resetStatementData( this.json["queryStatement"].id );
+			}else{
+				this.property.viewFilter.resetStatementData();
+			}
+		}
 	}
+
 });

+ 1 - 1
o2web/source/x_component_process_FormDesigner/Property.js

@@ -525,7 +525,7 @@ MWF.xApplication.process.FormDesigner.Property = MWF.FCProperty = 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.form.designer, {"filtrData": filtrData, "customData": null}, {
+                this.viewFilter = new MWF.xApplication.query.StatementDesigner.widget.ViewFilter(node, this.form.designer, {"filtrData": filtrData, "customData": null}, {
                     "statementId" : this.data.queryStatement ? this.data.queryStatement.id : "",
                     "withForm" : true,
                     "onChange": function(ids){

+ 47 - 2
o2web/source/x_component_process_Xform/StatementSelector.js

@@ -20,7 +20,7 @@ MWF.xApplication.process.Xform.StatementSelector = MWF.APPStatementSelector =  n
             var viewJson = {
                 "application": viewData.appName,
                 "statementName": viewData.name,
-                "viewId": viewData.id,
+                "statementId": viewData.id,
                 "isTitle": this.json.isTitle || "yes",
                 "select": this.json.select || "single",
                 "titleStyles": this.json.titleStyles,
@@ -72,6 +72,7 @@ MWF.xApplication.process.Xform.StatementSelector = MWF.APPStatementSelector =  n
                             "text": MWF.LP.process.button.ok,
                             "action": function(){
                                 //if (callback) callback(_self.view.selectedItems);
+                                debugger;
                                 if (callback) callback(_self.view.getData());
                                 this.close();
                             }
@@ -113,6 +114,50 @@ MWF.xApplication.process.Xform.StatementSelector = MWF.APPStatementSelector =  n
                 // }.bind(this));
             }.bind(this));
         }
-    }
+    },
+    doResult: function(data){
+        if (this.json.result === "script"){
+            this.selectedData = data;
+            return (this.json.selectedScript.code) ? this.form.Macro.exec(this.json.selectedScript.code, this) : "";
+        }else{
+            Object.each(this.json.selectedSetValues, function(v, k){
+                var value = "";
+                data.each(function(d, idx){
+                    // Object.each(d, function(dv, dk){
+                    //     if (dk===v) value = (value) ? (value+", "+dv) : dv;
+                    // }.bind(this));
+
+                    var pathList = v.split(".");
+                    for( var i=0; i<pathList.length; i++ ){
+                        var p = pathList[i];
+                        if( (/(^[1-9]\d*$)/.test(p)) )p = p.toInt();
+                        if( d[ p ] ){
+                            d = d[ p ];
+                        }else{
+                            d = "";
+                            break;
+                        }
+                    }
+
+                    if( typeOf(d) === "array" || typeOf(d) === "object" ) {
+                        d = JSON.stringify(d);
+                    }
+
+                    value = (value) ? (value+", "+d) : d;
+
+                }.bind(this));
+
+                var field = this.form.all[k];
+                if (field){
+                    field.setData(value);
+                    if (value){
+                        if (field.descriptionNode) field.descriptionNode.setStyle("display", "none");
+                    }else{
+                        if (field.descriptionNode) field.descriptionNode.setStyle("display", "block");
+                    }
+                }
+            }.bind(this));
+        }
+    },
 	
 }); 

+ 15 - 7
o2web/source/x_component_query_StatementDesigner/Statement.js

@@ -53,7 +53,7 @@ MWF.xApplication.query.StatementDesigner.Statement = new Class({
         if (!this.json.type) this.json.type = "select";
         if (!this.json.format) this.json.format = "jpql";
         if (!this.json.entityCategory) this.json.entityCategory = "official";
-        if (!this.json.entityClassName) this.json.entityClassName = "com.x.processplatform.core.entity.content.Task";
+        if (!this.json.entityClassName) this.json.entityClassName = ""; //"com.x.processplatform.core.entity.content.Task";
     },
     autoSave: function () {
         this.autoSaveTimerID = window.setInterval(function () {
@@ -609,6 +609,10 @@ MWF.xApplication.query.StatementDesigner.Statement = new Class({
                 this.changeEditorEntityClassName( entityClassName.split(".").getLast() );
             }
             this.loadFieldSelect();
+
+            this.json.table = "";
+            this.json.tableObj = null;
+
             if(this.view && this.view.property && this.view.property.viewFilter)this.view.property.viewFilter.setPathInputSelectOptions();
 
             //     var className = e.target.options[e.target.selectedIndex].value;
@@ -665,7 +669,7 @@ MWF.xApplication.query.StatementDesigner.Statement = new Class({
             var type = option.retrieve("type");
             var field = option.retrieve("field");
             if( !field )return;
-            var text = " " + field.name;
+            var text = field.name;
             if( this.countJpqlPage && this.countJpqlPage.isShow && !this.countJpqlPage.disabled ){
                 if( this.data.format === "script" && this.countScriptEditor.jsEditor ){
                     this.countScriptEditor.jsEditor.insertValue( text );
@@ -736,6 +740,10 @@ MWF.xApplication.query.StatementDesigner.Statement = new Class({
                     this.dynamicTableContent.set("text", name);
                     this.json.table = name;
                     this.json.tableObj = items[0].data;
+
+                    this.officialTableSelect.options[0].set("selected", true);
+                    this.json.entityClassName = "";
+
                     this.changeEditorEntityClassName( name );
                     this.loadFieldSelect();
                     if(this.view && this.view.property && this.view.property.viewFilter)this.view.property.viewFilter.setPathInputSelectOptions();
@@ -755,9 +763,9 @@ MWF.xApplication.query.StatementDesigner.Statement = new Class({
         //     this.designer.notice(this.designer.lp.inputStatementData, "error");
         //     return false;
         // }
-        o2.require("o2.widget.Mask", null, false);
-        this.runMask = new o2.widget.Mask();
-        this.runMask.loadNode(this.node);
+        // o2.require("o2.widget.Mask", null, false);
+        // this.runMask = new o2.widget.Mask();
+        // this.runMask.loadNode(this.node);
 
         this.saveSilence(function () {
             debugger;
@@ -776,9 +784,9 @@ MWF.xApplication.query.StatementDesigner.Statement = new Class({
                     if (flag) this.view.loadViewData();
                 }
                 this.setColumnDataPath(json);
-                this.runMask.hide();
+                // this.runMask.hide();
             }.bind(this), function () {
-                if (this.runMask) this.runMask.hide();
+                // if (this.runMask) this.runMask.hide();
             }.bind(this))
 
             // var json = this.jsonEditor.editor.getValue();

+ 17 - 4
o2web/source/x_component_query_StatementDesigner/widget/ViewFilter.js

@@ -349,9 +349,9 @@ MWF.xApplication.query.StatementDesigner.widget.ViewFilter = new Class({
     },
     setPathInputSelectOptions : function(){
         debugger;
-        var d = this.statementData;
         this.pathInputSelect.empty();
         if( !this.statementData )return;
+        var d = this.statementData;
         var fun = function ( tableName ) {
             o2.Actions.load("x_query_assemble_designer").QueryAction.getEntityProperties(
                 d.entityCategory === "dynamic" ? d.table : d.entityClassName,
@@ -375,6 +375,7 @@ MWF.xApplication.query.StatementDesigner.widget.ViewFilter = new Class({
                 }.bind(this)
             )
         }.bind(this);
+
         if( d.entityCategory === "dynamic" ){
             if( d.table ){
                 o2.Actions.load("x_query_assemble_designer").TableAction.get(d.table, function(json){
@@ -385,6 +386,21 @@ MWF.xApplication.query.StatementDesigner.widget.ViewFilter = new Class({
             fun( d.entityClassName.split(".").getLast() )
         }
     },
+    resetStatementData : function( statementId, callback ){
+        if( statementId && statementId !== "none" ){
+            this.options.statementId = statementId;
+            o2.Actions.load("x_query_assemble_designer").StatementAction.get( statementId, function (json) {
+                this.statementData = json.data;
+                this.setPathInputSelectOptions();
+                if(callback)callback();
+            }.bind(this))
+        }else{
+            this.options.statementId = "";
+            this.statementData = null;
+            this.setPathInputSelectOptions();
+            if(callback)callback();
+        }
+    },
     switchInputDisplay: function () {
         var formatType = this.datatypeInput.options[this.datatypeInput.selectedIndex].value;
 
@@ -499,7 +515,6 @@ MWF.xApplication.query.StatementDesigner.widget.ViewFilter = new Class({
         }.bind(this));
     },
     modifyOrAddFilterItem: function () {
-        debugger;
         var flag;
         if (this.currentFilterItem) {
             flag = this.modifyFilterItem();
@@ -879,7 +894,6 @@ MWF.xApplication.query.StatementDesigner.widget.ViewFilter = new Class({
         } catch (e) {
         }
 
-        debugger;
         if( this.options.withForm ){
             this.switchInputDisplay();
         }else{
@@ -993,7 +1007,6 @@ MWF.xApplication.query.StatementDesigner.widget.ViewFilter = new Class({
         this.fireEvent("change");
     },
     getData: function () {
-        debugger;
         var data = [];
         var customData = [];
         this.items.each(function (item) {