O2OA API

Module

form

form对象可在流程表单或内容管理表单中可用。(仅前端脚本可用)。

Usable Range

Process CMS

Syntax

//您可以在流程表单和内容管理的前端脚本中,通过this来获取form对象,如下:
var form = this.form;

Source

Members

static

currentRouteName

在用户提交的时候,选择的路由。仅在表单的“校验意见”和“校验路由”脚本中可用。只读。(仅流程表单中可用)

Syntax

var currentRouteName = this.form.currentRouteName;

Source

static

opinion

在用户提交的时候,输入的意见。仅在表单的“校验意见”和“校验路由”脚本中可用。只读。(仅流程表单中可用)

Syntax

var opinion = this.form.opinion;

Source

static

medias

在提交的时候,用户的手写意见以及录音意见,仅在表单的“校验意见”和“校验路由”脚本中可用。只读。(仅流程表单中可用)

Syntax

var medias = this.form.medias;

Source

Methods

static

publish(callback)

发布当前文档。(仅内容管理表单中可用)

Syntax

this.form.publish( callback );

Parameters

  • callback function

    发布后的回调方法,如果接收的参数为空表示校验未通过,如果参数不为空为发布后的回调

Source

static

getInfor() → {Object}

获取当前表单的基本信息。

Syntax

var form = this.form.getInfor();

Returns

  • Object

    表单的基本信息.

    {
       "id": "db3b2766-93a1-4058-b522-0edb922bd84f",   //表单ID
       "name": "报销申请表单",                         //表单名称
       "alias": "报销申请表单",                        //表单别名
       "description": "",                              //表单描述
       "application": "1dc23336-6be6-402b-bed6-36e707a1dd17",  //应用ID
       "lastUpdatePerson": "XX@huqi@P",                //最后修改人
       "lastUpdateTime": "2018-09-30 22:46:30",        //最后修改时间
       "icon": "...",                                  //表单图标
    }

Source

static

getApp() → {x_component_process_Work}

获取打开当前文档的component对象。平台中每一个窗口应用,就是一个component对象。此处获取到的对象为x_component_process_Work。

Syntax

var app = this.form.getApp();

Returns

  • x_component_process_Work

    打开当前文档的component对象.

Example

var app = this.form.getApp();
         //所有component对象都有以下方法。
         app.openInNewWindow();  //在新窗口中打开当前应用
         app.setCurrent();   //将当前应用设置为激活状态
         app.minSize();      //应用窗口最小化
         app.maxSize();      //应用窗口最大化
         app.restoreSize();  //应用窗口还原
         app.refresh();      //刷新应用
         app.close();        //关闭应用
         app.setTitle(str);  //设置应用标题
         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

static

get(name, subformNameopt) → {FormComponent}

获取表单元素对象。

Actionbar(操作条)Address(地址输入框)Attachment(附件框)Button(按钮)
Calendar(日期输入框)Checkbox(多选按钮)Combox(组合框)Datagrid(数据网格)
Div(容器)Htmleditor(富文本编辑框)Html(内置html)Iframe(嵌入Iframe)
Image(图片)Label(文本)Log(流程意见)Monitor(流程监控)
Number(数字输入框)Office(office控件)Opinion(意见框)Org(人员组织选择)
Radio(单选按钮)Select(选择框)Sidebar(侧边操作条)Stat(统计组件)
Subform(子表单)Tab(分页)Table(表格)Textarea(多行输入)
Textfield(文本输入框)Tree(树状控件)View(视图组件)ViewSelector(视图选择组件)
Documenteditor(公文编辑器)ImageClipper(图片编辑器)

Syntax

var field = this.form.get(name);
var field = this.form.get(name, subformName);

Parameters

  • name String

    字段标识

  • subformName String <optional>

    子表单/部件标识。当开发人员在插入子表单的时候,系统会检查输入类型(会在后台存值)的组件是否重名,如果重名则不允许插入。 但是布局组件(如div)重名会被允许。系统在展现表单的时候会判断子表单中组件的标识是否被使用,如果是会自动在组件前加上"子表单标识_",如:主表单有一个"div_1",则子表单"subform1"的"div_1"组件标识则变为"subform1_div_1"。 本参数就是用在这种情况下,可以正确返回子表单中的组件。

Returns

  • FormComponent

    请查看本文档的Classes导航下的FormComponents。

Examples

var field = this.form.get("subject");
var field = this.form.get("div", "subform1"); //获取子表单“subform1”中的div,如果子表单无此组件,而主表单有,则返回主表单的组件。

Source

static

getField(name) → {FormComponent}

获取表单中可输入的字段元素对象。

Address(地址输入框)Attachment(附件框)Calendar(日期输入框)Checkbox(多选按钮)
Combox(组合框)Datagrid(数据网格)Htmleditor(富文本编辑框)Number(数字输入框)
Org(人员组织选择)Radio(单选按钮)Select(选择框)Textarea(多行输入)
Textfield(文本输入框)

Syntax

var field = this.form.getField(name);

Parameters

  • name String

    字段标识

Returns

  • FormComponent

    请查看本文档的Classes导航下的FormComponents。

Example

var field = this.form.getField("subject");

Source

static

save(callbackopt, silentopt)

保存当前表单所绑定的业务数据。
this.form.save()会触发 beforeSave和afterSave事件,因此在beforeSave和afterSave中不允许使用本方法。同时不建议在queryLoad里使用本方法。

Syntax

this.form.save(callback, silent);

Parameters

  • callback function <optional>

    保存后的回调

  • silent Boolean <optional>

    是否静默,否提示保存成功,默认为false

Example

this.form.save(function(){
     //do someting
 }, true);

Source

static

verify() → {Boolean}

根据表单中所有组件的校验设置和“流转校验”脚本进行校验。

Description

本校验不包括校验意见,校验路由;通常用在弹出提交界面时候的校验

Syntax

this.form.verify()

Returns

  • Boolean

    是否通过校验

Example

if( !this.form.verify() ){
     return false;
 }
 

Source

static

process(optionopt)

对当前表单打开的流程实例进行流转。(仅流程表单中可用)
可以通过this.workContext.getControl().allowProcessing来判断当前用户是否有权限进行流转。
this.form.process()会触发 beforeSave、afterSave、beforeProcess、afterProcess事件,因此在上述事件中不允许使用本方法。

Parameters

  • option Object <optional>

    流程的相关数据,如果不带此参数,则弹出路由选择和意见填写框
    格式如下:

    
    {
    "routeName": "", //流转到下一步要选择的路由名称
    "opinion": "", //流转意见
    "callback": function(json){} //回调方法,有json参数表示正常流转,json参数为流转后返回的数据。
    }
    

Examples

//不带参数,弹出路由选择和意见填写框
         this.form.process();
//带参数,流转
         this.form.process({
            "routeName": "送审批",
            "opinion": "同意",
            "callback": function(json){
                if(json)this.form.notice("process success", "success");
            }.bind(this)
      });

Source

static

reset(optionopt)

对当前文档的待办重新设定处理人。(仅流程表单中可用)
可以通过this.workContext.getControl().allowReset来判断当前用户是否有权限重置处理人。
this.form.reset()会触发 beforeReset、afterReset事件,因此在上述事件中不允许使用本方法。

Parameters

  • option Object <optional>

    进行重置处理人的相关参数,如果不带此参数,弹出重置处理人对话框
    格式如下:

    
    {
    "names": "", //{Array|String} 要重置给哪些身份
    "opinion": "", //流转意见
    "success": function(){}, //重置成功后的回调方法
    "failure": function(){} //重置失败后的回调方法
    }
    

Examples

//不带参数,弹出重置处理人对话框
         this.form.reset();
//带参数,直接调用后台服务重置
         this.form.reset({
            "names": ["张三@zhangsan@I"],
            "opinion": "授权处理",
            "success": function(json){
                this.form.notice("reset success", "success");
            }.bind(this),
            "failure": function(xhr, text, error){
                //xhr--HttpRequest请求对象
                //text--HttpResponse内容文本
                //error--错误信息
                this.form.notice("reset failure:"+error, "error");
            }.bind(this)
        });

Source

static

retract(optionopt)

撤回文档操作,上一个处理人收回已经流转下去的文件。(仅流程表单中可用)
这个操作只允许上一个处理人在流转文件之后,下一个处理人未处理的时候执行。
可以通过this.workContext.getControl().allowRetract来判断当前用户是否有权限撤回。
this.form.retract()会触发 beforeRetract、afterRetract事件,因此在上述事件中不允许使用本方法。

Parameters

  • option Object <optional>

    进行撤回的相关参数,如果不提供option参数,则弹出撤回对话框。
    格式如下:

    
    {
    "success": function(){}, //撤回成功后的回调方法
    "failure": function(){} //撤回失败后的回调方法
    }
    

Examples

//不带参数,则弹出撤回对话框
         this.form.retract();
//带参数,直接调用后台服务撤回
         this.form.retract({
            "success": function(json){
                this.form.notice("retract success", "success");
            }.bind(this),
            "failure": function(xhr, text, error){
                //xhr--HttpRequest请求对象
                //text--HttpResponse内容文本
                //error--错误信息
                this.form.notice("retract failure: "+error, "error");
            }.bind(this)
        });

Source

static

addSplit(optionopt)

在已拆分的工作上添加分支。(仅流程表单中可用)
可以通过this.workContext.getControl().allowAddSplit来判断当前用户是否有权限。

Parameters

  • option Object <optional>

    添加分支的相关参数,如果不提供option参数,则弹出添加分支对话框。
    格式如下:

    
    {
    "value" : [], //splitValueList 添加的拆分值,拆分值取决于流程拆分节点的设置
    "trimExist" : true, //排除已经存在的拆分值.
    "success": function(){}, //执行成功后的回调方法
    "failure": function(){} //执行失败后的回调方法
    }
    

Examples

//不带参数,则弹出添加分支对话框
         this.form.addSplit();
//带参数,直接添加分支
         this.form.addSplit({
            "value" : ["开发部@kfb@U"],
            "trimExist" : true,
            "success": function(json){
                this.form.notice("addSplit success", "success");
            }.bind(this),
            "failure": function(xhr, text, error){
                //xhr--HttpRequest请求对象
                //text--HttpResponse内容文本
                //error--错误信息
                this.form.notice("addSplit failure: "+error, "error");
            }.bind(this)
        });

Source

static

deleteWork(optionopt)

删除当前工作文档。(仅流程表单中可用)
可以通过this.workContext.getControl().allowDeleteWork来判断当前用户是否有权限删除文档。

Parameters

  • option Object <optional>

    删除相关参数,如果不提供option参数,则弹出删除对话框。
    格式如下:

    
    {
    "success": function(){}, //执行成功后的回调方法
    "failure": function(){} //执行失败后的回调方法
    }
    

Examples

//不带参数,则弹出删除提示对话框
         this.form.deleteWork();
//带参数,直接调用服务删除
         this.form.deleteWork({
            "success": function(json){
                this.form.notice("deleteWork success", "success");
            }.bind(this),
            "failure": function(xhr, text, error){
                //xhr--HttpRequest请求对象
                //text--HttpResponse内容文本
                //error--错误信息
                this.form.notice("deleteWork failure: "+error, "error");
            }.bind(this)
        });

Source

static

sendRead(optionopt)

对当前工作发送待阅。(仅流程表单中可用)
能查看工作的人都有权限发送。
this.form.sendRead()会触发 beforeSendRead、afterSendRead,因此在上述事件中不允许使用本方法。

Parameters

  • option Object <optional>

    发送待阅的相关参数,如果不带此参数,弹出发送待阅对话框
    格式如下:

    
    {
    "identityList": "", //{Array|String} 要给哪些身份发送待阅
    "notify": true, //是否发送待阅通知(需要服务器开启消息)
    "success": function(){}, //成功后的回调方法
    "failure": function(){} //失败后的回调方法
    }
    

Examples

//不带参数,弹出发送待阅对话框
         this.form.sendRead();
//带参数,直接调用后台服务发送待阅
         this.form.sendRead({
            "identityList": ["张三@zhangsan@I"],
            "notify": false,
            "success": function(json){
                this.form.notice("send read success", "success");
            }.bind(this),
            "failure": function(xhr, text, error){
                //xhr--HttpRequest请求对象
                //text--HttpResponse内容文本
                //error--错误信息
                this.form.notice("send read failure:"+error, "error");
            }.bind(this)
        });

Source

static

addReview(optionopt)

对当前工作添加阅读人(参阅)。(仅流程表单中可用)
能查看工作的人都有权限添加。
this.form.addReview()会触发 beforeAddReview、afterAddReview,因此在上述事件中不允许使用本方法。

Parameters

  • option Object <optional>

    添加阅读人的相关参数,如果不带此参数,弹出添加阅读人对话框
    格式如下:

    
    {
    "personList": "", //{Array|String} 要添加哪些阅读人
    "success": function(){}, //成功后的回调方法
    "failure": function(){} //失败后的回调方法
    }
    

Examples

//不带参数,弹出添加阅读人对话框
         this.form.addReview();
//带参数,直接调用后台服务发送待阅
         this.form.addReview({
            "personList": ["张三@zhangsan@P"],
            "success": function(json){
                this.form.notice("add review success", "success");
            }.bind(this),
            "failure": function(xhr, text, error){
                //xhr--HttpRequest请求对象
                //text--HttpResponse内容文本
                //error--错误信息
                this.form.notice("add review failure:"+error, "error");
            }.bind(this)
        });

Source

static

startIM(jobIdopt)

创建关联当前工作的聊天群。(仅流程表单中可用)
根据当前工作的关联人员创建聊天群。

Parameters

  • jobId String <optional>

    当前工作的jobId

Example

//带参数,启动创建界面
         this.form.startIM("jobId");

Source

static

addTask(optionopt)

添加待办人,可用于加签等操作。(仅流程表单中可用)
可以通过this.workContext.getControl().allowAddTask来判断当前用户是否有权限。

Parameters

  • option Object <optional>

    添加待办人的相关参数,如果不提供option参数,则弹出加签对话框。
    格式如下:

    
    {
      "mode" : "single", //加签模式:single,queue,parallel
      "before" : true, //是否是前加签,false后加签.
      "distinguishedNameList": [], //加签人的身份数组。
      "routeName" : "", //增加待办在流程记录中显示的路由.
      "opinion" : "", //加签意见
      "success": function(){}, //执行成功后的回调方法
      "failure": function(){} //执行失败后的回调方法
    }
             

Examples

//不带参数,则弹出加签对话框
this.form.addTask();
//带参数,根据参数执行添加待办操作
this.form.addTask({
  "mode" : "single",
  "before": false,
  "distinguishedNameList": ["张三@XXXX@I", "李四@XXXX@I"],
  "routeName" : "添加审阅人",
  "opinion" : "请张三、李四审阅",
  "success": function(json){
      this.form.notice("addTask success", "success");
  }.bind(this),
  "failure": function(xhr, text, error){
      //xhr--HttpRequest请求对象
      //text--HttpResponse内容文本
      //error--错误信息
      this.form.notice("addTask failure: "+error, "error");
  }.bind(this)
});

Source

static

confirm(type, title, text, width, height, ok, cancel)

弹出一个确认框,带确认和关闭按钮

Parameters

  • type String

    要显示的信息类型。可选值:success 成功,info :信息,error :错误, wran : 警告

  • title String

    确认框标题栏显示文本。

  • text String | Object

    确认框的内容显示文本。值为html的时候见下面的样例“使用html传入内容”。

  • width Number

    确认框的宽度。

  • height String

    确认框的高度。

  • ok function

    点击“确定”按钮后的回调函数。

  • cancel function

    点击“取消”按钮后的回调函数。

Examples

this.form.confirm("wran", "删除确认", "您确定要删除吗?", 300, 100,function(){
  //执行删除代码
  this.close();
}, function(){
  this.close();
});
//使用html传入内容, v8.1开始支持
this.form.confirm("wran", "删除确认", {
    html: "您确定要删除吗!<br/>"
}, 300, 100,function(){
  //执行删除代码
  this.close();
}, function(){
  this.close();
});

Source

static

alert(type, title, text, width, height)

弹出一个带关闭按钮的信息框

Parameters

  • type String

    要显示的信息类型。可选值:success 成功,info :信息,error :错误, wran : 警告

  • title String

    信息框标题栏显示文本。

  • text String | Object

    信息框的内容显示文本。值为html的时候见下面的样例“使用html传入内容”。

  • width Number

    信息框宽度。

  • height String

    信息框的高度。

Examples

this.form.alert("wran", "必填提醒", "请填写标题!", 300, 100);
//使用html传入内容
this.form.alert("wran", "必填提醒", {
    html: "请填写标题!<br/>"
}, 300, 100);

Source

static

notice(content, typeopt, targetopt, whereopt, offsetopt, optionopt)

弹出一个提示框

Parameters

  • content String

    要显示的信息文本

  • type String <optional>

    要显示的信息类型。可选值:success 成功,info :信息,error :错误, warn : 警告

  • target Element <optional>

    信息框显示位置的参考DOM对象。

  • where Object <optional>

    信息框显示相对于target的x轴和y轴位置。
    如: {"x": "center", "y": "center"}
    x :
     水平位置,可用“left”、“right”和“center”;可以用数组定义外部(outside)位置和内部(inside)位置,如:['right', 'inside']
    y :
     垂直位置,可用“top”、“bottom”和“center”;可以用数组定义外部(outside)位置和内部(inside)位置,如:['top', 'outside']。

  • offset Object <optional>

    相对位置的偏移量,允许负值。如:{"x": 10, "y": -10}

  • option Object <optional>

    其他选项。如: { delayClose: 5000 } 在5秒后关闭

Example

this.form.notice("this is my information", "info");

Source

static

dialog(options) → {Object}

弹出一个对话框层。

Parameters

  • options Object

    弹出框选项:
    如果有buttonList参数,则ok,cancel参数无效。
    对话框内容的优先级为moduleName、content、url、html、text,有前面的参数则后面的参数无效。
    调用弹出框对象后各事件执行先后顺序 onQueryLoad-->onPostLoad-->onQueryShow-->onPostShow。
    其他说明如下:

    {
      "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": "
    html内容
    ", //内容参数,优先级为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指向对话框对象。 }

Returns

  • Object

    对话框对象。

Examples

//打开一个对话框,使用html作为内容
var _self = this;
var dlg = 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关闭对话框
      }
  }
});
//打开一个对话框,使用表单中的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();
             }
         }
     ]
});
//打开一个对话框,创建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)
  });

Source

static

selectOrg(container, options) → {Object}

弹出人员组织选择界面,支持身份、个人、组织、群组的单个选择或复合选择。该方法参数适用于 new MWF.O2Selector()。

Parameters

  • container Element

    人员选择界面的所在容器,默认为当前应用的容器。

  • options Object

    人员组织选择选项。

    {
     "type": "", //选择类型,和types二选一,可选值为 identity(身份), person(个人), unit(组织), group(群组),
     "types": [], //复合选择,和type二选一,如 ["identity", "person", "unit", "group"]
     "count": 0, //选择数量,0表示不限制
     "title": "", //选择界面的title
     "values": [], //已选择的值
    
     "groups": [], //选择的群组范围,选择群组时有效。
    
     "units": [], //选择的组织范围,选择身份和组织时有效
     "resultType" : "", //可以设置成"person"(个人),那么结果返回个人。选择身份时有效。用在选择人员,但是需要按照组织层级展现的场景。
     "dutys": [], //选择的职务范围,选择身份时有效。
     "categoryType": "", //可使用unit或duty。如果指定了选择的职务范围(dutys不为空),按unit(组织)还是按duty(职务)来展现分类,默认为按unit。该参数在选择身份时有效。
    
     "noUnit" : false, //在选择身份的时候,是否只使用include选项。
     "include" : [], //增加的可选项。选择身份的时候,没有传units表示选中全员,include不生效,可以使用onUnit选项表示只使用include选项。
     "exclude" : [], //排除的可选项
    
     "expandSubEnable" : true, //是否允许展开下一层,选择身份和组织时有效
     "selectAllEnable" : true,  //分类是否允许全选下一层,选择身份和组织时有效
    
     "level1Indent" : 10, //第一级的缩进
     "indent" : 10, //后续的缩进
     "zIndex": 1000, //选择界面的zIndex,
    
     "onComplete" : function( selectedItemList ){
         //点击确定时执行
         //selectedItemList为选中的item对象,下面的selectedDataList为选中的数据
         var selectedDataList = selectedItemList.map( function(item){
             return item.data;
         })
     },
     "onCancel" : function(selector) {
         //点击取消时的事件, selector 为选择器, this为选择器
     },
     "onQueryLoad" : function(selector) {
         //加载选择器前事件, selector 为选择器, this为选择器
     },
     "onLoad" : function(selector) {
         //加载选择器后事件, selector 为选择器, this为选择器
     },
     "onCancel" : function(selector) {
         //点击取消时的事件, selector 为选择器, this为选择器
     },
     "onQueryLoadCategory" : function(category) {
         //加载分类前事件, category 为 分类对象, this为选择器
     },
     "onPostLoadCategory" : function(category) {
         //加载分类后事件, category 为 分类对象, this为选择器
     },
     "onSelectCategory" : function(category){
         //选择分类, category 为 分类对象, this为选择器
     },
     "onUnselectCategory": function(category){
         //取消选择分类, category 为 分类对象, this为选择器
     },
     "onQueryLoadItem" : function(item){
         //加载项目前事件, item 为 项目对象, this为选择器
     },
     "onPostLoadItem" : function(item){
         //加载项目后事件, item 为 项目对象, this为选择器
     },
     "onSelectItem" : function(item){
         //选择项目事件, item 为 项目对象, this为选择器
     },
     "onUnselectItem" : function(item){
         //取消选择项目事件, item 为 项目对象, this为选择器
     },
     "onExpand" : function( obj ){
         //展开分类, obj 为分类/项目, this为选择器
     },
     "onCollapse" : function(obj){
          //折叠分类,obj 为分类/项目, this为选择器
      }
    }

Returns

  • Object

    人员组织选择器对象。

Examples

//选择身份
var selector = this.form.selectOrg(null, {
  type: "identity",
  onComplete : function( selectedItemList ){
     //点击确定时执行
     //selectedItemList为选中的item对象,下面的selectedDataList为选中的数据
     var selectedDataList = selectedItemList.map( function(item){
         return item.data;
     })
 }
});
//在限定组织内选择身份
var selector = this.form.selectOrg(null, {
  type: "identity",
  units: ["兰德纵横@landzone@U"],
  onComplete : function( selectedItemList ){
 }
});
//在限定职务时选择身份
var selector = this.form.selectOrg(null, {
  type: "identity",
  dutys: ["部门正职"],
  onComplete : function( selectedItemList ){
 }
});
//同时选择组织、群组、身份、个人
var selector = this.form.selectOrg(null, {
  types: ["unit", "group", "identity", "person"],
  onComplete : function( selectedItemList ){
 }
});

Source

static

addEvent(type, event)

给表单添加事件。

Parameters

  • type String

    事件名称,参考本API Classer->FormComponents->Form的事件

  • event function

    事件方法。

Example

this.form.addEvent("afterLoad", function(){
            this.form.notice("表单载入完成", "success");
        }.bind(this));

Source

static

print(applicationopt, formopt)

用一个新的浏览器窗口来打开当前文档,用于打印。(仅流程表单中可用)
如不指定表单,则使用表单设计中指定的打印表单。

Parameters

  • application String <optional>

    指定表单所在的流程应用ID或名称。省略此参数表示当前应用。

  • form String <optional>

    指定表单ID或名称。

Examples

//在新窗口中使用当前表单中配置的打印表单打开当前文档
         this.form.print();
//在新窗口中使用“订单打印表单”表单打开当前文档
         this.form.print("订单打印表单");
//在新窗口中使用“订单管理”应用中的“订单打印表单”表单打开当前文档
         this.form.print("订单管理", "订单打印表单");

Source

static

openWindow(applicationopt, formopt)

同print方法。(仅流程表单中可用)

Parameters

  • application String <optional>

    指定表单所在的流程应用ID或名称。省略此参数表示当前应用。

  • form String <optional>

    指定表单ID或名称。

See

  • this.form.print()

Example

this.form.openWindow();

Source

static

openWork(workIdopt, workCompletedIdopt, titleopt, optionsopt)

打开一个在流转或已完成的流程实例。

Parameters

  • workId String <optional>

    在流转的流程实例ID。workId和workCompletedId两个参数必须提供其中一个

  • workCompletedId String <optional>

    已完成的流程实例ID。

  • title String <optional>

    手机端打开时的窗口标题。

  • options Object <optional>

    其他选项,如只读参数。

Examples

this.form.openWork(id, "", "work title");
//以只读方式打开
this.form.openWork(id, "", "work title", {
  readonly : true
});

Source

static

openJob(id, choiceopt, optionsopt, callbackopt)

使用流程的jobId打开工作。

Parameters

  • id String

    流程的jobId,如果流程拆分后,有多个流程实例(workId会有多个),但jobId是唯一的。

  • choice Boolean <optional>

    如果有多个流程实例,是否弹出界面选择。如果传入false,则直接打开第一个工作。

  • options Object <optional>

    打开工作时传入的选项。

  • callback function <optional>

    打开工作成功或失败的回调方法,如果打开成功,该方法可以获取打开的工作的对象(桌面模式)或窗口句柄(浏览器页签模式);如果打开失败,此方法第一个参数是一个Error,其cause属性可获取通过jobId查询到的work数据。

Examples

this.form.openJob(jobId, true);
this.form.openJob(jobId, true, {}, function(handel){
            //通过Error.prototype.isPrototypeOf(handel)来判断handel是否是一个错误。
            //如果打开成功,handel为打开的工作的对象(桌面模式)或窗口句柄(浏览器页签模式)
            //如果打开错误,handel为为一个Error对象,其cause属性可获取通过jobId查询到的work数据
         });

Source

static

openDocument(id, titleopt, optionsopt)

打开一个内容管理文档。

Parameters

  • id String

    内容管理文档实例的ID。

  • title Boolean <optional>

    手机APP端打开时的窗口标题。

  • options Object <optional>

    其他参数,内容如下

    {
      "readonly": true, //是否以只读方式打开,默认为true
      "forceFormId": "xxxxxx", //不管编辑还是阅读都用此表单id打开,优先使用。6.0版本之前使用 printFormId。
      "readFormId": "xxxxxx", //强制的阅读表单id,优先于表单的readFormId。6.0版本之前使用 formId。
      "editFormId": "xxxxxx", //强制的编辑表单id,优先于表单的formId。6.0版本之前使用 formEditId。
       "saveOnClose" : true, //关闭草稿的时候是否自动保存
       "onPostPublish" : function( documentData ){ //发布前执行方法,但数据已经准备好,该事件在桌面模式打开有效
          //documentData 为文档数据
       },
       "onAfterPublish" : function( form, documentData ){ //发布后执行的方法,该事件在桌面模式打开有效
          //form为内容管理Form对象,documentData 为文档数据
       },
       "onAfterSave": function( form, documentData ){ //保存后执行的方法,该事件在桌面模式打开有效
          //form为内容管理Form对象,documentData 为文档数据
       },
       "onBeforeClose": function(){ //关闭前执行的方法,该事件在桌面模式打开有效
    
       },
       "onPostDelete" : function(){ //删除文档后执行的方法,该事件在桌面模式打开有效
       }
    }

Example

this.form.openDocument(id, "document title");

Source

static

openPortal(portal, pageopt, paropt)

打开一个门户页面。

Parameters

  • portal String

    要打开的门户应用名称、别名或ID。

  • page String <optional>

    要打开的页面名称、别名或ID。如果忽略,则打开门户的默认首页

  • par Object <optional>

    打开页面可以传入参数。
    在被打开的页面中,可以通过脚本this.page.parameters访问到此参数。

Example

this.form.openPortal(id, "", {"type": "my type"});

Source

static

openCMS(name)

打开一个内容管理栏目(应用)。

Parameters

  • name String

    内容管理栏目的名称、别名或ID。

Example

this.form.openCMS("通知公告");

Source

static

openApplication(name, optionsopt, statusopt)

打开任意一个component应用。

Parameters

  • name String

    要打开的component的名称。component对应的名称可以在“控制面板-系统设置-界面设置-模块部署”中找到(即“组件路径”)。

  • options Object <optional>

    打开的component的相关参数,对应该应用源码Main.js中的的options。

  • status Object <optional>

    打开的component的状态,对应用户的操作后的状态。请按照下面的方式获取该参数:双击桌面模式的应用,在打开应用的浏览器地址上可以查到对应的status。

Examples

//打开会议管理
         this.form.openApplication("Meeting");
//打开会议管理的周视图
         this.form.openApplication("Meeting", null, {"action":"toWeek" });
//打开一个流转中的流程实例。与 this.form.openWork(id, "", "work title");效果相同
         this.form.openApplication("process.Work", {
            "workId": id,   //流程实例ID
            "width": "1200",    //宽度
            "height": "800",    //高度
            "docTitle": "work title",   //APP端窗口标题
            "appId": "process.Work"+id  //给新打开的component实例一个唯一名称
        });

Source

static

createDocument(columnOrOptionsopt, categoryopt, dataopt, identity | Arrayopt, callbackopt, targetopt, latestopt, selectColumnEnableopt, ignoreTitleopt, restrictToColumnopt)

创建一条内容管理文档。

Parameters

  • columnOrOptions String | Object <optional>

    如果不传参数,则弹出范围为平台所有栏目的选择界面。
    当使用String时为内容管理应用(栏目)的名称、别名或ID。
    当使用Object时,本参数后面的参数省略,传入如下格式的内容:

    {
      "column" : column, //(string)可选,内容管理应用(栏目)的名称、别名或ID
      "category" : category, //(string)可选,要创建的文档所属的分类的名称、别名或ID
      "data" : data, //(json object)可选,创建文档时默认的业务数据
      "identity" : identity, //(string | Array)可选,创建文档所使用的身份。如果此参数为空,且当前人有多个身份的情况下,会弹出身份选择对话框;如果此参数为数组,则弹出数组范围内的身份供选择;否则使用默认身份。
      "callback" : callback, //(funcation)可选,文档创建后的回调函数。
      "target" : target, //(boolean)可选,为true时,在当前页面打开创建的文档;否则打开新窗口。默认false。(当前表单或页面在浏览器单独打开的时候该参数有效。)
      "latest" : latest, //(boolean)可选,为true时,如果当前用户已经创建了此分类的文档,并且没有发布过,直接调用此文档为新文档;否则创建一个新文档。默认true。
      "selectColumnEnable" : selectColumnEnable, //(boolean)可选,是否可以选择应用和分类进行创建文档。有category参数时为默认false,否则默认为true。
      "ignoreTitle" : ignoreTitle //(boolean)可选,值为false时,创建的时候需要强制填写标题,默认为false。
      "restrictToColumn" : restrictToColumn //(boolean)可选,值为true时,会限制在传入的栏目中选择分类,默认为false。
    }
  • category String <optional>

    要创建的文档所属的分类的名称、别名或ID

  • data Object <optional>

    创建文档时默认的业务数据

  • identity | Array String <optional>

    可选,创建文档所使用的身份。如果此参数为空,且当前人有多个身份的情况下,会弹出身份选择对话框;如果此参数为数组,则弹出数组范围内的身份供选择;否则使用默认身份。

  • callback function <optional>

    文档创建后的回调函数

  • target Boolean <optional>

    为true时,在当前页面打开创建的文档;否则打开新窗口。默认false。(当前表单或页面在浏览器单独打开的时候该参数有效。)

  • latest Boolean <optional>

    为true时,如果当前用户已经创建了此分类的文档,并且没有发布过,直接调用此文档为新文档;否则创建一个新文档。默认true。

  • selectColumnEnable Boolean <optional>

    是否可以选择应用和分类进行创建文档。有category参数时为默认false,否则默认为true。

  • ignoreTitle Boolean <optional>

    值为false时,创建的时候需要强制填写标题,默认为false。

  • restrictToColumn Boolean <optional>

    值为true时,会限制在传入的栏目中选择分类,默认为false。

Examples

//启动一个通知公告
         this.form.createDocument("", "通知公告");
//启动一个通知公告,标题为:关于XX的通知,启动后提示
         this.form.createDocument("", "通知公告", {"subject": "关于XX的通知"}, function(json){
            this.form.notice("创建成功!", "success");
        }.bind(this));
//启动一个通知公告,标题为:关于XX的通知,启动后提示
         this.form.createDocument({
            category : "通知公告",
            data : {"subject": "关于XX的通知"},
            callback : function(json){
                this.form.notice("创建成功!", "success");
            }.bind(this)
         });

Source

static

startProcess(app, process, dataopt, identityopt, callbackopt, targetopt, latestopt, afterCreatedopt, skipDraftCheckopt)

启动一个流程实例。

Parameters

  • app String

    流程应用的名称、别名或ID。

  • process String

    要启动的流程的名称、别名或ID。

  • data Object <optional>

    流程启动时默认的业务数据。

  • identity String | Array <optional>

    流程启动所使用的身份。如果此参数为空/空字符串,且当前人有多个身份的情况下,会弹出身份选择对话框;如果此参数为数组,则弹出数组范围内的身份供选择;否则使用默认身份。

  • callback function <optional>

    流程启动后的回调函数,可以获取到启动的数据。

  • target Boolean <optional>

    为true时,在当前页面打开启动的流程实例;否则打开新窗口。默认false。(当前表单或页面在浏览器单独打开的时候该参数有效。)

  • latest Boolean <optional>

    为true时,如果当前用户已经创建了此流程的实例,并且没有流转过,直接调用此实例为新流程实例;否则创建一个新实例。默认false。

  • afterCreated function <optional>

    流程创建后的回调,可以获取到创建的流程Work对象(桌面模式)或者Window对象(浏览器模式)。

  • skipDraftCheck Boolean <optional>

    是否跳过新建检查(默认根据流程的新建检查配置),设置true则不进行新建检查。

Examples

//启动一个发文管理实例
         this.form.startProcess("公文管理", "发文管理");
//启动一个发文管理实例,标题为:my file title,启动后提示
         this.form.startProcess("公文管理", "发文管理", {"title": "my file title"}, "张三@kfb_zhangsan@I", function(json){
            this.form.notice("create file success!", "success");
        }, false, false, function(workApp){
              if( layout.inBrowser ){ //浏览器模式
                //workApp 为流程的window对象
              }else{
                //workApp 为流程Work app对象
              }
        });

Source

results matching

    No results matching ''