Skip to content

获取表单列表

获取当前账号下的表单列表,支持按 search_key 对表单标题、备注、编号做模糊搜索,也支持按 number 做表单编号精确查询。

该接口返回两层核心数据:

  • data.list:当前页的表单列表
  • data.page:当前分页状态,可用于判断是否还有下一页

请求示例

python
import requests

url = "https://open.cli.im/api/v2/rpc/record/getFormList"
data = {
    "page": 1,
    "page_size": 10,
    "search_key": "设备",
    "number": "D32"
}
headers = {
    "Authorization": "Bearer <你的API Key>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=data, headers=headers)
print(response.text)
bash
curl -X POST 'https://open.cli.im/api/v2/rpc/record/getFormList' \
  -H 'Authorization: Bearer <你的API Key>' \
  -H 'Content-Type: application/json' \
  -d '{"page":1,"page_size":10,"search_key":"设备","number":"D32"}'

请求参数

参数类型必填说明
pageinteger页码,默认 1
page_sizeinteger每页条数,默认 10,最大 20
search_keystring模糊搜索关键字,匹配表单标题、表单备注、表单编号
numberstring表单编号精确查询,例如 D32

补充说明:

  • search_keynumber 可单独使用,也可同时传入。
  • 若同时传入,服务端会按组合条件返回结果。
  • 该接口使用页码分页,是否继续翻页建议根据 data.page.current_pagedata.page.last_page 判断。

请求体示例

json
{
  "page": 1,
  "page_size": 10,
  "search_key": "设备",
  "number": "D32"
}

完整返回示例

json
{
  "code": 0,
  "message": "",
  "data": {
    "version": "v1",
    "list": [
      {
        "id": 122507,
        "name": "设备巡检",
        "type": 0,
        "type_text": "普通表单",
        "number": "D32",
        "note": "每日设备巡检记录",
        "created_at": 1740623881,
        "created_at_iso": "2025-02-27 10:38:01(UTC+08:00)",
        "updated_at": 1740710281,
        "updated_at_iso": "2025-02-28 10:38:01(UTC+08:00)",
        "active_at": 1740796681,
        "active_at_iso": "2025-03-01 10:38:01(UTC+08:00)",
        "project": {
          "id": 1104,
          "name": "小米园区",
          "number": "F1"
        }
      },
      {
        "id": 122508,
        "name": "安全检查",
        "type": 0,
        "type_text": "普通表单",
        "number": "D62",
        "note": "",
        "created_at": 1740710281,
        "created_at_iso": "2025-02-28 10:38:01(UTC+08:00)",
        "updated_at": 1740710281,
        "updated_at_iso": "2025-02-28 10:38:01(UTC+08:00)",
        "active_at": 0,
        "active_at_iso": "",
        "project": null
      }
    ],
    "page": {
      "current_page": 1,
      "last_page": 3,
      "per_page": 10,
      "total": 42
    }
  }
}

响应结构总览

路径类型说明
codeinteger平台状态码,0 表示成功
messagestring状态消息;成功时通常为空字符串
dataobject业务响应包装层
data.versionstring当前返回结构版本,当前为 v1
data.listarray表单列表
data.pageobject分页信息

data.list 元素字段

字段类型说明
idinteger表单 ID
namestring表单名称
typeinteger表单类型
type_textstring表单类型说明
numberstring表单编号(企业内唯一序号,如 D32
notestring表单备注
created_atinteger创建时间(Unix 时间戳,秒)
created_at_isostring创建时间的格式化字符串,示例:2025-02-27 10:38:01(UTC+08:00)
updated_atinteger更新时间(Unix 时间戳,秒)
updated_at_isostring更新时间的格式化字符串
active_atinteger活跃时间(Unix 时间戳,秒;无则为 0)
active_at_isostring活跃时间的格式化字符串;无值时通常为空字符串
projectobjectnull

data.list[].project 字段

data.list[].project 不为 null 时,包含以下字段:

字段类型说明
idinteger分区 ID
namestring分区名称
numberstring分区编号

data.page 对象

字段类型说明
current_pageinteger当前页码
last_pageinteger最后一页页码
per_pageinteger每页条数
totalinteger表单总数

分页说明

场景说明
首次请求可不传 page,默认从第 1 页开始
翻到下一页page 递增后再次请求
是否还有下一页建议比较 data.page.current_pagedata.page.last_page
空结果页data.list 为空数组,data.page.total 可能为 0

data.page.current_page >= data.page.last_page 时,通常表示已经到达最后一页。

空列表示例

json
{
  "code": 0,
  "message": "",
  "data": {
    "version": "v1",
    "list": [],
    "page": {
      "current_page": 1,
      "last_page": 1,
      "per_page": 10,
      "total": 0
    }
  }
}

错误响应

失败时通常返回非成功状态,响应体可能包含以下字段:

json
{
  "code": 400,
  "error_code": 100300,
  "message": "System error",
  "message_detail": ""
}
字段类型说明
codeintegerHTTP 状态码或平台错误状态
error_codeinteger业务错误码
messagestring错误摘要
message_detailstring详细错误信息,可能为空字符串

具体错误码定义见:错误码说明