提交 ea5b921e 编写于 作者: U unknown

查询中增加视图

上级 09dbc8a8
......@@ -33,10 +33,18 @@
<div style="background-color: #EEE; height:24px; line-height: 24px; text-align: center; font-weight: bold">数据</div>
<div class="MWFDataData" id="text{$.pid}dataDataEditor">
<table width="100%" border="0" cellpadding="5" cellspacing="0" class="editTable">
<tr>
<td class="editTableTitle">选择路径:</td>
<td class="editTableValue">
<select class="MWFDataPathSelect" id="text{$.pid}dataPathSelected" onchange=" var v=this.options[this.selectedIndex].value; if (true){var n = $('text{$.pid}viewColumnPathInput'); n.set('value', v); n.focus();} ">
</select>
<div style="line-height: 20px;color:#999;">注:正确填写了查询语句,再测试语句或刷新视图数据可显示(刷新)选择路径。</div>
</td>
</tr>
<tr>
<td class="editTableTitle">数据路径:</td>
<td class="editTableValue">
<input onkeypress="$('text{$.pid}dataPathSelected').getElement('option').set('selected', true); $('text{$.pid}dataPathSelectedCMS').getElement('option').set('selected', true)" id="text{$.pid}viewColumnPathInput" type="text" name="path" value="text{$.path}" class="editTableInput"/>
<input id="text{$.pid}viewColumnPathInput" type="text" name="path" value="text{$.path}" class="editTableInput"/>
<div style="line-height: 20px;color:#999;">注:指该列相对单条数据的路径。比如 0,title,或 0.title</div>
</td>
</tr>
......
......@@ -21,12 +21,27 @@
<div style="height:24px; text-align: center; line-height: 24px; background-color: #EEE; border-top: 1px solid #999; font-weight: bold">执行权限</div>
<table width="100%" border="0" cellpadding="5" cellspacing="0" class="editTable" id="processEditStarter">
<tr>
<td class="editTableTitle">匿名访问:</td>
<td class="editTableValue">
<input class="editTableRadio" name="anonymousAccessible" text{($.anonymousAccessible===true)?'checked':''} type="radio" value="true"
onclick="if(this.checked){
$('text{$.pid}executePersonListTr').setStyle('display', 'none');
$('text{$.pid}executeUnitListTr').setStyle('display', 'none');
}"/>允许
<input class="editTableRadio" name="anonymousAccessible" text{($.anonymousAccessible!==true)?'checked':''} type="radio" value="false"
onclick="if(this.checked){
$('text{$.pid}executePersonListTr').setStyle('display', '');
$('text{$.pid}executeUnitListTr').setStyle('display', '');
}"/>不允许
</td>
</tr>
<tr id="text{$.pid}executePersonListTr" style="display:text{($.anonymousAccessible==true)?'none':''}">
<td class="editTableTitle">执行人:</td>
<td class="editTableValue">
<div class="MWFPersonIdentity" name="executePersonList"></div>
</td>
</tr>
<tr>
<tr id="text{$.pid}executeUnitListTr" style="display:text{($.anonymousAccessible==true)?'none':''}">
<td class="editTableTitle">执行组织:</td>
<td class="editTableValue">
<div class="MWFPersonUnit" name="executeUnitList"></div>
......@@ -34,9 +49,8 @@
</tr>
</table>
</div>
</div>
<div title="JSON" class="MWFTab">
<div class="MWFJSONArea" style="font-family: Verdana, Geneva, sans-serif; font-size:14px"></div>
</div>
<div title="JSON" class="MWFTab">
<div class="MWFJSONArea" style="font-family: Verdana, Geneva, sans-serif; font-size:14px"></div>
</div>
</div>
\ No newline at end of file
......@@ -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;
......
......@@ -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<pathList.length; i++ ){
var p = pathList[i];
if( (/(^[1-9]\d*$)/.test(p)) )p = p.toInt();
if( obj[ p ] ){
obj = obj[ p ];
}else{
obj = "";
break;
}
}.bind(this));
// Object.each(line.data, function(d, k){
// var td = new Element("td", {"styles": 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);
// }.bind(this));
}.bind(this));
this.setContentColumnWidth();
this.setContentHeight();
} else if (this.json.data.noDataText) {
var noDataTextNodeStyle = this.css.noDataTextNode;
if (this.json.data.viewStyles) {
if (this.json.data.viewStyles["noDataTextNode"]) {
noDataTextNodeStyle = this.json.data.viewStyles["noDataTextNode"]
}
}
if( code && code.trim())obj = MWF.Macro.exec( code, {"value": obj, "data": line, "entry": c});
var toName = function (value) {
if(typeOf(value) === "array"){
Array.each( value, function (v, idx) {
value[idx] = toName(v)
})
}else if( typeOf(value) === "object" ){
Object.each( value, function (v, key) {
value[key] = toName(v);
})
}else if( typeOf( value ) === "string" ){
value = o2.name.cn( value )
}
return value;
};
var d;
if( obj!= undefined && obj!= null ){
if( typeOf(obj) === "array" ) {
d = c.isName ? JSON.stringify(toName(Array.clone(obj))) : JSON.stringify(obj);
}else if( typeOf(obj) === "object" ){
d = c.isName ? JSON.stringify(toName(Object.clone(obj))) : JSON.stringify(obj);
}else{
d = c.isName ? o2.name.cn( obj.toString() ) : obj;
}
}
if (d != undefined && d != null ) {
var td = new Element("td", {
"styles": this.json.data.viewStyles ? this.json.data.viewStyles["contentTd"] : this.css.viewContentTdNode
}).inject(tr);
if (c.isHtml) {
td.set("html", d);
} else {
this.json.data.viewStyles["noDataTextNode"] = this.css.noDataTextNode
td.set("text", d);
}
}
this.noDataTextNode = new Element("div", {
"styles": noDataTextNodeStyle,
"text": this.json.data.noDataText
}).inject(this.viewContentBodyNode);
}
}.bind(this));
}.bind(this));
}.bind(this));
this.setContentColumnWidth();
this.setContentHeight();
} else if (this.json.data.noDataText) {
var noDataTextNodeStyle = this.css.noDataTextNode;
if (this.json.data.viewStyles) {
if (this.json.data.viewStyles["noDataTextNode"]) {
noDataTextNodeStyle = this.json.data.viewStyles["noDataTextNode"]
} else {
this.json.data.viewStyles["noDataTextNode"] = this.css.noDataTextNode
}
}
this.noDataTextNode = new Element("div", {
"styles": noDataTextNodeStyle,
"text": this.json.data.noDataText
}).inject(this.viewContentBodyNode);
}
// }.bind(this));
// }.bind(this));
}
},
addColumn: function () {
......@@ -1422,6 +1512,38 @@ MWF.xApplication.query.StatementDesigner.View.Column = new Class({
this.domListNode = this.view.domListNode;
this.load();
},
refreshColumnPathData: function () {
if (this.property) {
this.property.loadDataPathSelect();
}
},
getColumnDataPath: function () {
return this.view.statement.getColumnDataPath();
},
showProperty: function () {
if (!this.property) {
this.property = new MWF.xApplication.query.StatementDesigner.Property(this, this.view.designer.propertyContentArea, this.view.designer, {
"path": this.propertyPath,
"onPostLoad": function () {
this.property.show();
var processDiv = this.property.propertyContent.getElements("#" + this.json.id + "dataPathSelectedProcessArea");
var cmsDiv = this.property.propertyContent.getElements("#" + this.json.id + "dataPathSelectedCMSArea");
if (this.view.json.type == "cms") {
processDiv.setStyle("display", "none");
cmsDiv.setStyle("display", "block");
} else {
processDiv.setStyle("display", "block");
cmsDiv.setStyle("display", "none");
}
}.bind(this)
});
this.property.load();
} else {
this.property.show();
}
},
selected: function () {
if (this.view.statement.currentSelectedModule) {
if (this.view.statement.currentSelectedModule == this) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册