@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
package/README.md
CHANGED
|
@@ -146,6 +146,7 @@ configureWorkflow({
|
|
|
146
146
|
| `dealUserId` | 当前用户 ID;自动解析待办和拾取任务时使用 | `string` | 条件 | — |
|
|
147
147
|
| `dealUserName` | 当前用户名称 | `string` | 否 | — |
|
|
148
148
|
| `variables` | 发送、办毕时提交的流程变量 | `Record<string, unknown>` | 否 | `{}` |
|
|
149
|
+
| `assignmentQueryParams` | 内置发送弹窗查询候选办理人时附加的自定义路由参数 | `Record<string, unknown>` | 否 | `{}` |
|
|
149
150
|
| `autoResolveWork` | 未传 `workId` 时自动查询当前用户待办 | `boolean` | 否 | `true` |
|
|
150
151
|
| `autoHandleDialogs` | 在组件内部处理发送和跳转弹窗 | `boolean` | 否 | `true` |
|
|
151
152
|
| `forceSingleAssignee` | 每个下一节点仅允许选择一名办理人 | `boolean` | 否 | `false`|
|
|
@@ -347,7 +348,7 @@ function handleWork({ action, workData }: {
|
|
|
347
348
|
- 填写审批意见;
|
|
348
349
|
- 确认后调用任务发送接口,成功后关闭弹窗并提示“发送成功”。
|
|
349
350
|
|
|
350
|
-
办理人候选数据通过 `POST /flowstream/server/assignment/event/query`
|
|
351
|
+
办理人候选数据通过 `POST /flowstream/server/assignment/event/query` 加载。业务路由需要额外上下文时,可通过 `assignmentQueryParams` 追加任意数量的请求字段,也可以不传。组件维护的 `processDefinitionId`、`activityId`、`userId` 和懒加载 `parentId` 优先级更高,不能被扩展参数覆盖。
|
|
351
352
|
|
|
352
353
|
#### 1) 属性定义(Properties)
|
|
353
354
|
|
|
@@ -359,6 +360,7 @@ function handleWork({ action, workData }: {
|
|
|
359
360
|
| `workId` | 当前工作项 ID | `string \| number` | 是 | — |
|
|
360
361
|
| `processInstanceId` | 流程实例 ID | `string \| number` | 否 | `''` |
|
|
361
362
|
| `variables` | 当前业务流程变量 | `Record<string, unknown>` | 否 | `{}` |
|
|
363
|
+
| `assignmentQueryParams` | 查询候选办理人时附加的自定义路由参数 | `Record<string, unknown>` | 否 | `{}` |
|
|
362
364
|
| `dealUser` | 当前用户,可传 `id` 或 `userId` | `object` | 否 | `{}` |
|
|
363
365
|
| `bpmnXml` | BPMN XML;用于辅助判断下一节点是单人还是多人办理 | `string` | 否 | `''` |
|
|
364
366
|
| `showTrigger` | 是否显示组件自身的发送按钮 | `boolean` | 否 | `true` |
|
|
@@ -406,6 +408,10 @@ import { ref } from 'vue'
|
|
|
406
408
|
import { FlowButtons, FlowSend } from '@leadal/flowstream-ui-plus'
|
|
407
409
|
|
|
408
410
|
const sendVisible = ref(false)
|
|
411
|
+
const assignmentQueryParams = {
|
|
412
|
+
projectId: currentProject.id,
|
|
413
|
+
tenantId: currentTenant.id,
|
|
414
|
+
}
|
|
409
415
|
|
|
410
416
|
function handleFlowAction(action: string) {
|
|
411
417
|
if (action === 'taskSend') sendVisible.value = true
|
|
@@ -436,6 +442,7 @@ function handleAfterSend() {
|
|
|
436
442
|
:work-id="task.workId"
|
|
437
443
|
:deal-user="currentUser"
|
|
438
444
|
:variables="variables"
|
|
445
|
+
:assignment-query-params="assignmentQueryParams"
|
|
439
446
|
:show-trigger="false"
|
|
440
447
|
default-opinion="同意"
|
|
441
448
|
@after-send="handleAfterSend"
|
|
@@ -670,7 +677,7 @@ const firstHandleNodes: FlowNode[] = result.data || []
|
|
|
670
677
|
import flowstream from '@leadal/flowstream-ui-plus'
|
|
671
678
|
|
|
672
679
|
async function submitBusiness() {
|
|
673
|
-
await flowstream.getRuntimeService().start({
|
|
680
|
+
const result = await flowstream.getRuntimeService().start({
|
|
674
681
|
processDefinitionId,
|
|
675
682
|
draftUserId: currentUser.id,
|
|
676
683
|
draftUserName: currentUser.name,
|
|
@@ -679,6 +686,21 @@ async function submitBusiness() {
|
|
|
679
686
|
name: borrowTitle,
|
|
680
687
|
},
|
|
681
688
|
variables,
|
|
689
|
+
assignmentQueryParams: {
|
|
690
|
+
projectId: currentProject.id,
|
|
691
|
+
tenantId: currentTenant.id,
|
|
692
|
+
},
|
|
693
|
+
async onBeforeStart(startArgs) {
|
|
694
|
+
// 可执行同步校验,也可以 await 业务项目自己的表单弹窗。
|
|
695
|
+
const formData = await openBusinessForm()
|
|
696
|
+
if (!formData) return false
|
|
697
|
+
startArgs.variables = { ...startArgs.variables, ...formData }
|
|
698
|
+
return true
|
|
699
|
+
},
|
|
700
|
+
async onBeforeSend(context) {
|
|
701
|
+
// false:实例已经创建,但不打开审批人选择弹窗。
|
|
702
|
+
return validateBeforeSend(context)
|
|
703
|
+
},
|
|
682
704
|
onStarted(result) {
|
|
683
705
|
saveFlowRelation(result.processInstanceId)
|
|
684
706
|
},
|
|
@@ -687,15 +709,52 @@ async function submitBusiness() {
|
|
|
687
709
|
refreshBusinessList()
|
|
688
710
|
},
|
|
689
711
|
onClose() {
|
|
690
|
-
//
|
|
712
|
+
// 未发送就关闭弹窗时,运行时服务会撤销刚创建的流程实例。
|
|
691
713
|
},
|
|
692
714
|
onError(error) {
|
|
693
715
|
console.error(error.phase, error.message)
|
|
694
716
|
},
|
|
695
717
|
})
|
|
718
|
+
if (result === false) return
|
|
696
719
|
}
|
|
697
720
|
```
|
|
698
721
|
|
|
699
|
-
`start()` 返回 `
|
|
722
|
+
`onBeforeStart` 在首办节点查询和 `quickStart` 之前执行;返回 `false` 时 `start()` 返回 `false`,不会创建流程实例。`onBeforeSend` 在实例创建成功后、发送弹窗打开前执行;返回 `false` 时 `start()` 仍返回流程实例结果,但不会弹窗,并保留当前会话。之后调用 `await flowstream.getRuntimeService().open()` 会重新执行 `onBeforeSend`,通过后才打开弹窗;若决定放弃,调用 `close()` 会撤销该实例并释放会话。
|
|
723
|
+
|
|
724
|
+
两个前置钩子都支持 `boolean | Promise<boolean>`。因此业务项目需要“弹表单、校验通过后再启动”时,应让业务弹窗封装成 Promise,而不是由流程组件识别业务字段:
|
|
725
|
+
|
|
726
|
+
```ts
|
|
727
|
+
let finishBeforeStart: ((allowed: boolean) => void) | undefined
|
|
728
|
+
|
|
729
|
+
function waitForBusinessForm() {
|
|
730
|
+
businessDialogVisible.value = true
|
|
731
|
+
return new Promise<boolean>(resolve => {
|
|
732
|
+
finishBeforeStart = resolve
|
|
733
|
+
})
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
async function confirmBusinessForm() {
|
|
737
|
+
const valid = await businessFormRef.value?.validate().catch(() => false)
|
|
738
|
+
if (!valid) return
|
|
739
|
+
businessDialogVisible.value = false
|
|
740
|
+
finishBeforeStart?.(true)
|
|
741
|
+
finishBeforeStart = undefined
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
function cancelBusinessForm() {
|
|
745
|
+
businessDialogVisible.value = false
|
|
746
|
+
finishBeforeStart?.(false)
|
|
747
|
+
finishBeforeStart = undefined
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
await flowstream.getRuntimeService().start({
|
|
751
|
+
processDefinitionId,
|
|
752
|
+
draftUserId: currentUser.id,
|
|
753
|
+
draftUserName: currentUser.name,
|
|
754
|
+
onBeforeStart: waitForBusinessForm,
|
|
755
|
+
})
|
|
756
|
+
```
|
|
757
|
+
|
|
758
|
+
业务弹窗通过右上角关闭、路由离开或组件卸载时也必须 `resolve(false)`,避免 `start()` 一直处于等待状态。`singleAssignee` 默认为 `true`,也可在启动参数中传入 `dialogTitle`、`dialogWidth`、`defaultOpinion`、`bpmnXml` 和 `assignmentQueryParams`。
|
|
700
759
|
|
|
701
760
|
`quickStart()`、`getFirstHandleNodes()`、`nextSendNode()`、`nodeAssistant()` 和 `sendTask()` 仍作为底层 API 导出,供组件内部及高级扩展使用;普通业务项目应优先调用 `flowstream.getRuntimeService().start()`,不要自行复制流程编排。
|