@leadal/flowstream-ui-plus 0.0.2 → 0.0.4
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.
- package/README.md +63 -4
- package/dist/flowstream-ui-plus.js +3320 -3280
- package/dist/flowstream-ui-plus.umd.cjs +12 -12
- package/dist/index.d.ts +153 -82
- package/dist/style.css +1 -1
- package/docs//346/216/245/345/205/245/346/226/207/346/241/243.md +35 -5
- package/package.json +1 -1
|
@@ -179,6 +179,10 @@ const diagramRef = ref<InstanceType<typeof FlowDiagram>>()
|
|
|
179
179
|
:process-definition-id="task.processDefinitionId"
|
|
180
180
|
:deal-user-id="loginUser.id"
|
|
181
181
|
:deal-user-name="loginUser.name"
|
|
182
|
+
:assignment-query-params="{
|
|
183
|
+
projectId: currentProject.id,
|
|
184
|
+
tenantId: currentTenant.id,
|
|
185
|
+
}"
|
|
182
186
|
force-single-assignee
|
|
183
187
|
:before-action="validateBeforeAction"
|
|
184
188
|
:after-action="reloadAfterAction"
|
|
@@ -206,6 +210,10 @@ import { ref } from 'vue'
|
|
|
206
210
|
import { FlowSend } from '@leadal/flowstream-ui-plus'
|
|
207
211
|
|
|
208
212
|
const sendVisible = ref(false)
|
|
213
|
+
const assignmentQueryParams = {
|
|
214
|
+
projectId: currentProject.id,
|
|
215
|
+
tenantId: currentTenant.id,
|
|
216
|
+
}
|
|
209
217
|
|
|
210
218
|
function handleAction(action: string) {
|
|
211
219
|
if (action === 'taskSend') sendVisible.value = true
|
|
@@ -222,6 +230,7 @@ function handleAction(action: string) {
|
|
|
222
230
|
:deal-user="currentUser"
|
|
223
231
|
:show-trigger="false"
|
|
224
232
|
:variables="variables"
|
|
233
|
+
:assignment-query-params="assignmentQueryParams"
|
|
225
234
|
@before-send="handleBeforeSend"
|
|
226
235
|
@after-send="handleAfterSend"
|
|
227
236
|
@error="handleError"
|
|
@@ -231,6 +240,8 @@ function handleAction(action: string) {
|
|
|
231
240
|
|
|
232
241
|
推荐通过 `v-model` 控制弹窗,避免宿主依赖组件实例;实例仍公开 `open()`、`close()`、`getNextNode()`、`assembleData()` 和 `send()`。组件通过 `nodeAssistant` 请求 `POST /flowstream/server/assignment/event/query` 加载下一节点候选人,并在确认时直接提交 `/flowstream/server/task/event/send`。
|
|
233
242
|
|
|
243
|
+
`assignmentQueryParams` 是可选的自定义路由参数对象,可以传一个、多个字段或不传。它会追加到每次候选办理人查询(包括组织树懒加载)中。组件自己的 `processDefinitionId`、`activityId`、`userId` 和 `parentId` 不允许被该对象覆盖。使用 `FlowButtons` 内置发送弹窗或 `getRuntimeService().start()` 时也可传入同名参数。
|
|
244
|
+
|
|
234
245
|
## 10. ui-flow-jump
|
|
235
246
|
|
|
236
247
|
`FlowJump` 内置“开始节点 + 办理人”选择弹窗。办理人支持组织树懒加载;如果节点没有配置办理人,组件会回填当前用户。跳转不编辑业务变量,请求中固定提交 `variables: {}`。
|
|
@@ -292,12 +303,25 @@ const firstHandleNodes = result.data || []
|
|
|
292
303
|
import flowstream from '@leadal/flowstream-ui-plus'
|
|
293
304
|
|
|
294
305
|
async function submit() {
|
|
295
|
-
await flowstream.getRuntimeService().start({
|
|
306
|
+
const result = await flowstream.getRuntimeService().start({
|
|
296
307
|
processDefinitionId,
|
|
297
308
|
draftUserId: currentUser.id,
|
|
298
309
|
draftUserName: currentUser.name,
|
|
299
310
|
business: { key: businessId, name: businessName },
|
|
300
311
|
variables,
|
|
312
|
+
assignmentQueryParams: {
|
|
313
|
+
projectId: currentProject.id,
|
|
314
|
+
tenantId: currentTenant.id,
|
|
315
|
+
},
|
|
316
|
+
async onBeforeStart(startArgs) {
|
|
317
|
+
const formData = await openBusinessForm()
|
|
318
|
+
if (!formData) return false
|
|
319
|
+
startArgs.variables = { ...startArgs.variables, ...formData }
|
|
320
|
+
return true
|
|
321
|
+
},
|
|
322
|
+
async onBeforeSend(context) {
|
|
323
|
+
return validateBeforeSend(context)
|
|
324
|
+
},
|
|
301
325
|
onStarted(result) {
|
|
302
326
|
saveFlowRelation(result.processInstanceId)
|
|
303
327
|
},
|
|
@@ -306,22 +330,29 @@ async function submit() {
|
|
|
306
330
|
refreshBusinessList()
|
|
307
331
|
},
|
|
308
332
|
onClose() {
|
|
309
|
-
console.log('
|
|
333
|
+
console.log('发送弹窗已关闭;未发送时流程实例会被撤销')
|
|
310
334
|
},
|
|
311
335
|
onError(error) {
|
|
312
336
|
console.error(error.phase, error.message)
|
|
313
337
|
},
|
|
314
338
|
})
|
|
339
|
+
if (result === false) return
|
|
315
340
|
}
|
|
316
341
|
```
|
|
317
342
|
|
|
318
|
-
- `start()`
|
|
343
|
+
- `onBeforeStart(args)` 在任何流程查询和启动接口之前执行,支持 `boolean | Promise<boolean>`;返回 `false` 时不会创建流程实例,`start()` 返回 `false`。
|
|
344
|
+
- `start()` 通过启动校验后,内部依次完成首办节点解析、`quickStart`、发送弹窗初始化、下一节点和候选办理人查询。
|
|
345
|
+
- `onBeforeSend(context)` 在实例创建成功后、审批人选择弹窗打开前执行,也支持 Promise;返回 `false` 时保留流程实例和当前会话,但不打开弹窗。
|
|
346
|
+
- 条件稍后满足时调用 `await flowstream.getRuntimeService().open()`,组件会重新执行 `onBeforeSend`;决定放弃时调用 `close()` 撤销实例并释放会话。
|
|
319
347
|
- 调用成功后直接打开选择弹窗,业务模板不需要挂载隐藏组件。
|
|
320
348
|
- 候选办理人可以有多个;`singleAssignee` 默认开启,每个下一节点只能选择一人。
|
|
349
|
+
- 自定义业务路由参数通过 `assignmentQueryParams` 传入,并自动附加到候选办理人查询请求。
|
|
321
350
|
- 用户确认后由内部发送组件调用 `sendTask()`;`onAfterSend` 参数中的 `sendData.flowNodeAssignees` 是实际发送的下一节点和办理人。
|
|
322
|
-
-
|
|
351
|
+
- 用户未发送就关闭弹窗时会撤销刚创建的流程实例并释放会话;只有 `onBeforeSend` 返回 `false`、弹窗尚未打开时,才能调用 `open()` 在条件满足后继续。
|
|
323
352
|
- `processDefinitionId`、`draftUserId`、`draftUserName` 均为必填;快速启动不支持多个首办节点或多个起草人待办。
|
|
324
353
|
|
|
354
|
+
业务表单弹窗应由接入项目实现,并将用户操作转换为 Promise:确认且校验成功时 `resolve(true)`,取消、关闭或组件卸载时 `resolve(false)`。不要只修改一个响应式布尔变量而不结束 Promise,否则 `start()` 会一直等待。
|
|
355
|
+
|
|
325
356
|
## 14. 获取应用与流程
|
|
326
357
|
|
|
327
358
|
业务页面需要「选应用 → 选流程 → 发起」级联场景时,可查询应用列表和流程定义列表。
|
|
@@ -358,4 +389,3 @@ const flows = await flowstream.getRuntimeService().getFlows({ appId })
|
|
|
358
389
|
- 接口约定(路径待后端确认):`POST /flowstream/server/repository/app/event/list`、`POST /flowstream/server/repository/flowdef/event/list`。
|
|
359
390
|
- `FlowApp`、`FlowDefinition` 类型已从库中导出,字段以后端实际返回为准。
|
|
360
391
|
- 拿到流程定义后,将 `flow.id` 作为 `processDefinitionId` 传给 `runtimeService.start()` 即可完成发起。
|
|
361
|
-
|