O2OA API

Class

Application

Extends

Application 门户中嵌入的系统component对象或网页iframe(模块部署中配置的网页URL)。

Usable Range

Portal

Example

//可以在脚本中获取该组件
//方法1:
var application = this.form.get("fieldId"); //获取组件
//方法2
var application = this.target; //在组件本身的脚本中获取

Source

Members

iframeObject

当模块部署中配置的是@url:开头的链接时,嵌入的iframe.

Type

  • Object

Example

var iframe = this.form.get("fieldId").iframe; //获取iframe
iframe.src; //获取iframe的地址

Source

componentObject

嵌入的component对象.

Type

  • Object

Example

var app = this.form.get("fieldId").component; //获取component对象
app.recordStatus(); //获取应用的当前状态
app.refresh();      //刷新应用
app.dialog(option); //弹出一个对话框(详见MWF.widget.Dialog)
app.notice(content, type, target, where, offset); //显示一个通知消息
app.confirm(type, e, title, text, width, height, ok, cancel); //显示一个确认框
app.alert(type, e, title, text, width, height); //弹出一个信息框
app.addEvent(type, fun); //为应用绑定一个事件

Source

jsonJsonObject

组件的配置信息,比如id,类型,是否只读等等。可以在组件的queryLoad事件里修改该配置来对组件做一些改变。

Type

  • JsonObject

Example

//可以在脚本中获取该组件
var json = this.form.get("fieldId").json; //获取组件对象
var id = json.id; //获取组件的id
var type = json.type; //获取组件的类型,如Textfield 为文本输入组件,Select为下拉组件

//在组件queryLoad事件里设置组件只读。
//当前组件的queryLoad事件运行时还没有在form里注册,通过this.form.get("fieldId")不能获取到当前组件,需要用this.target获取。
var json = this.target.json;
json.isReadonly = true; //设置组件为只读。

Source

Methods

active(callback)

当组件被设置为延迟激活,通过active方法激活

Parameters

  • callback function

    激活后的回调方法(不保证组件加载完成),另外已经激活过该方法还会被执行。

Example

var app = this.form.get("fieldId");
app.active(function(){
    //do someting
})

Source

loadIframe(src)

加载Iframe

Parameters

  • src String

    iframe的src,如'https://www.baidu.com/'

Example

this.form.get("fieldId").clean(); //清除当前嵌入的对象
this.form.get("fieldId").loadIframe('https://www.baidu.com/'); //加载iframe

Source

loadComponent(path, statusopt, optionsopt, callbackopt)

加载系统组件

Parameters

  • path String

    组件的路径,如'Calendar'

  • status Object | null <optional>

    组件的状态

  • options Object | null <optional>

    组件的选项

  • callback function <optional>

    加载后的回调

Examples

this.form.get("fieldId").clean(); //清除当前嵌入的对象
this.form.get("fieldId").loadComponent('Calendar'); //加载日程安排
this.form.get("fieldId").clean(); //清除当前嵌入的对象
this.form.get("fieldId").loadComponent('cms.Module', {
 "columnId":"25434995-45d2-4c9a-a344-55ad0deff071"
 }); //加载id为25434995-45d2-4c9a-a344-55ad0deff071的内容管理栏目

Source

getComponentPath(callback)

获取获取表单设计配置的component对象的路径

Parameters

  • callback function

    获取路径后的回调方法,参数为路径

Example

this.form.get("fieldId").getComponentPath(function(path){
    //path为路径
})

Source

getParentModule(typeopt, validateFunctionopt) → {MWF.xApplication.process.Xform.$Module}

获取当前组件所在的祖先组件.

Parameters

  • type String <optional>

    需要获取的组件类型。 如果该参数省略,则获取离当前组件最近的祖先组件。type有效值如下:

    form- 表单
    common- 通用组件
    datatable- 数据表格
    datatableline- 数据表格行
    datatemplate- 数据模板
    datatemplateline- 数据模板行
    div- 容器组件
    elcommon- Element通用组件
    elcontainer- Element容器组件
    subform- 子表单
    source- 数据源组件
    subsource- 子数据源
    subsourceitem- 子数据项组件
    tab- 分页组件
    tabpage- 分页组件的某个分页
    table- 表格
    tabletd- 单元格
    widget- 部件
  • validateFunction function <optional>

    进一步校验,参数为获取到匹配到类型的组件,返回false继续往上取对应类型的组件,返回true返回该组件。

Returns

Example

var module = this.target.getParentModule(); //获取最近的祖先。

var datatemplateLine = this.target.getParentModule("datatemplateline"); //获取当前组件所在的数据模板行.

var module = this.target.getParentModule(null, function(module){
    return module.json.id === "div_1";
}); //获取当前组件id为div_1的父组件。

Source

addRelatedDisplay(pathopt, cbopt)

给当前组件增加一个显示关联数据,当这个数据改变时,刷新当前组件的可见状态.

Parameters

  • path String | Array.<String> <optional>

    要关联的数据路径。

  • cb function <optional>

    提供一个返回布尔值的函数,用于检查当前组件是否可显示,返回true表示当前组件可见,返回false则隐藏当前组件

Example

//在组件的load事件中,添加下面的代码:
this.target.addRelatedDisplay('dataType', ()=>{
 return this.data.dataType==='1'
});

//加入以上代码后,只要 “dataType” 的值改变,就会检查当前组件是否隐藏或显示。当 dataType 值为 “1” 时,当前组件显示,否则隐藏当前组件。

Source

addRelatedValue(pathopt, cbopt)

给当前组件增加一个值关联数据,当这个数据改变时,刷新当前组件的值.

Parameters

  • path String | Array.<String> <optional>

    要关联的数据路径。

  • cb function <optional>

    提供一个函数,当关联数据发生改变时,执行此函数,返回的值更新为当前组件的值。

Example

//在field类的组件(如文本框)的load事件中,添加下面的代码:
this.target.addRelatedValue(['price', 'count'], ()=>{
 return this.data.price * this.data.count;
});

//加入以上代码后,只要 price 或 count 的值改变,就会计算当前组件的值,其值是 price 乘以 count。

Source

Events

queryLoadApplication

component对象初始化后,加载之前触发,this.event可获取component对象。

results matching

    No results matching ''