adtec-core-package 3.1.1 → 3.1.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adtec-core-package",
3
- "version": "3.1.1",
3
+ "version": "3.1.3",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "exports": {
@@ -152,6 +152,7 @@ provide('flowDesign', {
152
152
  nodesError: nodesError,
153
153
  getTaskNodes: getTaskNodes,
154
154
  getParentNodes: getParentNodes,
155
+ getPathNodes: (id: string) => getPathNodes(id, props.process, []),
155
156
  addFormItem: addFormItem,
156
157
  deleteFormItem: deleteFormItem,
157
158
  getNodeById: getNodeById,
@@ -1,5 +1,5 @@
1
1
  <script setup lang="ts">
2
- import type { ErrorInfo, FlowNode, NodeType } from './type'
2
+ import type { BranchNode, ErrorInfo, FlowNode, NodeType } from './type'
3
3
  import { ClickOutside as vClickOutside, type InputInstance } from 'element-plus'
4
4
  import Add from './Add.vue'
5
5
  import { computed, inject, nextTick, ref, type Ref, watchEffect } from 'vue'
@@ -10,6 +10,8 @@ const _inject = inject<{
10
10
  readOnly?: Ref<boolean>
11
11
  nodesError: Ref<Recordable<ErrorInfo[]>>
12
12
  processInst: Ref<IWfProcessInstVo>
13
+ getNodeById?: (id: string) => FlowNode | undefined
14
+ getPathNodes?: (id: string) => FlowNode[]
13
15
  }>('flowDesign', {
14
16
  readOnly: ref(false),
15
17
  nodesError: ref({}),
@@ -120,15 +122,45 @@ watchEffect(() => {
120
122
  headColor.value = '#9B9EA1'
121
123
  }
122
124
  if ($props.node.type === 'jump') {
123
- //jump节点若pid完成,则其也完成
124
- if (
125
- $props.node.pid &&
126
- ((_inject.processInst.value.hisTasks?.some((x) => x.taskDefKey == $props.node.pid) &&
127
- !_inject.processInst.value.activeTasks?.some((x) => x.taskDefKey == $props.node.pid)) ||
128
- _inject.processInst.value.flows?.some((x) => x.taskDefKey == $props.node.pid))
129
- ) {
130
- nodeClass.value = 'node-complete'
131
- headColor.value = '#18AD43'
125
+ const flowKeys = (_inject.processInst.value.flows ?? []).map((x) => x.taskDefKey)
126
+ const parentNode = $props.node.pid ? _inject.getNodeById?.($props.node.pid) : undefined
127
+ const isGatewayDefaultTrunkJump =
128
+ (parentNode?.type === 'exclusive' || parentNode?.type === 'inclusive') &&
129
+ (parentNode as BranchNode).child?.id === $props.node.id
130
+
131
+ if (isGatewayDefaultTrunkJump) {
132
+ // 网关主干 jump(exclusive.child):仅以 def 默认条件 sequenceFlow 是否执行判断
133
+ const defaultCondition = (parentNode as BranchNode).children?.find((c) => c.def)
134
+ if (defaultCondition && flowKeys.includes(defaultCondition.id)) {
135
+ nodeClass.value = 'node-complete'
136
+ headColor.value = '#18AD43'
137
+ } else {
138
+ nodeClass.value = 'node-unstart'
139
+ headColor.value = '#9B9EA1'
140
+ }
141
+ } else {
142
+ const pathNodes = _inject.getPathNodes?.($props.node.id) ?? []
143
+ const parentCondition = [...pathNodes].reverse().find((x) => x.type === 'condition')
144
+
145
+ if (parentCondition) {
146
+ // jump 在 BPMN 中仅为连线,以所属条件分支的 sequenceFlow 是否执行判断
147
+ if (flowKeys.includes(parentCondition.id)) {
148
+ nodeClass.value = 'node-complete'
149
+ headColor.value = '#18AD43'
150
+ } else {
151
+ nodeClass.value = 'node-unstart'
152
+ headColor.value = '#9B9EA1'
153
+ }
154
+ } else if (parentNode?.type === 'approval') {
155
+ // 线性审批后的 jump:父审批已完成即可
156
+ if (
157
+ _inject.processInst.value.hisTasks?.some((x) => x.taskDefKey == $props.node.pid) &&
158
+ !_inject.processInst.value.activeTasks?.some((x) => x.taskDefKey == $props.node.pid)
159
+ ) {
160
+ nodeClass.value = 'node-complete'
161
+ headColor.value = '#18AD43'
162
+ }
163
+ }
132
164
  }
133
165
  }
134
166
  }
@@ -0,0 +1,65 @@
1
+ import type { IParameter } from '../interface/Message'
2
+
3
+ function isPlainObject(value: unknown): value is Record<string, unknown> {
4
+ return typeof value === 'object' && value !== null && !Array.isArray(value)
5
+ }
6
+
7
+ function isParameterItem(value: unknown): value is IParameter {
8
+ return !!value && typeof value === 'object' && 'code' in value
9
+ }
10
+
11
+ function isParameterArray(value: unknown): value is IParameter[] {
12
+ return Array.isArray(value) && value.every(isParameterItem)
13
+ }
14
+
15
+ /** RouterChangeBus 等场景会传入空对象,不应覆盖已有 params */
16
+ function isEmptyPlainObject(value: unknown): boolean {
17
+ return isPlainObject(value) && Object.keys(value).length === 0
18
+ }
19
+
20
+ function objectToParameterArray(obj: Record<string, unknown>): IParameter[] {
21
+ return Object.entries(obj).map(([code, value]) => ({ code, value }))
22
+ }
23
+
24
+ function mergeParameterArrays(base: IParameter[], incoming: IParameter[]): IParameter[] {
25
+ const map = new Map<string, IParameter>()
26
+ for (const item of base) {
27
+ if (item?.code != null) map.set(String(item.code), item)
28
+ }
29
+ for (const item of incoming) {
30
+ if (item?.code != null) map.set(String(item.code), item)
31
+ }
32
+ return Array.from(map.values())
33
+ }
34
+
35
+ /**
36
+ * 合并 route.meta.params,兼容两种历史格式:
37
+ * - IParameter[]:工作流 / openMenuByRandom(页面用 .find(c => c.code))
38
+ * - Record:embed / 对象 query(页面用 params.id 等)
39
+ */
40
+ export function mergeRouteMetaParams(existing: unknown, incoming: unknown): unknown {
41
+ if (incoming === undefined || incoming === null) return existing
42
+ if (isEmptyPlainObject(incoming)) return existing
43
+
44
+ if (Array.isArray(incoming)) {
45
+ if (isParameterArray(existing)) {
46
+ return mergeParameterArrays(existing, incoming)
47
+ }
48
+ return incoming
49
+ }
50
+
51
+ if (isPlainObject(incoming)) {
52
+ if (isParameterArray(existing)) {
53
+ return mergeParameterArrays(existing, objectToParameterArray(incoming))
54
+ }
55
+ const base = isPlainObject(existing) ? existing : {}
56
+ return { ...base, ...incoming }
57
+ }
58
+
59
+ return incoming
60
+ }
61
+
62
+ /** openMenu 仅对含键的普通对象写入 router.query(数组不走 query) */
63
+ export function shouldPushRouteQueryParams(params: unknown): params is Record<string, unknown> {
64
+ return isPlainObject(params) && Object.keys(params).length > 0
65
+ }