提交 19022e39 编写于 作者: 蔡祥熠

Merge branch 'feature/api_dialog' into 'develop'

Merge of feature/api_dialog api中加入了dialog方法 to develop

See merge request o2oa/o2oa!876
......@@ -460,7 +460,7 @@ o2.widget.Dialog = o2.DL = new Class({
// // this.content.setStyle("display", "block");
// //this.fireEvent("postShow");
var pn = this.node.getOffsetParent();
var pn = this.node.getOffsetParent() || this.node.getParent();
var p = pn.getPosition();
var h = this.css.to.height.toInt();
......
......@@ -1718,6 +1718,9 @@ MWF.xScript.CMSEnvironment = function(ev){
"notice": function(content, type, target, where, offset, option){
_form.notice(content, type, target, where, offset, option);
},
"dialog": function ( options ) {
_form.dialog( options );
},
"addEvent": function(e, f){_form.addEvent(e, f);},
"openWork": function(id, completedId, title, options){
var op = options || {};
......
......@@ -3125,6 +3125,176 @@ MWF.xScript.Environment = function(ev){
_form.notice(content, type, target, where, offset, option);
},
/**弹出一个对话框层。
* @method dialog
* @static
* @param {(Object)} options
* 弹出框选项:<br/>
* 如果有buttonList参数,则ok,cancel参数无效。<br/>
* 对话框内容的优先级为moduleName、content、url、html、text,有前面的参数则后面的参数无效。<br/>
* 调用弹出框对象后各事件执行先后顺序 onQueryLoad-->onPostLoad-->onQueryShow-->onPostShow。<br/>
* 其他说明如下:
* <pre><code class="language-js">{
* "style" : "default", //(string)可选,弹出框使用的样式,默认是user,系统内置一些样式,比如:user,blue_flat,o2,flat等,对应样式文件位置:webserver\o2_core\o2\widget\$Dialog,用户也可以自己增加自定义样式风格,对应文件及结构参考已有样式风格。
* "title" : "", //(string)可选,弹出框头部标题,在isTitle参数为true时有效。
* "width" : 300, //(number)可选,弹出框宽度。 默认值:300
* "height" : 150, //(number)可选,弹出框高度。 默认值:150
* "isTitle" : true, //(boolean)可选,弹出框是否有标题栏。默认值:true。
* "isMax" : false, //(boolean)可选,标题栏是否有最大化按钮,相对应有还原按钮,默认值:false。
* "isClose" : false, //(boolean)可选,标题栏是否有关闭按钮。默认值:false。
* "isResize" : true, //(boolean)可选,弹出框大小是否可调整。默认值:true。
* "isMove" : true, //(boolean)可选,弹出框是否可移动。默认值:true。
* "offset" : {"x":-200, "y": -100}, //(object)可选,弹出框相对容器(container)的x轴y轴位置偏移量,空则居中。
* "mask" : true, //(boolean)可选,是否需要遮罩层。默认值:true。
* "duration" : true, //(number)可选,动画显示弹出框效果时间。默认值:200。
* "zindex": 100, //(number)可选,弹出框的z轴优先级,默认为100(日期控件的zindex为300,选人控件为1000,最好不要高于300)。
* "buttonList" : [
* {
* "type": "ok", //(string) 样式,彩色底的按钮
* "text": "确定", //(string)text:按钮显示名称
* "action": function(){ //(function) 按钮对应的点击事件
* //do something,this指向本对话框对象
* this.close();
* }
* },
* {
* "type": "cancel", //(string) 样式,灰色底的按钮
* "text": "取消",
* "action": function(){
* //do something
* this.close();
* }
* }
* ], //(Array)可选,定义底部按钮,数组列表。无该参数则默认有确定和取消两个按钮,这个时候options可以传入ok或者cancel方法作为回调。如果传入空数组“[]”则底部无按钮。
* "ok": function(){}, //(function) 可选,无options.buttonList参数的时候,该方法作为“确定”按钮的回调方法,返回true关闭对话框,options.buttonList不为空则忽略该方法。
* "close": function(){}, //(function) 可选,无options.buttonList参数的时候,该方法作为“取消”按钮的回调方法,返回true关闭对话框,options.buttonList不为空则忽略该方法。
* "container" : this.form.getApp().content, //(Element/Dom)可选,弹出框层dom对象的父dom,位置相对对象。移动端默认插入到body中,PC端默认插入到表单节点所在容器(this.form.getApp().content)。
* "moduleName": "div_1", //内容参数,优先级为1,(String)可选,表示表单组件名称,系统会获取该组件的node节点作为对话框内容,关闭对话框节点会插回到原来的位置。
* "content": this.form.get("div1").node, //内容参数,优先级为2,(Element/Dom)可选,对话框内容,如果节点在document中,关闭对话框节点会插回到原来的位置。
* "url": "http://xxx/xxx.html", //内容参数,优先级为3,(String)可选,该参数所指向的内容作为对话框的内容。
* "html": "<div>html内容</div>", //内容参数,优先级为4,(String)可选,对话框的html内容。
* "text": "文本内容", //内容参数,优先级为5,(String)可选,对话框的文本内容。
* "onQueryClose": function(){}, //(function) 可选,关闭弹出框前事件,this指向对话框对象。
* "onPostClose": function(){}, //(function) 可选,关闭弹出框后事件,this指向对话框对象。
* "onQueryLoad": function(){}, //(function) 可选,弹出框载入前事件,this指向对话框对象。
* "onPostLoad": function(){}, //(function) 可选,弹出框载入后事件,this指向对话框对象。
* "onQueryShow": function(){}, //(function) 可选,弹出框显示前事件,this指向对话框对象。
* "onPostShow": function(){} //(function) 可选,弹出框显示后事件,this指向对话框对象。
* }</code></pre>
* @example
* //打开一个对话框,使用html作为内容
* var _self = this;
* this.form.dialog({
* "title": "填写内容",
* "width": "500",
* "height": "300",
* "html": "<div>内容:</div><div><input type='text'></div>",
* "ok": function(){
* var value = this.node.getElement("input").value; //this指向对话框对象
* if( !value ){
* _self.form.notice("请填写内容", "info");
* return false; //返回false不关闭对话框
* }else{
* return true; //返回true关闭对话框
* }
* }
*});
* @example
* //打开一个对话框,使用表单中的div_1组件作为内容
* var _self = this;
* this.form.dialog({
* "title": "填写内容",
* "width": "400",
* "height": "200",
* "moduleName": "div_1", //内容为表单上的组件,标识为div_1
* "buttonList" : [
* {
* "type": "ok", //(string) 样式,彩色底的按钮
* "text": "确定", //(string)text:按钮显示名称
* "action": function(){ //(function) 按钮对应的点击事件
* //do something,this指向本对话框对象
* var value = _self.form.get("textfield").getData(); //获取div_1中的组件textfield的值
* if( !value ){
* _self.form.notice("请填写内容","info");
* }else{
* this.close();
* }
* }
* },
* {
* "type": "cancel", //(string) 样式,灰色底的按钮
* "text": "取消",
* "action": function(){
* //do something
* this.close();
* }
* }
* ]
* });
* @example
* //打开一个对话框,创建Dom节点作为内容
* var _self = this;
* var content = new Element("div");
* new Element("label", {
* text: "内容:"
* }).inject(content);
* new Element("input", {
* type: "text"
* }).inject(content);
* this.form.dialog({
* "title": "填写内容",
* "width": "400",
* "height": "200",
* "zindex": 301, //z轴优先级为301
* "content": content, //new Element创建的内容,也可以使用 this.form.get(xx).node 作为内容
* "buttonList" : [
* {
* "type": "ok", //(string) 样式,彩色底的按钮
* "text": "确定", //(string)text:按钮显示名称
* "action": function(){ //(function) 按钮对应的点击事件
* //do something,this指向本对话框对象
* var value = this.node.getElement("input").get("value"); //获取对话框节点中的input的值
* if( !value ){
* _self.form.notice("请填写内容","info");
* }else{
* this.close();
* }
* }
* },
* {
* "type": "cancel", //(string) 样式,灰色底的按钮
* "text": "取消",
* "action": function(){
* //do something
* this.close();
* }
* }
* ],
* "onQueryClose": function(){
* console.log("-onQueryClose-");
* },
* "onPostClose": function(){
* console.log("-onPostClose-");
* },
* "onQueryLoad":function(){
* console.log("-onQueryLoad-");
* },
* "onPostLoad": function(){
* console.log("-onPostLoad-");
* },
* "onQueryShow": function(){
* console.log("-onQueryshow-");
* },
* "onPostShow": function(){
* console.log("-onPostShow-");
* }.bind(this)
* });
*/
"dialog": function ( options ) {
_form.dialog( options );
},
/**给表单添加事件。
* @method addEvent
* @static
......
......@@ -1808,6 +1808,16 @@ if (!MWF.xScript || !MWF.xScript.PageEnvironment) {
"notice": function (content, type, target, where, offset, option) {
_form.notice(content, type, target, where, offset, option);
},
/**打开一个对话框
* @method dialog
* @static
* @see module:form.dialog
*/
"dialog": function ( options ) {
_form.dialog( options );
},
/**给页面添加事件。
* @method addEvent
* @static
......
......@@ -4309,6 +4309,15 @@ MWF.xScript.ViewEnvironment = function (ev) {
_form.notice(content, type, target, where, offset, option);
},
/**打开一个对话框
* @method dialog
* @static
* @see module:form.dialog
*/
"dialog": function ( options ) {
_form.dialog( options );
},
/** 给视图添加事件。
* @method addEvent
* @static
......
......@@ -366,7 +366,7 @@ MWF.xApplication.cms.Module.QueryViewer = new Class({
"text": this.lp.action
}).inject(this.viewTitleLine);
viewCell.setStyle("width","40px");
if (this.json.titleStyles) viewCell.setStyles(this.json.titleStyles);
// if (this.json.titleStyles) viewCell.setStyles(this.json.titleStyles);
}
this.lookup(data);
......
......@@ -38,7 +38,7 @@ MWF.xApplication.portal.PageDesigner.Module.Table = MWF.PCTable = new Class({
tdContainer.table = this;
tdContainer.load(moduleData, td, this);
}else{
if(!json.event)json.events = Object.clone(data.events);
if(!json.events)json.events = Object.clone(data.events);
tdContainer = new MWF.PCTable$Td(this.form);
tdContainer.table = this;
tdContainer.load(json, td, this);
......
......@@ -2835,6 +2835,96 @@ MWF.xApplication.process.Xform.Form = MWF.APPForm = new Class(
}
new mBox.Notice(options);
},
dialog: function( options ){
if( !options )options = {};
var opts = {
"style" : options.style || "user",
"title": options.title || "",
"width": options.width || 300,
"height" : options.height || 150,
"isMax": o2.typeOf( options.isMax ) === "boolean" ? options.isMax : false,
"isClose": o2.typeOf( options.isClose ) === "boolean" ? options.isClose : true,
"isResize": o2.typeOf( options.isResize ) === "boolean" ? options.isResize : true,
"isMove": o2.typeOf( options.isMove ) === "boolean" ? options.isMove : true,
"isTitle": o2.typeOf( options.isTitle ) === "boolean" ? options.isTitle : true,
"offset": options.offset || null,
"mask": o2.typeOf( options.mask ) === "boolean" ? options.mask : true,
"container": options.container || ( layout.mobile ? $(documtn.body) : this.app.content ),
"duration": options.duration || 200,
"lp": options.lp || null,
"zindex": ( options.zindex || 100 ).toInt(),
"buttonList": options.buttonList || [
{
"type": "ok",
"text": MWF.LP.process.button.ok,
"action": function(){
if(options.ok){
var flag = options.ok.call( this );
if( flag === true || o2.typeOf(flag) === "null" )this.close();
}else{
this.close();
}
}
},
{
"type": "cancel",
"text": MWF.LP.process.button.cancel,
"action": function(){
if(options.close){
var flag = options.close.call(this);
if( flag === true || o2.typeOf(flag) === "null" )this.close();
}else{
this.close();
}
}
}
]
};
var positionNode;
if( options.moduleName ){
var module, name = options.moduleName, subformName = options.subformName;
if( subformName && this.all[subformName +"_"+ name] ){
module = this.all[subformName +"_"+ name];
}else{
module = this.all[name];
}
if( module ){
opts.content = module.node;
positionNode = new Element("div", {style:"display:none;"}).inject( opts.content, "before" );
}
}else if( options.content ) {
opts.content = options.content;
var parent = opts.content.getParent();
if(parent)positionNode = new Element("div", {style:"display:none;"}).inject( opts.content, "before" );
}
if( options.url )opts.url = options.url;
if( options.html )opts.html = options.html;
if( options.text )opts.text = options.text;
opts.onQueryClose = function(){
if( positionNode && opts.content ){
opts.content.inject( positionNode, "after" );
positionNode.destroy();
}
if( o2.typeOf(options.onQueryClose) === "function" )options.onQueryClose.call( this );
}
if(opts.onPostClose)opts.onPostClose = options.onPostClose;
if(opts.onQueryLoad)opts.onQueryLoad = options.onQueryLoad;
if(opts.onPostLoad)opts.onPostLoad = options.onPostLoad;
if(opts.onQueryShow)opts.onQueryShow = options.onQueryShow;
if(opts.onPostShow)opts.onPostShow = options.onPostShow;
for( var key in options ){
if( !opts.hasOwnProperty( key ) ){
opts[key] = options[key];
}
}
MWF.require("MWF.xDesktop.Dialog", function(){
var dialog = o2.DL.open(opts)
})
},
addSplit: function () {
if (!this.businessData.control["allowAddSplit"]) {
MWF.xDesktop.notice("error", { x: "right", y: "top" }, "Permission Denied");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册