O2OA API

Module

include

this.include是一个方法,当您在流程、门户、内容管理或服务管理中创建了脚本配置,可以使用this.include()用来引用脚本配置。
v8.0及以后版本中增加了服务管理的脚本配置。
(建议使用表单中的预加载脚本,需要判断加载的时候才使用本方法加载脚本,此时建议异步加载有助于表单加载速度。)

Syntax

//您可以在表单、流程、视图和查询视图的各个嵌入脚本中,通过this.include()来引用本应用或其他应用的脚本配置,如下:
this.include( optionsOrName, callback, async )

Parameters

  • optionsOrName String | Object | Array.<String> | Array.<Object>

    可以是脚本标识字符串(数组)或者是对象(数组)。

    
    //如果需要引用本应用的脚本配置,将options设置为String或者String Array。
    this.include("initScript") //脚本配置的名称、别名或id
    this.include(["initScript","initScript2"]) //可以是字符串数组
    
    //如果需要引用其他应用的脚本配置,将options设置为Object或者Object Array;
    this.include({
          //type: 应用类型。可以为 portal  process  cms  service。
          //如果没有该选项或者值为空字符串,则表示应用脚本和被应用的脚本配置类型相同。
          //比如在门户的A应用脚本中引用门户B应用的脚本配置,则type可以省略。
          type : "portal",
          application : "首页", // 门户、流程、CMS的名称、别名、id。 默认为当前应用,如果脚本在服务管理中忽略该参数
          name : "initScript" // 脚本配置的名称、别名或id
    })
    this.include([  //也可以对象和字符串混合数组
     {
          type : "portal",
          application : "首页",
          name : "initScript"
     },
     "initScript2"
    ])
    
    //引用服务管理中的脚本
    this.include({
      "type": "service",
      "name": "scriptName"
    });
    
    //引用流程管理中的脚本
    this.include({
      "type": "process",
      "application": "appName",
      "name": "scriptName"
    });
    
    //引用内容管理中的脚本
    this.include({
      "type": "cms",
      "application": "appName",
      "name": "scriptName"
    });
    
    //引用门户管理中的脚本
    this.include({
      "type": "portal",
      "application": "appName",
      "name": "scriptName"
    });
    
  • callback function <optional>

    加载后执行的回调方法

  • async Boolean <optional>

    是否异步加载

Examples

样例一:在通用脚本中定义返回当前人员名称的方法,在各个门户应用都使用这个方法显示人员名称。
1、在门户应用中有一个commonApp的应用,在该应用中创建一个脚本,命名为initScript,并定义方法。

//定义一个方法
this.define("getUserName", function(){
  return ( layout.desktop.session.user || layout.user ).name
}.bind(this))

2、在门户页面中添加事件'queryLoad',在事件中引入 initScript 脚本配置。

this.include({
     type : "portal",
     application : "commonApp",
     name : "initScript"
})

3、在门户页面的'load'事件中使用方法。

var userNameNode = this.page.get("userName").node; //获取Dom对象
var urerName = this.getUserName(); //使用initScript脚本中的方法
userNameNode.set("text", urerName ); //为DOM对象设置值

Source

results matching

    No results matching ''