diff --git a/src/components/bpmnProcessDesigner/package/designer/plugins/descriptor/flowableDescriptor.json b/src/components/bpmnProcessDesigner/package/designer/plugins/descriptor/flowableDescriptor.json index d1ca4a43..5544b2d0 100644 --- a/src/components/bpmnProcessDesigner/package/designer/plugins/descriptor/flowableDescriptor.json +++ b/src/components/bpmnProcessDesigner/package/designer/plugins/descriptor/flowableDescriptor.json @@ -1281,7 +1281,32 @@ "isBody": true } ] + }, + { + "name": "ButtonsSetting", + "superClass": ["Element"], + "meta": { + "allowedIn": ["bpmn:UserTask"] + }, + "properties": [ + { + "name": "flowable:id", + "type": "Integer", + "isAttr": true + }, + { + "name": "flowable:enable", + "type": "Boolean", + "isAttr": true + }, + { + "name": "flowable:displayName", + "type": "String", + "isAttr": true + } + ] } + ], "emumerations": [] } diff --git a/src/components/bpmnProcessDesigner/package/penal/custom-config/ElementCustomConfig.vue b/src/components/bpmnProcessDesigner/package/penal/custom-config/ElementCustomConfig.vue index 7008e3f3..9cf7e966 100644 --- a/src/components/bpmnProcessDesigner/package/penal/custom-config/ElementCustomConfig.vue +++ b/src/components/bpmnProcessDesigner/package/penal/custom-config/ElementCustomConfig.vue @@ -2,6 +2,7 @@ 1. 审批人与提交人为同一人时 2. 审批人拒绝时 3. 审批人为空时 + 4. 操作按钮 --> @@ -74,6 +75,35 @@ + + 操作按钮 + + + 操作按钮 + 显示名称 + 启用 + + + {{ OPERATION_BUTTON_NAME.get(item.id) }} + + + {{ item.displayName }} + + + + + + @@ -83,7 +113,9 @@ import { RejectHandlerType, REJECT_HANDLER_TYPES, ASSIGN_EMPTY_HANDLER_TYPES, - AssignEmptyHandlerType + AssignEmptyHandlerType, + OPERATION_BUTTON_NAME, + DEFAULT_BUTTON_SETTING } from '@/components/SimpleProcessDesignerV2/src/consts' import * as UserApi from '@/api/system/user' @@ -111,6 +143,11 @@ const assignEmptyHandlerType = ref() const assignEmptyUserIdsEl = ref() const assignEmptyUserIds = ref() +// 操作按钮 +const buttonsSettingEl = ref() +const { buttonsSetting, btnDisplayNameEdit, changeBtnDisplayName, btnDisplayNameBlurEvent } = + useButtonsSetting() + const elExtensionElements = ref() const otherExtensions = ref() const bpmnElement = ref() @@ -165,6 +202,22 @@ const resetCustomConfigList = () => { return num > Number.MAX_SAFE_INTEGER || num < -Number.MAX_SAFE_INTEGER ? item : num }) + // 操作按钮 + buttonsSettingEl.value = elExtensionElements.value.values?.filter( + (ex) => ex.$type === `${prefix}:ButtonsSetting` + ) + if (buttonsSettingEl.value.length === 0) { + DEFAULT_BUTTON_SETTING.forEach((item) => { + buttonsSettingEl.value.push( + bpmnInstances().moddle.create(`${prefix}:ButtonsSetting`, { + 'flowable:id': item.id, + 'flowable:displayName': item.displayName, + 'flowable:enable': item.enable + }) + ) + }) + } + // 保留剩余扩展元素,便于后面更新该元素对应属性 otherExtensions.value = elExtensionElements.value.values?.filter( @@ -173,7 +226,8 @@ const resetCustomConfigList = () => { ex.$type !== `${prefix}:RejectHandlerType` && ex.$type !== `${prefix}:RejectReturnTaskId` && ex.$type !== `${prefix}:AssignEmptyHandlerType` && - ex.$type !== `${prefix}:AssignEmptyUserIds` + ex.$type !== `${prefix}:AssignEmptyUserIds` && + ex.$type !== `${prefix}:ButtonsSetting` ) ?? [] // 更新元素扩展属性,避免后续报错 @@ -221,7 +275,8 @@ const updateElementExtensions = () => { rejectHandlerTypeEl.value, returnNodeIdEl.value, assignEmptyHandlerTypeEl.value, - assignEmptyUserIdsEl.value + assignEmptyUserIdsEl.value, + ...buttonsSettingEl.value ] }) bpmnInstances().modeling.updateProperties(toRaw(bpmnElement.value), { @@ -284,9 +339,114 @@ function findAllPredecessorsExcludingStart(elementId, modeler) { return Array.from(predecessors) // 返回前置节点数组 } +function useButtonsSetting() { + const buttonsSetting = ref() + // 操作按钮显示名称可编辑 + const btnDisplayNameEdit = ref([]) + const changeBtnDisplayName = (index: number) => { + btnDisplayNameEdit.value[index] = true + } + const btnDisplayNameBlurEvent = (index: number) => { + btnDisplayNameEdit.value[index] = false + const buttonItem = buttonsSetting.value![index] + buttonItem.displayName = buttonItem.displayName || OPERATION_BUTTON_NAME.get(buttonItem.id)! + } + return { + buttonsSetting, + btnDisplayNameEdit, + changeBtnDisplayName, + btnDisplayNameBlurEvent + } +} + const userOptions = ref([]) // 用户列表 onMounted(async () => { // 获得用户列表 userOptions.value = await UserApi.getSimpleUserList() }) + +