You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
296 lines
7.0 KiB
296 lines
7.0 KiB
![]()
2 weeks ago
|
|
||
|
# Workflow API 文档
|
||
|
## 流程示意
|
||
|

|
||
|
|
||
|
## 目录
|
||
|
|
||
|
- [流程图管理](#流程图管理)
|
||
|
- [流程实例管理](#流程实例管理)
|
||
|
- [任务管理](#任务管理)
|
||
|
- [表单管理](#表单管理)
|
||
|
- [Camunda部署-Docker](#Camunda部署-Docker)
|
||
|
|
||
|
## 项目导入
|
||
|
```javascript
|
||
|
import {
|
||
|
getProcessList,
|
||
|
getProcessInfo
|
||
|
//...其他
|
||
|
} from '/api/workflow'
|
||
|
```
|
||
|
## 流程图管理
|
||
|
|
||
|
### 获取流程图列表
|
||
|
```javascript
|
||
|
getProcessList({
|
||
|
firstResult = 0, // 起始索引
|
||
|
maxResults = 8, // 最大结果数
|
||
|
latestVersion = true // 是否最新版本
|
||
|
})
|
||
|
```
|
||
|
|
||
|
### 获取流程图信息
|
||
|
```javascript
|
||
|
getProcessInfo(processId) // processId: 流程图ID
|
||
|
```
|
||
|
|
||
|
### 获取流程图 XML
|
||
|
```javascript
|
||
|
getProcessXml(processId) // processId: 流程图ID
|
||
|
```
|
||
|
|
||
|
|
||
|
### 上传流程图
|
||
|
```javascript
|
||
|
const bpmnContent = '...'; // 流程图内容
|
||
|
const formData = new FormData()
|
||
|
const bpmnBlob = new Blob([bpmnContent], { type: 'application/octet-stream' });
|
||
|
formData.append('content', bpmnBlob, 'process.bpmn'); // 文件名应以 .bpmn 结尾
|
||
|
addModeler(formData)
|
||
|
```
|
||
|
|
||
|
|
||
|
### 删除流程图
|
||
|
```javascript
|
||
|
deleteProcess(processId) // processId: 流程图ID
|
||
|
```
|
||
|
|
||
|
### 创建流程实例
|
||
|
```javascript
|
||
|
start({
|
||
|
processKey: string, // 流程图key
|
||
|
formId: string, // 表单ID
|
||
|
createUser: string, // 创建人
|
||
|
formValues: object // 填写的表单数据
|
||
|
})
|
||
|
```
|
||
|
|
||
|
## 流程实例管理
|
||
|
|
||
|
### 获取流程实例列表
|
||
|
```javascript
|
||
|
getProcessInstanceList({
|
||
|
firstResult = 0, // 起始索引
|
||
|
maxResults = 8, // 最大结果数
|
||
|
processDefinitionKey, // 流程图key
|
||
|
sortOrder = "desc", // 排序方式:asc/desc
|
||
|
sortBy = "startTime" // 排序字段
|
||
|
})
|
||
|
```
|
||
|
|
||
|
### 删除流程实例
|
||
|
```javascript
|
||
|
deleteProcessInstance(processInstanceId) // processInstanceId: 流程实例ID
|
||
|
```
|
||
|
|
||
|
## 任务管理
|
||
|
|
||
|
### 获取流程实例任务列表
|
||
|
```javascript
|
||
|
getInstanceTaskList({
|
||
|
firstResult = 0, // 起始索引
|
||
|
maxResults = 8, // 最大结果数
|
||
|
processInstanceId // 流程实例ID
|
||
|
})
|
||
|
```
|
||
|
|
||
|
### 获取用户任务列表
|
||
|
```javascript
|
||
|
getUserTaskList({
|
||
|
firstResult = 0, // 起始索引
|
||
|
maxResults = 8, // 最大结果数
|
||
|
assignee, // 执行人ID
|
||
|
candidateUser, // 候选人ID
|
||
|
candidateGroup // 候选组ID
|
||
|
})
|
||
|
```
|
||
|
|
||
|
### 任务候选人管理
|
||
|
```javascript
|
||
|
// 查询任务节点候选人/组
|
||
|
getTaskCandidate(taskId)
|
||
|
|
||
|
// 添加节点候选人/组
|
||
|
addTaskCandidate({
|
||
|
taskId, // 任务ID
|
||
|
type, // 类型:candidate/assignee
|
||
|
userId, // 用户ID(与groupId二选一)
|
||
|
groupId // 组ID(与userId二选一)
|
||
|
})
|
||
|
|
||
|
// 删除节点候选人/组
|
||
|
deleteTaskCandidate({
|
||
|
taskId, // 任务ID
|
||
|
type, // 类型:candidate/assignee
|
||
|
userId, // 用户ID(与groupId二选一)
|
||
|
groupId // 组ID(与userId二选一)
|
||
|
})
|
||
|
```
|
||
|
|
||
|
### 任务操作
|
||
|
```javascript
|
||
|
// 认领任务
|
||
|
claim({
|
||
|
taskId, // 任务ID
|
||
|
userId // 用户ID
|
||
|
})
|
||
|
|
||
|
// 取消认领任务
|
||
|
unclaim(taskId)
|
||
|
|
||
|
// 完成任务
|
||
|
complete({
|
||
|
taskId, // 任务ID
|
||
|
variables: {
|
||
|
approvalResult: {
|
||
|
value: "approved" | "rejected", // 审批结果
|
||
|
type: "String"
|
||
|
}
|
||
|
}
|
||
|
})
|
||
|
|
||
|
// 添加任务评论---记录审批结果
|
||
|
setComment({
|
||
|
taskId, // 任务ID
|
||
|
message // 评论内容(JSON字符串) JSON.stringify({message: '执行成功',id: '其他的测试信息'})
|
||
|
|
||
|
})
|
||
|
```
|
||
|
|
||
|
## 表单管理
|
||
|
|
||
|
### 表单查询
|
||
|
```javascript
|
||
|
// 获取表单列表
|
||
|
getFormList({
|
||
|
page, // 页码
|
||
|
start, // 起始索引
|
||
|
limit // 最大结果数
|
||
|
})
|
||
|
|
||
|
// 获取表单详情
|
||
|
getFormDetail(formId)
|
||
|
|
||
|
// 获取表单字段
|
||
|
getFormFields(path)
|
||
|
```
|
||
|
|
||
|
### 表单操作
|
||
|
表单内容,暂不支持上传文件,手动填写在node服务端- /server/form下,写法与动态Form一致
|
||
|
```javascript
|
||
|
var config = require('../config'); //配置动态请求的基础路径
|
||
|
const formFields = [
|
||
|
{
|
||
|
tag: 'el-input',
|
||
|
label: '申请原因:',
|
||
|
key: 'reason',
|
||
|
value: '',
|
||
|
default: '',
|
||
|
attribute: {
|
||
|
clearable: true,
|
||
|
placeholder: '请输入申请原因',
|
||
|
},
|
||
|
},
|
||
|
{
|
||
|
tag: 'BaseSelect',
|
||
|
label: '申请人:',
|
||
|
key: 'user',
|
||
|
value: '',
|
||
|
default: '',
|
||
|
attribute: {//配置项内容
|
||
|
placeholder: '请选择申请人',
|
||
|
fetchOptions: {//动态请求配置
|
||
|
baseURL: config.env[process.env.NODE_ENV].formBaseURL, //请求的基础路径
|
||
|
url: `/system/user/list`,
|
||
|
method: "get",
|
||
|
data: {
|
||
|
page: 1,
|
||
|
limit: 999,
|
||
|
},
|
||
|
dataType: "json",
|
||
|
dataPath: "data.list",//默认值-data.list,可不指定
|
||
|
labelKey: "nickName",//默认值-name,可不指定
|
||
|
valueKey: "userId",//默认值-id,可不指定
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
];
|
||
|
module.exports = {
|
||
|
formFields
|
||
|
};
|
||
|
|
||
|
```
|
||
|
```javascript
|
||
|
// 添加表单
|
||
|
addForm({
|
||
|
formName: string, // 表单名称
|
||
|
formDesc: string, // 表单描述
|
||
|
formPath: string, // 表单内容--/form/test.js
|
||
|
userId: string // 创建人ID
|
||
|
})
|
||
|
|
||
|
// 更新表单
|
||
|
updateForm({
|
||
|
id: string, // 表单ID
|
||
|
formName: string, // 表单名称
|
||
|
formDesc: string, // 表单描述
|
||
|
formPath: string // 表单内容
|
||
|
})
|
||
|
|
||
|
// 删除表单
|
||
|
deleteForm(formId)
|
||
|
```
|
||
|
|
||
|
注意:所有 API 都返回 Promise 对象,可使用 async/await 处理异步请求。API 的基础 URL 由环境变量 `VITE_APP_BASE_PROCESS_API` 指定。
|
||
|
|
||
|
## Camunda部署-Docker
|
||
|
### 1.更改docker的镜像源
|
||
|
vi /etc/docker/daemon.json
|
||
|
```shell
|
||
|
{
|
||
|
"registry-mirrors": [
|
||
|
"https://docker.registry.cyou",
|
||
|
"https://docker-cf.registry.cyou",
|
||
|
"https://dockercf.jsdelivr.fyi",
|
||
|
"https://docker.jsdelivr.fyi",
|
||
|
"https://dockertest.jsdelivr.fyi",
|
||
|
"https://mirror.aliyuncs.com",
|
||
|
"https://dockerproxy.com",
|
||
|
"https://mirror.baidubce.com",
|
||
|
"https://docker.m.daocloud.io",
|
||
|
"https://docker.nju.edu.cn",
|
||
|
"https://docker.mirrors.sjtug.sjtu.edu.cn",
|
||
|
"https://docker.mirrors.ustc.edu.cn",
|
||
|
"https://mirror.iscas.ac.cn",
|
||
|
"https://docker.rainbond.cc"
|
||
|
]
|
||
|
}
|
||
|
```
|
||
|
|
||
|
```shell
|
||
|
systemctl daemon-reload
|
||
|
systemctl restart docker
|
||
|
```
|
||
|
### 2.拉取镜像
|
||
|
```shell
|
||
|
docker pull camunda/camunda-bpm-platform:latest
|
||
|
```
|
||
|
### 3.添加启动脚本
|
||
|
vi /data/camunda/docker-compose.yml
|
||
|
```shell
|
||
|
# 其中ports 1111为宿主机端口,8080为容器内部端口
|
||
|
version: '3'
|
||
|
services:
|
||
|
camunda:
|
||
|
image: camunda/camunda-bpm-platform:latest
|
||
|
ports:
|
||
|
- "1111:8080"
|
||
|
volumes:
|
||
|
- ./camunda-data:/camunda/data
|
||
|
|
||
|
```
|
||
|
```shell
|
||
|
#启动服务
|
||
|
docker-compose up -d
|
||
|
```
|