O2OA API

Module

queryStatement

当查询设计中使用了select语句,并且配置了视图,可以在查询视图中使用本章API。
queryStatement对象在查询视图中可用。它的很多方法与queryView类似。(仅前端脚本可用)

Usable Range

QueryStatement

Syntax

//您可以在查询视图中,通过this来获取queryStatement对象,如下:
var queryStatement = this.queryStatement;

Source

Methods

static

getParentEnvironment() → {MWF.xScript.Environment|MWF.xScript.CMSEnvironment}

当查询视图被嵌入到门户页面、流程表单或内容管理表单的时候,可以在查询视图写脚本的地方通过这个方法来获取页面或表单的上下文。

Syntax

this.queryStatement.getParentEnvironment();

Returns

  • MWF.xScript.Environment MWF.xScript.CMSEnvironment

    页面或表单的上下文.

Example

var env = this.queryStatement.getParentEnvironment(); //当视图被嵌入到页面的时候,可以在视图里获取页面的上下文
env.page.toPortal( "公文门户" ); //调用page的toPage() 跳转到其他门户

Source

static

getPageInfor() → {Object}

获取查询视图当前页的基本信息。

Syntax

this.queryStatement.getPageInfor();

Returns

  • Object

    当前页的信息,格式如下:

    {
        "pages": 3, //总页数
        "perPageCount": 50, //每页的条数
        "currentPageNumber": 1 // 当前页数
    }
    

Source

static

getPageData() → {Array.<Object>|Array.<Array>}

获取当前页的数据。

Syntax

var data = this.queryStatement.getPageData();

Returns

  • Array.<Object> Array.<Array>

    当前页数据。

    数据格式和 jpql 语句的写法有关
    如: "select o from table o" 返回 json数组
    [
         {
            "id" : "id1",
            "title" : "title1"
        },
         {
            "id" : "id2",
            "title" : "title2"
        },
         ...
    ]
    
    如:"select id, title from table o" 返回 二维数组:
    [
         ["id1", "title1"],
         ["id2", "title2"],
         ...
    ]
    

Source

static

toPage(pageNumber, callbackopt)

跳转到指定的页面。

Syntax

var data = this.queryStatement.toPage( pageNumber, callback );

Parameters

  • pageNumber Number

    需要跳转的页码。

  • callback function <optional>

    跳转的页面数据加载完成以后的回调方法。

Example

// 跳转到第2页并且获取该页的数据。
this.queryStatement.toPage( 2, function(){
     var data = this.queryStatement.getPageData();
}.bind(this) )

Source

static

getSelectedData() → {Array.<Object>|Array.<Array>}

获取选中的条目的数据。

Syntax

var data = this.queryStatement.getSelectedData();

Returns

  • Array.<Object> Array.<Array>

    选中的条目的数据。

    数据格式和 jpql 语句的写法有关
    如: "select o from table o" 返回 json数组
    [
         {
            "id" : "id1",
            "title" : "title1"
        },
         {
            "id" : "id2",
            "title" : "title2"
        },
         ...
    ]
    
    如:"select id, title from table o" 返回 二维数组:
    [
         ["id1", "title1"],
         ["id2", "title2"],
         ...
    ]
    

Source

static

getStatementInfor() → {Object}

获取查询的配置信息。

Syntax

this.queryStatement.getStatementInfor();

Returns

  • Object

    查询的配置信息.

    {
       "query": "26d21c71-5114-4496-8ca1-a69e56324841", //所属应用id
       "id": "ee334220-66d3-4f78-afce-8ccf6b995c8c", //查询id
       "name": "测试查询", //名称
       "alias": "", //别名
       "description": "", //描述
       "table": "", //自建表的id
       "entityClassName": "com.x.processplatform.core.entity.content.Task", //系统表表名
       "entityCategory": "official", //表类型 official(系统表) 或 dynamic(自建表)
       "format": "jpql", //语句类型,jpql 或者 script(脚本) , v8.0后还有 sql, sqlScript
       "type": "select", //select/update/delete
       "data": "SELECT o FROM Task o where o.person = :person", //查询语句
       "countData": "SELECT count(o.id) FROM Task o where o.person = :person", //总数语句
       "countScriptText" : "", //总数语句脚本
       "scriptText" : "", //查询语句脚本
       "viewJson": { ... } //视图相关信息
    }

Source

static

setStatementFilter(filteropt, parameteropt, callbackopt)

增加查询语句where子句的过滤条件。

Syntax

this.queryStatement.setStatementFilter( filter, parameter, callback );

Parameters

  • filter Array.<StatementFilter> | Null <optional>

    过滤条件。
    过滤条件。当不传参数、参数为null或为空数组的情况下,表示清空非视图默认的过滤条件。
    如果传入非空数组的时候,参数如下:

    [
       {
         "path":"o.title", //查询语句格式为jpql使用o.title,为原生sql中使用xtitle
         "comparison":"like",
         "value":"关于",
         "formatType":"textValue"
     }
    ]
    
  • parameter StatementParameter <optional>

    过滤条件。对查询语句where子句的形如":person"的参数部分进行赋值,参数如下:

    
    //假设语句为 select count(o.id) from Read o where (o.person = :person) and (o.startTime > :startTime) and (o.applicationName like :applicationName) and (o.processName = :processName)。
    //那么可能的参数如下:
    {
       "person" : "", //出于安全考虑参数名称为下列值时,不需要填写参数值,后台默认赋值,person(当前人),identityList(当前人身份列表),unitList(当前人所在直接组织), unitAllList(当前人所在所有组织), groupList(当前人所在群组),roleList(当前人拥有的角色)。v8.0以后系统自动解析,不需要再传这类参数。
       "startTime" : (new Date("2020-01-01")), //如果对比的是日期,需要传入 Date 类型
       "applicationName" : "%test%", //如果运算符用的是 like, noLike,模糊查询
       "processName" : "test流程", //其他写确定的值
       "?1": "关于" //v8.0后查询语句支持问号加数字的传参
    }
    
  • callback function <optional>

    过滤完成并重新加载数据后的回调方法。

Source

static

switchStatement(options)

把当前查询视图切换成另外一个查询视图。

Syntax

this.queryStatement.switchStatement( options );

Parameters

  • options Object

    需要跳转的参数配置。参数说明如下:

    下列说明的filter属性参考StatementFilter, parameter属性参考StatementParameter
    this.queryStatement.switchStatement({
        "statementId": statementId, //必选,查询的名称、别名、id
        "isTitle": "yes", //可选,是否显示视图的标题行,可选值有:yes no
        "select": "multi", //可选,是否允许新视图选择,如果不传,则使用原视图的配置, 可选值有: 不允许选择 none, 单选 single,多选 multi
        "showActionbar": false, //可选,是否显示操作条
        "filter": [  //可选,增加查询语句where子句的过滤条件
          {
            "path": "o.title", //查询语句格式为jpql使用o.title,为原生sql中使用xtitle
            "title": "标题",
            "type": "filter",
            "comparison": "like",
            "formatType": "textValue",
            "value": "测试"
          }
        ],
        //假设语句为 select count(o.id) from Read o where (o.person = :person) and (o.startTime > :startTime) and (o.applicationName like :applicationName) and (o.processName = :processName)
        "parameter" : { //可选,对查询语句where语句的形如":person"的参数部分进行赋值
          "person" : "", //出于安全考虑参数名称为下列值时,不需要填写参数值,后台默认赋值,person(当前人),identityList(当前人身份列表),unitList(当前人所在直接组织), unitAllList(当前人所在所有组织), groupList(当前人所在群组),roleList(当前人拥有的角色)。v8.0以后系统自动解析,不需要再传这类参数。
          "startTime" : (new Date("2020-01-01")), //如果对比的是日期,需要传入 Date 类型
          "applicationName" : "%test%", //如果运算符用的是 like, noLike,模糊查询
          "processName" : "test流程" //其他写确定的值
          "?1": "关于" //v8.0后查询语句支持问号加数字的传参
        }
      })
    

Source

results matching

    No results matching ''