220 lines
4.4 KiB
Markdown
220 lines
4.4 KiB
Markdown
# 任务操作指南
|
|
|
|
> 来源:前端 `views/workFlow/components/FlowParser.vue`、`flowTodo/index.vue`
|
|
|
|
## 任务生命周期
|
|
|
|
```
|
|
发起 → 待办 → 审批中 → 通过/拒绝/退回 → 结束
|
|
```
|
|
|
|
## FlowParser.vue 核心代码
|
|
|
|
```typescript
|
|
// 获取任务详情
|
|
function getBeforeInfo(config) {
|
|
const query = {
|
|
taskNodeId: config.taskNodeId,
|
|
operatorId: config.operatorId,
|
|
flowId: config.flowId,
|
|
opType: config.opType,
|
|
};
|
|
getFlowTaskInfo(config.id || '0', query).then((res) => {
|
|
state.formInfo = res.data.formInfo || {};
|
|
state.taskInfo = res.data.taskInfo || {};
|
|
state.flowInfo = res.data.flowInfo || {};
|
|
state.btnInfo = res.data.btnInfo || {};
|
|
});
|
|
}
|
|
```
|
|
|
|
## opType 含义
|
|
|
|
| opType | 含义 | 说明 |
|
|
|--------|------|------|
|
|
| -1 | 新建/编辑 | 我发起的新建/编辑 |
|
|
| 0 | 详情 | 我发起的详情 |
|
|
| 1 | 待签 | 待签收事宜 |
|
|
| 2 | 待办 | 待审批事宜 |
|
|
| 3 | 在办 | 审批中 |
|
|
| 4 | 已办 | 已完成 |
|
|
| 5 | 抄送 | 抄送事宜 |
|
|
| 6 | 监控 | 流程监控 |
|
|
|
|
## 发起流程
|
|
|
|
### FlowPopup.vue
|
|
|
|
```typescript
|
|
function toDetail(record) {
|
|
const data = {
|
|
id: record.taskId,
|
|
flowId: record.flowId,
|
|
opType: -1, // 发起
|
|
operatorId: record.id,
|
|
};
|
|
openFlowParser(true, data);
|
|
}
|
|
```
|
|
|
|
### API 调用
|
|
|
|
```python
|
|
# 发起流程
|
|
task = client.workflow.launch_task(version_id, {
|
|
"f_amount": 5000,
|
|
"f_reason": "办公用品采购",
|
|
})
|
|
|
|
# 快捷发起(推荐)
|
|
task = client.workflow.create({
|
|
"flowId": version_id,
|
|
"status": 1,
|
|
"flowUrgent": 1,
|
|
"isFlow": 1,
|
|
"formData": {"f_amount": 5000},
|
|
})
|
|
task_id = task.id
|
|
```
|
|
|
|
### launch_task 参数
|
|
|
|
```python
|
|
{
|
|
"flowId": version_id, # 版本ID(必须)
|
|
"status": 1, # 1=发起, 0=暂存
|
|
"flowUrgent": 1, # 紧急程度 1=普通 2=紧急 3=特别紧急
|
|
"isFlow": 1, # 整数1,不是布尔值True
|
|
"formData": { # 表单数据,dict直接传
|
|
"f_orderNo": "PO-001",
|
|
"f_amount": 5000,
|
|
}
|
|
}
|
|
```
|
|
|
|
## 待办列表
|
|
|
|
### flowTodo/index.vue
|
|
|
|
```typescript
|
|
function toDetail(record) {
|
|
const data = {
|
|
id: record.taskId,
|
|
flowId: record.flowId,
|
|
opType: 2, // 待办
|
|
operatorId: record.id,
|
|
};
|
|
openFlowParser(true, data);
|
|
}
|
|
```
|
|
|
|
### API 调用
|
|
|
|
```python
|
|
# 获取待办列表
|
|
resp = client.workflow.get_before_list("1", {
|
|
"currentPage": 1,
|
|
"pageSize": 20,
|
|
})
|
|
for item in resp.data.get("list", []):
|
|
print(f"待办: {item['fullName']}, operatorId={item['id']}")
|
|
|
|
# 快捷获取待办(推荐)
|
|
tasks = client.workflow.get_pending_tasks()
|
|
```
|
|
|
|
## 撤回发起
|
|
|
|
```python
|
|
# 撤回发起
|
|
client.workflow.launch_recall(task_id, {
|
|
"handleOpinion": "撤回原因",
|
|
})
|
|
|
|
# 撤销发起
|
|
client.workflow.revoke(task_id, {
|
|
"handleOpinion": "撤销原因",
|
|
})
|
|
```
|
|
|
|
## 催办
|
|
|
|
```python
|
|
client.workflow.press(task_id)
|
|
```
|
|
|
|
## 获取流程实例人员
|
|
|
|
```python
|
|
# 获取实例相关人员
|
|
resp = client.workflow.get_task_user_list({
|
|
"taskId": task_id,
|
|
"currentPage": 1,
|
|
"pageSize": 20,
|
|
})
|
|
|
|
# 获取事件日志
|
|
resp = client.workflow.get_event_log(task_id)
|
|
|
|
# 获取流转记录
|
|
resp = client.workflow.get_record_list(task_id, node_id)
|
|
|
|
# 获取抄送人员
|
|
resp = client.workflow.get_circulate_list(task_id, node_id)
|
|
```
|
|
|
|
## 发起列表
|
|
|
|
```python
|
|
# 获取我发起的流程
|
|
resp = client.workflow.get_launch_list({
|
|
"currentPage": 1,
|
|
"pageSize": 20,
|
|
})
|
|
```
|
|
|
|
## 任务状态 (taskInfo.status)
|
|
|
|
| status | 名称 | 说明 |
|
|
|--------|------|------|
|
|
| 1 | 进行中 | 审批中 |
|
|
| 2 | 已通过 | 审批通过 |
|
|
| 3 | 已拒绝 | 审批拒绝 |
|
|
| 4 | 已终止 | 被终止 |
|
|
| 5 | 已暂停 | 暂停中 |
|
|
| 6 | 撤销中 | 撤销操作中 |
|
|
| 7 | 已撤销 | 已撤销 |
|
|
| 8 | 已退回 | 被退回 |
|
|
| 9 | 已撤回 | 已撤回 |
|
|
|
|
## 发起后操作
|
|
|
|
| 方法 | 说明 |
|
|
|------|------|
|
|
| `launch_recall(task_id)` | 撤回发起 |
|
|
| `revoke(task_id)` | 撤销发起(终止流程) |
|
|
| `press(task_id)` | 催办 |
|
|
|
|
## 批量操作
|
|
|
|
```python
|
|
# 批量签收
|
|
client.workflow.batch_sign({
|
|
"ids": [op_id_1, op_id_2],
|
|
"type": 0, # 0=签收, 1=退签
|
|
})
|
|
|
|
# 批量办理
|
|
client.workflow.batch_handle({
|
|
"ids": [op_id_1, op_id_2],
|
|
})
|
|
|
|
# 批量审批
|
|
client.workflow.batch_operation({
|
|
"batchHandleList": [
|
|
{"operatorId": op_id_1, "status": 1, "handleOpinion": "同意"},
|
|
{"operatorId": op_id_2, "status": 1, "handleOpinion": "同意"},
|
|
],
|
|
})
|
|
```
|