From 88ace6613b6802aba4fafe76e32f06eb5e33f552 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 29 Oct 2020 10:38:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E5=A2=9E=E5=8A=A0=E8=A7=86?= =?UTF-8?q?=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Module/Statement.js | 2 +- .../x_component_process_Xform/Statement.js | 1 + o2web/source/x_component_query_Query/Main.js | 14 +- .../x_component_query_Query/Statement.js | 144 ++++++++-------- .../x_component_query_Query/lp/zh-cn.js | 1 + .../$Statement/view.html | 2 +- .../Property.js | 6 +- .../lp/zh-cn.js | 5 +- .../widget/ViewFilter.js | 158 ++++++++++++++---- 9 files changed, 214 insertions(+), 119 deletions(-) diff --git a/o2web/source/x_component_process_FormDesigner/Module/Statement.js b/o2web/source/x_component_process_FormDesigner/Module/Statement.js index 022416db27..849c057479 100644 --- a/o2web/source/x_component_process_FormDesigner/Module/Statement.js +++ b/o2web/source/x_component_process_FormDesigner/Module/Statement.js @@ -91,7 +91,7 @@ MWF.xApplication.process.FormDesigner.Module.Statement = MWF.FCStatement = new C this._showActionbar(); } - var columnList = viewData.selectEntryList || viewData.selectList; + var columnList = viewData.data ? (viewData.data.selectEntryList || viewData.data.selectList) : []; columnList.each(function(column){ if (!column.hideColumn){ var viewCell = new Element("td", { diff --git a/o2web/source/x_component_process_Xform/Statement.js b/o2web/source/x_component_process_Xform/Statement.js index f8cb3d53fd..504e2ad1c2 100644 --- a/o2web/source/x_component_process_Xform/Statement.js +++ b/o2web/source/x_component_process_Xform/Statement.js @@ -48,6 +48,7 @@ MWF.xApplication.process.Xform.Statement = MWF.APPStatement = new Class({ var viewJson = { "application": (this.json.queryStatement) ? this.json.queryStatement.appName : this.json.application, "statementName": (this.json.queryStatement) ? this.json.queryStatement.name : this.json.statementName, + "statementId": (this.json.queryStatement) ? this.json.queryStatement.id : this.json.statementId, "isTitle": this.json.isTitle || "yes", "select": this.json.select || "none", "titleStyles": this.json.titleStyles, diff --git a/o2web/source/x_component_query_Query/Main.js b/o2web/source/x_component_query_Query/Main.js index 6704e8eed9..fdc1c3f2f2 100644 --- a/o2web/source/x_component_query_Query/Main.js +++ b/o2web/source/x_component_query_Query/Main.js @@ -80,7 +80,7 @@ MWF.xApplication.query.Query.Main = new Class({ this.naviStatTitleNode = new Element("div", {"styles": this.css.naviStatTitleNode, "text": this.lp.stat}).inject(this.naviContentNode); this.naviStatContentNode = new Element("div", {"styles": this.css.naviStatContentNode}).inject(this.naviContentNode); - this.naviStatementTitleNode = new Element("div", {"styles": this.css.naviStatementTitleNode, "text": this.lp.stat}).inject(this.naviContentNode); + this.naviStatementTitleNode = new Element("div", {"styles": this.css.naviStatementTitleNode, "text": this.lp.statement}).inject(this.naviContentNode); this.naviStatementContentNode = new Element("div", {"styles": this.css.naviStatementContentNode}).inject(this.naviContentNode); this.setContentHeightFun = this.setContentHeight.bind(this); @@ -131,7 +131,10 @@ MWF.xApplication.query.Query.Main = new Class({ }.bind(this)); } }.bind(this)); - MWF.Actions.get("x_query_assemble_surface").listStatement(this.options.id, function(json){ + MWF.Actions.load("x_query_assemble_surface").StatementAction.listWithQuery(this.options.id, { + "justSelect" : true, + "hasView" : true + }, function(json){ //this.action.listStat(this.options.id, function(json){ if (json.data){ json.data.each(function(statement){ @@ -152,8 +155,8 @@ MWF.xApplication.query.Query.Main = new Class({ var item = new MWF.xApplication.query.Query.StatItem(stat, this); return item; }, - createStatementNaviItem: function(stat){ - var item = new MWF.xApplication.query.Query.StatementItem(stat, this); + createStatementNaviItem: function(statement){ + var item = new MWF.xApplication.query.Query.StatementItem(statement, this); return item; }, @@ -251,7 +254,8 @@ MWF.xApplication.query.Query.StatementItem = new Class({ this.viewContent.empty(); this.viewer = new MWF.QStatement(this.app, this.viewContent, { "application": this.view.query, - "statementName": this.view.name + "statementName": this.view.name, + "statementId" : this.view.id }); }.bind(this)); } diff --git a/o2web/source/x_component_query_Query/Statement.js b/o2web/source/x_component_query_Query/Statement.js index a54a47993d..0fad5f81b2 100644 --- a/o2web/source/x_component_query_Query/Statement.js +++ b/o2web/source/x_component_query_Query/Statement.js @@ -98,48 +98,55 @@ MWF.xApplication.query.Query.Statement = MWF.QStatement = new Class({ lookup: function(data, callback){ if( this.lookuping )return; this.lookuping = true; - this.getLookupAction(function(){ - if (this.json.application){ + // this.getLookupAction(function(){ + // if (this.json.application){ var d = data || {}; - d.count = this.json.count; - this.lookupAction.bundleView(this.json.id, d, function(json){ - this.bundleItems = json.data.valueList; - - this._initPage(); - if (this.bundleItems.length){ - if( this.noDataTextNode )this.noDataTextNode.destroy(); - this.loadCurrentPageData( function () { + // d.count = this.json.count; + // this.lookupAction.bundleView(this.json.id, d, function(json){ + // this.bundleItems = json.data.valueList; + + // this._initPage(); + + this.currentPage = this.options.defaultPage || 1; + this.options.defaultPage = null; + + if( this.noDataTextNode )this.noDataTextNode.destroy(); + this.loadCurrentPageData( function (json) { + if( typeOf(json.count) === "number" )this.totalCount = json.count; + if(this.totalCount){ this.fireEvent("postLoad"); //用户配置的事件 this.lookuping = false; if(callback)callback(this); - }.bind(this)); - }else{ - //this._loadPageNode(); - this.viewPageAreaNode.empty(); - if( this.viewJson.noDataText ){ - var noDataTextNodeStyle = this.css.noDataTextNode; - if( this.viewJson.viewStyles && this.viewJson.viewStyles["noDataTextNode"] ){ - noDataTextNodeStyle = this.viewJson.viewStyles["noDataTextNode"]; + }else{ + this.viewPageAreaNode.empty(); + if( this.viewJson.noDataText ){ + var noDataTextNodeStyle = this.css.noDataTextNode; + if( this.viewJson.viewStyles && this.viewJson.viewStyles["noDataTextNode"] ){ + noDataTextNodeStyle = this.viewJson.viewStyles["noDataTextNode"]; + } + this.noDataTextNode = new Element( "div", { + "styles": noDataTextNodeStyle, + "text" : this.viewJson.noDataText + }).inject( this.contentAreaNode ); } - this.noDataTextNode = new Element( "div", { - "styles": noDataTextNodeStyle, - "text" : this.viewJson.noDataText - }).inject( this.contentAreaNode ); - } - if (this.loadingAreaNode){ - this.loadingAreaNode.destroy(); - this.loadingAreaNode = null; + // if (this.loadingAreaNode){ + // this.loadingAreaNode.destroy(); + // this.loadingAreaNode = null; + // } + this.fireEvent("postLoad"); //用户配置的事件 + this.lookuping = false; + if(callback)callback(this); } - this.fireEvent("postLoad"); //用户配置的事件 - this.lookuping = false; - if(callback)callback(this); - } - }.bind(this)); - } - }.bind(this)); + + + }.bind(this), true,"all"); + + // }.bind(this)); + // } + // }.bind(this)); }, - loadCurrentPageData: function( callback, async ){ + loadCurrentPageData: function( callback, async, type ){ //是否需要在翻页的时候清空之前的items ? if( this.pageloading )return; @@ -148,27 +155,32 @@ MWF.xApplication.query.Query.Statement = MWF.QStatement = new Class({ this.items = []; var p = this.currentPage; - var d = {}; - var valueList = this.bundleItems.slice((p-1)*this.json.pageSize,this.json.pageSize*p); - d.bundleList = valueList; + var d = { + "filterList" : [], + "parameter" : { + + } + }; while (this.viewTable.rows.length>1){ this.viewTable.deleteRow(-1); } //this.createLoadding(); - this.loadViewRes = this.lookupAction.loadView(this.json.name, this.json.application, d, function(json){ - this.viewData = json.data; + this.loadViewRes = o2.Actions.load("x_query_assemble_surface").StatementAction.executeV2( + this.json.statementId || this.json.statementName, + type || "data", p, this.json.pageSize, d, function(json){ + + this.gridJson = json.data; this.fireEvent("postLoadPageData"); - if (this.viewJson.group.column){ - this.gridJson = json.data.groupGrid; - // this.loadGroupData(); - }else{ - this.gridJson = json.data.grid; + // if (this.viewJson.group.column){ + // this.gridJson = json.data.groupGrid; + // }else{ + // this.gridJson = json.data.grid; this.loadData(); - } + // } if (this.gridJson.length) this._loadPageNode(); if (this.loadingAreaNode){ this.loadingAreaNode.destroy(); @@ -180,10 +192,19 @@ MWF.xApplication.query.Query.Statement = MWF.QStatement = new Class({ this.fireEvent("loadView"); //options 传入的事件 this.fireEvent("postLoadPage"); - if(callback)callback(); + if(callback)callback( json ); }.bind(this), null, async === false ? false : true ); }, - + getView: function(callback){ + this.getViewRes = o2.Actions.load("x_query_assemble_surface").StatementAction.get(this.json.statementId || this.json.statementName, function(json){ + debugger; + this.viewJson = JSON.decode(json.data.view); + this.json.application = json.data.query; + //this.json = Object.merge(this.json, json.data); + this.statementJson = json.data; + if (callback) callback(); + }.bind(this)); + }, loadData: function(){ if (this.gridJson.length){ @@ -212,31 +233,6 @@ MWF.xApplication.query.Query.Statement = MWF.QStatement = new Class({ if( to == this.gridJson.length )this.isItemsLoaded = true; } }, - getView: function(callback){ - this.getLookupAction(function(){ - if (this.json.application){ - this.getViewRes = this.lookupAction.getStatement(this.json.statementName, this.json.application, function(json){ - this.viewJson = JSON.decode(json.data.data); - this.json = Object.merge(this.json, json.data); - if (callback) callback(); - }.bind(this)); - - // this.lookupAction.invoke({"name": "getView","async": true, "parameter": {"view": this.json.statementName, "application": this.json.application},"success": function(json){ - // this.viewJson = JSON.decode(json.data.data); - // this.json = Object.merge(this.json, json.data); - // //var viewData = JSON.decode(json.data.data); - // if (callback) callback(); - // }.bind(this)}); - }else{ - this.getViewRes = this.lookupAction.getViewById(this.json.viewId, function(json){ - this.viewJson = JSON.decode(json.data.data); - this.json.application = json.data.query; - this.json = Object.merge(this.json, json.data); - if (callback) callback(); - }.bind(this)); - } - }.bind(this)); - }, getFilter: function(){ var filterData = []; if (this.searchStatus==="custom"){ @@ -255,7 +251,7 @@ MWF.xApplication.query.Query.Statement = MWF.QStatement = new Class({ "path": entry.path, "value": key, "formatType": entry.formatType, - "logic": "or", + "logic": "and", "comparison": "like" }; filterData.push(d); @@ -267,7 +263,7 @@ MWF.xApplication.query.Query.Statement = MWF.QStatement = new Class({ "path": entry.path, "value": v, "formatType": entry.formatType, - "logic": "or", + "logic": "and", "comparison": "like" }; filterData.push(d); diff --git a/o2web/source/x_component_query_Query/lp/zh-cn.js b/o2web/source/x_component_query_Query/lp/zh-cn.js index 9b7e91f31b..49fb72990b 100644 --- a/o2web/source/x_component_query_Query/lp/zh-cn.js +++ b/o2web/source/x_component_query_Query/lp/zh-cn.js @@ -10,6 +10,7 @@ MWF.xApplication.query.Query.LP = { "noDescription": "未定义描述", "view": "视图", "stat": "统计", + "statement" : "查询", "customSearch": "高级搜索", "searchKeywork": "输入关键字搜索视图", "yes": "是", diff --git a/o2web/source/x_component_query_StatementDesigner/$Statement/view.html b/o2web/source/x_component_query_StatementDesigner/$Statement/view.html index 219331b262..334a86ee77 100644 --- a/o2web/source/x_component_query_StatementDesigner/$Statement/view.html +++ b/o2web/source/x_component_query_StatementDesigner/$Statement/view.html @@ -108,7 +108,7 @@ 参数: -
注:参数对应查询语句和总数语句中对应的where条件,形如":filed"
+
注:参数对应查询语句和总数语句中形如":field"的where条件,填写"field"。
diff --git a/o2web/source/x_component_query_StatementDesigner/Property.js b/o2web/source/x_component_query_StatementDesigner/Property.js index 7215f5b27a..da77ab491b 100644 --- a/o2web/source/x_component_query_StatementDesigner/Property.js +++ b/o2web/source/x_component_query_StatementDesigner/Property.js @@ -58,18 +58,18 @@ MWF.xApplication.query.StatementDesigner.Property = MWF.SDProperty = new Class({ }, loadViewFilter: function () { var nodes = this.propertyContent.getElements(".MWFViewFilter"); - //var filtrData = this.view.data.data.filterList; + var filtrData = this.view.data.data.filterList; var customData = this.view.data.data.customFilterList; 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, { - // "filtrData": filtrData, + "filtrData": filtrData, "customData": customData }, { "onChange": function (ids) { var data = this.getData(); - // _slef.changeJsonDate(["data", "filterList"], data.data); + _slef.changeJsonDate(["data", "filterList"], data.data); _slef.changeJsonDate(["data", "customFilterList"], data.customData); } }); diff --git a/o2web/source/x_component_query_StatementDesigner/lp/zh-cn.js b/o2web/source/x_component_query_StatementDesigner/lp/zh-cn.js index 678927ed5e..2a20d69492 100644 --- a/o2web/source/x_component_query_StatementDesigner/lp/zh-cn.js +++ b/o2web/source/x_component_query_StatementDesigner/lp/zh-cn.js @@ -36,5 +36,8 @@ MWF.xApplication.query.StatementDesigner.LP = Object.merge( MWF.xApplication.que "newLineSuccess": "插入数据成功", "newLineJsonError": "插入数据错误,数据格式有误", "queryStatement": "查询语句", - "countStatement": "总数语句" + "countStatement": "总数语句", + + "mastInputParameter" : "请输入参数", + "pathExecption" : "路径的写法是\"表别名.字段名\",格式不正确" }); \ No newline at end of file diff --git a/o2web/source/x_component_query_StatementDesigner/widget/ViewFilter.js b/o2web/source/x_component_query_StatementDesigner/widget/ViewFilter.js index 42add5ccf7..d3d0706aa4 100644 --- a/o2web/source/x_component_query_StatementDesigner/widget/ViewFilter.js +++ b/o2web/source/x_component_query_StatementDesigner/widget/ViewFilter.js @@ -34,7 +34,7 @@ MWF.xApplication.query.StatementDesigner.widget.ViewFilter = new Class({ loadData: function () { if (this.filtrData.filtrData && this.filtrData.filtrData.length) { this.filtrData.filtrData.each(function (data) { - this.items.push(new MWF.xApplication.query.ViewDesigner.widget.ViewFilter.Item(this, data)); + this.items.push(new MWF.xApplication.query.StatementDesigner.widget.ViewFilter.Item(this, data)); }.bind(this)); } @@ -65,6 +65,27 @@ MWF.xApplication.query.StatementDesigner.widget.ViewFilter = new Class({ this.scriptArea.load(v); }.bind(this)); }, + createFilterValueScriptArea: function (node) { + var title = node.get("title"); + + MWF.require("MWF.widget.ScriptArea", function () { + this.filterValueScriptArea = new MWF.widget.ScriptArea(node, { + "title": title, + "isload": true, + "isbind": false, + "maxObj": this.app.formContentNode || this.app.pageContentNode, + "onChange": function () { + this.filterValueScriptData = this.filterValueScriptArea.toJson(); + }.bind(this), + "onSave": function () { + //this.app.saveForm(); + }.bind(this), + "style": "formula" + }); + var v = (this.filterValueScriptData) ? this.filterValueScriptData.code : ""; + this.filterValueScriptArea.load(v); + }.bind(this)); + }, createCustomFilterValueScriptArea: function (node) { var title = node.get("title"); @@ -103,6 +124,7 @@ MWF.xApplication.query.StatementDesigner.widget.ViewFilter = new Class({ this.titleInput = this.inputAreaNode.getElement(".titleInput_vf"); this.pathInput = this.inputAreaNode.getElement(".pathInput_vf"); + this.parameterInput = this.inputAreaNode.getElement(".parameterInput_vf"); this.datatypeInput = this.inputAreaNode.getElement(".datatypeInput_vf"); this.restrictFilterInput = this.inputAreaNode.getElement(".restrictFilterInput_vf"); @@ -124,8 +146,15 @@ MWF.xApplication.query.StatementDesigner.widget.ViewFilter = new Class({ if (this.app.statement.view) { var dataId = this.app.statement.view.data.id; - this.customFilterValueTypes = this.inputAreaNode.getElements("[name='" + dataId + "viewCustomFilterValueType']"); + this.filterValueType = this.inputAreaNode.getElements("[name='" + dataId + "viewFilterValueType']"); + this.filterValueScriptDiv = this.inputAreaNode.getElement("#" + dataId + "viewFilterValueScriptDiv"); + this.filterValueScript = this.inputAreaNode.getElement("[name='" + dataId + "viewFilterValueScript']"); + if (this.filterValueScript) { + this.createFilterValueScriptArea(this.filterValueScript); + } + + this.customFilterValueTypes = this.inputAreaNode.getElements("[name='" + dataId + "viewCustomFilterValueType']"); this.customFilterValueScriptDiv = this.inputAreaNode.getElement("#" + dataId + "viewCustomFilterValueScriptDiv"); this.customFilterValueScript = this.inputAreaNode.getElement("[name='" + dataId + "viewCustomFilterValueScript']"); if (this.customFilterValueScript) { @@ -294,65 +323,85 @@ MWF.xApplication.query.StatementDesigner.widget.ViewFilter = new Class({ }.bind(this)); }, modifyOrAddFilterItem: function () { + debugger; + var flag; if (this.currentFilterItem) { - this.modifyFilterItem(); + flag = this.modifyFilterItem(); } else { if (this.restrictFilterInput.checked) { - this.addFilterItem(); + flag = this.addFilterItem(); } else { - this.addCustomFilterItem(); + flag = this.addCustomFilterItem(); } } - this.setData({ - "logic": "and", - "path": "", - "title": "", - "type": this.restrictFilterInput.checked ? "restrict" : "custom", - "comparison": "equals", - "formatType": "textValue", - "value": "", - "otherValue": "", - "code": "" - }); + if( flag ){ + this.setData({ + "logic": "and", + "path": "", + "parameter" : "", + "title": "", + "type": this.restrictFilterInput.checked ? "restrict" : "custom", + "comparison": "equals", + "formatType": "textValue", + "value": "", + "otherValue": "", + "code": "" + }); + } }, modifyFilterItem: function () { var data = this.getInputData(); - if (this.verificationData(data)) { - this.currentFilterItem.reload(data); - this.currentFilterItem.unSelected(); - this.fireEvent("change"); + if( this.restrictFilterInput.checked ){ + if (this.verificationData(data)) { + this.currentFilterItem.reload(data); + this.currentFilterItem.unSelected(); + this.fireEvent("change"); + return true; + } + }else{ + if (this.verificationDataCustom(data)) { + this.currentFilterItem.reload(data); + this.currentFilterItem.unSelected(); + this.fireEvent("change"); + return true; + } } + return false; }, addFilterItem: function () { var data = this.getInputData(); if (this.verificationData(data)) { this.items.push(new MWF.xApplication.query.StatementDesigner.widget.ViewFilter.Item(this, data)); this.fireEvent("change"); + return true; } + return false; }, addCustomFilterItem: function () { var data = this.getInputData(); if (this.verificationDataCustom(data)) { this.items.push(new MWF.xApplication.query.StatementDesigner.widget.ViewFilter.ItemCustom(this, data)); this.fireEvent("change"); + return true; } + return false; }, verificationData: function (data) { - if (!data.path) { + if (!data.parameter) { this.verificationNode = new Element("div", {"styles": this.css.verificationNode}).inject(this.inputAreaNode); new Element("div", { "styles": this.css.verificationTextNode, - "text": this.app.lp.mastInputPath + "text": this.app.lp.mastInputParameter }).inject(this.verificationNode); - this.pathInput.focus(); - this.pathInput.setStyle("background-color", "#fbe8e8"); + this.parameterInput.focus(); + this.parameterInput.setStyle("background-color", "#fbe8e8"); - this.pathInput.addEvents({ + this.parameterInput.addEvents({ "keydown": function () { if (this.verificationNode) { this.verificationNode.destroy(); this.verificationNode = null; - this.pathInput.setStyle("background-color", "#FFF"); + this.parameterInput.setStyle("background-color", "#FFF"); } }.bind(this), "click": function () { @@ -397,11 +446,12 @@ MWF.xApplication.query.StatementDesigner.widget.ViewFilter = new Class({ }); return false; } - if (!data.path) { + if (!data.path || data.path.indexOf(".")<1 ) { this.verificationNode = new Element("div", {"styles": this.css.verificationNode}).inject(this.inputAreaNode); + var text = !data.path ? this.app.lp.mastInputPath : this.app.lp.pathExecption; new Element("div", { "styles": this.css.verificationTextNode, - "text": this.app.lp.mastInputPath + "text": text }).inject(this.verificationNode); this.pathInput.focus(); this.pathInput.setStyle("background-color", "#fbe8e8"); @@ -428,6 +478,8 @@ MWF.xApplication.query.StatementDesigner.widget.ViewFilter = new Class({ getInputData: function () { // var logic = this.logicInput.options[this.logicInput.selectedIndex].value; var path = this.pathInput.get("value"); + var parameter = this.parameterInput.get("value"); + var title = this.titleInput.get("value"); if (this.restrictFilterInput.checked) var type = "restrict"; if (this.customFilterInput.checked) var type = "custom"; @@ -476,16 +528,21 @@ MWF.xApplication.query.StatementDesigner.widget.ViewFilter = new Class({ break; } if (type === "restrict") { + this.filterValueType.each(function (radio) { + if (radio.get("checked")) valueType = radio.get("value"); + }); return { //"logic": logic, - "path": path, + "parameter": parameter, "title": title, "type": type, //"comparison": comparison, "formatType": formatType, "value": value, //"otherValue": value2, - "code": this.scriptData + "code": this.scriptData, + "valueType": valueType, + "valueScript": this.filterValueScriptData }; } else { var valueType = ""; @@ -493,11 +550,11 @@ MWF.xApplication.query.StatementDesigner.widget.ViewFilter = new Class({ if (radio.get("checked")) valueType = radio.get("value"); }); return { - "logic": "and", + // "logic": "and", "path": path, "title": title, "type": type, - "comparison": comparison, + // "comparison": comparison, "formatType": formatType, "value": value, "otherValue": value2, @@ -518,6 +575,7 @@ MWF.xApplication.query.StatementDesigner.widget.ViewFilter = new Class({ this.titleInput.set("value", data.title); this.pathInput.set("value", data.path); + this.parameterInput.set("value", data.parameter); // for (var i=0; i