feat(modeler): 新建流程(空白/单人/两级/会签4模板+NewProcessDialog)

模板库 src/modeler/templates/:4 个 BPMN 模板以真实流程为骨架抽形,全小写
元素名 + isExecutable="true" + 完整 BPMNDiagram DI;单人/两级带 activiti:candidateUsers
示例(全角【】+type:user),会签带 multiInstanceLoopCharacteristics+elementVariable+完成条件。
占位符 __PROCESS_ID__/__PROCESS_NAME__ 由 buildNewProcessXml 按用户 key/名称实例化:
ASCII key 直作 process id;中文 key 净化为 ASCII 并记 idMap(发布 restore 回中文 process key)。

NewProcessDialog:名称/key(可中文)/模板下拉,确认产实例化 XML 交父页 importXML。
ProcessModelerPage:新建流程按钮由 disabled 变可用→开对话框→pending newDraft 挂 Modeler+
import 模板(首存前不落草稿,走 createDraft 首存路径,展示名进草稿 name,diff 基线清空)。

模板正确性测试(fromXML 无警告/真序列化后全小写/isExecutable/会签含 multiInstance)+
NewProcessDialog+页面接线测试;全量 vitest 270 绿、tsc -b、build 通过。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-07-02 15:49:16 +08:00
parent 8ea0ef2f1e
commit 2477f67afe
10 changed files with 777 additions and 39 deletions

View File

@@ -0,0 +1,45 @@
// 新建流程模板——两级审批(start → 一级 userTask → 二级 userTask → end)。
//
// 两个 userTask 各带 activiti:candidateUsers(type:user,content 留空供侧板填人);结构、
// 全角【】/&quot; 转义、约束(全小写元素名 + isExecutable + 完整 DI + 占位符)同 single-approval。
export const TWO_LEVEL_BPMN = `<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/processdef">
<process id="__PROCESS_ID__" name="__PROCESS_NAME__" isExecutable="true">
<startEvent id="start_1" name="发起"></startEvent>
<userTask id="task_level1" name="一级审批" activiti:exclusive="false" activiti:candidateUsers="\${candidateUsersHandler.getCandidateUsers(execution,'【&quot;items&quot;:[【&quot;type&quot;:&quot;user&quot;,&quot;content&quot;:&quot;&quot;,&quot;isCandidate&quot;:true,&quot;isSendMail&quot;:false,&quot;isSendPhone&quot;:false,&quot;isSendMessage&quot;:false】]】')}"></userTask>
<userTask id="task_level2" name="二级审批" activiti:exclusive="false" activiti:candidateUsers="\${candidateUsersHandler.getCandidateUsers(execution,'【&quot;items&quot;:[【&quot;type&quot;:&quot;user&quot;,&quot;content&quot;:&quot;&quot;,&quot;isCandidate&quot;:true,&quot;isSendMail&quot;:false,&quot;isSendPhone&quot;:false,&quot;isSendMessage&quot;:false】]】')}"></userTask>
<endEvent id="end_1" name="结束"></endEvent>
<sequenceFlow id="flow_1" sourceRef="start_1" targetRef="task_level1"></sequenceFlow>
<sequenceFlow id="flow_2" sourceRef="task_level1" targetRef="task_level2"></sequenceFlow>
<sequenceFlow id="flow_3" sourceRef="task_level2" targetRef="end_1"></sequenceFlow>
</process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane bpmnElement="__PROCESS_ID__" id="BPMNPlane_1">
<bpmndi:BPMNShape bpmnElement="start_1" id="BPMNShape_start_1">
<omgdc:Bounds height="30.0" width="30.0" x="150.0" y="85.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="task_level1" id="BPMNShape_task_level1">
<omgdc:Bounds height="80.0" width="100.0" x="230.0" y="60.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="task_level2" id="BPMNShape_task_level2">
<omgdc:Bounds height="80.0" width="100.0" x="390.0" y="60.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="end_1" id="BPMNShape_end_1">
<omgdc:Bounds height="28.0" width="28.0" x="550.0" y="86.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="flow_1" id="BPMNEdge_flow_1">
<omgdi:waypoint x="180.0" y="100.0"></omgdi:waypoint>
<omgdi:waypoint x="230.0" y="100.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow_2" id="BPMNEdge_flow_2">
<omgdi:waypoint x="330.0" y="100.0"></omgdi:waypoint>
<omgdi:waypoint x="390.0" y="100.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow_3" id="BPMNEdge_flow_3">
<omgdi:waypoint x="490.0" y="100.0"></omgdi:waypoint>
<omgdi:waypoint x="550.0" y="100.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>`;