adtec-core-package 3.1.2 → 3.1.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/package.json
CHANGED
|
@@ -123,21 +123,35 @@ watchEffect(() => {
|
|
|
123
123
|
}
|
|
124
124
|
if ($props.node.type === 'jump') {
|
|
125
125
|
const flowKeys = (_inject.processInst.value.flows ?? []).map((x) => x.taskDefKey)
|
|
126
|
-
const
|
|
127
|
-
const
|
|
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
|
|
128
130
|
|
|
129
|
-
if (
|
|
130
|
-
// jump
|
|
131
|
-
|
|
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)) {
|
|
132
135
|
nodeClass.value = 'node-complete'
|
|
133
136
|
headColor.value = '#18AD43'
|
|
134
137
|
} else {
|
|
135
138
|
nodeClass.value = 'node-unstart'
|
|
136
139
|
headColor.value = '#9B9EA1'
|
|
137
140
|
}
|
|
138
|
-
} else
|
|
139
|
-
const
|
|
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') {
|
|
141
155
|
// 线性审批后的 jump:父审批已完成即可
|
|
142
156
|
if (
|
|
143
157
|
_inject.processInst.value.hisTasks?.some((x) => x.taskDefKey == $props.node.pid) &&
|
|
@@ -146,16 +160,6 @@ watchEffect(() => {
|
|
|
146
160
|
nodeClass.value = 'node-complete'
|
|
147
161
|
headColor.value = '#18AD43'
|
|
148
162
|
}
|
|
149
|
-
} else if (parentNode?.type === 'exclusive' || parentNode?.type === 'inclusive') {
|
|
150
|
-
// 网关主干 default jump:默认条件连线已执行时高亮
|
|
151
|
-
const defaultCondition = (parentNode as BranchNode).children?.find((c) => c.def)
|
|
152
|
-
if (defaultCondition && flowKeys.includes(defaultCondition.id)) {
|
|
153
|
-
nodeClass.value = 'node-complete'
|
|
154
|
-
headColor.value = '#18AD43'
|
|
155
|
-
} else {
|
|
156
|
-
nodeClass.value = 'node-unstart'
|
|
157
|
-
headColor.value = '#9B9EA1'
|
|
158
|
-
}
|
|
159
163
|
}
|
|
160
164
|
}
|
|
161
165
|
}
|
|
@@ -0,0 +1,103 @@
|
|
|
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
|
+
}
|
|
66
|
+
|
|
67
|
+
function extractParameterArray(value: unknown): IParameter[] | undefined {
|
|
68
|
+
if (isParameterArray(value)) return value
|
|
69
|
+
if (isPlainObject(value)) {
|
|
70
|
+
const vals = Object.values(value)
|
|
71
|
+
if (vals.length > 0 && vals.every(isParameterItem)) {
|
|
72
|
+
return vals as IParameter[]
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return undefined
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* 从 route.meta.params(数组 / 对象 / 历史 spread 损坏)或 route.query 读取单个参数。
|
|
80
|
+
* 页面侧请用此函数替代 params.find(c => c.code === 'xxx')?.value
|
|
81
|
+
*/
|
|
82
|
+
export function getRouteMetaParam(
|
|
83
|
+
params: unknown,
|
|
84
|
+
code: string,
|
|
85
|
+
query?: Record<string, unknown>,
|
|
86
|
+
): unknown {
|
|
87
|
+
const paramList = extractParameterArray(params)
|
|
88
|
+
if (paramList) {
|
|
89
|
+
const item = paramList.find((c) => c.code === code)
|
|
90
|
+
if (item && item.value !== undefined && item.value !== null && item.value !== '') {
|
|
91
|
+
return item.value
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (isPlainObject(params) && code in params) {
|
|
95
|
+
const direct = params[code]
|
|
96
|
+
if (direct !== undefined && direct !== null && direct !== '') return direct
|
|
97
|
+
}
|
|
98
|
+
if (query && code in query) {
|
|
99
|
+
const q = query[code]
|
|
100
|
+
if (q !== undefined && q !== null && q !== '') return q
|
|
101
|
+
}
|
|
102
|
+
return undefined
|
|
103
|
+
}
|