Skip to content

Commit 41f8f0c

Browse files
committed
feat: bpm设计器适配Simple设计器,操作按钮
1 parent 6041a6e commit 41f8f0c

File tree

2 files changed

+188
-3
lines changed

2 files changed

+188
-3
lines changed

src/components/bpmnProcessDesigner/package/designer/plugins/descriptor/flowableDescriptor.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,7 +1281,32 @@
12811281
"isBody": true
12821282
}
12831283
]
1284+
},
1285+
{
1286+
"name": "ButtonsSetting",
1287+
"superClass": ["Element"],
1288+
"meta": {
1289+
"allowedIn": ["bpmn:UserTask"]
1290+
},
1291+
"properties": [
1292+
{
1293+
"name": "flowable:id",
1294+
"type": "Integer",
1295+
"isAttr": true
1296+
},
1297+
{
1298+
"name": "flowable:enable",
1299+
"type": "Boolean",
1300+
"isAttr": true
1301+
},
1302+
{
1303+
"name": "flowable:displayName",
1304+
"type": "String",
1305+
"isAttr": true
1306+
}
1307+
]
12841308
}
1309+
12851310
],
12861311
"emumerations": []
12871312
}

src/components/bpmnProcessDesigner/package/penal/custom-config/ElementCustomConfig.vue

Lines changed: 163 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
1. 审批人与提交人为同一人时
33
2. 审批人拒绝时
44
3. 审批人为空时
5+
4. 操作按钮
56
-->
67
<template>
78
<div class="panel-tab__content">
@@ -74,6 +75,35 @@
7475
</div>
7576
</div>
7677
</el-radio-group>
78+
79+
<el-divider content-position="left">操作按钮</el-divider>
80+
<div class="button-setting-pane">
81+
<div class="button-setting-title">
82+
<div class="button-title-label">操作按钮</div>
83+
<div class="pl-4 button-title-label">显示名称</div>
84+
<div class="button-title-label">启用</div>
85+
</div>
86+
<div class="button-setting-item" v-for="(item, index) in buttonsSettingEl" :key="index">
87+
<div class="button-setting-item-label"> {{ OPERATION_BUTTON_NAME.get(item.id) }} </div>
88+
<div class="button-setting-item-label">
89+
<input
90+
type="text"
91+
class="editable-title-input"
92+
@blur="btnDisplayNameBlurEvent(index)"
93+
v-mountedFocus
94+
v-model="item.displayName"
95+
:placeholder="item.displayName"
96+
v-if="btnDisplayNameEdit[index]"
97+
/>
98+
<el-button v-else text @click="changeBtnDisplayName(index)"
99+
>{{ item.displayName }} &nbsp;<Icon icon="ep:edit"
100+
/></el-button>
101+
</div>
102+
<div class="button-setting-item-label">
103+
<el-switch v-model="item.enable" />
104+
</div>
105+
</div>
106+
</div>
77107
</div>
78108
</template>
79109

@@ -83,7 +113,9 @@ import {
83113
RejectHandlerType,
84114
REJECT_HANDLER_TYPES,
85115
ASSIGN_EMPTY_HANDLER_TYPES,
86-
AssignEmptyHandlerType
116+
AssignEmptyHandlerType,
117+
OPERATION_BUTTON_NAME,
118+
DEFAULT_BUTTON_SETTING
87119
} from '@/components/SimpleProcessDesignerV2/src/consts'
88120
import * as UserApi from '@/api/system/user'
89121
@@ -111,6 +143,11 @@ const assignEmptyHandlerType = ref()
111143
const assignEmptyUserIdsEl = ref()
112144
const assignEmptyUserIds = ref()
113145
146+
// 操作按钮
147+
const buttonsSettingEl = ref()
148+
const { buttonsSetting, btnDisplayNameEdit, changeBtnDisplayName, btnDisplayNameBlurEvent } =
149+
useButtonsSetting()
150+
114151
const elExtensionElements = ref()
115152
const otherExtensions = ref()
116153
const bpmnElement = ref()
@@ -165,6 +202,22 @@ const resetCustomConfigList = () => {
165202
return num > Number.MAX_SAFE_INTEGER || num < -Number.MAX_SAFE_INTEGER ? item : num
166203
})
167204
205+
// 操作按钮
206+
buttonsSettingEl.value = elExtensionElements.value.values?.filter(
207+
(ex) => ex.$type === `${prefix}:ButtonsSetting`
208+
)
209+
if (buttonsSettingEl.value.length === 0) {
210+
DEFAULT_BUTTON_SETTING.forEach((item) => {
211+
buttonsSettingEl.value.push(
212+
bpmnInstances().moddle.create(`${prefix}:ButtonsSetting`, {
213+
'flowable:id': item.id,
214+
'flowable:displayName': item.displayName,
215+
'flowable:enable': item.enable
216+
})
217+
)
218+
})
219+
}
220+
168221
// 保留剩余扩展元素,便于后面更新该元素对应属性
169222
otherExtensions.value =
170223
elExtensionElements.value.values?.filter(
@@ -173,7 +226,8 @@ const resetCustomConfigList = () => {
173226
ex.$type !== `${prefix}:RejectHandlerType` &&
174227
ex.$type !== `${prefix}:RejectReturnTaskId` &&
175228
ex.$type !== `${prefix}:AssignEmptyHandlerType` &&
176-
ex.$type !== `${prefix}:AssignEmptyUserIds`
229+
ex.$type !== `${prefix}:AssignEmptyUserIds` &&
230+
ex.$type !== `${prefix}:ButtonsSetting`
177231
) ?? []
178232
179233
// 更新元素扩展属性,避免后续报错
@@ -221,7 +275,8 @@ const updateElementExtensions = () => {
221275
rejectHandlerTypeEl.value,
222276
returnNodeIdEl.value,
223277
assignEmptyHandlerTypeEl.value,
224-
assignEmptyUserIdsEl.value
278+
assignEmptyUserIdsEl.value,
279+
...buttonsSettingEl.value
225280
]
226281
})
227282
bpmnInstances().modeling.updateProperties(toRaw(bpmnElement.value), {
@@ -284,9 +339,114 @@ function findAllPredecessorsExcludingStart(elementId, modeler) {
284339
return Array.from(predecessors) // 返回前置节点数组
285340
}
286341
342+
function useButtonsSetting() {
343+
const buttonsSetting = ref<ButtonSetting[]>()
344+
// 操作按钮显示名称可编辑
345+
const btnDisplayNameEdit = ref<boolean[]>([])
346+
const changeBtnDisplayName = (index: number) => {
347+
btnDisplayNameEdit.value[index] = true
348+
}
349+
const btnDisplayNameBlurEvent = (index: number) => {
350+
btnDisplayNameEdit.value[index] = false
351+
const buttonItem = buttonsSetting.value![index]
352+
buttonItem.displayName = buttonItem.displayName || OPERATION_BUTTON_NAME.get(buttonItem.id)!
353+
}
354+
return {
355+
buttonsSetting,
356+
btnDisplayNameEdit,
357+
changeBtnDisplayName,
358+
btnDisplayNameBlurEvent
359+
}
360+
}
361+
287362
const userOptions = ref<UserApi.UserVO[]>([]) // 用户列表
288363
onMounted(async () => {
289364
// 获得用户列表
290365
userOptions.value = await UserApi.getSimpleUserList()
291366
})
292367
</script>
368+
369+
<style lang="scss" scoped>
370+
.button-setting-pane {
371+
display: flex;
372+
flex-direction: column;
373+
font-size: 14px;
374+
margin-top: 8px;
375+
376+
.button-setting-desc {
377+
padding-right: 8px;
378+
margin-bottom: 16px;
379+
font-size: 16px;
380+
font-weight: 700;
381+
}
382+
383+
.button-setting-title {
384+
display: flex;
385+
justify-content: space-between;
386+
align-items: center;
387+
height: 45px;
388+
padding-left: 12px;
389+
background-color: #f8fafc0a;
390+
border: 1px solid #1f38581a;
391+
392+
& > :first-child {
393+
width: 100px !important;
394+
text-align: left !important;
395+
}
396+
397+
& > :last-child {
398+
text-align: center !important;
399+
}
400+
401+
.button-title-label {
402+
width: 150px;
403+
font-size: 13px;
404+
font-weight: 700;
405+
color: #000;
406+
text-align: left;
407+
}
408+
}
409+
410+
.button-setting-item {
411+
align-items: center;
412+
display: flex;
413+
justify-content: space-between;
414+
height: 38px;
415+
padding-left: 12px;
416+
border: 1px solid #1f38581a;
417+
border-top: 0;
418+
419+
& > :first-child {
420+
width: 100px !important;
421+
}
422+
423+
& > :last-child {
424+
text-align: center !important;
425+
}
426+
427+
.button-setting-item-label {
428+
width: 150px;
429+
overflow: hidden;
430+
text-align: left;
431+
text-overflow: ellipsis;
432+
white-space: nowrap;
433+
}
434+
435+
.editable-title-input {
436+
height: 24px;
437+
max-width: 130px;
438+
margin-left: 4px;
439+
line-height: 24px;
440+
border: 1px solid #d9d9d9;
441+
border-radius: 4px;
442+
transition: all 0.3s;
443+
444+
&:focus {
445+
border-color: #40a9ff;
446+
outline: 0;
447+
box-shadow: 0 0 0 2px rgb(24 144 255 / 20%);
448+
}
449+
}
450+
}
451+
}
452+
</style>

0 commit comments

Comments
 (0)