Skip to content

Commit 70c3a09

Browse files
committed
Merge remote-tracking branch 'xunchangguo/bpm/serviceTask' into feature/bpm
2 parents 3c7526d + f545dcc commit 70c3a09

File tree

8 files changed

+114
-6
lines changed

8 files changed

+114
-6
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@
9696
"@vitejs/plugin-vue": "^5.0.4",
9797
"@vitejs/plugin-vue-jsx": "^3.1.0",
9898
"autoprefixer": "^10.4.17",
99-
"bpmn-js": "8.10.0",
100-
"bpmn-js-properties-panel": "0.46.0",
99+
"bpmn-js": "^17.9.2",
100+
"bpmn-js-properties-panel": "5.23.0",
101101
"consola": "^3.2.3",
102102
"eslint": "^8.57.0",
103103
"eslint-config-prettier": "^9.1.0",

src/components/bpmnProcessDesigner/package/designer/plugins/palette/CustomPalette.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,12 @@ F.prototype.getPaletteEntries = function () {
165165
'bpmn-icon-user-task',
166166
translate('Create User Task')
167167
),
168+
'create.service-task': createAction(
169+
'bpmn:ServiceTask',
170+
'activity',
171+
'bpmn-icon-service',
172+
translate('Create Service Task')
173+
),
168174
'create.data-object': createAction(
169175
'bpmn:DataObjectReference',
170176
'data-object',

src/components/bpmnProcessDesigner/package/designer/plugins/palette/paletteProvider.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,12 @@ PaletteProvider.prototype.getPaletteEntries = function () {
171171
'bpmn-icon-user-task',
172172
translate('Create User Task')
173173
),
174+
'create.service-task': createAction(
175+
'bpmn:ServiceTask',
176+
'activity',
177+
'bpmn-icon-service',
178+
translate('Create Service Task')
179+
),
174180
'create.data-object': createAction(
175181
'bpmn:DataObjectReference',
176182
'data-object',

src/components/bpmnProcessDesigner/package/designer/plugins/translate/zh.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export default {
5656
'Create EndEvent': '创建结束事件',
5757
'Create Task': '创建任务',
5858
'Create User Task': '创建用户任务',
59+
'Create Service Task': '创建服务任务',
5960
'Create Gateway': '创建网关',
6061
'Create DataObjectReference': '创建数据对象',
6162
'Create DataStoreReference': '创建数据存储',

src/components/bpmnProcessDesigner/package/penal/PropertiesPanel.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@
2727
<element-form :id="elementId" :type="elementType" />
2828
</el-collapse-item>
2929
<el-collapse-item name="task" v-if="elementType.indexOf('Task') !== -1" key="task">
30-
<template #title><Icon icon="ep:checked" />任务(审批人)</template>
30+
<template #title><Icon icon="ep:checked" />任务</template>
3131
<element-task :id="elementId" :type="elementType" />
3232
</el-collapse-item>
3333
<el-collapse-item
3434
name="multiInstance"
35-
v-if="elementType.indexOf('Task') !== -1"
35+
v-if="elementType.indexOf('Task') !== -1 && elementType !== 'UserTask'"
3636
key="multiInstance"
3737
>
3838
<template #title><Icon icon="ep:help-filled" />多实例(会签配置)</template>

src/components/bpmnProcessDesigner/package/penal/properties/ElementProperties.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ const attributeFormRef = ref()
7575
const bpmnInstances = () => (window as any)?.bpmnInstances
7676
7777
const resetAttributesList = () => {
78-
console.log(window, 'windowwindowwindowwindowwindowwindowwindow')
7978
bpmnElement.value = bpmnInstances().bpmnElement
8079
otherExtensionList.value = [] // 其他扩展配置
8180
bpmnElementProperties.value =
@@ -85,7 +84,7 @@ const resetAttributesList = () => {
8584
otherExtensionList.value.push(ex)
8685
}
8786
return ex.$type === `${prefix}:Properties`
88-
}) ?? []
87+
}) ?? [];
8988
9089
// 保存所有的 扩展属性字段
9190
bpmnElementPropertyList.value = bpmnElementProperties.value.reduce(

src/components/bpmnProcessDesigner/package/penal/task/ElementTask.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
<script lang="ts" setup>
3232
import UserTask from './task-components/UserTask.vue'
33+
import ServiceTask from './task-components/ServiceTask.vue'
3334
import ScriptTask from './task-components/ScriptTask.vue'
3435
import ReceiveTask from './task-components/ReceiveTask.vue'
3536
@@ -50,6 +51,7 @@ const installedComponent = ref({
5051
// 接收消息任务,需要在全局下插入新的消息实例,并在该节点下的 messageRef 属性绑定该实例
5152
// 发送任务、服务任务、业务规则任务共用一个相同配置
5253
UserTask: 'UserTask', // 用户任务配置
54+
ServiceTask: 'ServiceTask', // 服务任务配置
5355
ScriptTask: 'ScriptTask', // 脚本任务配置
5456
ReceiveTask: 'ReceiveTask' // 消息接收任务
5557
})
@@ -82,6 +84,9 @@ watch(
8284
if (props.type == installedComponent.value.UserTask) {
8385
witchTaskComponent.value = UserTask
8486
}
87+
if (props.type == installedComponent.value.ServiceTask) {
88+
witchTaskComponent.value = ServiceTask
89+
}
8590
if (props.type == installedComponent.value.ScriptTask) {
8691
witchTaskComponent.value = ScriptTask
8792
}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<template>
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>

0 commit comments

Comments
 (0)