Usable Range
Process
CMS
Example
//可以在脚本中获取该组件
//方法1:
var sourceText = this.form.get("fieldId"); //获取组件
//方法2
var sourceText = this.target; //在组件本身的脚本中获取
Source
Members
documentListArray.<Object>
当前组件关联的文档。
Type
-
Array.<Object>
Example
//可以在脚本中获取该组件
var documentList = this.form.get("fieldId").documentList; //当前组件关联的文档
Source
nodeElement
组件的节点,mootools封装过的Dom对象,可以直接使用原生的js和moootools方法访问和操作该对象。
Type
-
Element
Overrides
See
Example
//可以在脚本中获取该组件
var field = this.form.get("fieldId"); //获取组件对象
field.node.setStyle("font-size","12px"); //给节点设置样式
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
formMWF.xApplication.process.Xform.Form
组件的所在表单对象.
Type
Example
var form = this.form.get("fieldId").form; //获取组件所在表单对象
var container = form.container; //获取表单容器
Source
parentLineMWF.xApplication.process.Xform.Datatemplate.Line|MWF.xApplication.process.Xform.DatatablePC.Line|MWF.xApplication.process.Xform.DatatableMobile.Line
当前组件在数据表格或者数据模板中时,可以通过此属性获取所在行(条目)对象.
Type
-
MWF.xApplication.process.Xform.Datatemplate.Line|MWF.xApplication.process.Xform.DatatablePC.Line|MWF.xApplication.process.Xform.DatatableMobile.Line
Example
//获取当前组件所在数据模板/数据表格的行(条目)对象
var line = this.target.parentLine;
//获取当前字段所在行下标
var index = line.getIndex();
//获取当前字段所在条目的subject字段的值
var data = line.getModule("subject").getData();
//设置当前字段所在条目的subject字段的值
line.getModule("subject").setData("test1");
Source
Methods
set(data, callbackopt, asyncopt) → {Promise}
Summary
设置关联文档,清空所有的已关联文档后再关联。
Parameters
-
data
Array.<Object>.
-
callback
function<optional>
-
async
Boolean<optional>
是否异步执行,默认为异步。如果组件未加载完成的时候执行该方法,强制为异步。
Returns
-
Promise
Examples
this.form.get("fieldId").set([{
type: 'processPlatform', //类型,processPlatform表示流程,cms表示内容管理,如果为空默认为流程
bundle: '', //流程实例的 job, 或者是内容管理文档的id
view: '' //视图的id
}], function(json){
//json.data.failureList 关联失败列表
//json.data.successList 关联成功列表
}, true);
var p = this.form.get("fieldId").set([{
type: 'processPlatform',
bundle: '',
view: ''
}]);
p.then(function(json){
//json.data.failureList 关联失败列表
//json.data.successList 关联成功列表
})
this.form.get('fieldId').set([])取消所有关联
Source
add(data, toTopopt, keepOrderopt, callbackopt, asyncopt) → {Promise|Object}
Summary
根据传入的数据添加关联文档。
Parameters
-
data
Array.<Object> -
toTop
Boolean<optional>
是否添加到已有文档前面,默认为否。
-
keepOrder
Boolean<optional>
如果添加的已经存在,是否保留原有位置, 默认不保留。
-
callback
function<optional>
-
async
Boolean<optional>
是否为异步,默认为异步。如果组件未加载完成的时候执行该方法,强制为异步。
Returns
-
PromiseObject
Examples
this.form.get("fieldId").add([{
type: 'processPlatform', //类型,processPlatform表示流程,cms表示内容管理,如果为空默认为流程
bundle: '', //流程实例的 job, 或者是内容管理文档的id
view: '' //视图的id
}],
true,
true,
function(json){
//json.data.failureList 关联失败列表
//json.data.successList 关联成功列表
}, true);
var p = this.form.get("fieldId").add([{
type: 'processPlatform',
bundle: '',
view: ''
}]);
p.then(function(json){
//json.data.failureList 关联失败列表
//json.data.successList 关联成功列表
})
Source
cancel(bundles, callbackopt, asyncopt) → {Promise}
Summary
取消指定的关联。
Parameters
-
bundles
Array.<String> -
callback
function<optional>
-
async
Boolean<optional>
是否为异步,默认为异步。如果组件未加载完成的时候执行该方法,强制为异步。
Returns
-
Promise
Example
this.form.get("fieldId").cancel([id1, id2]);
Source
get() → {Promise|Array.<Object>}
Summary
得到关联的列表。
Returns
-
PromiseArray.<Object>如果组件未加载完成的时候执行该方法,返回promise,否则返回对象数组。
[ { "site": "associatedDocument", //组件site,如果没有设置,则为组件id "type": "cms", //类型,processPlatform表示流程,cms表示内容管理 "bundle": "909b78e1-3ec2-4c63-b756-200ff734c318", //流程实例的 job, 或者是内容管理文档的id "view": "b5bd7fae-239e-4cab-aa34-8c63350d9e97" //视图的id } ]
Examples
var documentList = this.form.get('fieldId').get();
var documentList = Promise.resolve( this.form.get('fieldId').get() )
Source
validate(routeNameopt) → {Boolean}
Summary
根据组件的校验设置进行校验。
Parameters
-
routeName
String<optional>
可选,路由名称.
Inherited From
Returns
-
Boolean是否通过校验
Example
if( !this.form.get('fieldId').validate() ){
return false;
}
Source
getSource(typeopt) → {Source|SubSource|SubSourceItem}
当前组件在数据源组件中时,可以通过此方法获取所在的上级数据源/子数据源/子数项组件.
Parameters
-
type
String<optional>
需要获取的类型,"source"为表示数据源,"subSource"表示子数据源,"subSourceItem"表示子数据项组件。 如果该参数省略,则获取离当前组件最近的上述组件。
Inherited From
Returns
-
SourceSubSourceSubSourceItem。
Example
var source = this.target.getSource(); //获取当前组件的所在子上级数据源/子数据源/子数项组件.
var data = source.data; //获取数据
var source = this.form.get("fieldId").getSource("source"); //获取数据源组件
var data = source.data; //获取数据
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返回该组件。
Inherited From
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
hide()
Summary
隐藏组件.
Inherited From
Example
this.form.get("fieldId").hide(); //隐藏组件
Source
show()
Summary
显示组件.
Inherited From
Example
this.form.get("fieldId").show(); //显示组件
Source
_isIntegerString(str) → {boolean}
判断一个字符串是否可以转换为一个整数
Parameters
-
str
string
Inherited From
Returns
-
boolean
Source
addRelatedDisplay(pathopt, cbopt)
给当前组件增加一个显示关联数据,当这个数据改变时,刷新当前组件的可见状态.
Parameters
-
path
String|Array.<String><optional>
要关联的数据路径。
-
cb
function<optional>
提供一个返回布尔值的函数,用于检查当前组件是否可显示,返回true表示当前组件可见,返回false则隐藏当前组件
Inherited From
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>
提供一个函数,当关联数据发生改变时,执行此函数,返回的值更新为当前组件的值。
Inherited From
Example
//在field类的组件(如文本框)的load事件中,添加下面的代码:
this.target.addRelatedValue(['price', 'count'], ()=>{
return this.data.price * this.data.count;
});
//加入以上代码后,只要 price 或 count 的值改变,就会计算当前组件的值,其值是 price 乘以 count。
Source
Events
beforeLoadView
视图参数(options)已经准备好,还未加载视图时执行。可以通过this.event得到视图参数,并可修改this.event修改视图的加载。
See
loadView
异步加载视图后执行。
See
select
选中视图中的一条记录后执行。可以通过this.event获取该次选择的记录。
See
unselect
取消选中视图中的一条记录后执行。可以通过this.event获取该次取消选择的记录。
See
selectResult
点击确定后执行的事件。可以通过this.event获取选择的记录列表。
See
afterSelectResult
选择完成后,并且整理了关联文档数据后事件。可以通过this.event获取记录列表。
See
deleteDocument
删除关联文档前执行的事件。可以通过this.event获取删除的记录。
See
afterDeleteDocument
删除关联文档后执行的事件。可以通过this.event获取删除的记录。
See
queryLoad
组件加载前触发。queryLoad执行的时候,当前组件没有在form里注册,通过this.form.get("fieldId")不能获取到当前组件,需要用this.target获取。
postLoad
组件加载后触发.
load
组件加载后触发.