forked from erp-dev/erp
feat: query all process nodes for business_object
This commit is contained in:
@@ -268,6 +268,37 @@ Authorization: Bearer <access_token>
|
||||
- **描述**: 获取当前待执行节点(`current_state`)的参数模板。
|
||||
- **注意**: `current_state` 指的是下一个待执行的节点。如果流程已完成,则返回空。
|
||||
|
||||
#### 3.7.5. 获取流程的所有节点
|
||||
|
||||
- **GET** `/api/v1/stateflow/business-objects/{id}/process-nodes/`
|
||||
- **描述**: 获取业务对象所属流程的所有状态节点列表,按顺序排列。
|
||||
- **响应示例**:
|
||||
```json
|
||||
{
|
||||
"count": 3,
|
||||
"nodes": [
|
||||
{
|
||||
"id": 1,
|
||||
"state_id": 10,
|
||||
"state_name": "质检",
|
||||
"order": 0
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"state_id": 11,
|
||||
"state_name": "包装",
|
||||
"order": 1
|
||||
},
|
||||
{
|
||||
"id": 3,
|
||||
"state_id": 12,
|
||||
"state_name": "发货",
|
||||
"order": 2
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### 3.8. 参数与日志接口 (Custom Actions)
|
||||
|
||||
#### 3.8.1. 获取状态流转记录列表
|
||||
@@ -737,7 +768,7 @@ token = response.json()['access']
|
||||
# 创建状态
|
||||
headers = {'Authorization': f'Bearer {token}'}
|
||||
response = requests.post(
|
||||
'http://localhost:8000/api/v1/states/',
|
||||
'http://localhost:8000/api/v1/stateflow/states/',
|
||||
json={
|
||||
'name': '待审核',
|
||||
'description': '等待审核'
|
||||
@@ -745,26 +776,50 @@ response = requests.post(
|
||||
headers=headers
|
||||
)
|
||||
state = response.json()
|
||||
|
||||
# 获取业务对象的流程节点
|
||||
business_object_id = 1
|
||||
response = requests.get(
|
||||
f'http://localhost:8000/api/v1/stateflow/business-objects/{business_object_id}/process-nodes/',
|
||||
headers=headers
|
||||
)
|
||||
nodes_data = response.json()
|
||||
print(f"流程共有 {nodes_data['count']} 个节点")
|
||||
for node in nodes_data['nodes']:
|
||||
print(f" 节点 {node['order']}: {node['state_name']}")
|
||||
```
|
||||
|
||||
### JavaScript (fetch)
|
||||
|
||||
```javascript
|
||||
// 获取状态列表
|
||||
const response = await fetch('/api/v1/states/?limit=10&offset=0', {
|
||||
const response = await fetch('/api/v1/stateflow/states/?limit=10&offset=0', {
|
||||
headers: {
|
||||
'Authorization': `Bearer ${token}`
|
||||
}
|
||||
});
|
||||
const data = await response.json();
|
||||
console.log(data.results);
|
||||
|
||||
// 获取业务对象的流程节点
|
||||
const businessObjectId = 1;
|
||||
const nodesResponse = await fetch(
|
||||
`/api/v1/stateflow/business-objects/${businessObjectId}/process-nodes/`,
|
||||
{
|
||||
headers: {
|
||||
'Authorization': `Bearer ${token}`
|
||||
}
|
||||
}
|
||||
);
|
||||
const nodesData = await nodesResponse.json();
|
||||
console.log(`流程共有 ${nodesData.count} 个节点:`, nodesData.nodes);
|
||||
```
|
||||
|
||||
### curl
|
||||
|
||||
```bash
|
||||
# 创建流程
|
||||
curl -X POST "http://localhost:8000/api/v1/processes/" \
|
||||
curl -X POST "http://localhost:8000/api/v1/stateflow/processes/" \
|
||||
-H "Authorization: Bearer <token>" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{
|
||||
@@ -775,4 +830,8 @@ curl -X POST "http://localhost:8000/api/v1/processes/" \
|
||||
{"state_id": 2, "order": 1}
|
||||
]
|
||||
}'
|
||||
|
||||
# 获取业务对象的流程节点
|
||||
curl -X GET "http://localhost:8000/api/v1/stateflow/business-objects/1/process-nodes/" \
|
||||
-H "Authorization: Bearer <token>"
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user