From ea5b921e6726a1eb014164c0273a07494a14b26b Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 20 Oct 2020 22:03:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E4=B8=AD=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E8=A7=86=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../$Statement/column.html | 10 +- .../$Statement/statement.html | 24 +- .../Property.js | 15 ++ .../Statement.js | 238 +++++++++++++----- 4 files changed, 223 insertions(+), 64 deletions(-) diff --git a/o2web/source/x_component_query_StatementDesigner/$Statement/column.html b/o2web/source/x_component_query_StatementDesigner/$Statement/column.html index d014f3fdc1..065dc06d14 100644 --- a/o2web/source/x_component_query_StatementDesigner/$Statement/column.html +++ b/o2web/source/x_component_query_StatementDesigner/$Statement/column.html @@ -33,10 +33,18 @@
数据
+ + + + diff --git a/o2web/source/x_component_query_StatementDesigner/$Statement/statement.html b/o2web/source/x_component_query_StatementDesigner/$Statement/statement.html index 6046d9b34d..0d7c0820de 100644 --- a/o2web/source/x_component_query_StatementDesigner/$Statement/statement.html +++ b/o2web/source/x_component_query_StatementDesigner/$Statement/statement.html @@ -21,12 +21,27 @@
执行权限
选择路径: + +
注:正确填写了查询语句,再测试语句或刷新视图数据可显示(刷新)选择路径。
+
数据路径: - +
注:指该列相对单条数据的路径。比如 0,title,或 0.title
+ + + + - +
匿名访问: + 允许 + 不允许 +
执行人:
执行组织:
@@ -34,9 +49,8 @@
- -
-
-
+
+
+
\ No newline at end of file diff --git a/o2web/source/x_component_query_StatementDesigner/Property.js b/o2web/source/x_component_query_StatementDesigner/Property.js index 5f81cf2f63..7215f5b27a 100644 --- a/o2web/source/x_component_query_StatementDesigner/Property.js +++ b/o2web/source/x_component_query_StatementDesigner/Property.js @@ -35,12 +35,27 @@ MWF.xApplication.query.StatementDesigner.Property = MWF.SDProperty = new Class({ this.loadActionArea(); this.loadStylesList(); this.loadMaplist(); + this.loadDataPathSelect(); } }.bind(this)); } else { this.propertyContent.setStyle("display", "block"); } }, + loadDataPathSelect : function(){ + var nodes = this.propertyContent.getElements(".MWFDataPathSelect"); + nodes.each( function (select) { + select.empty(); + var option = new Element("option", {"text": "none", "value" : ""}).inject(select); + this.module.getColumnDataPath().each(function(model){ + var option = new Element("option", { + "text": model, + "value": model, + "selected": (this.data[name]==model) + }).inject(select); + }.bind(this)); + }.bind(this)) + }, loadViewFilter: function () { var nodes = this.propertyContent.getElements(".MWFViewFilter"); //var filtrData = this.view.data.data.filterList; diff --git a/o2web/source/x_component_query_StatementDesigner/Statement.js b/o2web/source/x_component_query_StatementDesigner/Statement.js index f96a5fa89f..9b3d61ff86 100644 --- a/o2web/source/x_component_query_StatementDesigner/Statement.js +++ b/o2web/source/x_component_query_StatementDesigner/Statement.js @@ -441,7 +441,7 @@ MWF.xApplication.query.StatementDesigner.Statement = new Class({ "option": {"mode": "json"} }); this.jsonEditor.load(function () { - this.jsonEditor.editor.setValue("{}"); + this.jsonEditor.editor.setValue(this.data.testParameters || "{}"); }.bind(this)); }.bind(this), false); }, @@ -605,14 +605,22 @@ MWF.xApplication.query.StatementDesigner.Statement = new Class({ this.runMask.loadNode(this.node); this.saveSilence(function () { - debugger; this.execute(function (json) { + this.executeData = json; o2.require("o2.widget.JsonParse", function () { this.runResultNode.empty(); var jsonResult = new o2.widget.JsonParse(json, this.runResultNode); jsonResult.load(); }.bind(this)); + if (this.view) { + var flag = true; + if (this.data.type !== "select") flag = false; + if (this.data.format === "script" && !this.data.scriptText) flag = false; + if (this.data.format !== "script" && !this.data.data) flag = false; + if (flag) this.view.loadViewData(); + } + this.setColumnDataPath(json); this.runMask.hide(); }.bind(this), function () { if (this.runMask) this.runMask.hide(); @@ -672,6 +680,44 @@ MWF.xApplication.query.StatementDesigner.Statement = new Class({ // }.bind(this)) }.bind(this)); }, + setColumnDataPath: function (json) { + if (this.data.type !== "select") return; + if (this.data.format === "script" && !this.data.scriptText) return; + if (this.data.format !== "script" && !this.data.data) return; + this.columnDataPathList = []; + debugger; + var addPath = function (value, key) { + if (typeOf(value) === "array") { + Array.each(value, function (v, idx) { + var path = (key || typeOf(key) === "number") ? (key + "." + idx) : idx.toString(); + if (!this.columnDataPathList.contains(path)) this.columnDataPathList.push(path); + if (typeOf(v) === "array" || typeOf(v) === "object") addPath(v, path); + }.bind(this)) + } else if (typeOf(value) === "object") { + Object.each(value, function (v, k) { + var path = (key || typeOf(key) === "number") ? (key + "." + k) : k; + if (!this.columnDataPathList.contains(path)) this.columnDataPathList.push(path); + if (typeOf(v) === "array" || typeOf(v) === "object") addPath(v, path); + addPath(v, path); + }.bind(this)) + } else { + // if( key && !this.columnDataPathList.indexOf(key) )this.columnDataPathList.push(key); + } + }.bind(this); + for (var i = 0; i < json.data.length && i < 10; i++) { + var d = json.data[i]; + addPath(d); + } + this.columnDataPathList.sort(); + if (this.view && this.view.items) { + this.view.items.each(function (column) { + column.refreshColumnPathData() + }) + } + }, + getColumnDataPath: function () { + return this.columnDataPathList || []; + }, execute: function (success, failure) { var json = this.jsonEditor.editor.getValue(); var o = JSON.parse(json); @@ -737,6 +783,7 @@ MWF.xApplication.query.StatementDesigner.Statement = new Class({ //} if (this.editor) this.data.data = this.editor.editor.getValue(); if (this.scriptEditor) this.data.scriptText = this.scriptEditor.toJson().code; + if (this.jsonEditor) this.data.testParameters = this.jsonEditor.editor.getValue(); this.designer.actions.saveStatement(this.data, function (json) { this.designer.notice(this.designer.lp.save_success, "success", this.node, {"x": "left", "y": "bottom"}); @@ -763,6 +810,7 @@ MWF.xApplication.query.StatementDesigner.Statement = new Class({ if (this.editor) this.data.data = this.editor.editor.getValue(); if (this.scriptEditor) this.data.scriptText = this.scriptEditor.toJson().code; + if (this.jsonEditor) this.data.testParameters = this.jsonEditor.editor.getValue(); this.designer.actions.saveStatement(this.data, function (json) { //this.designer.notice(this.designer.lp.save_success, "success", this.node, {"x": "left", "y": "bottom"}); @@ -946,7 +994,7 @@ MWF.xApplication.query.StatementDesigner.View = new Class({ }.bind(this) }); this.refreshNode.addEvent("click", function (e) { - this.loadViewData(); + this.statement.runStatement(); e.stopPropagation(); }.bind(this)); this.addColumnNode.addEvent("click", function (e) { @@ -994,70 +1042,112 @@ MWF.xApplication.query.StatementDesigner.View = new Class({ }, loadViewData: function () { + debugger; if (this.data.id) { - this.statement.saveSilence(function () { - this.viewContentBodyNode.empty(); - this.viewContentTableNode = new Element("table", { - "styles": this.css.viewContentTableNode, - "border": "0px", - "cellPadding": "0", - "cellSpacing": "0" - }).inject(this.viewContentBodyNode); + // this.statement.saveSilence(function () { + this.viewContentBodyNode.empty(); + this.viewContentTableNode = new Element("table", { + "styles": this.css.viewContentTableNode, + "border": "0px", + "cellPadding": "0", + "cellSpacing": "0" + }).inject(this.viewContentBodyNode); - this.statement.execute( function (json) { - var entries = {}; + // this.statement.execute( function (json) { - json.data.selectList.each(function (entry) { - entries[entry.column] = entry; - }.bind(this)); + // this.statement.setColumnDataPath( json ); + + var entries = {}; - if (json.data.grid.length) { - json.data.grid.each(function (line, idx) { - var tr = new Element("tr", { - "styles": this.json.data.viewStyles ? this.json.data.viewStyles["contentTr"] : this.css.viewContentTrNode - }).inject(this.viewContentTableNode); - - //this.createViewCheckboxTd( tr ); - - Object.each(entries, function (c, k) { - var d = line.data[k]; - if (d != undefined) { - var td = new Element("td", { - "styles": this.json.data.viewStyles ? this.json.data.viewStyles["contentTd"] : this.css.viewContentTdNode - }).inject(tr); - //td.set("text", (entries[k].code) ? MWF.Macro.exec(entries[k].code, {"value": d, "gridData": json.data.grid, "data": json.data, "entry": line}) : d); - if (c.isHtml) { - td.set("html", d); - } else { - td.set("text", d); - } - //td.set("text", d); + this.json.data.selectList.each(function (entry) { + entries[entry.column] = entry; + }.bind(this)); + + if (this.statement.executeData && this.statement.executeData.data && this.statement.executeData.data.length) { + this.statement.executeData.data.each(function (line, idx) { + var tr = new Element("tr", { + "styles": this.json.data.viewStyles ? this.json.data.viewStyles["contentTr"] : this.css.viewContentTrNode + }).inject(this.viewContentTableNode); + + //this.createViewCheckboxTd( tr ); + + Object.each(entries, function (c, k) { + debugger; + + var path = c.path, code = c.code, obj = line; + if( path ){ + var pathList = path.split("."); + for( var i=0; i