@leadal/flowstream-ui-plus 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,265 @@
1
+ # FlowStream UI Plus 接入文档
2
+
3
+ `@leadal/flowstream-ui-plus` 提供 FlowStream 业务工程需要的 Vue 3 运行时组件。流程设计与编辑由工作流程引擎内部完成,组件库不导出 Editor。
4
+
5
+ ## 1. 环境要求
6
+
7
+ - Node.js `>= 18`
8
+ - pnpm `>= 8`
9
+ - Vue `>= 3.4`
10
+ - Element Plus `>= 2.8`
11
+
12
+ ```bash
13
+ pnpm add @leadal/flowstream-ui-plus vue element-plus
14
+ ```
15
+
16
+ ## 2. 本地 link
17
+
18
+ ```bash
19
+ cd workflow-components-vue3
20
+ pnpm run build
21
+ pnpm link --global
22
+
23
+ cd /path/to/components-demo-vue3-web
24
+ pnpm link --global @leadal/flowstream-ui-plus
25
+ ```
26
+
27
+ 重新修改组件库后需要再次执行 `pnpm run build`;如果开发服务器没有感知 link 包变化,请重启开发服务器。
28
+
29
+ ## 3. 公共组件清单
30
+
31
+ 只公开以下 5 个主组件和 1 个子组件:
32
+
33
+ | 按需导出名 | 全局标签 | 说明 |
34
+ | --- | --- | --- |
35
+ | `FlowButtons` | `ui-flow-buttons` | 流程操作按钮组 |
36
+ | `FlowButton` | `ui-flow-button` | 单个流程按钮,作为按钮组子组件使用 |
37
+ | `FlowDiagram` | `ui-flow-diagram` | BPMN 流程图和办理轨迹 |
38
+ | `FlowSend` | `ui-flow-send` | 发送任务 |
39
+ | `FlowJump` | `ui-flow-jump` | 跳转任务 |
40
+ | `FlowGrid` | `ui-flow-grid` | 待办、已办、草稿统一列表 |
41
+
42
+ `SvgIcon`、轨迹表格、基础表格等仍可作为上述组件的内部实现,但不属于公共导出。
43
+
44
+ ## 4. 全量注册
45
+
46
+ ```ts
47
+ import { createApp } from 'vue'
48
+ import ElementPlus from 'element-plus'
49
+ import 'element-plus/dist/index.css'
50
+ import FlowstreamUIPlus from '@leadal/flowstream-ui-plus'
51
+ import '@leadal/flowstream-ui-plus/style.css'
52
+ import App from './App.vue'
53
+
54
+ const app = createApp(App)
55
+
56
+ app.use(ElementPlus)
57
+ app.use(FlowstreamUIPlus, {
58
+ baseURL: import.meta.env.VITE_FLOWSTREAM_ORIGIN,
59
+ timeout: 60_000,
60
+ getToken: () => localStorage.getItem('access_token') || undefined,
61
+ })
62
+
63
+ app.mount('#app')
64
+ ```
65
+
66
+ `baseURL` 是接口前缀。传入地址时组件库会按原值使用(仅移除末尾 `/`):
67
+
68
+ - 留空:生产构建不添加前缀;测试/开发源码模式默认添加 `/api`。
69
+ - `/api`:显式使用测试环境代理。通过 npm/pnpm link 消费构建产物时,应使用这种配置。
70
+ - `http://127.0.0.1:19090`:直连 FlowStream,最终请求为 `http://127.0.0.1:19090/flowstream/...`。
71
+ - `https://example.com/api`:使用已有 `/api` 网关前缀。
72
+
73
+ 本地前端代理应将 `/api` 转发到 FlowStream 服务,并移除 `/api` 前缀。
74
+
75
+ ## 5. 按需注册
76
+
77
+ ```ts
78
+ import {
79
+ FlowButton,
80
+ FlowButtons,
81
+ FlowDiagram,
82
+ FlowGrid,
83
+ FlowJump,
84
+ FlowSend,
85
+ configureWorkflow,
86
+ } from '@leadal/flowstream-ui-plus'
87
+ import '@leadal/flowstream-ui-plus/style.css'
88
+
89
+ configureWorkflow({
90
+ baseURL: import.meta.env.VITE_FLOWSTREAM_ORIGIN,
91
+ getToken: () => localStorage.getItem('access_token') || undefined,
92
+ })
93
+ ```
94
+
95
+ ## 6. ui-flow-grid
96
+
97
+ `type` 为必传属性,支持:
98
+
99
+ - `todo`:待办,操作事件的 `action` 为 `view`。
100
+ - `done`:已办,操作事件的 `action` 为 `handle`。
101
+ - `draft`:草稿,操作事件的 `action` 为 `view`;调用 `create()` 时为 `create`。
102
+
103
+ ```vue
104
+ <script setup lang="ts">
105
+ import { ref } from 'vue'
106
+ import { FlowGrid } from '@leadal/flowstream-ui-plus'
107
+
108
+ const gridRef = ref<InstanceType<typeof FlowGrid>>()
109
+
110
+ function createDraft() {
111
+ gridRef.value?.create({
112
+ name: '请假流程',
113
+ processDefinitionId: 'Process_leave:1:xxxx',
114
+ })
115
+ }
116
+
117
+ function handleWork(payload: {
118
+ action: 'view' | 'handle' | 'create'
119
+ workData: Record<string, unknown>
120
+ }) {
121
+ console.log(payload)
122
+ }
123
+ </script>
124
+
125
+ <template>
126
+ <div class="flow-grid-page">
127
+ <ui-flow-grid
128
+ ref="gridRef"
129
+ type="draft"
130
+ :deal-user-id="currentUserId"
131
+ :app-id="appId"
132
+ :app-module-id="appModuleId"
133
+ @on-handle="handleWork"
134
+ @error="console.error"
135
+ />
136
+ </div>
137
+ </template>
138
+
139
+ <style scoped>
140
+ .flow-grid-page { height: 100%; min-height: 500px; }
141
+ </style>
142
+ ```
143
+
144
+ 实例公开 `loadTableData()`、`create(flow)`、`data`、`loading` 和 `pageConfig`。
145
+
146
+ ## 7. ui-flow-diagram
147
+
148
+ 父容器必须设置明确高度。
149
+
150
+ ```vue
151
+ <script setup lang="ts">
152
+ import { ref } from 'vue'
153
+ import { FlowDiagram } from '@leadal/flowstream-ui-plus'
154
+
155
+ const diagramRef = ref<InstanceType<typeof FlowDiagram>>()
156
+ </script>
157
+
158
+ <template>
159
+ <div style="height: 700px">
160
+ <ui-flow-diagram
161
+ ref="diagramRef"
162
+ :process-definition-id="processDefinitionId"
163
+ :process-instance-id="processInstanceId"
164
+ @loaded="handleLoaded"
165
+ @error="handleError"
166
+ />
167
+ </div>
168
+ </template>
169
+ ```
170
+
171
+ 调用 `diagramRef.value?.refresh()` 可以刷新流程图和办理轨迹。
172
+
173
+ ## 8. ui-flow-buttons 与 ui-flow-button
174
+
175
+ `FlowButtons` 根据 `workId` 请求当前可用操作。发送、保存、启动和跳转等需要业务页面参与的动作通过 `execute-action` 交给宿主处理,其中发送动作名为 `taskSend`。
176
+
177
+ ```vue
178
+ <ui-flow-buttons
179
+ :work-id="task.workId"
180
+ :process-instance-id="task.processInstanceId"
181
+ :before-action="validateBeforeAction"
182
+ :after-action="reloadAfterAction"
183
+ @after-action="handleAfterAction"
184
+ @execute-action="handleAction"
185
+ @error="handleError"
186
+ />
187
+ ```
188
+
189
+ 内部操作(如办毕、退回、撤回、收回、挂起、恢复和终止)成功后会触发 `after-action(action, result)`;也兼容 `afterAction` 函数型 prop。宿主可在该事件中提示成功并刷新列表。
190
+
191
+ 单按钮子组件可按需使用:
192
+
193
+ ```vue
194
+ <ui-flow-button type="save" @click="saveForm" />
195
+ ```
196
+
197
+ ## 9. ui-flow-send
198
+
199
+ `FlowSend` 是完整的发送办理组件,内置下一环节解析、办理人选择、流程变量、审批意见和确认发送弹窗。直接使用时点击组件按钮即可打开;与 `FlowButtons` 配合时可隐藏自身按钮,由 `taskSend` 操作调用实例的 `open()`。
200
+
201
+ ```vue
202
+ <script setup lang="ts">
203
+ import { ref } from 'vue'
204
+ import { FlowSend } from '@leadal/flowstream-ui-plus'
205
+
206
+ const sendVisible = ref(false)
207
+
208
+ function handleAction(action: string) {
209
+ if (action === 'taskSend') sendVisible.value = true
210
+ }
211
+ </script>
212
+
213
+ <template>
214
+ <ui-flow-send
215
+ v-model="sendVisible"
216
+ :process-definition-id="task.processDefinitionId"
217
+ :process-instance-id="task.processInstanceId"
218
+ :activity="task"
219
+ :work-id="task.workId"
220
+ :deal-user="currentUser"
221
+ :show-trigger="false"
222
+ :variables="variables"
223
+ @before-send="handleBeforeSend"
224
+ @after-send="handleAfterSend"
225
+ @error="handleError"
226
+ />
227
+ </template>
228
+ ```
229
+
230
+ 推荐通过 `v-model` 控制弹窗,避免宿主依赖组件实例;实例仍公开 `open()`、`close()`、`getNextNode()`、`assembleData()` 和 `send()`。组件请求 `nodeAssistant` 加载下一节点候选人,并在确认时直接提交 `/flowstream/server/task/event/send`。
231
+
232
+ ## 10. ui-flow-jump
233
+
234
+ `FlowJump` 内置“开始节点 + 办理人”选择弹窗。办理人支持组织树懒加载;如果节点没有配置办理人,组件会回填当前用户。跳转不编辑业务变量,请求中固定提交 `variables: {}`。
235
+
236
+ ```vue
237
+ <script setup lang="ts">
238
+ import { ref } from 'vue'
239
+ import { FlowJump } from '@leadal/flowstream-ui-plus'
240
+
241
+ const jumpVisible = ref(false)
242
+ </script>
243
+
244
+ <template>
245
+ <ui-flow-jump
246
+ v-model="jumpVisible"
247
+ :process-definition-id="task.processDefinitionId"
248
+ :process-instance-id="task.processInstanceId"
249
+ :work-id="task.workId"
250
+ :deal-user="{ id: currentUserId, name: currentUserName }"
251
+ :show-trigger="false"
252
+ @before-jump="handleBeforeJump"
253
+ @after-jump="handleAfterJump"
254
+ @error="handleError"
255
+ />
256
+ </template>
257
+ ```
258
+
259
+ `showTrigger` 默认是 `true`,此时组件自身显示“跳转”按钮并负责打开弹窗;与 `FlowButtons` 配合时设为 `false`,在按钮组触发 `taskJump`/`jump` 后执行 `jumpVisible.value = true`。实例同时公开 `open()`、`close()`、`getStartNodes()`、`assembleData()` 和 `jump()`。
260
+
261
+ ## 11. 错误处理
262
+
263
+ 组件请求只将服务端 `code` 为 `0` 或 `200` 的响应视为成功。建议统一监听 `error` 事件,并在入口通过 `getToken` 配置认证信息。
264
+
265
+ 流程图空白时,优先检查父容器高度、流程定义 ID、流程实例 ID 以及 BPMN 下载接口。
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@leadal/flowstream-ui-plus",
3
+ "version": "0.0.1",
4
+ "description": "FlowStream workflow components for Vue 3",
5
+ "type": "module",
6
+ "main": "dist/flowstream-ui-plus.umd.cjs",
7
+ "module": "dist/flowstream-ui-plus.js",
8
+ "types": "dist/index.d.ts",
9
+ "style": "dist/style.css",
10
+ "files": [
11
+ "dist",
12
+ "README.md",
13
+ "docs"
14
+ ],
15
+ "exports": {
16
+ ".": {
17
+ "types": "./dist/index.d.ts",
18
+ "import": "./dist/flowstream-ui-plus.js",
19
+ "require": "./dist/flowstream-ui-plus.umd.cjs"
20
+ },
21
+ "./style.css": "./dist/style.css"
22
+ },
23
+ "scripts": {
24
+ "dev": "vite",
25
+ "build": "vue-tsc --noEmit && vite build",
26
+ "typecheck": "vue-tsc --noEmit",
27
+ "pack:lib": "pnpm run build && pnpm pack"
28
+ },
29
+ "peerDependencies": {
30
+ "element-plus": "^2.8.0",
31
+ "vue": "^3.4.0"
32
+ },
33
+ "dependencies": {
34
+ "@leadal/netiler-ui3-plus": "^0.0.5",
35
+ "axios": "^1.9.0",
36
+ "bpmn-js": "^18.6.2",
37
+ "camunda-bpmn-moddle": "^7.0.1",
38
+ "dayjs": "^1.11.13",
39
+ "diagram-js": "^15.23.2"
40
+ },
41
+ "devDependencies": {
42
+ "@element-plus/icons-vue": "^2.3.1",
43
+ "@types/node": "^22.10.0",
44
+ "@vitejs/plugin-vue": "^5.2.0",
45
+ "element-plus": "^2.8.0",
46
+ "sass": "^1.83.0",
47
+ "typescript": "^5.7.0",
48
+ "vite": "^6.0.0",
49
+ "vite-plugin-dts": "^4.5.0",
50
+ "vue": "^3.5.0",
51
+ "vue-tsc": "^2.2.0"
52
+ },
53
+ "engines": {
54
+ "node": ">=18",
55
+ "pnpm": ">=8"
56
+ },
57
+ "license": "UNLICENSED"
58
+ }