Files
aibridge/docs/workflow/06-examples/02-standard-flow.md
T
2026-05-18 09:28:15 +08:00

3.5 KiB
Raw Blame History

自由审批流程示例(type=0)

来源:平台示例 leaveApply、purapplyedae9、Paymentapplydc652、resignation

特点

  • 标准审批流程,用户自定义节点和连线
  • 可设计多级审批、会签、并行等复杂流程
  • 需要使用 FlowProcess 组件设计

平台示例

模板 ID 说明
请假申请 585824179933152389 请假类型(事假/病假/婚假/产假/丧假/年假/调休)、时长验证
采购申请 585824148157105285 行政采购审批
付款申请(标准) 585824103953335429 财务付款审批
离职申请触发 623164145176412357 HR离职申请

flowXml(标准流程 - 空模板)

<?xml version="1.0" encoding="UTF-8"?>
<bpmn2:definitions ...>
  <bpmn2:process id="Process_1" isExecutable="true">
    <bpmn2:startEvent id="Event_04q7xii" />
  </bpmn2:process>
</bpmn2:definitions>

flowNodes(仅发起节点)

{
    "global": {
        "type": "global",
        "nodeId": "global",
        "formId": "form_id",
        "titleType": 0,
        "connectList": [],
    },
    "Event_04q7xii": {
        "type": "start",
        "nodeId": "Event_04q7xii",
        "nodeName": "流程发起",
        "formId": "form_id",
    },
}

设计器操作流程

1. DesignForm.vue -> 创建模板 -> 获取 template_id
2. Form.vue -> 点击"确定并设计" -> 打开 FlowProcess 组件
3. FlowProcess -> 添加节点 -> 配置节点属性
4. 保存 -> save_flow
5. 发布 -> type=1

多级审批配置

{
    "Activity_dept": {
        "type": "approver",
        "nodeName": "部门经理审批",
        "assigneeType": 1,       # 发起人上级
        "managerLevel": 1,       # 直属上级
        "counterSign": 0,         # 或签
    },
    "Activity_hr": {
        "type": "approver",
        "nodeName": "HR审批",
        "assigneeType": 6,        # 指定成员
        "approvers": [{"id": "hr_user_id", "type": "user"}],
        "counterSign": 1,         # 会签
        "counterSignConfig": {
            "auditType": 1,
            "auditRatio": 100,
        },
    },
}

会签配置

{
    "counterSign": 1,  # 0=或签, 1=会签, 2=依次审批
    "counterSignConfig": {
        "auditType": 1,      # 1=按百分比, 2=按人数
        "auditRatio": 100,  # 100%=全部通过
        "auditNum": 2,       # 人数
        "rejectType": 0,
        "rejectRatio": 10,
        "rejectNum": 1,
    }
}

代码示例

from aibridge import JNPFClient, JNPFConfig

config = JNPFConfig()
client = JNPFClient.from_config(config)
client.login()

# 创建标准流程(只有发起节点,需要在设计器中添加审批节点)
result = client.workflow.create_standard_flow(
    full_name="请假申请",
    en_code="leaveFlow",
    form_id="visual_dev_form_id",
    form_name="请假申请表单",
)

print(f"模板ID: {result['template_id']}")
print(f"版本ID: {result['version_id']}")

# 获取流程信息(需要在设计器中设计后)
flow_info = client.workflow.get_flow_info(result["version_id"])
print(f"flowNodes: {flow_info.data.get('flowNodes')}")

前端设计器源码

文件 说明
views/onlineDev/flowEngine/Form.vue 流程设计主入口
views/onlineDev/flowEngine/DesignForm.vue 模板基本信息表单
components/FlowProcess/ BPMN 流程设计器组件
components/FlowProcess/src/helper/config.ts 节点默认配置
components/FlowProcess/src/propPanel/ApproverNode.vue 审批节点配置面板