usable range
process
cms
portal
since
- v6.2
example
//可以在脚本中获取该组件
//方法1:
var importer = this.form.get("fieldid"); //获取组件
//方法2
var importer = this.target; //在组件本身的脚本中获取
source
members
importermwf.xapplication.query.query.importer
导入模型对象.
type
example
var importer = this.form.get("fieldid").importer; //获取组件
if(importer)importer.importfromexcel(); //执行导入
source
nodeelement
组件的节点,mootools封装过的dom对象,可以直接使用原生的js和moootools方法访问和操作该对象。
type
-
element
example
//可以在脚本中获取该组件
var field = this.form.get("fieldid"); //获取组件对象
field.node.setstyle("font-size","12px"); //给节点设置样式
source
jsonjsonobject
组件的配置信息,比如id,类型,是否只读等等。可以在组件的queryload事件里修改该配置来对组件做一些改变。
type
-
jsonobject
inherited from
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
inherited from
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
inherited from
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
validate(routenameopt) → {boolean}
summary
根据组件的校验设置进行校验。
parameters
-
routename
string
可选,路由名称.
inherited from
returns
-
boolean
是否通过校验
example
if( !this.form.get('fieldid').validate() ){
return false;
}
source
getsource(typeopt) → {source|subsource|subsourceitem}
当前组件在数据源组件中时,可以通过此方法获取所在的上级数据源/子数据源/子数项组件.
parameters
-
type
string
需要获取的类型,"source"为表示数据源,"subsource"表示子数据源,"subsourceitem"表示子数据项组件。 如果该参数省略,则获取离当前组件最近的上述组件。
inherited from
returns
-
source
subsource
subsourceitem
。
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
需要获取的组件类型。 如果该参数省略,则获取离当前组件最近的祖先组件。type有效值如下:
form- 表单common- 通用组件datatable- 数据表格datatableline- 数据表格行datatemplate- 数据模板datatemplateline- 数据模板行div- 容器组件elcommon- element通用组件elcontainer- element容器组件subform- 子表单source- 数据源组件subsource- 子数据源subsourceitem- 子数据项组件tab- 分页组件tabpage- 分页组件的某个分页table- 表格tabletd- 单元格widget- 部件 -
validatefunction
function
进一步校验,参数为获取到匹配到类型的组件,返回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
events
loadimporter
加载importer(导入模型对象)的时候执行,可以通过this.target.importer获取导入模型对象。
see
beforeimport
导入前触发,this.event指向导入的数据,您可以通过修改this.event来修改数据。
see
example
this.event数据格式如下:
[
[ "标题一","张三","男","大学本科","计算机","2001-1-2","2019-9-2" ], //第一行数据
[ "标题二","李四","男","大学专科","数学","1998-1-2","2018-9-2" ] //第二行数据
]
validimport
数据已经生成,前台进行数据校验时触发,this.event指向导入的数据。
see
example
this.event数据格式如下:
{
"data" : [
[ "标题一","张三","男","大学本科","计算机","2001-1-2","2019-9-2" ], //第一行数据
[ "标题二","李四","男","大学专科","数学","1998-1-2","2018-9-2" ] //第二行数据
],
"rowlist": [], //导入的行对象数组,数据格式常见本章api的aftercreaterowdata说明。
"validted" : true //是否校验通过,可以在本事件中修改该参数,确定是否强制导入
}
afterimport
前台校验成功,并且后台执行完导入后触发,this.event指向后台返回的导入结果。
see
example
this.event格式如下:
{
"status": "导入成功", //导入结果:状态有 "导入成功","部分成功","导入失败"
"data": {}, //前台组织好的需要导入的数据
"rowlist": [], //前台组织的行对象数组
"count" : 10, //导入总数量
"failcount": 0, //失败数量
"distribution": "" //导入时候时的错误信息
}
beforecreaterowdata
创建每行需要导入的数据前触发,this.event指向当前行对象,您可以通过修改this.event.importdata来修改数据。
see
aftercreaterowdata
创建每行需要导入的数据后触发,this.event指向当前行对象。
see
example
this.event格式如下:
{
"importdata": [ "标题一","张三","男","大学本科","计算机","2001-1-2","2019-9-2" ], //导入的数据
"data" : {//根据导入模型生成的业务数据
{
"subject", "标题一", //subject为导入模型列配置的路径
"name" : "张三",
...
},
"document": { //如果导入目标是内容管理,则包含document对象
"title": "标题一"
"identity": "xxx@xxx@i"
...
},
"work": { //如果导入目标是流程管理,则包含work对象
"title": "标题一"
"identity": "xxx@xxx@i"
...
},
"errortextlist" : [], //错误信息
"errortextlistexcel": [] //在出错界面导出excel时的错误信息
}
queryload
组件加载前触发。queryload执行的时候,当前组件没有在form里注册,通过this.form.get("fieldid")不能获取到当前组件,需要用this.target获取。
postload
组件加载后触发.
load
组件加载后触发.