O2OA API

Module

view

您可以通过view对象,获取视图数据或选择视图数据。

Syntax

//您可以在流程表单、内容管理表单或门户页面中,通过this来获取view对象,如下:
var view = this.view;

Source

Methods

static

lookup(view, callback, asyncopt) → {Promise}

获取指定视图的数据。

Syntax

//通过回调方法获取数据
this.view.lookup(view, callback, async);

//返回Promise对象后处理
var promise = this.view.lookup( view );
promise.then(function(data){
    //data 为返回的数据。
})

Parameters

  • view Object

    要访问的视图信息。数据格式如下:

    以下的filter参数参考ViewFilter
    
    {
     "view" : "testView", //(String)必选,视图的名称、别名或ID
     "application" : "test数据中心应用", //(String)必选,视图所在数据应用的名称、别名或ID
     "filter": [ //(Array of Object)可选,对视图进行过滤的条件。json数组格式,每个数组元素描述一个过滤条件。
          {
              "logic":"and",
              "path":"$work.title",
              "comparison":"like",
              "value":"7月",
              "formatType":"textValue"
          }
     ]
    }
    
  • callback function

    访问成功后的回调函数

  • async Boolean <optional>

    同步或异步调用。true:异步;false:同步。默认为true。

Returns

  • Promise

    返回Promise

Examples

//获取“财务管理”应用中“报销审批数据”视图中的数据
//过滤条件为标题($work.title)包含包含(like))“7月”。
this.view.lookup({
  "view": "报销审批数据",
  "application": "财务管理",
  "filter": [
      {
          "logic":"and",
          "path":"$work.title",
          "comparison":"like",
          "value":"7月",
          "formatType":"textValue"
      }
  ]
}, function(data){
  var grid = data.grid; //得到过滤后的数据
  var groupGrid = data.groupGrid; //如果有分类,得到带分类的数据
  //......
});
//同上,通过返回值获取数据
var promise = this.view.lookup({
  "view": "报销审批数据",
  "application": "财务管理",
  "filter": [
      {
          "logic":"and",
          "path":"$work.title",
          "comparison":"like",
          "value":"7月",
          "formatType":"textValue"
      }
  ]
});
promise.then(function(data){
  var grid = data.grid; //得到过滤后的数据
  var groupGrid = data.groupGrid; //如果有分类,得到带分类的数据
  //......
})
//获取“财务管理”应用中“报销审批数据”视图中的数据
//过滤条件为标题($work.title)包含包含(like))“7月”,并且总金额大于500小于5000
this.view.lookup({
  "view": "报销审批数据",
  "application": "财务管理",
  "filter": [
      {
          "logic":"and",
          "path":"$work.title",
          "comparison":"like",
          "value":"7月",
          "formatType":"textValue"
      },
      {
          "logic":"and",
          "path":"amount",
          "comparison":"range",
          "value":500,
          "otherValue":5000,
          "formatType":"numberValue"
      },
  ]
}, function(data){
  var grid = data.grid; //得到过滤后的数据
  var groupGrid = data.groupGrid; //如果有分类,得到带分类的数据
  //......
});

Source

static

select(view, callback)

通过视图进行数据选择。

Syntax

this.view.select(view, callback);

Parameters

  • view Object

    要访问的视图信息。数据格式如下:

    以下的filter参数参考ViewFilter
    
    {
     "view" : "testView", //(String)必选,视图的名称、别名或ID
     "application" : "test数据中心应用", //(String)必选,视图所在数据应用的名称、别名或ID
     "isTitle" : true, //(Boolean)可选,是否显示视图标题。默认true
     "isMulti" : true,  //(Boolean)可选,是否允许多选。默认true
     "width" : 700, //(Number)可选,选择框的宽度。默认700
     "height" : 400,  //(Number)可选,选择框的高度。默认400
     "caption" : "标题", //(String)可选,选择框的标题
     "filter": [ //(Array of Object)可选,对视图进行过滤的条件。json数组格式,每个数组元素描述一个过滤条件。
          {
              "logic":"and",
              "path":"$work.title",
              "comparison":"like",
              "value":"7月",
              "formatType":"textValue"
          }
     ]
    }
    
  • callback function

    必选,当选择完成,点击“确定”之后的回调函数。

Example

this.view.select({
   "application": "物业材料",  //数据中心中的应用
   "view": "物业材料视图",     //视图的名称
   "isMulti": false,           //只允许单选
}, function(items) {
   //如果选择了某个数据,将数据赋值给表单输入框
   if (items.length) {
       //物料名称,表单中输入框名为“materialName”, 视图中列的名称为“ylmc”
       this.data.materialName = items[0].data.ylmc;
       //规格,表单中输入框名为“specification”, 视图中列的名称为“gg”
       this.data.specification = items[0].data.gg;
       //单价,表单中输入框名为“price”, 视图中列的名称为“dj”
       this.data.price = items[0].data.dj;
   }
}.bind(this));

Source

results matching

    No results matching ''