1. 平台API
  2. 流程 API

本协议约定低代码平台流程引擎需要提供的相关API接口的规范,包括请求接口参数,返回值等规则。

接口验证

调用接口需要在请求的Headers中添加用户身份验证信息,详情请参阅 接口验证

API 清单

名称请求操作
发起审批POST
暂存审批单POST
提交草稿中申请单POST
提交审批中申请单POST

API 规范

以下是各个流程 API 的详细规范。

发起审批

新建一个草稿状态的审批单。

URI

/api/workflow/v2/draft

Method

POST

请求参数

请求该接口时需要传入以下参数。

名称类型描述
instanceobject审批单字段值

其中instance属性描述如下:

名称类型描述
spacestring工作区_id
flowstring流程_id
applicantstring申请人_id
{
    "instance": {
        "space": "hKdnwE55WcnWveYxS",
        "flow": "BayiYu3sk2hv3M2HW",
        "applicant": "62ede4f62161e377e35de58c"
    }
}

返回值

  • 该API接口请求成功时返回值格式如下:
名称类型描述
instanceobject审批单字段值

其中instance属性描述如下:

名称类型描述
_idstring创建成功的申请单_id
spacestring工作区_id
flowstring流程_id
flow_versionstring流程版本_id
formstring表单版本_id
form_versionstring表单版本_id
{
    "instance": {
        "_id": "zMiGNe2sJm9KuruvM",
        "space": "hKdnwE55WcnWveYxS",
        "flow": "BayiYu3sk2hv3M2HW",
        "flow_version": "Nvc5wjsgHYkXnNHhk",
        "form": "Pdq8neQvT7fv5aTyd",
        "form_version": "thX4kKBAx6iCgciWD"
    }
}

instance中返回的是创建成功的审批单记录信息。

暂存草稿审批单

URI

/api/workflow/v2/instance/save

Method

POST

请求参数

请求该接口时需要传入以下参数。

名称类型描述
instanceobject审批单字段值

其中instance属性描述如下:

名称类型描述
_idstring申请单_id
spacestring工作区_id
flowstring流程_id
flow_versionstring流程版本_id
formstring表单版本_id
form_versionstring表单版本_id
applicantstring申请人_id
applicant_namestring申请人姓名
applicant_organizationstring申请人所属组织_id
applicant_organization_namestring申请人所属组织名称
applicant_organization_fullnamestring申请人所属组织全称
codestring申请单Code
traces[object]签核历程
submit_datedatetime提交时间

其中traces属性描述如下:

名称类型描述
_idstring签核历程_id
approves[object]审批历程

其中approves属性描述如下:

名称类型描述
_idstring审批历程_id
descriptionstring审批内容
valuesobject申请单字段值
next_steps[object]下一步骤信息

其中next_steps属性描述如下: | 名称 | 类型| 描述 | |----|----|----| | step | string | 下一步骤_id | | users | [string] | 下一步骤处理人 |

{
    "instance": {
        "_id": "zMiGNe2sJm9KuruvM",
        "space": "hKdnwE55WcnWveYxS",
        "flow": "BayiYu3sk2hv3M2HW",
        "flow_version": "Nvc5wjsgHYkXnNHhk",
        "form": "Pdq8neQvT7fv5aTyd",
        "form_version": "thX4kKBAx6iCgciWD",
        "applicant": "62ede4f62161e377e35de58c",
        "applicant_name": "xxx",
        "applicant_organization": "XypyNbzGCJbHMNyWv",
        "applicant_organization_name": "xxx",
        "applicant_organization_fullname": "xxx",
        "code": "",
        "traces": [
            {
                "_id": "7f316cb404fddf2098c8fd2d",
                "approves": [
                    {
                        "_id": "97628d0b9a33b541816caeeb",
                        "description": "",
                        "values": {
                            "field1": "xx",
                            "field2": "xx",
                            "field3": "xx"
                        },
                        "next_steps": [
                            {
                                "step": "e28faf97-a1c4-4bdd-90e5-1b43d42aa10b",
                                "users": []
                            }
                        ]
                    }
                ]
            }
        ],
        "submit_date": xxx
    }
}

返回值

  • 该API接口请求成功时返回值格式如下:
名称类型描述
instanceboolean是否成功
{
    "instance": true
}

提交草稿中申请单

把草稿状态的申请单提交到下一步骤。

URI

/api/workflow/submit

Method

POST

请求参数

请求该接口时需要传入以下参数。

名称类型描述
Instancesobject[]申请单内容

以下表格描述了Instances中的对象键值信息:

名称类型描述
_idstring审批单_id
flowstring当前流程_id
namestring审批单名称
applicantstring申请人_id
submitterstring提交人_id
inbox_usersstring[]待审核人_id集合
tracesobject[]签核历程

以下表格描述了 traces 中的对象键值信息:

名称类型描述
_idstring签核历程_id
stepstring签核历程步骤_id
approvesobject[]审批历程

以下表格描述了 approves 中的对象键值信息:

名称类型描述
_idstring审批历程_id
descriptionstring[]审批意见
valuesobject申请单字段值
next_stepsstring[]下一步骤信息
attachmentsstring[]附件

以下表格描述了 next_steps 中的对象键值信息:

名称类型描述
stepstring下一步骤_id
users[string]下一步骤处理人
{
    "Instances": [{
        "_id": "e6viWhvARgo4xSxBC",
        "inbox_users": [],
        "name": "Test",
        "submitter": "62ede4f62161e377e35de58c",
        "flow": "BayiYu3sk2hv3M2HW",
        "applicant": "62ede4f62161e377e35de58c",
        "traces": [{
            "_id": "0aed02a8113d7e1a22d5a245",
            "step": "Ryu58zkQKrFLdvWpw",
            "approves": [{
                "_id": "5865e212c0e80024005090f9",
                "description": "",
                "values": {
                    "field1": "xxx",
                    "field2": "xxx",
                    "field3": "xxx"
                },
                "next_steps": [{
                    "step": "e28faf97-a1c4-4bdd-90e5-1b43d42aa10b",
                    "users": [
                        "62ede4f62161e377e35de58c"
                    ]
                }]
            }]
        }]
    }]
}

traces 是每个步骤的签核历程,approves 则是每个签核历程中的审批历程,里面记录了详细的审批表单信息。

返回值

  • 该API接口请求成功时返回值格式如下:
{
    "result": [...]
}

result中返回的是一个对象数组,该数组中包含的键值信息如下所示:

名称类型描述
alertsstring提示信息

alerts中主要是提示流程版本是否已升级。

  • 该API接口请求失败时返回值格式如下:
{
    errors: [{ errorMessage: "..." }]
}

提交审批中申请单

把审批中的申请单提交到下一步骤。

URI

/api/workflow/engine

Method

POST

请求参数

请求该接口时需要传入以下参数。

名称类型描述
Approvalsobject[]审批内容

以下表格描述了Approvals中的对象键值信息:

名称类型描述
instancestring当前审批单_id
tracestring当前签核历程_id
_idstring当前审批历程_id
valuesobject审批表单值
next_stepsobject[]下一步骤
judgestring审批状态
descriptionstring审批意见
geolocationstring审批地点

以下表格描述了next_steps中的对象键值信息:

名称类型描述
stepstring下一步骤_id
usersstring[]下一步骤处理人_id

以下表格描述了judge数据字典:

名称类型描述
approvedstring核准
rejectedstring驳回
terminatedstring被取回
reassignedstring转签核
relocatedstring重定位

返回值

  • 该API接口请求成功时返回空对象。

  • 该API接口请求失败时返回值格式如下:

{
    errors: [{ errorMessage: "..." }]
}