o2oa api: view | o2oa开发平台-游戏厅捕鱼达人

module

您可以通过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

    同步或异步调用。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

网站地图