| | |
| | | /** |
| | | * 生成默认的 BPMN 流程图 XML |
| | | * |
| | | * 历史问题:这里原本只生成一个空的 <bpmn2:process>,没有任何节点, |
| | | * 打开「流程模型 → 修改 → 流程设计」时画布一片空白,客户反馈「没有流程模型,需要配置一下」。 |
| | | * |
| | | * 现改为生成一个可用的最小流程骨架:发起人 → 审批人 → 结束, |
| | | * 客户打开即可在画布上直接选中节点配置审批人,或继续增删节点。 |
| | | * 注意:审批节点故意不预置办理人,由客户在右侧属性面板里选择。 |
| | | */ |
| | | function defaultEmpty(key, name, type) { |
| | | if (!type) type = 'camunda'; |
| | | const TYPE_TARGET = { |
| | | activiti: 'http://activiti.org/bpmn', |
| | | camunda: 'http://bpmn.io/schema/bpmn', |
| | | flowable: 'http://flowable.org/bpmn', |
| | | }; |
| | | // 扩展属性(如 flowable:assignee)的命名空间,camunda 与 bpmn.io 的 targetNamespace 不同 |
| | | const TYPE_EXTENSION_NS = { |
| | | activiti: 'http://activiti.org/bpmn', |
| | | camunda: 'http://camunda.org/schema/1.0/bpmn', |
| | | flowable: 'http://flowable.org/bpmn', |
| | | }; |
| | | return `<?xml version="1.0" encoding="UTF-8"?> |
| | |
| | | xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" |
| | | xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" |
| | | xmlns:di="http://www.omg.org/spec/DD/20100524/DI" |
| | | xmlns:${type}="${TYPE_EXTENSION_NS[type]}" |
| | | id="diagram_${key}" |
| | | targetNamespace="${TYPE_TARGET[type]}"> |
| | | <bpmn2:process id="${key}" name="${name}" isExecutable="true"> |
| | | <bpmn2:startEvent id="StartEvent_1" name="发起人"> |
| | | <bpmn2:outgoing>Flow_1</bpmn2:outgoing> |
| | | </bpmn2:startEvent> |
| | | <bpmn2:sequenceFlow id="Flow_1" sourceRef="StartEvent_1" targetRef="Activity_1" /> |
| | | <bpmn2:userTask id="Activity_1" name="审批人"> |
| | | <bpmn2:incoming>Flow_1</bpmn2:incoming> |
| | | <bpmn2:outgoing>Flow_2</bpmn2:outgoing> |
| | | </bpmn2:userTask> |
| | | <bpmn2:sequenceFlow id="Flow_2" sourceRef="Activity_1" targetRef="EndEvent_1" /> |
| | | <bpmn2:endEvent id="EndEvent_1" name="结束"> |
| | | <bpmn2:incoming>Flow_2</bpmn2:incoming> |
| | | </bpmn2:endEvent> |
| | | </bpmn2:process> |
| | | <bpmndi:BPMNDiagram id="BPMNDiagram_1"> |
| | | <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="${key}"> |
| | | <bpmndi:BPMNShape id="StartEvent_1_di" bpmnElement="StartEvent_1"> |
| | | <dc:Bounds x="180" y="160" width="36" height="36" /> |
| | | <bpmndi:BPMNLabel> |
| | | <dc:Bounds x="187" y="203" width="22" height="14" /> |
| | | </bpmndi:BPMNLabel> |
| | | </bpmndi:BPMNShape> |
| | | <bpmndi:BPMNShape id="Activity_1_di" bpmnElement="Activity_1"> |
| | | <dc:Bounds x="280" y="138" width="100" height="80" /> |
| | | <bpmndi:BPMNLabel /> |
| | | </bpmndi:BPMNShape> |
| | | <bpmndi:BPMNShape id="EndEvent_1_di" bpmnElement="EndEvent_1"> |
| | | <dc:Bounds x="432" y="160" width="36" height="36" /> |
| | | <bpmndi:BPMNLabel> |
| | | <dc:Bounds x="439" y="203" width="22" height="14" /> |
| | | </bpmndi:BPMNLabel> |
| | | </bpmndi:BPMNShape> |
| | | <bpmndi:BPMNEdge id="Flow_1_di" bpmnElement="Flow_1"> |
| | | <di:waypoint x="216" y="178" /> |
| | | <di:waypoint x="280" y="178" /> |
| | | </bpmndi:BPMNEdge> |
| | | <bpmndi:BPMNEdge id="Flow_2_di" bpmnElement="Flow_2"> |
| | | <di:waypoint x="380" y="178" /> |
| | | <di:waypoint x="432" y="178" /> |
| | | </bpmndi:BPMNEdge> |
| | | </bpmndi:BPMNPlane> |
| | | </bpmndi:BPMNDiagram> |
| | | </bpmn2:definitions>`; |