O2OA API

Module

Table

this.Table是一个工具类,您可以使用这个类对数据中心的数据表进行增删改查操作。

Syntax

//您可以在页面、表单、流程各个嵌入脚本中,通过this.Table()来返回Table的对象,如下:
var table = new this.Table( tableName )

Parameters

  • tableName String

    数据表的id、名称或别名。

Returns

  • Object

    table对象

Source

Methods

listRowNext(id, count, successopt, failureopt, asyncopt) → {Promise}

列示表中的行对象,下一页。

Syntax

table.listRowNext( id, count, success, failure, async )
//或
var promise = table.listRowNext( id, count );
promise.then(function(json){
    //json为返回的数据
})

Parameters

  • id String

    当前页最后一条数据的Id,如果是第一页使用"(0)"。

  • count String | Number

    下一页的行数

  • success function <optional>

    调用成功时的回调函数。

  • failure function <optional>

    调用错误时的回调函数。

  • async Boolean <optional>

    是否异步调用,默认为true。

Returns

  • Promise

    返回Promise

Example

var table = new this.Table("table1");

table.listRowNext( "0", 20, function(data){
   //data 形如
   //{
   //    "type": "success",
   //    "data":[
   //       {
   //        "id": "5584e6d1-8088-4694-a948-8968ac8d4923", //数据的id
   //        "createTime": "2021-11-01 16:23:41", //数据创建时间
   //        "updateTime": "2021-11-01 16:23:41", //数据更新时间
   //         ... //定义的字段(列)和值
   //        }
  //     ],
  //       "message": "",
  //     "date": "2021-11-01 18:34:19",
  //     "spent": 13,
  //}
}, function(xhr){
   //xhr 为 xmlHttpRequest
});

Source

listRowPrev(id, count, successopt, failureopt, asyncopt) → {Promise}

列示表中的行对象,上一页。

Syntax

table.listRowPrev( id, count, success, failure, async )
//或
var promise = table.listRowPrev( id, count );
promise.then(function(json){
    //json为返回的数据
})

Parameters

  • id String

    当前页第一条数据的Id,如果是最后一页使用"(0)"。

  • count String | Number

    上一页的行数

  • success function <optional>

    调用成功时的回调函数。

  • failure function <optional>

    调用错误时的回调函数。

  • async Boolean <optional>

    是否异步调用,默认为true。

Returns

  • Promise

    返回Promise

Example

var table = new this.Table("table1");

table.listRowPrev( "0", 20, function(data){
   //data 形如
   //{
   //    "type": "success",
   //    "data":[
   //       {
   //        "id": "5584e6d1-8088-4694-a948-8968ac8d4923", //数据的id
   //        "createTime": "2021-11-01 16:23:41", //数据创建时间
   //        "updateTime": "2021-11-01 16:23:41", //数据更新时间
   //         ... //定义的字段(列)和值
   //        }
  //     ],
  //       "message": "",
  //     "date": "2021-11-01 18:34:19",
  //     "spent": 13,
  //}
}, function(xhr){
   //xhr 为 xmlHttpRequest
});

Source

listRowSelect(whereopt, orderByopt, sizeopt, successopt, failureopt, asyncopt) → {Promise}

根据条件获取表中的数据。

Syntax

table.listRowSelect( where, orderBy, size, success, failure, async )
//或
var promise = table.listRowSelect( where, orderBy, size );
promise.then(function(json){
    //json为返回的数据
})

Parameters

  • where String <optional>

    查询条件,格式为jpql语法,o.name='zhangsan',允许为空。

  • orderBy String <optional>

    排序条件,格式为:o.updateTime desc,允许为空

  • size String | Number <optional>

    返回结果集数量,允许为空。

  • success function <optional>

    调用成功时的回调函数。

  • failure function <optional>

    调用错误时的回调函数。

  • async Boolean <optional>

    是否异步调用,默认为true。

Returns

  • Promise

    返回Promise

Example

var table = new this.Table("table1");

//查询字段name等于zhangsan的数据,结果按updateTime倒序
table.listRowSelect( "o.name='zhangsan'", "o.updateTime desc", 20, function(data){
   //data 形如
   //{
   //    "type": "success",
   //    "data":[
   //       {
   //        "id": "5584e6d1-8088-4694-a948-8968ac8d4923", //数据的id
   //        "createTime": "2021-11-01 16:23:41", //数据创建时间
   //        "updateTime": "2021-11-01 16:23:41", //数据更新时间
   //         ... //定义的字段(列)和值
   //        }
  //     ],
  //       "message": "",
  //     "date": "2021-11-01 18:34:19",
  //     "spent": 13,
  //}
}, function(xhr){
   //xhr 为 xmlHttpRequest
});

Source

rowCountWhere(where, successopt, failureopt, asyncopt) → {Promise}

通过where 统计数量。

Syntax

table.rowCountWhere( where, success, failure, async )
//或
var promise = table.rowCountWhere( where );
promise.then(function(json){
    //json为返回的数据
})

Parameters

  • where String

    查询条件,格式为jpql语法,o.name='zhangsan'。

  • success function <optional>

    调用成功时的回调函数。

  • failure function <optional>

    调用错误时的回调函数。

  • async Boolean <optional>

    是否异步调用,默认为true。

Returns

  • Promise

    返回Promise

Example

var table = new this.Table("table1");

//查询字段name等于zhangsan的数据,结果按updateTime倒序
table.rowCountWhere( "o.name='zhangsan", function(data){
   //data 形如
   //{
   //   "type": "success",
   //  "data": {
   //      "value": 5 //符合条件数据的总条数
   //  },
   //  "message": "",
   //  "date": "2021-11-01 18:32:27"
   //}
}, function(xhr){
   //xhr 为 xmlHttpRequest
});

Source

deleteRow(id, successopt, failureopt, asyncopt) → {Promise}

删除数据表中指定id的记录。

Syntax

table.deleteRow( id, success, failure, async )
//或
var promise = table.deleteRow( id );
promise.then(function(json){
    //json为返回的数据
})

Parameters

  • id String

    需要删除记录的id。

  • success function <optional>

    调用成功时的回调函数。

  • failure function <optional>

    调用错误时的回调函数。

  • async Boolean <optional>

    是否异步调用,默认为true。

Returns

  • Promise

    返回Promise

Example

var table = new this.Table("table1");

table.deleteRow( "e1f89185-d8b0-4b66-9e34-aed3323d0d79", function(data){
   //data 形如
   //{
   //   "type": "success",
   //  "data": {
   //      "value": true //true表示删除成功,false表示无此数据
   //  },
   //  "message": "",
   //  "date": "2021-11-01 18:32:27"
   //}
}, function(xhr){
   //xhr 为 xmlHttpRequest
});

Source

deleteAllRow(successopt, failureopt, asyncopt) → {Promise}

删除指定表中所有行的数据。

Syntax

table.deleteAllRow( success, failure, async )
//或
var promise = table.deleteAllRow();
promise.then(function(json){
    //json为返回的数据
})

Parameters

  • success function <optional>

    调用成功时的回调函数。

  • failure function <optional>

    调用错误时的回调函数。

  • async Boolean <optional>

    是否异步调用,默认为true。

Returns

  • Promise

    返回Promise

Example

var table = new this.Table("table1");

table.deleteAllRow( function(data){
   //data 形如
   //{
   //   "type": "success",
   //  "data": {
   //      "value": 1 //表示删除的条数,0表示无数据
   //  },
   //  "message": "",
   //  "date": "2021-11-01 18:32:27"
   //}
}, function(xhr){
   //xhr 为 xmlHttpRequest
});

Source

getRow(需要获取记录的id。, successopt, failureopt, asyncopt) → {Promise}

获取数据表中指定id的记录。

Syntax

table.getRow( id, success, failure, async )
//或
var promise = table.getRow( id );
promise.then(function(json){
    //json为返回的数据
})

Parameters

  • 需要获取记录的id。 id
  • success function <optional>

    调用成功时的回调函数。

  • failure function <optional>

    调用错误时的回调函数。

  • async Boolean <optional>

    是否异步调用,默认为true。

Returns

  • Promise

    返回Promise

Example

var table = new this.Table("table1");

table.getRow( "e1f89185-d8b0-4b66-9e34-aed3323d0d79", function(data){
   //data 形如
   //{
   //    "type": "success",
   //    "data":{
   //        "id": "5584e6d1-8088-4694-a948-8968ac8d4923", //数据的id
   //        "createTime": "2021-11-01 16:23:41", //数据创建时间
   //        "updateTime": "2021-11-01 16:23:41", //数据更新时间
   //         ... //定义的字段(列)和值
   //     },
  //     "message": "",
  //     "date": "2021-11-01 18:34:19",
  //     "spent": 13,
  //}
}, function(xhr){
   //xhr 为 xmlHttpRequest
});

Source

insertRow(data, successopt, failureopt, asyncopt) → {Promise}

往数据表中批量插入数据。

Syntax

table.insertRow( data, success, failure, async )
//或
var promise = table.insertRow( data );
promise.then(function(json){
    //json为返回的数据
})

Parameters

  • data Array.<Object>

    需要插入的数据。

  • success function <optional>

    调用成功时的回调函数。

  • failure function <optional>

    调用错误时的回调函数。

  • async Boolean <optional>

    是否异步调用,默认为true。

Returns

  • Promise

    返回Promise

Example

var table = new this.Table("table1");
var data = [
 {
   "subject": "标题一",
   ... //其他字段
 },
 ...
];
table.insertRow( data, function(data){
   //data 形如
   //{
   //   "type": "success",
   //  "data": {
   //      "value": true //true表示插入成功
   //  },
   //  "message": "",
   //  "date": "2021-11-01 18:32:27"
   //}
}, function(xhr){
   //xhr 为 xmlHttpRequest
});

Source

addRow(data, successopt, failureopt, asyncopt) → {Promise}

往数据表中插入单条数据。

Syntax

table.addRow( data, success, failure, async )
//或
var promise = table.addRow( data );
promise.then(function(json){
    //json为返回的数据
})

Parameters

  • data Object

    需要插入的数据。

  • success function <optional>

    调用成功时的回调函数。

  • failure function <optional>

    调用错误时的回调函数。

  • async Boolean <optional>

    是否异步调用,默认为true。

Returns

  • Promise

    返回Promise

Example

var table = new this.Table("table1");
var data = {
   "subject": "标题一",
   ... //其他字段
 };
table.addRow( data, function(data){
   //data 形如
   //{
   //   "type": "success",
   //  "data": {
   //      "id": 2cf3a20d-b166-490b-8d29-05544db3d79b //true表示修改成功
   //  },
   //  "message": "",
   //  "date": "2021-11-01 18:32:27"
   //}
}, function(xhr){
   //xhr 为 xmlHttpRequest
});

Source

updateRow(id, data, successopt, failureopt, asyncopt) → {Promise}

往数据表中修改单条数据。

Syntax

table.updateRow( id, data, success, failure, async )
//或
var promise = table.updateRow( id, data );
promise.then(function(json){
    //json为返回的数据
})

Parameters

  • id String

    需要修改的数据id。

  • data Object

    需要修改的数据。

  • success function <optional>

    调用成功时的回调函数。

  • failure function <optional>

    调用错误时的回调函数。

  • async Boolean <optional>

    是否异步调用,默认为true。

Returns

  • Promise

    返回Promise

Example

var table = new this.Table("table1");
var data = {
   "id" : "2cf3a20d-b166-490b-8d29-05544db3d79b",
   "subject": "标题一",
   ... //其他字段
 };
table.updateRow( "2cf3a20d-b166-490b-8d29-05544db3d79b", data, function(data){
   //data 形如
   //{
   //   "type": "success",
   //  "data": {
   //      "value": true //true表示修改成功
   //  },
   //  "message": "",
   //  "date": "2021-11-01 18:32:27"
   //}
}, function(xhr){
   //xhr 为 xmlHttpRequest
});

Source

results matching

    No results matching ''