提交 | 用户 | 时间
|
820397
|
1 |
// 初始化表单数据 |
H |
2 |
export function initListenerForm(listener) { |
9259c2
|
3 |
console.log(listener) |
820397
|
4 |
let self = { |
H |
5 |
...listener |
|
6 |
} |
|
7 |
if (listener.script) { |
|
8 |
self = { |
|
9 |
...listener, |
|
10 |
...listener.script, |
|
11 |
scriptType: listener.script.resource ? 'externalScript' : 'inlineScript' |
|
12 |
} |
|
13 |
} |
|
14 |
if (listener.event === 'timeout' && listener.eventDefinitions) { |
|
15 |
if (listener.eventDefinitions.length) { |
|
16 |
let k = '' |
|
17 |
for (const key in listener.eventDefinitions[0]) { |
|
18 |
console.log(listener.eventDefinitions, key) |
|
19 |
if (key.indexOf('time') !== -1) { |
|
20 |
k = key |
|
21 |
self.eventDefinitionType = key.replace('time', '').toLowerCase() |
|
22 |
} |
|
23 |
} |
|
24 |
console.log(k) |
|
25 |
self.eventTimeDefinitions = listener.eventDefinitions[0][k].body |
|
26 |
} |
|
27 |
} |
|
28 |
return self |
|
29 |
} |
|
30 |
|
|
31 |
export function initListenerType(listener) { |
9259c2
|
32 |
listener.id = listener.$attrs.id |
820397
|
33 |
let listenerType |
H |
34 |
if (listener.class) listenerType = 'classListener' |
|
35 |
if (listener.expression) listenerType = 'expressionListener' |
|
36 |
if (listener.delegateExpression) listenerType = 'delegateExpressionListener' |
|
37 |
if (listener.script) listenerType = 'scriptListener' |
|
38 |
return { |
|
39 |
...JSON.parse(JSON.stringify(listener)), |
|
40 |
...(listener.script ?? {}), |
|
41 |
listenerType: listenerType |
|
42 |
} |
|
43 |
} |
|
44 |
|
|
45 |
/** 将 ProcessListenerDO 转换成 initListenerForm 想同的 Form 对象 */ |
|
46 |
export function initListenerForm2(processListener) { |
|
47 |
if (processListener.valueType === 'class') { |
|
48 |
return { |
|
49 |
listenerType: 'classListener', |
|
50 |
class: processListener.value, |
|
51 |
event: processListener.event, |
|
52 |
fields: [] |
|
53 |
} |
|
54 |
} else if (processListener.valueType === 'expression') { |
|
55 |
return { |
|
56 |
listenerType: 'expressionListener', |
|
57 |
expression: processListener.value, |
|
58 |
event: processListener.event, |
|
59 |
fields: [] |
|
60 |
} |
|
61 |
} else if (processListener.valueType === 'delegateExpression') { |
|
62 |
return { |
|
63 |
listenerType: 'delegateExpressionListener', |
|
64 |
delegateExpression: processListener.value, |
|
65 |
event: processListener.event, |
|
66 |
fields: [] |
|
67 |
} |
|
68 |
} |
|
69 |
throw new Error('未知的监听器类型') |
|
70 |
} |
|
71 |
|
|
72 |
export const listenerType = { |
|
73 |
classListener: 'Java 类', |
|
74 |
expressionListener: '表达式', |
|
75 |
delegateExpressionListener: '代理表达式', |
|
76 |
scriptListener: '脚本' |
|
77 |
} |
|
78 |
|
|
79 |
export const eventType = { |
|
80 |
create: '创建', |
|
81 |
assignment: '指派', |
|
82 |
complete: '完成', |
|
83 |
delete: '删除', |
|
84 |
update: '更新', |
|
85 |
timeout: '超时' |
|
86 |
} |
|
87 |
|
|
88 |
export const fieldType = { |
|
89 |
string: '字符串', |
|
90 |
expression: '表达式' |
|
91 |
} |