Files
2026-05-18 09:28:15 +08:00

128 lines
3.3 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 简单流程示例(type=1)
> 来源:平台示例 crmOrder、salesOrder、materialapply、paymentapply
## 特点
- 预定义三节点:发起 → 审批 → 结束
- 快速配置,无需设计流程图
- 支持指定审批人
## 平台示例
| 模板 | ID | 说明 |
|------|-----|------|
| CRM订单 | 585361795057715206 | 订单管理,含商品明细、收款计划 |
| 销售订单 | 585824509966156933 | 发票类型、商品明细 |
| 物资申请 | 588008146002249413 | 行政物资申请 |
| 付款申请 | 588010241019348677 | 财务付款申请 |
## flowXml(URL编码后)
```xml
<?xml version="1.0" encoding="UTF-8"?>
<bpmn2:definitions ...>
<bpmn2:process id="Process_1" isExecutable="true">
<bpmn2:startEvent id="Event_0oz4pwh">
<bpmn2:outgoing>Flow_1iadlmn</bpmn2:outgoing>
</bpmn2:startEvent>
<bpmn2:userTask id="Activity_1qf73gq">
<bpmn2:incoming>Flow_1iadlmn</bpmn2:incoming>
<bpmn2:outgoing>Flow_1kz1x8a</bpmn2:outgoing>
</bpmn2:userTask>
<bpmn2:sequenceFlow id="Flow_1iadlmn" sourceRef="Event_0oz4pwh" targetRef="Activity_1qf73gq" />
<bpmn2:endEvent id="Event_0zlhfee">
<bpmn2:incoming>Flow_1kz1x8a</bpmn2:incoming>
</bpmn2:endEvent>
<bpmn2:sequenceFlow id="Flow_1kz1x8a" sourceRef="Activity_1qf73gq" targetRef="Event_0zlhfee" />
</bpmn2:process>
</bpmn2:definitions>
```
## flowNodes 结构
```python
{
"global": {
"type": "global",
"nodeId": "global",
"formId": "form_id",
"titleType": 0,
"connectList": ["Flow_1iadlmn", "Flow_1kz1x8a"],
},
"Event_0oz4pwh": {
"type": "start",
"nodeId": "Event_0oz4pwh",
"nodeName": "流程发起",
"formId": "form_id",
},
"Activity_1qf73gq": {
"type": "approver",
"nodeId": "Activity_1qf73gq",
"nodeName": "部门审批",
"formId": "form_id",
"assigneeType": 6,
"approvers": [{"id": "user_id", "type": "user"}],
"counterSign": 0,
"hasOpinion": True,
"hasAuditBtn": True,
"hasRejectBtn": True,
},
"Event_0zlhfee": {
"type": "end",
"nodeId": "Event_0zlhfee",
},
}
```
## 代码示例
```python
from aibridge import JNPFClient, JNPFConfig
config = JNPFConfig()
client = JNPFClient.from_config(config)
client.login()
# 一键创建简单流程
result = client.workflow.create_simple_flow(
full_name="采购审批",
en_code="purchaseFlow",
form_id="visual_dev_form_id",
approver_user_ids=["admin"], # 审批人
form_name="采购申请",
)
print(f"模板ID: {result['template_id']}")
print(f"版本ID: {result['version_id']}")
# 发起流程
task = client.workflow.launch_task(result["version_id"], {
"f_orderNo": "PO-2026-001",
"f_amount": 5000,
"f_reason": "办公用品采购",
})
print(f"任务ID: {task.id}")
# 审批
tasks = client.workflow.get_pending_tasks()
if tasks:
client.workflow.approve(tasks[0]["taskOperatorId"], "同意采购")
```
## 审批按钮配置
```python
{
"hasAuditBtn": True,
"auditBtnText": "同意", # 按钮文字
"hasRejectBtn": True,
"rejectBtnText": "拒绝",
"hasBackBtn": False,
"backBtnText": "退回",
"hasFreeApproverBtn": False,
"hasTransferBtn": False,
"hasAssistBtn": False,
}
```