提交 88ace661 编写于 作者: U unknown

查询增加视图

上级 8c48b9e6
......@@ -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", {
......
......@@ -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,
......
......@@ -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));
}
......
......@@ -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);
......
......@@ -10,6 +10,7 @@ MWF.xApplication.query.Query.LP = {
"noDescription": "未定义描述",
"view": "视图",
"stat": "统计",
"statement" : "查询",
"customSearch": "高级搜索",
"searchKeywork": "输入关键字搜索视图",
"yes": "",
......
......@@ -108,7 +108,7 @@
<td class="editTableTitle">参数:</td>
<td class="editTableValue">
<input type="text" class="editTableInput parameterInput_vf"/>
<div style="line-height: 20px;color:#999;">注:参数对应查询语句和总数语句中对应的where条件,形如":filed"</div>
<div style="line-height: 20px;color:#999;">注:参数对应查询语句和总数语句中形如":field"的where条件,填写"field"。</div>
</td>
</tr>
<tr id="text{$.id}pathInputTr">
......
......@@ -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);
}
});
......
......@@ -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
......@@ -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<this.comparisonInput.options.length; i++){
// if (this.comparisonInput.options[i].value===data.comparison){
......@@ -613,6 +671,27 @@ MWF.xApplication.query.StatementDesigner.widget.ViewFilter = new Class({
}
}
if (data.type === "restrict") {
this.filterValueType.each(function (radio) {
if (data.valueType) {
if (data.valueType === radio.get("value")) radio.set("checked", true);
} else {
if ("input" === radio.get("value")) radio.set("checked", true);
}
});
if (this.filterValueScriptArea) {
if (!data.valueType || data.valueType === "input") {
this.filterValueScriptDiv.hide();
this.filterValueScriptData = "";
this.filterValueScriptArea.editor.setValue("");
} else {
this.filterValueScriptDiv.show();
this.filterValueScriptData = data.valueScript;
this.filterValueScriptArea.editor.setValue(data.valueScript ? data.valueScript.code : "");
}
}
}
this.switchInputDisplay();
if (this.datatypeInput.onchange) {
......@@ -628,6 +707,7 @@ MWF.xApplication.query.StatementDesigner.widget.ViewFilter = new Class({
this.fireEvent("change");
},
getData: function () {
debugger;
var data = [];
var customData = [];
this.items.each(function (item) {
......@@ -668,9 +748,9 @@ MWF.xApplication.query.StatementDesigner.widget.ViewFilter.Item = new Class({
getText: function () {
var lp = this.app.lp.filter;
if (this.data.formatType === "numberValue") {
return this.data.title + " " + this.data.path + " " + this.data.value;
return this.data.title + " " + this.data.parameter + " " + this.data.value;
} else {
return this.data.title + " " + this.data.path + " \"" + this.data.value + "\"";
return this.data.title + " " + this.data.parameter + " \"" + this.data.value + "\"";
}
},
reload: function (data) {
......@@ -678,6 +758,11 @@ MWF.xApplication.query.StatementDesigner.widget.ViewFilter.Item = new Class({
this.contentNode.set("text", this.getText());
},
selected: function () {
if( this.filter.verificationNode ){
this.filter.verificationNode.destroy();
this.filter.verificationNode = null;
this.filter.parameterInput.setStyle("background-color", "#FFF");
}
this.filter.restrictFilterInput.set("checked", true);
this.filter.restrictFilterInput.click();
if (this.filter.currentFilterItem) this.filter.currentFilterItem.unSelected();
......@@ -715,6 +800,11 @@ MWF.xApplication.query.StatementDesigner.widget.ViewFilter.ItemCustom = new Clas
this.load();
},
selected: function () {
if( this.filter.verificationNode ){
this.filter.verificationNode.destroy();
this.filter.verificationNode = null;
this.filter.pathInput.setStyle("background-color", "#FFF");
}
this.filter.customFilterInput.set("checked", true);
this.filter.customFilterInput.click();
if (this.filter.currentFilterItem) this.filter.currentFilterItem.unSelected();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册