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:
94
src/modeler/NewProcessDialog.test.tsx
Normal file
94
src/modeler/NewProcessDialog.test.tsx
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
import { describe, it, expect, vi } from 'vitest';
|
||||||
|
import { render, screen, fireEvent } from '@testing-library/react';
|
||||||
|
import { NewProcessDialog, type NewProcessResult } from './NewProcessDialog';
|
||||||
|
|
||||||
|
function renderDialog() {
|
||||||
|
const onConfirm = vi.fn<[NewProcessResult], void>();
|
||||||
|
const onClose = vi.fn();
|
||||||
|
render(<NewProcessDialog onConfirm={onConfirm} onClose={onClose} />);
|
||||||
|
return { onConfirm, onClose };
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('NewProcessDialog', () => {
|
||||||
|
it('渲染名称/key/模板三字段', () => {
|
||||||
|
renderDialog();
|
||||||
|
expect(screen.getByTestId('new-process-name')).toBeInTheDocument();
|
||||||
|
expect(screen.getByTestId('new-process-key')).toBeInTheDocument();
|
||||||
|
expect(screen.getByTestId('new-process-template')).toBeInTheDocument();
|
||||||
|
// 模板下拉含四个模板
|
||||||
|
expect(screen.getByText('空白流程')).toBeInTheDocument();
|
||||||
|
expect(screen.getByText('单人审批')).toBeInTheDocument();
|
||||||
|
expect(screen.getByText('两级审批')).toBeInTheDocument();
|
||||||
|
expect(screen.getByText('会签')).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('name/key 任一为空 → 确认禁用且 onConfirm 不触发', () => {
|
||||||
|
const { onConfirm } = renderDialog();
|
||||||
|
const confirm = screen.getByTestId('new-process-confirm');
|
||||||
|
expect(confirm).toBeDisabled();
|
||||||
|
// 只填 name,key 仍空 → 仍禁用
|
||||||
|
fireEvent.change(screen.getByTestId('new-process-name'), { target: { value: '请假审批' } });
|
||||||
|
expect(confirm).toBeDisabled();
|
||||||
|
fireEvent.click(confirm);
|
||||||
|
expect(onConfirm).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('key 仅空白也判无效', () => {
|
||||||
|
renderDialog();
|
||||||
|
fireEvent.change(screen.getByTestId('new-process-name'), { target: { value: 'n' } });
|
||||||
|
fireEvent.change(screen.getByTestId('new-process-key'), { target: { value: ' ' } });
|
||||||
|
expect(screen.getByTestId('new-process-confirm')).toBeDisabled();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('填齐 + 选会签模板 → 确认,onConfirm 收到实例化 XML(含 multiInstance,占位符已替换)', () => {
|
||||||
|
const { onConfirm } = renderDialog();
|
||||||
|
fireEvent.change(screen.getByTestId('new-process-name'), { target: { value: '合同会签' } });
|
||||||
|
fireEvent.change(screen.getByTestId('new-process-key'), { target: { value: 'contractCosign' } });
|
||||||
|
fireEvent.change(screen.getByTestId('new-process-template'), { target: { value: 'cosign' } });
|
||||||
|
fireEvent.click(screen.getByTestId('new-process-confirm'));
|
||||||
|
expect(onConfirm).toHaveBeenCalledTimes(1);
|
||||||
|
const r = onConfirm.mock.calls[0][0];
|
||||||
|
expect(r.name).toBe('合同会签');
|
||||||
|
expect(r.key).toBe('contractCosign');
|
||||||
|
// process id/key 已替换为用户输入(ASCII key),占位符无残留。
|
||||||
|
expect(r.xml).toContain('id="contractCosign"');
|
||||||
|
expect(r.xml).toContain('bpmnElement="contractCosign"');
|
||||||
|
expect(r.xml).not.toContain('__PROCESS_ID__');
|
||||||
|
expect(r.xml).not.toContain('__PROCESS_NAME__');
|
||||||
|
// 选中的是会签模板。
|
||||||
|
expect(r.xml).toContain('multiInstanceLoopCharacteristics');
|
||||||
|
expect(r.idMap).toEqual({});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('默认模板为空白流程(不含 userTask)', () => {
|
||||||
|
const { onConfirm } = renderDialog();
|
||||||
|
fireEvent.change(screen.getByTestId('new-process-name'), { target: { value: '空白' } });
|
||||||
|
fireEvent.change(screen.getByTestId('new-process-key'), { target: { value: 'blankProc' } });
|
||||||
|
fireEvent.click(screen.getByTestId('new-process-confirm'));
|
||||||
|
const r = onConfirm.mock.calls[0][0];
|
||||||
|
expect(r.xml).not.toContain('userTask');
|
||||||
|
expect(r.xml).toContain('id="blankProc"');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('中文 key → onConfirm.idMap 记录 {中文 key→净化 ASCII id},XML 内 process id 为 ASCII', () => {
|
||||||
|
const { onConfirm } = renderDialog();
|
||||||
|
fireEvent.change(screen.getByTestId('new-process-name'), { target: { value: '总包合同交底' } });
|
||||||
|
fireEvent.change(screen.getByTestId('new-process-key'), { target: { value: '总包合同交底' } });
|
||||||
|
fireEvent.change(screen.getByTestId('new-process-template'), { target: { value: 'single-approval' } });
|
||||||
|
fireEvent.click(screen.getByTestId('new-process-confirm'));
|
||||||
|
const r = onConfirm.mock.calls[0][0];
|
||||||
|
expect(r.key).toBe('总包合同交底');
|
||||||
|
expect(Object.keys(r.idMap)).toEqual(['总包合同交底']);
|
||||||
|
const asciiId = r.idMap['总包合同交底'];
|
||||||
|
expect(asciiId).toMatch(/^[A-Za-z_][A-Za-z0-9_.-]*$/); // ASCII NCName
|
||||||
|
expect(r.xml).toContain('id="' + asciiId + '"');
|
||||||
|
expect(r.xml).not.toContain('id="总包合同交底"'); // moddle 拒中文 id
|
||||||
|
});
|
||||||
|
|
||||||
|
it('取消 → onClose,不 onConfirm', () => {
|
||||||
|
const { onConfirm, onClose } = renderDialog();
|
||||||
|
fireEvent.click(screen.getByTestId('new-process-cancel'));
|
||||||
|
expect(onClose).toHaveBeenCalled();
|
||||||
|
expect(onConfirm).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
});
|
||||||
113
src/modeler/NewProcessDialog.tsx
Normal file
113
src/modeler/NewProcessDialog.tsx
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
// 新建流程对话框(T4.1)。
|
||||||
|
//
|
||||||
|
// 字段:名称(展示名)/ key(流程标识,允许中文——引擎 process key 既有中文事实)/ 模板下拉。
|
||||||
|
// 确认时按选中模板 + 用户输入实例化 XML(buildNewProcessXml 替换占位符、按 key 定 ASCII process id
|
||||||
|
// 并算发布还原 idMap),把结果交父页进入编辑态(父页 importXML,尚未存草稿)。
|
||||||
|
import { useState } from 'react';
|
||||||
|
import { Dialog } from '../components/ui';
|
||||||
|
import { PROCESS_TEMPLATES, getTemplate, buildNewProcessXml } from './templates';
|
||||||
|
|
||||||
|
/** 新建结果:交父页 importXML + 首存草稿用(name→草稿名/process name,key→草稿 key,idMap→metaInfo)。 */
|
||||||
|
export interface NewProcessResult {
|
||||||
|
name: string;
|
||||||
|
key: string;
|
||||||
|
/** 实例化后的 BPMN(占位符已替换,可直接 importXML)。 */
|
||||||
|
xml: string;
|
||||||
|
/** 发布还原映射(中文 key 时 {原 key→净化 id},ASCII key 时空)。 */
|
||||||
|
idMap: Record<string, string>;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface NewProcessDialogProps {
|
||||||
|
onConfirm: (r: NewProcessResult) => void;
|
||||||
|
onClose: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function NewProcessDialog({ onConfirm, onClose }: NewProcessDialogProps) {
|
||||||
|
const [name, setName] = useState('');
|
||||||
|
const [key, setKey] = useState('');
|
||||||
|
const [templateId, setTemplateId] = useState(PROCESS_TEMPLATES[0].id);
|
||||||
|
|
||||||
|
const nameOk = name.trim().length > 0;
|
||||||
|
const keyOk = key.trim().length > 0;
|
||||||
|
const valid = nameOk && keyOk;
|
||||||
|
|
||||||
|
function handleConfirm() {
|
||||||
|
if (!valid) return;
|
||||||
|
const tpl = getTemplate(templateId);
|
||||||
|
if (!tpl) return;
|
||||||
|
const built = buildNewProcessXml(tpl.xml, name, key);
|
||||||
|
onConfirm({ name: name.trim(), key: key.trim(), xml: built.xml, idMap: built.idMap });
|
||||||
|
}
|
||||||
|
|
||||||
|
const foot = (
|
||||||
|
<>
|
||||||
|
<button className="btn" data-testid="new-process-cancel" onClick={onClose}>
|
||||||
|
取消
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
className="btn btn-primary"
|
||||||
|
data-testid="new-process-confirm"
|
||||||
|
onClick={handleConfirm}
|
||||||
|
disabled={!valid}
|
||||||
|
>
|
||||||
|
创建并编辑
|
||||||
|
</button>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Dialog title="新建流程" width={480} onClose={onClose} foot={foot}>
|
||||||
|
<div style={{ display: 'flex', flexDirection: 'column', gap: 14 }}>
|
||||||
|
<Field label="流程名称" hint="展示名,可用中文">
|
||||||
|
<input
|
||||||
|
data-testid="new-process-name"
|
||||||
|
value={name}
|
||||||
|
onChange={(e) => setName(e.target.value)}
|
||||||
|
placeholder="如:请假审批"
|
||||||
|
style={inputStyle}
|
||||||
|
/>
|
||||||
|
</Field>
|
||||||
|
<Field label="流程标识(key)" hint="引擎 process key,可用中文;发布后作为流程唯一标识">
|
||||||
|
<input
|
||||||
|
data-testid="new-process-key"
|
||||||
|
value={key}
|
||||||
|
onChange={(e) => setKey(e.target.value)}
|
||||||
|
placeholder="如:leaveApply 或 请假审批"
|
||||||
|
style={inputStyle}
|
||||||
|
/>
|
||||||
|
</Field>
|
||||||
|
<Field label="起始模板">
|
||||||
|
<select
|
||||||
|
data-testid="new-process-template"
|
||||||
|
value={templateId}
|
||||||
|
onChange={(e) => setTemplateId(e.target.value)}
|
||||||
|
style={inputStyle}
|
||||||
|
>
|
||||||
|
{PROCESS_TEMPLATES.map((t) => (
|
||||||
|
<option key={t.id} value={t.id}>
|
||||||
|
{t.label}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
|
</select>
|
||||||
|
</Field>
|
||||||
|
{!valid ? (
|
||||||
|
<div data-testid="new-process-hint" style={{ fontSize: 12, color: 'var(--text-3)' }}>
|
||||||
|
请填写流程名称与 key。
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
</Dialog>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function Field({ label, hint, children }: { label: string; hint?: string; children: React.ReactNode }) {
|
||||||
|
return (
|
||||||
|
<label style={{ display: 'flex', flexDirection: 'column', gap: 4 }}>
|
||||||
|
<span style={{ fontSize: 13, fontWeight: 600 }}>{label}</span>
|
||||||
|
{children}
|
||||||
|
{hint ? <span style={{ fontSize: 11, color: 'var(--text-3)' }}>{hint}</span> : null}
|
||||||
|
</label>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const inputStyle: React.CSSProperties = { width: '100%', padding: '6px 8px', boxSizing: 'border-box' };
|
||||||
35
src/modeler/templates/blank.bpmn.ts
Normal file
35
src/modeler/templates/blank.bpmn.ts
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
// 新建流程模板——空白(1 startEvent + 1 endEvent,供纯手绘)。
|
||||||
|
//
|
||||||
|
// ⚠️ CRITICAL(阶段 3 教训):元素名一律**全小写**(<definitions><process><startEvent/>…);
|
||||||
|
// 缺 isExecutable="true" 会被 Flowable ProcessValidator 拒(看到 0 个可执行流程);缺完整
|
||||||
|
// BPMNDiagram DI 则画布空白。故模板源字符串即含小写元素名 + isExecutable + 完整 DI。
|
||||||
|
//
|
||||||
|
// 占位符(由 templates/index.ts 的 buildNewProcessXml 实例化替换):
|
||||||
|
// __PROCESS_ID__ —— 进 <process id> 与 <bpmndi:BPMNPlane bpmnElement>(决定 process key)。
|
||||||
|
// 本身是合法 NCName(`_`+大写字母+`_`),故未替换的原模板也能过 moddle 校验。
|
||||||
|
// __PROCESS_NAME__ —— 进 <process name>(展示名,name 属性对 NCName 无限制)。
|
||||||
|
//
|
||||||
|
// 空白模板 start→end 直连即最小可部署流程,用户在流上插入节点或另起手绘。
|
||||||
|
|
||||||
|
export const BLANK_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>
|
||||||
|
<endEvent id="end_1" name="结束"></endEvent>
|
||||||
|
<sequenceFlow id="flow_1" sourceRef="start_1" 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="180.0" y="85.0"></omgdc:Bounds>
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNShape bpmnElement="end_1" id="BPMNShape_end_1">
|
||||||
|
<omgdc:Bounds height="28.0" width="28.0" x="320.0" y="86.0"></omgdc:Bounds>
|
||||||
|
</bpmndi:BPMNShape>
|
||||||
|
<bpmndi:BPMNEdge bpmnElement="flow_1" id="BPMNEdge_flow_1">
|
||||||
|
<omgdi:waypoint x="210.0" y="100.0"></omgdi:waypoint>
|
||||||
|
<omgdi:waypoint x="320.0" y="100.0"></omgdi:waypoint>
|
||||||
|
</bpmndi:BPMNEdge>
|
||||||
|
</bpmndi:BPMNPlane>
|
||||||
|
</bpmndi:BPMNDiagram>
|
||||||
|
</definitions>`;
|
||||||
46
src/modeler/templates/cosign.bpmn.ts
Normal file
46
src/modeler/templates/cosign.bpmn.ts
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
// 新建流程模板——会签(start → 多实例 userTask → end)。
|
||||||
|
//
|
||||||
|
// userTask 挂 multiInstanceLoopCharacteristics(并行):
|
||||||
|
// - activiti:collection = multiInstance 表达式(multiInstanceUsersHandler.getUsers,全角【】+
|
||||||
|
// items 一项 type:user;逐字对齐 candidateExpression codec 的 'multiInstance' 变体 build 输出)。
|
||||||
|
// - activiti:elementVariable="assignee" + userTask activiti:assignee="${assignee}":每个实例把
|
||||||
|
// 集合元素绑到 assignee 变量再据此派任(对照真实会签流「总包合同交底」结构)。
|
||||||
|
// - completionCondition ${nrOfCompletedInstances/nrOfInstances==1}(全票通过,对齐侧板 all 预设)。
|
||||||
|
//
|
||||||
|
// 约束同其余模板:全小写元素名 + isExecutable + 完整 DI + 占位符。
|
||||||
|
|
||||||
|
export const COSIGN_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_cosign" name="会签审批" activiti:exclusive="false" activiti:assignee="\${assignee}">
|
||||||
|
<multiInstanceLoopCharacteristics isSequential="false" activiti:collection="\${multiInstanceUsersHandler.getUsers(execution,'【"items":[【"type":"user","content":"","isCandidate":true,"isSendMail":false,"isSendPhone":false,"isSendMessage":false】]】')}" activiti:elementVariable="assignee">
|
||||||
|
<completionCondition>\${nrOfCompletedInstances/nrOfInstances==1}</completionCondition>
|
||||||
|
</multiInstanceLoopCharacteristics>
|
||||||
|
</userTask>
|
||||||
|
<endEvent id="end_1" name="结束"></endEvent>
|
||||||
|
<sequenceFlow id="flow_1" sourceRef="start_1" targetRef="task_cosign"></sequenceFlow>
|
||||||
|
<sequenceFlow id="flow_2" sourceRef="task_cosign" 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_cosign" id="BPMNShape_task_cosign">
|
||||||
|
<omgdc:Bounds height="80.0" width="100.0" x="250.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="430.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="250.0" y="100.0"></omgdi:waypoint>
|
||||||
|
</bpmndi:BPMNEdge>
|
||||||
|
<bpmndi:BPMNEdge bpmnElement="flow_2" id="BPMNEdge_flow_2">
|
||||||
|
<omgdi:waypoint x="350.0" y="100.0"></omgdi:waypoint>
|
||||||
|
<omgdi:waypoint x="430.0" y="100.0"></omgdi:waypoint>
|
||||||
|
</bpmndi:BPMNEdge>
|
||||||
|
</bpmndi:BPMNPlane>
|
||||||
|
</bpmndi:BPMNDiagram>
|
||||||
|
</definitions>`;
|
||||||
89
src/modeler/templates/index.ts
Normal file
89
src/modeler/templates/index.ts
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
// 新建流程模板库 + 实例化助手(T4.1 §0.5 P3)。
|
||||||
|
//
|
||||||
|
// 四个模板以真实流程结构为骨架抽形;模板源用占位符 __PROCESS_ID__ / __PROCESS_NAME__,
|
||||||
|
// 由 {@link buildNewProcessXml} 按用户输入的 key/名称实例化替换。
|
||||||
|
//
|
||||||
|
// 🔑 中文 key 与 moddle 的冲突:bpmn-moddle 拒非 ASCII 的 process id(NCName 校验),故进
|
||||||
|
// Modeler 的 XML 里 <process id> 必须是 ASCII。方案对齐存量改造链(后端 BpmnIdSanitizer + 发布
|
||||||
|
// restore):
|
||||||
|
// - key 是合法 ASCII NCName → 直接用作 process id,idMap 空(发布即以该 key 部署,无需还原)。
|
||||||
|
// - key 含中文等非法字符 → process id 用稳定 ASCII(与 BpmnIdSanitizer 同哈希方案),
|
||||||
|
// idMap={原中文 key → 净化 id};发布时后端按 metaInfo.eip4IdMap restore 回中文 key(process
|
||||||
|
// key = XML <process id>,见 ProcessModelController.deploy)。
|
||||||
|
|
||||||
|
import { BLANK_BPMN } from './blank.bpmn';
|
||||||
|
import { SINGLE_APPROVAL_BPMN } from './single-approval.bpmn';
|
||||||
|
import { TWO_LEVEL_BPMN } from './two-level.bpmn';
|
||||||
|
import { COSIGN_BPMN } from './cosign.bpmn';
|
||||||
|
|
||||||
|
export interface ProcessTemplate {
|
||||||
|
id: string;
|
||||||
|
label: string;
|
||||||
|
/** 未实例化的模板源(含 __PROCESS_ID__/__PROCESS_NAME__ 占位符)。 */
|
||||||
|
xml: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const PROCESS_TEMPLATES: ProcessTemplate[] = [
|
||||||
|
{ id: 'blank', label: '空白流程', xml: BLANK_BPMN },
|
||||||
|
{ id: 'single-approval', label: '单人审批', xml: SINGLE_APPROVAL_BPMN },
|
||||||
|
{ id: 'two-level', label: '两级审批', xml: TWO_LEVEL_BPMN },
|
||||||
|
{ id: 'cosign', label: '会签', xml: COSIGN_BPMN },
|
||||||
|
];
|
||||||
|
|
||||||
|
export function getTemplate(id: string): ProcessTemplate | undefined {
|
||||||
|
return PROCESS_TEMPLATES.find((t) => t.id === id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** ASCII NCName 判定(逐字对齐后端 BpmnIdSanitizer.isValidNcName:首字符字母/下划线,余加数字/-/.)。 */
|
||||||
|
export function isAsciiNcName(s: string): boolean {
|
||||||
|
return /^[A-Za-z_][A-Za-z0-9_.\-]*$/.test(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Java String.hashCode(int 溢出语义),与后端 BpmnIdSanitizer 的净化 id 生成一致。 */
|
||||||
|
function javaHashCode(s: string): number {
|
||||||
|
let h = 0;
|
||||||
|
for (let i = 0; i < s.length; i++) {
|
||||||
|
h = (Math.imul(31, h) + s.charCodeAt(i)) | 0;
|
||||||
|
}
|
||||||
|
return h;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 中文等非法 key → 稳定 ASCII id:`n` + hex(hashCode & 0x7fffffff)(对齐 BpmnIdSanitizer.sanitize)。 */
|
||||||
|
function sanitizedId(key: string): string {
|
||||||
|
return 'n' + (javaHashCode(key) & 0x7fffffff).toString(16);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 属性值 XML 转义(name 进 name="…",须转义 & < > " 与 ')。 */
|
||||||
|
function xmlEscapeAttr(s: string): string {
|
||||||
|
return s
|
||||||
|
.replace(/&/g, '&')
|
||||||
|
.replace(/</g, '<')
|
||||||
|
.replace(/>/g, '>')
|
||||||
|
.replace(/"/g, '"')
|
||||||
|
.replace(/'/g, ''');
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface NewProcessXml {
|
||||||
|
/** 实例化后的 BPMN(占位符已替换,可直接 importXML)。 */
|
||||||
|
xml: string;
|
||||||
|
/** 实际写入 <process id> 的 ASCII id。 */
|
||||||
|
processId: string;
|
||||||
|
/** 发布还原映射;ASCII key 时为空对象。 */
|
||||||
|
idMap: Record<string, string>;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用用户输入的名称/key 实例化模板:把 __PROCESS_ID__ 换成 ASCII 的 processId、__PROCESS_NAME__ 换成
|
||||||
|
* 转义后的展示名。返回实例化 XML + 发布还原用的 idMap。key 前后空白已 trim。
|
||||||
|
*/
|
||||||
|
export function buildNewProcessXml(templateXml: string, name: string, key: string): NewProcessXml {
|
||||||
|
const trimmedKey = key.trim();
|
||||||
|
const processId = isAsciiNcName(trimmedKey) ? trimmedKey : sanitizedId(trimmedKey);
|
||||||
|
const idMap = processId === trimmedKey ? {} : { [trimmedKey]: processId };
|
||||||
|
const xml = templateXml
|
||||||
|
.split('__PROCESS_ID__')
|
||||||
|
.join(processId)
|
||||||
|
.split('__PROCESS_NAME__')
|
||||||
|
.join(xmlEscapeAttr(name.trim()));
|
||||||
|
return { xml, processId, idMap };
|
||||||
|
}
|
||||||
41
src/modeler/templates/single-approval.bpmn.ts
Normal file
41
src/modeler/templates/single-approval.bpmn.ts
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
// 新建流程模板——单人审批(start → 1 userTask → end)。
|
||||||
|
//
|
||||||
|
// userTask 带 activiti:candidateUsers 示例表达式:外层对象用**全角【】**包裹(引擎运行期
|
||||||
|
// CandidateUsersHandler 全局 【→{ 还原为 JSON),items 一项 type:user(content 留空供用户在
|
||||||
|
// EIP4 侧板填人员 id)。逐字对齐 candidateExpression codec 的 build 输出:
|
||||||
|
// businessObject 值层:${candidateUsersHandler.getCandidateUsers(execution,'【"items":[…】]】')}
|
||||||
|
// XML 属性层:内层引号写作 "(属性以 " 分隔)。
|
||||||
|
//
|
||||||
|
// 约束同 blank:全小写元素名 + isExecutable="true" + 完整 DI;占位符 __PROCESS_ID__/__PROCESS_NAME__。
|
||||||
|
|
||||||
|
export const SINGLE_APPROVAL_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_approve" name="审批" activiti:exclusive="false" activiti:candidateUsers="\${candidateUsersHandler.getCandidateUsers(execution,'【"items":[【"type":"user","content":"","isCandidate":true,"isSendMail":false,"isSendPhone":false,"isSendMessage":false】]】')}"></userTask>
|
||||||
|
<endEvent id="end_1" name="结束"></endEvent>
|
||||||
|
<sequenceFlow id="flow_1" sourceRef="start_1" targetRef="task_approve"></sequenceFlow>
|
||||||
|
<sequenceFlow id="flow_2" sourceRef="task_approve" 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_approve" id="BPMNShape_task_approve">
|
||||||
|
<omgdc:Bounds height="80.0" width="100.0" x="240.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="400.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="240.0" y="100.0"></omgdi:waypoint>
|
||||||
|
</bpmndi:BPMNEdge>
|
||||||
|
<bpmndi:BPMNEdge bpmnElement="flow_2" id="BPMNEdge_flow_2">
|
||||||
|
<omgdi:waypoint x="340.0" y="100.0"></omgdi:waypoint>
|
||||||
|
<omgdi:waypoint x="400.0" y="100.0"></omgdi:waypoint>
|
||||||
|
</bpmndi:BPMNEdge>
|
||||||
|
</bpmndi:BPMNPlane>
|
||||||
|
</bpmndi:BPMNDiagram>
|
||||||
|
</definitions>`;
|
||||||
150
src/modeler/templates/templates.test.ts
Normal file
150
src/modeler/templates/templates.test.ts
Normal file
@@ -0,0 +1,150 @@
|
|||||||
|
import { describe, it, expect } from 'vitest';
|
||||||
|
import BpmnModdle from 'bpmn-moddle';
|
||||||
|
import activiti from '../moddle/activiti.json';
|
||||||
|
import {
|
||||||
|
PROCESS_TEMPLATES,
|
||||||
|
buildNewProcessXml,
|
||||||
|
isAsciiNcName,
|
||||||
|
} from './index';
|
||||||
|
|
||||||
|
// 模板可部署前提的三重门(对照 T4.1):
|
||||||
|
// ① bpmn-moddle fromXML 无警告(结构合法,activiti 扩展属性全被描述符识别)。
|
||||||
|
// ② 真序列化(fromXML→toXML)后基础元素名**全小写**——防 PascalCase 回归(Flowable 大小写敏感,
|
||||||
|
// <Process>/<UserTask> 会被 ProcessValidator 判 0 个可执行流程、部署失败,见 moddle/serialization.test)。
|
||||||
|
// ③ 保留 isExecutable="true"(缺则 ProcessValidator 拒)。
|
||||||
|
// ④ 会签模板含 multiInstanceLoopCharacteristics。
|
||||||
|
// 均用**实例化后**(buildNewProcessXml 替换占位符)的 XML,逐字复现新建流程真正 importXML/部署的源。
|
||||||
|
|
||||||
|
/** 元素名正则(可选 bpmn: 前缀 + 精确 token + 分隔符),大小写敏感(同 serialization.test)。 */
|
||||||
|
const openTag = (name: string) => new RegExp('<(bpmn:)?' + name + '[\\s/>]');
|
||||||
|
|
||||||
|
// [小写名, PascalCase 名]——出现小写即断言对应 PascalCase 不出现。
|
||||||
|
const BASE_TYPES: Array<[lower: string, pascal: string]> = [
|
||||||
|
['definitions', 'Definitions'],
|
||||||
|
['process', 'Process'],
|
||||||
|
['startEvent', 'StartEvent'],
|
||||||
|
['endEvent', 'EndEvent'],
|
||||||
|
['sequenceFlow', 'SequenceFlow'],
|
||||||
|
['userTask', 'UserTask'],
|
||||||
|
['multiInstanceLoopCharacteristics', 'MultiInstanceLoopCharacteristics'],
|
||||||
|
];
|
||||||
|
|
||||||
|
async function roundTrip(xml: string): Promise<{ out: string; warnings: unknown[] }> {
|
||||||
|
const moddle = new BpmnModdle({ activiti });
|
||||||
|
const { rootElement, warnings } = await moddle.fromXML(xml);
|
||||||
|
const { xml: out } = await moddle.toXML(rootElement, { format: true });
|
||||||
|
return { out, warnings: warnings ?? [] };
|
||||||
|
}
|
||||||
|
|
||||||
|
describe('新建流程模板库', () => {
|
||||||
|
it('登记齐 4 个模板(空白/单人/两级/会签)', () => {
|
||||||
|
expect(PROCESS_TEMPLATES.map((t) => t.id)).toEqual([
|
||||||
|
'blank',
|
||||||
|
'single-approval',
|
||||||
|
'two-level',
|
||||||
|
'cosign',
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
|
for (const t of PROCESS_TEMPLATES) {
|
||||||
|
describe(`模板 ${t.id}`, () => {
|
||||||
|
// ASCII key → process id 直接用 key,不引 idMap;此实例化 XML 即真正被 importXML/部署的源。
|
||||||
|
const { xml, processId, idMap } = buildNewProcessXml(t.xml, '测试流程', 'TestProc');
|
||||||
|
|
||||||
|
it('占位符已全部替换(无 __PROCESS_ID__/__PROCESS_NAME__ 残留)', () => {
|
||||||
|
expect(xml).not.toContain('__PROCESS_ID__');
|
||||||
|
expect(xml).not.toContain('__PROCESS_NAME__');
|
||||||
|
expect(processId).toBe('TestProc');
|
||||||
|
expect(idMap).toEqual({});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('① bpmn-moddle fromXML 无警告(结构合法)', async () => {
|
||||||
|
const { warnings } = await roundTrip(xml);
|
||||||
|
expect(warnings).toEqual([]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('② 真序列化后基础元素名全小写(无 PascalCase,Flowable 可识别)', async () => {
|
||||||
|
const { out } = await roundTrip(xml);
|
||||||
|
for (const [lower, pascal] of BASE_TYPES) {
|
||||||
|
if (openTag(lower).test(out)) {
|
||||||
|
expect(out, `不应含 PascalCase <${pascal}>`).not.toMatch(openTag(pascal));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 每个模板至少含小写 process/startEvent/endEvent/sequenceFlow。
|
||||||
|
for (const lower of ['process', 'startEvent', 'endEvent', 'sequenceFlow']) {
|
||||||
|
expect(out, `应含小写 <${lower}>`).toMatch(openTag(lower));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
it('③ 保留 isExecutable="true"(ProcessValidator 前提)', async () => {
|
||||||
|
const { out } = await roundTrip(xml);
|
||||||
|
expect(out).toMatch(/<(bpmn:)?process[\s][^>]*isExecutable="true"/);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('含完整 BPMNDiagram DI(画布不空白)', () => {
|
||||||
|
expect(xml).toContain('BPMNDiagram');
|
||||||
|
expect(xml).toContain('BPMNPlane');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
it('④ 会签模板含 multiInstanceLoopCharacteristics + elementVariable + 完成条件', async () => {
|
||||||
|
const cosign = PROCESS_TEMPLATES.find((t) => t.id === 'cosign')!;
|
||||||
|
const { xml } = buildNewProcessXml(cosign.xml, '会签流程', 'CosignProc');
|
||||||
|
const { out } = await roundTrip(xml);
|
||||||
|
expect(out).toMatch(openTag('multiInstanceLoopCharacteristics'));
|
||||||
|
expect(out).toContain('elementVariable="assignee"');
|
||||||
|
expect(out).toMatch(/completionCondition/);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('单人/两级/会签模板均含 userTask(空白模板不含)', async () => {
|
||||||
|
for (const id of ['single-approval', 'two-level', 'cosign']) {
|
||||||
|
const t = PROCESS_TEMPLATES.find((x) => x.id === id)!;
|
||||||
|
const { out } = await roundTrip(buildNewProcessXml(t.xml, 'n', 'K').xml);
|
||||||
|
expect(out, `${id} 应含 userTask`).toMatch(openTag('userTask'));
|
||||||
|
}
|
||||||
|
const blank = PROCESS_TEMPLATES.find((x) => x.id === 'blank')!;
|
||||||
|
const { out } = await roundTrip(buildNewProcessXml(blank.xml, 'n', 'K').xml);
|
||||||
|
expect(out).not.toMatch(openTag('userTask'));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('buildNewProcessXml —— key/名称替换', () => {
|
||||||
|
const single = PROCESS_TEMPLATES.find((t) => t.id === 'single-approval')!;
|
||||||
|
|
||||||
|
it('ASCII key 直接作 process id,idMap 空', () => {
|
||||||
|
const { xml, processId, idMap } = buildNewProcessXml(single.xml, '请假审批', 'LeaveApply');
|
||||||
|
expect(processId).toBe('LeaveApply');
|
||||||
|
expect(idMap).toEqual({});
|
||||||
|
expect(xml).toContain('id="LeaveApply"');
|
||||||
|
expect(xml).toContain('bpmnElement="LeaveApply"'); // DI plane 引用同步替换
|
||||||
|
});
|
||||||
|
|
||||||
|
it('中文 key → process id 净化为 ASCII,idMap={原 key→净化 id},XML 内无中文 id', async () => {
|
||||||
|
const { xml, processId, idMap } = buildNewProcessXml(single.xml, '总包合同交底', '总包合同交底');
|
||||||
|
expect(isAsciiNcName(processId)).toBe(true);
|
||||||
|
expect(idMap).toEqual({ 总包合同交底: processId });
|
||||||
|
expect(xml).toContain('id="' + processId + '"');
|
||||||
|
expect(xml).toContain('bpmnElement="' + processId + '"');
|
||||||
|
// moddle 拒中文 id:中文 key 实例化后仍能 fromXML(证明 id 已净化为 ASCII)。
|
||||||
|
const { warnings } = await roundTrip(xml);
|
||||||
|
expect(warnings).toEqual([]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('展示名进 process name(中文/特殊字符转义,round-trip 还原原文)', async () => {
|
||||||
|
const { xml } = buildNewProcessXml(single.xml, 'A&B <测试>', 'K');
|
||||||
|
expect(xml).toContain('name="A&B <测试>"');
|
||||||
|
const moddle = new BpmnModdle({ activiti });
|
||||||
|
const { rootElement } = await moddle.fromXML(xml);
|
||||||
|
const proc = (rootElement as { rootElements: Array<{ $type: string; name?: string }> }).rootElements.find(
|
||||||
|
(e) => e.$type === 'bpmn:Process',
|
||||||
|
);
|
||||||
|
expect(proc?.name).toBe('A&B <测试>');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('key 前后空白 trim 后再判定/替换', () => {
|
||||||
|
const { processId, idMap } = buildNewProcessXml(single.xml, 'n', ' LeaveApply ');
|
||||||
|
expect(processId).toBe('LeaveApply');
|
||||||
|
expect(idMap).toEqual({});
|
||||||
|
});
|
||||||
|
});
|
||||||
45
src/modeler/templates/two-level.bpmn.ts
Normal file
45
src/modeler/templates/two-level.bpmn.ts
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
// 新建流程模板——两级审批(start → 一级 userTask → 二级 userTask → end)。
|
||||||
|
//
|
||||||
|
// 两个 userTask 各带 activiti:candidateUsers(type:user,content 留空供侧板填人);结构、
|
||||||
|
// 全角【】/" 转义、约束(全小写元素名 + 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,'【"items":[【"type":"user","content":"","isCandidate":true,"isSendMail":false,"isSendPhone":false,"isSendMessage":false】]】')}"></userTask>
|
||||||
|
<userTask id="task_level2" name="二级审批" activiti:exclusive="false" activiti:candidateUsers="\${candidateUsersHandler.getCandidateUsers(execution,'【"items":[【"type":"user","content":"","isCandidate":true,"isSendMail":false,"isSendPhone":false,"isSendMessage":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>`;
|
||||||
@@ -370,4 +370,79 @@ describe('ProcessModelerPage', () => {
|
|||||||
expect(screen.queryByTestId('publish-diff-empty')).not.toBeInTheDocument();
|
expect(screen.queryByTestId('publish-diff-empty')).not.toBeInTheDocument();
|
||||||
expect(screen.getByTestId('publish-diff-list')).toHaveTextContent('办理人变更');
|
expect(screen.getByTestId('publish-diff-list')).toHaveTextContent('办理人变更');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// ── T4.1 新建流程(模板库 + NewProcessDialog;NewProcessDialog 不 mock,跑真实例化) ─────
|
||||||
|
it('“新建流程”按钮可用并打开新建对话框', async () => {
|
||||||
|
renderPage();
|
||||||
|
const btn = await screen.findByTestId('process-modeler-new');
|
||||||
|
expect(btn).not.toBeDisabled();
|
||||||
|
fireEvent.click(btn);
|
||||||
|
expect(await screen.findByTestId('new-process-name')).toBeInTheDocument();
|
||||||
|
expect(screen.getByTestId('new-process-template')).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('新建确认→挂 Modeler 并 importXML 模板实例化 XML(process id=用户 key,不取存量源)', async () => {
|
||||||
|
renderPage();
|
||||||
|
fireEvent.click(await screen.findByTestId('process-modeler-new'));
|
||||||
|
fireEvent.change(await screen.findByTestId('new-process-name'), { target: { value: '请假审批' } });
|
||||||
|
fireEvent.change(screen.getByTestId('new-process-key'), { target: { value: 'leaveApply' } });
|
||||||
|
fireEvent.change(screen.getByTestId('new-process-template'), { target: { value: 'single-approval' } });
|
||||||
|
fireEvent.click(screen.getByTestId('new-process-confirm'));
|
||||||
|
await waitFor(() => expect(importXMLMock).toHaveBeenCalled());
|
||||||
|
const xml = importXMLMock.mock.calls[0][0] as string;
|
||||||
|
expect(xml).toContain('id="leaveApply"');
|
||||||
|
expect(xml).toContain('userTask');
|
||||||
|
expect(xml).not.toContain('__PROCESS_ID__');
|
||||||
|
// 新建不走任何存量/草稿取源。
|
||||||
|
expect(mSource).not.toHaveBeenCalled();
|
||||||
|
expect(mSourceByKey).not.toHaveBeenCalled();
|
||||||
|
expect(mGetModel).not.toHaveBeenCalled();
|
||||||
|
// 打开器叠层消失(newDraft 激活)。
|
||||||
|
expect(screen.queryByTestId('process-modeler-open-select')).not.toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('新建会签模板→importXML 含 multiInstance', async () => {
|
||||||
|
renderPage();
|
||||||
|
fireEvent.click(await screen.findByTestId('process-modeler-new'));
|
||||||
|
fireEvent.change(await screen.findByTestId('new-process-name'), { target: { value: '会签' } });
|
||||||
|
fireEvent.change(screen.getByTestId('new-process-key'), { target: { value: 'cosignFlow' } });
|
||||||
|
fireEvent.change(screen.getByTestId('new-process-template'), { target: { value: 'cosign' } });
|
||||||
|
fireEvent.click(screen.getByTestId('new-process-confirm'));
|
||||||
|
await waitFor(() => expect(importXMLMock).toHaveBeenCalled());
|
||||||
|
expect(importXMLMock.mock.calls[0][0] as string).toContain('multiInstanceLoopCharacteristics');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('新建后存草稿→createDraft 带展示名/key/空 eip4IdMap,回填 ?modelId= 重载', async () => {
|
||||||
|
renderPage();
|
||||||
|
fireEvent.click(await screen.findByTestId('process-modeler-new'));
|
||||||
|
fireEvent.change(await screen.findByTestId('new-process-name'), { target: { value: '请假审批' } });
|
||||||
|
fireEvent.change(screen.getByTestId('new-process-key'), { target: { value: 'leaveApply' } });
|
||||||
|
fireEvent.click(screen.getByTestId('new-process-confirm'));
|
||||||
|
await waitFor(() => expect(importXMLMock).toHaveBeenCalled());
|
||||||
|
await waitFor(() => expect(saveBtn()).not.toBeDisabled());
|
||||||
|
fireEvent.click(saveBtn());
|
||||||
|
await waitFor(() => expect(mCreateDraft).toHaveBeenCalled());
|
||||||
|
const body = mCreateDraft.mock.calls[0][0];
|
||||||
|
expect(body.name).toBe('请假审批'); // 展示名(非 key)
|
||||||
|
expect(body.key).toBe('leaveApply');
|
||||||
|
expect(JSON.parse(body.metaInfo!).eip4IdMap).toEqual({}); // ASCII key 无还原映射
|
||||||
|
expect(mFromProcDef).not.toHaveBeenCalled();
|
||||||
|
// 首存回填 ?modelId=NEW-1 → 按 modelId 重载。
|
||||||
|
await waitFor(() => expect(mGetModel).toHaveBeenCalledWith('NEW-1'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('新建中文 key→process id 净化为 ASCII,createDraft.metaInfo.eip4IdMap 记录还原映射', async () => {
|
||||||
|
renderPage();
|
||||||
|
fireEvent.click(await screen.findByTestId('process-modeler-new'));
|
||||||
|
fireEvent.change(await screen.findByTestId('new-process-name'), { target: { value: '总包合同交底' } });
|
||||||
|
fireEvent.change(screen.getByTestId('new-process-key'), { target: { value: '总包合同交底' } });
|
||||||
|
fireEvent.click(screen.getByTestId('new-process-confirm'));
|
||||||
|
await waitFor(() => expect(importXMLMock).toHaveBeenCalled());
|
||||||
|
expect(importXMLMock.mock.calls[0][0] as string).not.toContain('id="总包合同交底"');
|
||||||
|
await waitFor(() => expect(saveBtn()).not.toBeDisabled());
|
||||||
|
fireEvent.click(saveBtn());
|
||||||
|
await waitFor(() => expect(mCreateDraft).toHaveBeenCalled());
|
||||||
|
const meta = JSON.parse(mCreateDraft.mock.calls[0][0].metaInfo!);
|
||||||
|
expect(Object.keys(meta.eip4IdMap)).toEqual(['总包合同交底']);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import {
|
|||||||
} from '../api/processModeler';
|
} from '../api/processModeler';
|
||||||
import { Eip4Panel, type PanelModeler } from '../modeler/Eip4Panel';
|
import { Eip4Panel, type PanelModeler } from '../modeler/Eip4Panel';
|
||||||
import { PublishConfirm } from '../modeler/PublishConfirm';
|
import { PublishConfirm } from '../modeler/PublishConfirm';
|
||||||
|
import { NewProcessDialog, type NewProcessResult } from '../modeler/NewProcessDialog';
|
||||||
import { toast } from '../components/ui';
|
import { toast } from '../components/ui';
|
||||||
|
|
||||||
// bpmn-js/lib/Modeler 自带类型,但选项对象里的标准面板模块(本项目无类型)与 moddle JSON
|
// bpmn-js/lib/Modeler 自带类型,但选项对象里的标准面板模块(本项目无类型)与 moddle JSON
|
||||||
@@ -78,6 +79,8 @@ export function ProcessModelerPage() {
|
|||||||
const modelIdRef = useRef<string>('');
|
const modelIdRef = useRef<string>('');
|
||||||
// 当前载入流程的 key(存量 procDefKey / 草稿 key)——新建草稿的 name/key 源。
|
// 当前载入流程的 key(存量 procDefKey / 草稿 key)——新建草稿的 name/key 源。
|
||||||
const loadedKeyRef = useRef<string>('');
|
const loadedKeyRef = useRef<string>('');
|
||||||
|
// 新建流程的展示名(首存草稿的 name 用;存量/草稿路为空,createDraft 回退用 key)。
|
||||||
|
const newNameRef = useRef<string>('');
|
||||||
// 打开时的**原始**源 XML(发布影响摘要的 diff 基线:openSource vs 当前 saveXML)。
|
// 打开时的**原始**源 XML(发布影响摘要的 diff 基线:openSource vs 当前 saveXML)。
|
||||||
const openSourceRef = useRef<string>('');
|
const openSourceRef = useRef<string>('');
|
||||||
// 基线归属标识:openSourceRef 对应哪个打开目标。存量首存会 setParams(modelId) 触发载入 effect
|
// 基线归属标识:openSourceRef 对应哪个打开目标。存量首存会 setParams(modelId) 触发载入 effect
|
||||||
@@ -90,6 +93,10 @@ export function ProcessModelerPage() {
|
|||||||
const [saving, setSaving] = useState(false);
|
const [saving, setSaving] = useState(false);
|
||||||
// 发布弹窗:非 null 时展示 PublishConfirm,xml=点发布瞬间的 saveXML 结果。
|
// 发布弹窗:非 null 时展示 PublishConfirm,xml=点发布瞬间的 saveXML 结果。
|
||||||
const [publish, setPublish] = useState<{ xml: string } | null>(null);
|
const [publish, setPublish] = useState<{ xml: string } | null>(null);
|
||||||
|
// 新建流程:对话框开关 + pending 新建(非 null 时无 URL 目标也挂 Modeler 并 import 模板实例化 XML,
|
||||||
|
// 首存前不落草稿——走 T2.5 createDraft 首存路径)。
|
||||||
|
const [showNewDialog, setShowNewDialog] = useState(false);
|
||||||
|
const [newDraft, setNewDraft] = useState<NewProcessResult | null>(null);
|
||||||
const [options, setOptions] = useState<ProcessOption[]>([]);
|
const [options, setOptions] = useState<ProcessOption[]>([]);
|
||||||
const [optionsError, setOptionsError] = useState('');
|
const [optionsError, setOptionsError] = useState('');
|
||||||
// 打开器 tab:存量流程 / 草稿。
|
// 打开器 tab:存量流程 / 草稿。
|
||||||
@@ -123,9 +130,10 @@ export function ProcessModelerPage() {
|
|||||||
};
|
};
|
||||||
}, [isAdmin, hasTarget, openTab, draftsReload]);
|
}, [isAdmin, hasTarget, openTab, draftsReload]);
|
||||||
|
|
||||||
// 有目标时挂载 Modeler 并载入 BPMN(草稿→getModel / 存量→source)。
|
// 有目标(或 pending 新建)时挂载 Modeler 并载入 BPMN(草稿→getModel / 存量→source / 新建→模板)。
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isAdmin || !hasTarget) return;
|
if (!isAdmin) return;
|
||||||
|
if (!hasTarget && !newDraft) return;
|
||||||
let alive = true;
|
let alive = true;
|
||||||
let modeler: ModelerLike | null = null;
|
let modeler: ModelerLike | null = null;
|
||||||
setLoadState('loading');
|
setLoadState('loading');
|
||||||
@@ -133,24 +141,33 @@ export function ProcessModelerPage() {
|
|||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
try {
|
try {
|
||||||
// 三条路统一成 {found,bpmnXml,idMap,key}。
|
// 新建流程:无 URL 目标但有 pending newDraft → 直接用模板实例化 XML(无远端取源、无 found 守卫)。
|
||||||
let src: { found: boolean; bpmnXml?: string; idMap?: Record<string, string>; key?: string };
|
const isNew = !hasTarget && !!newDraft;
|
||||||
if (modelIdParam) {
|
let bpmnXml: string;
|
||||||
const m = await getModel(modelIdParam);
|
// 非新建三条路统一成 {found,bpmnXml,idMap,key}。
|
||||||
src = { found: m.found, bpmnXml: m.bpmnXml, idMap: parseMetaIdMap(m.metaInfo), key: m.key };
|
let src: { found: boolean; bpmnXml?: string; idMap?: Record<string, string>; key?: string } | undefined;
|
||||||
} else if (procDefId) {
|
if (isNew) {
|
||||||
const s = await fetchProcDefSource(procDefId);
|
bpmnXml = newDraft!.xml;
|
||||||
src = { found: s.found, bpmnXml: s.bpmnXml, idMap: s.idMap, key: s.procDefKey };
|
|
||||||
} else {
|
} else {
|
||||||
const s = await fetchProcDefSourceByKey(procKey);
|
if (modelIdParam) {
|
||||||
src = { found: s.found, bpmnXml: s.bpmnXml, idMap: s.idMap, key: s.procDefKey };
|
const m = await getModel(modelIdParam);
|
||||||
|
src = { found: m.found, bpmnXml: m.bpmnXml, idMap: parseMetaIdMap(m.metaInfo), key: m.key };
|
||||||
|
} else if (procDefId) {
|
||||||
|
const s = await fetchProcDefSource(procDefId);
|
||||||
|
src = { found: s.found, bpmnXml: s.bpmnXml, idMap: s.idMap, key: s.procDefKey };
|
||||||
|
} else {
|
||||||
|
const s = await fetchProcDefSourceByKey(procKey);
|
||||||
|
src = { found: s.found, bpmnXml: s.bpmnXml, idMap: s.idMap, key: s.procDefKey };
|
||||||
|
}
|
||||||
|
if (!alive) return;
|
||||||
|
if (!src.found || !src.bpmnXml) {
|
||||||
|
setLoadError('未找到该流程的 BPMN 源(可能未部署或无布局信息)');
|
||||||
|
setLoadState('error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
bpmnXml = src.bpmnXml;
|
||||||
}
|
}
|
||||||
if (!alive) return;
|
if (!alive) return;
|
||||||
if (!src.found || !src.bpmnXml) {
|
|
||||||
setLoadError('未找到该流程的 BPMN 源(可能未部署或无布局信息)');
|
|
||||||
setLoadState('error');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!canvasRef.current) {
|
if (!canvasRef.current) {
|
||||||
// 画布容器缺失(异常时序):明确报错,别停在 loading 无提示(T1.5 评审 M-2)。
|
// 画布容器缺失(异常时序):明确报错,别停在 loading 无提示(T1.5 评审 M-2)。
|
||||||
setLoadError('画布未就绪,请重试');
|
setLoadError('画布未就绪,请重试');
|
||||||
@@ -176,22 +193,33 @@ export function ProcessModelerPage() {
|
|||||||
/* 面板模块缺失 / stub 时忽略 */
|
/* 面板模块缺失 / stub 时忽略 */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
idMapRef.current = src.idMap ?? {};
|
if (isNew) {
|
||||||
loadedKeyRef.current = src.key ?? '';
|
// 新建:idMap(中文 key 还原用)/key/名称进 ref,供首存 createDraft;无原始源→diff 基线空。
|
||||||
// diff 基线:仅在**首次打开某目标**时捕获原始源;同目标重跑(含首存后 procKey→modelId
|
idMapRef.current = newDraft!.idMap;
|
||||||
// 的 reload,归属已由 handleSaveDraft 预置成新 modelId)则保留,防 I1 基线被冲成「已存版」。
|
loadedKeyRef.current = newDraft!.key;
|
||||||
const openTargetKey = modelIdParam
|
newNameRef.current = newDraft!.name;
|
||||||
? 'model:' + modelIdParam
|
modelIdRef.current = '';
|
||||||
: procDefId
|
openSourceRef.current = '';
|
||||||
? 'pd:' + procDefId
|
baselineTargetRef.current = 'new:' + newDraft!.key;
|
||||||
: 'pk:' + procKey;
|
} else {
|
||||||
if (baselineTargetRef.current !== openTargetKey) {
|
idMapRef.current = src!.idMap ?? {};
|
||||||
openSourceRef.current = src.bpmnXml; // 此处 bpmnXml 已由上方 found 守卫保证非空
|
loadedKeyRef.current = src!.key ?? '';
|
||||||
baselineTargetRef.current = openTargetKey;
|
newNameRef.current = '';
|
||||||
|
// diff 基线:仅在**首次打开某目标**时捕获原始源;同目标重跑(含首存后 procKey→modelId
|
||||||
|
// 的 reload,归属已由 handleSaveDraft 预置成新 modelId)则保留,防 I1 基线被冲成「已存版」。
|
||||||
|
const openTargetKey = modelIdParam
|
||||||
|
? 'model:' + modelIdParam
|
||||||
|
: procDefId
|
||||||
|
? 'pd:' + procDefId
|
||||||
|
: 'pk:' + procKey;
|
||||||
|
if (baselineTargetRef.current !== openTargetKey) {
|
||||||
|
openSourceRef.current = bpmnXml; // 此处 bpmnXml 已由上方 found 守卫保证非空
|
||||||
|
baselineTargetRef.current = openTargetKey;
|
||||||
|
}
|
||||||
|
// 草稿路:记住 modelId(后续保存走 PUT);存量路:清空(首次保存新建草稿)。
|
||||||
|
modelIdRef.current = modelIdParam || '';
|
||||||
}
|
}
|
||||||
// 草稿路:记住 modelId(后续保存走 PUT);存量路:清空(首次保存新建草稿)。
|
await modeler.importXML(bpmnXml);
|
||||||
modelIdRef.current = modelIdParam || '';
|
|
||||||
await modeler.importXML(src.bpmnXml);
|
|
||||||
if (!alive) return;
|
if (!alive) return;
|
||||||
modelerRef.current = modeler;
|
modelerRef.current = modeler;
|
||||||
setModelerReady(modeler);
|
setModelerReady(modeler);
|
||||||
@@ -222,7 +250,7 @@ export function ProcessModelerPage() {
|
|||||||
modelerRef.current = null;
|
modelerRef.current = null;
|
||||||
setModelerReady(null);
|
setModelerReady(null);
|
||||||
};
|
};
|
||||||
}, [isAdmin, procDefId, procKey, modelIdParam]);
|
}, [isAdmin, procDefId, procKey, modelIdParam, newDraft]);
|
||||||
|
|
||||||
// 保存草稿:saveXML → 有 modelId 走 PUT(不重发 metaInfo,保住 eip4IdMap);
|
// 保存草稿:saveXML → 有 modelId 走 PUT(不重发 metaInfo,保住 eip4IdMap);
|
||||||
// 无 modelId:存量按 procDefId 走 from-procdef(后端写 metaInfo)再 PUT 覆盖为编辑源;
|
// 无 modelId:存量按 procDefId 走 from-procdef(后端写 metaInfo)再 PUT 覆盖为编辑源;
|
||||||
@@ -246,17 +274,21 @@ export function ProcessModelerPage() {
|
|||||||
setParams({ modelId }, { replace: true });
|
setParams({ modelId }, { replace: true });
|
||||||
} else {
|
} else {
|
||||||
const key = loadedKeyRef.current || procKey || 'new_process';
|
const key = loadedKeyRef.current || procKey || 'new_process';
|
||||||
|
// 新建流程用展示名(newNameRef);存量按 key 无展示名,回退用 key。
|
||||||
|
const name = newNameRef.current || key;
|
||||||
// metaInfo 结构与 from-procdef 对齐(sourceProcDefId 便于 T3.x 影响摘要/审计,
|
// metaInfo 结构与 from-procdef 对齐(sourceProcDefId 便于 T3.x 影响摘要/审计,
|
||||||
// 虽 restore 只读 eip4IdMap)。
|
// 虽 restore 只读 eip4IdMap;新建中文 key 的 idMap 使发布 restore 回中文 process key)。
|
||||||
const metaInfo = JSON.stringify({
|
const metaInfo = JSON.stringify({
|
||||||
eip4IdMap: idMapRef.current,
|
eip4IdMap: idMapRef.current,
|
||||||
sourceProcDefId: procDefId || '',
|
sourceProcDefId: procDefId || '',
|
||||||
originalKey: key,
|
originalKey: key,
|
||||||
});
|
});
|
||||||
modelId = await createDraft({ name: key, key, bpmnXml: xml, metaInfo });
|
modelId = await createDraft({ name, key, bpmnXml: xml, metaInfo });
|
||||||
modelIdRef.current = modelId;
|
modelIdRef.current = modelId;
|
||||||
// I1:同上,reload 保留原始源基线。
|
// I1:同上,reload 保留原始源基线。
|
||||||
baselineTargetRef.current = 'model:' + modelId;
|
baselineTargetRef.current = 'model:' + modelId;
|
||||||
|
// 新建首存后清 pending newDraft:随后回填 ?modelId= 触发按 modelId 正常重载(幂等)。
|
||||||
|
if (newDraft) setNewDraft(null);
|
||||||
setParams({ modelId }, { replace: true });
|
setParams({ modelId }, { replace: true });
|
||||||
}
|
}
|
||||||
toast('已保存草稿', 'ok');
|
toast('已保存草稿', 'ok');
|
||||||
@@ -346,7 +378,9 @@ export function ProcessModelerPage() {
|
|||||||
<span className="muted" style={{ fontSize: 12, flex: 1 }}>
|
<span className="muted" style={{ fontSize: 12, flex: 1 }}>
|
||||||
{hasTarget
|
{hasTarget
|
||||||
? `已打开:${modelIdParam ? '草稿 ' + modelIdParam : procDefId || procKey}`
|
? `已打开:${modelIdParam ? '草稿 ' + modelIdParam : procDefId || procKey}`
|
||||||
: '在线编辑 BPMN 流程定义(可编辑存量 / 草稿)'}
|
: newDraft
|
||||||
|
? `新建流程:${newDraft.name}(${newDraft.key})`
|
||||||
|
: '在线编辑 BPMN 流程定义(可编辑存量 / 草稿 / 新建)'}
|
||||||
</span>
|
</span>
|
||||||
<button
|
<button
|
||||||
className="btn btn-sm"
|
className="btn btn-sm"
|
||||||
@@ -376,8 +410,8 @@ export function ProcessModelerPage() {
|
|||||||
<div style={{ flex: 1, position: 'relative', minWidth: 0, background: '#fff' }}>
|
<div style={{ flex: 1, position: 'relative', minWidth: 0, background: '#fff' }}>
|
||||||
<div ref={canvasRef} data-testid="process-modeler-canvas" style={{ width: '100%', height: '100%' }} />
|
<div ref={canvasRef} data-testid="process-modeler-canvas" style={{ width: '100%', height: '100%' }} />
|
||||||
|
|
||||||
{/* 未打开任何流程:叠加打开器(存量流程 / 草稿 两 tab) */}
|
{/* 未打开任何流程且无 pending 新建:叠加打开器(存量流程 / 草稿 两 tab) */}
|
||||||
{!hasTarget ? (
|
{!hasTarget && !newDraft ? (
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
@@ -426,7 +460,12 @@ export function ProcessModelerPage() {
|
|||||||
{optionsError ? (
|
{optionsError ? (
|
||||||
<div style={{ color: 'var(--err)', fontSize: 12 }}>{optionsError}</div>
|
<div style={{ color: 'var(--err)', fontSize: 12 }}>{optionsError}</div>
|
||||||
) : null}
|
) : null}
|
||||||
<button className="btn btn-sm" data-testid="process-modeler-new" disabled title="新建流程(下阶段)">
|
<button
|
||||||
|
className="btn btn-sm"
|
||||||
|
data-testid="process-modeler-new"
|
||||||
|
onClick={() => setShowNewDialog(true)}
|
||||||
|
title="新建流程(空白 / 单人 / 两级 / 会签 模板)"
|
||||||
|
>
|
||||||
+ 新建流程
|
+ 新建流程
|
||||||
</button>
|
</button>
|
||||||
</>
|
</>
|
||||||
@@ -515,6 +554,17 @@ export function ProcessModelerPage() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* 新建流程对话框(名称/key/模板 → 实例化模板进入编辑态,首存前不落草稿) */}
|
||||||
|
{showNewDialog ? (
|
||||||
|
<NewProcessDialog
|
||||||
|
onClose={() => setShowNewDialog(false)}
|
||||||
|
onConfirm={(r) => {
|
||||||
|
setShowNewDialog(false);
|
||||||
|
setNewDraft(r); // 触发挂载 effect:importXML(模板实例化 XML) + 清空 diff 基线
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
|
|
||||||
{/* 同人确认发布弹窗(影响摘要 + 节点级 diff + 422 校验清单) */}
|
{/* 同人确认发布弹窗(影响摘要 + 节点级 diff + 422 校验清单) */}
|
||||||
{publish && modelIdRef.current ? (
|
{publish && modelIdRef.current ? (
|
||||||
<PublishConfirm
|
<PublishConfirm
|
||||||
|
|||||||
Reference in New Issue
Block a user