import { ModdleElement } from '../type' ; export const ProcessNameMapping = { 'bpmn:Process' : '流程' , 'bpmn:SubProcess' : '子流程' , } ; export const EventNameMapping = { 'bpmn:StartEvent' : '开始事件' , 'bpmn:EndEvent' : '结束事件' , 'bpmn:MessageEventDefinition' : '消息' , 'bpmn:TimerEventDefinition' : '定时' , 'bpmn:ConditionalEventDefinition' : '条件' , 'bpmn:SignalEventDefinition' : '信号' , } ; export const FlowNameMapping = { 'bpmn:SequenceFlow' : ( businessObject ) => { const defaultName = '顺序流' ; if ( businessObject . conditionExpression ) { return '条件' + defaultName ; } if ( businessObject . sourceRef . default ) { return '默认' + defaultName ; } return defaultName ; } , } ; export const GatewayNameMapping = { 'bpmn:ExclusiveGateway' : '互斥网关' , 'bpmn:ParallelGateway' : '并行网关' , 'bpmn:ComplexGateway' : '复杂网关' , 'bpmn:EventBasedGateway' : '事件网关' , } ; export const TaskNameMapping = { 'bpmn:Task' : '普通任务' , 'bpmn:UserTask' : '用户任务' , 'bpmn:ReceiveTask' : '接收任务' , 'bpmn:SendTask' : '发送任务' , 'bpmn:ManualTask' : '手工任务' , 'bpmn:BusinessRuleTask' : '业务规则任务' , 'bpmn:ServiceTask' : '服务任务' , 'bpmn:ScriptTask' : '脚本任务' , 'bpmn:CallActivity' : '调用任务' , } ; export const OtherNameMapping = { 'bpmn:Participant' : '池/参与者' , 'bpmn:Group' : '分组' , 'bpmn:DataStoreReference' : '数据存储' , 'bpmn:DataObjectReference' : '数据对象' , } ; export const NameMapping = { ... ProcessNameMapping , ... EventNameMapping , ... FlowNameMapping , ... GatewayNameMapping , ... TaskNameMapping , ... OtherNameMapping , } ; param businessObject export const resolveTypeName = ( businessObject ) : string => { const eventDefinitions = businessObject . eventDefinitions ; const nameMappingElement = NameMapping [ businessObject . $type ] ; if ( typeof nameMappingElement === 'function' ) { return nameMappingElement ( businessObject ) ; } return eventDefinitions ? NameMapping [ eventDefinitions [ 0 ] . $type ] + nameMappingElement : nameMappingElement ; } ;