From ca22cdd5550cfa0defb0f430c538698182cdaec1 Mon Sep 17 00:00:00 2001 From: 潘志宝 <979469083@qq.com> Date: 星期一, 30 十二月 2024 16:42:49 +0800 Subject: [PATCH] Merge branch 'master' of http://dlindusit.com:53929/r/iailab-plat-ui-vue3 --- src/components/bpmnProcessDesigner/package/penal/multi-instance/ElementMultiInstance.vue | 139 ++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 134 insertions(+), 5 deletions(-) diff --git a/src/components/bpmnProcessDesigner/package/penal/multi-instance/ElementMultiInstance.vue b/src/components/bpmnProcessDesigner/package/penal/multi-instance/ElementMultiInstance.vue index 7cd16f7..de2fb0d 100644 --- a/src/components/bpmnProcessDesigner/package/penal/multi-instance/ElementMultiInstance.vue +++ b/src/components/bpmnProcessDesigner/package/penal/multi-instance/ElementMultiInstance.vue @@ -1,6 +1,30 @@ <template> <div class="panel-tab__content"> - <el-form label-width="90px"> + <el-radio-group v-model="approveMethod" @change="onApproveMethodChange"> + <div class="flex-col"> + <div v-for="(item, index) in APPROVE_METHODS" :key="index"> + <el-radio :value="item.value" :label="item.value"> + {{ item.label }} + </el-radio> + <el-form-item prop="approveRatio"> + <el-input-number + v-model="approveRatio" + :min="10" + :max="100" + :step="10" + size="small" + v-if=" + item.value === ApproveMethodType.APPROVE_BY_RATIO && + approveMethod === ApproveMethodType.APPROVE_BY_RATIO + " + @change="onApproveRatioChange" + /> + </el-form-item> + </div> + </div> + </el-radio-group> + <!-- 与Simple设计器配置合并,保留以前的代码 --> + <el-form label-width="90px" style="display: none"> <el-form-item label="快捷配置"> <el-button size="small" @click="changeConfig('依次审批')">依次审批</el-button> <el-button size="small" @click="changeConfig('会签')">会签</el-button> @@ -76,11 +100,14 @@ </template> <script lang="ts" setup> +import { ApproveMethodType, APPROVE_METHODS } from '@/components/SimpleProcessDesignerV2/src/consts' + defineOptions({ name: 'ElementMultiInstance' }) const props = defineProps({ businessObject: Object, - type: String + type: String, + id: String }) const prefix = inject('prefix') const loopCharacteristics = ref('') @@ -267,16 +294,118 @@ } } +/** + * -----新版本多实例----- + */ +const approveMethod = ref() +const approveRatio = ref(100) +const otherExtensions = ref() +const getElementLoopNew = () => { + const extensionElements = + bpmnElement.value.businessObject?.extensionElements ?? + bpmnInstances().moddle.create('bpmn:ExtensionElements', { values: [] }) + approveMethod.value = extensionElements.values.filter( + (ex) => ex.$type === `${prefix}:ApproveMethod` + )?.[0]?.value + + otherExtensions.value = + extensionElements.values.filter((ex) => ex.$type !== `${prefix}:ApproveMethod`) ?? [] + + if (!approveMethod.value) { + approveMethod.value = ApproveMethodType.SEQUENTIAL_APPROVE + updateLoopCharacteristics() + } +} +const onApproveMethodChange = () => { + approveRatio.value = 100 + updateLoopCharacteristics() +} +const onApproveRatioChange = () => { + updateLoopCharacteristics() +} +const updateLoopCharacteristics = () => { + // 根据ApproveMethod生成multiInstanceLoopCharacteristics节点 + if (approveMethod.value === ApproveMethodType.RANDOM_SELECT_ONE_APPROVE) { + bpmnInstances().modeling.updateProperties(toRaw(bpmnElement.value), { + loopCharacteristics: null + }) + } else { + if (approveMethod.value === ApproveMethodType.APPROVE_BY_RATIO) { + multiLoopInstance.value = bpmnInstances().moddle.create( + 'bpmn:MultiInstanceLoopCharacteristics', + { isSequential: false, collection: '${coll_userList}' } + ) + multiLoopInstance.value.completionCondition = bpmnInstances().moddle.create( + 'bpmn:FormalExpression', + { + body: '${ nrOfCompletedInstances/nrOfInstances >= ' + approveRatio.value / 100 + '}' + } + ) + } + if (approveMethod.value === ApproveMethodType.ANY_APPROVE) { + multiLoopInstance.value = bpmnInstances().moddle.create( + 'bpmn:MultiInstanceLoopCharacteristics', + { isSequential: false, collection: '${coll_userList}' } + ) + multiLoopInstance.value.completionCondition = bpmnInstances().moddle.create( + 'bpmn:FormalExpression', + { + body: '${ nrOfCompletedInstances > 0 }' + } + ) + } + if (approveMethod.value === ApproveMethodType.SEQUENTIAL_APPROVE) { + multiLoopInstance.value = bpmnInstances().moddle.create( + 'bpmn:MultiInstanceLoopCharacteristics', + { isSequential: true, collection: '${coll_userList}' } + ) + multiLoopInstance.value.loopCardinality = bpmnInstances().moddle.create( + 'bpmn:FormalExpression', + { + body: '1' + } + ) + multiLoopInstance.value.completionCondition = bpmnInstances().moddle.create( + 'bpmn:FormalExpression', + { + body: '${ nrOfCompletedInstances >= nrOfInstances }' + } + ) + } + bpmnInstances().modeling.updateProperties(toRaw(bpmnElement.value), { + loopCharacteristics: toRaw(multiLoopInstance.value) + }) + } + + // 添加ApproveMethod到ExtensionElements + const extensions = bpmnInstances().moddle.create('bpmn:ExtensionElements', { + values: [ + ...otherExtensions.value, + bpmnInstances().moddle.create(`${prefix}:ApproveMethod`, { + value: approveMethod.value + }) + ] + }) + bpmnInstances().modeling.updateProperties(toRaw(bpmnElement.value), { + extensionElements: extensions + }) +} + onBeforeUnmount(() => { multiLoopInstance.value = null bpmnElement.value = null }) watch( - () => props.businessObject, + () => props.id, (val) => { - bpmnElement.value = bpmnInstances().bpmnElement - getElementLoop(val) + if (val) { + nextTick(() => { + bpmnElement.value = bpmnInstances().bpmnElement + // getElementLoop(val) + getElementLoopNew() + }) + } }, { immediate: true } ) -- Gitblit v1.9.3