提交 | 用户 | 时间
|
9259c2
|
1 |
<template> |
H |
2 |
<div> |
|
3 |
<el-form-item label="执行类型" key="executeType"> |
|
4 |
<el-select v-model="serviceTaskForm.executeType"> |
|
5 |
<el-option label="Java类" value="class" /> |
|
6 |
<el-option label="表达式" value="expression" /> |
|
7 |
<el-option label="代理表达式" value="delegateExpression" /> |
|
8 |
</el-select> |
|
9 |
</el-form-item> |
|
10 |
<el-form-item |
|
11 |
v-if="serviceTaskForm.executeType === 'class'" |
|
12 |
label="Java类" |
|
13 |
prop="class" |
|
14 |
key="execute-class" |
|
15 |
> |
|
16 |
<el-input v-model="serviceTaskForm.class" clearable @change="updateElementTask" /> |
|
17 |
</el-form-item> |
|
18 |
<el-form-item |
|
19 |
v-if="serviceTaskForm.executeType === 'expression'" |
|
20 |
label="表达式" |
|
21 |
prop="expression" |
|
22 |
key="execute-expression" |
|
23 |
> |
|
24 |
<el-input v-model="serviceTaskForm.expression" clearable @change="updateElementTask" /> |
|
25 |
</el-form-item> |
|
26 |
<el-form-item |
|
27 |
v-if="serviceTaskForm.executeType === 'delegateExpression'" |
|
28 |
label="代理表达式" |
|
29 |
prop="delegateExpression" |
|
30 |
key="execute-delegate" |
|
31 |
> |
|
32 |
<el-input v-model="serviceTaskForm.delegateExpression" clearable @change="updateElementTask" /> |
|
33 |
</el-form-item> |
|
34 |
</div> |
|
35 |
</template> |
|
36 |
|
|
37 |
<script lang="ts" setup> |
|
38 |
defineOptions({ name: 'ServiceTask' }) |
|
39 |
const props = defineProps({ |
|
40 |
id: String, |
|
41 |
type: String |
|
42 |
}) |
|
43 |
|
|
44 |
const defaultTaskForm = ref({ |
|
45 |
executeType: '', |
|
46 |
class: '', |
|
47 |
expression: '', |
|
48 |
delegateExpression: '' |
|
49 |
}) |
|
50 |
|
|
51 |
const serviceTaskForm = ref<any>({}) |
|
52 |
const bpmnElement = ref() |
|
53 |
|
|
54 |
const bpmnInstances = () => (window as any)?.bpmnInstances |
|
55 |
|
|
56 |
const resetTaskForm = () => { |
|
57 |
for (let key in defaultTaskForm.value) { |
|
58 |
let value = bpmnElement.value?.businessObject[key] || defaultTaskForm.value[key] |
|
59 |
serviceTaskForm.value[key] = value |
|
60 |
if (value) { |
|
61 |
serviceTaskForm.value.executeType = key |
|
62 |
} |
|
63 |
} |
|
64 |
} |
|
65 |
|
|
66 |
const updateElementTask = () => { |
|
67 |
let taskAttr = Object.create(null); |
|
68 |
const type = serviceTaskForm.value.executeType; |
|
69 |
for (let key in serviceTaskForm.value) { |
|
70 |
if (key !== 'executeType' && key !== type) taskAttr[key] = null; |
|
71 |
} |
|
72 |
taskAttr[type] = serviceTaskForm.value[type] || ""; |
|
73 |
bpmnInstances().modeling.updateProperties(toRaw(bpmnElement.value), taskAttr) |
|
74 |
} |
|
75 |
|
|
76 |
onBeforeUnmount(() => { |
|
77 |
bpmnElement.value = null |
|
78 |
}) |
|
79 |
|
|
80 |
watch( |
|
81 |
() => props.id, |
|
82 |
() => { |
|
83 |
bpmnElement.value = bpmnInstances().bpmnElement |
|
84 |
nextTick(() => { |
|
85 |
resetTaskForm() |
|
86 |
}) |
|
87 |
}, |
|
88 |
{ immediate: true } |
|
89 |
) |
|
90 |
|
|
91 |
</script> |