diff --git a/apps/api/src/app/seed-mvp-flow.ts b/apps/api/src/app/seed-mvp-flow.ts
index 18da8e1..e72437c 100644
--- a/apps/api/src/app/seed-mvp-flow.ts
+++ b/apps/api/src/app/seed-mvp-flow.ts
@@ -5,8 +5,8 @@
* 无条件边作默认兜底);汇合 = 多入边异或。活动契约不带负责人岗位 —— 分派归运营。
* 10 节点 14 边(E1–E14);审批点 A5 的两个去向就是它自己的两条条件出边(verdict 由引擎注入)。
*
- * 几何:顺序流一律画成**真边**(卡点画法已废除,2026-07-28 第三轮),零交叉:
- * 直达与回跳各占一条车道,长线避框走 —— 见 diagram 里逐段注记。
+ * 几何:顺序流一律画成**真边**(卡点画法已废除);现行几何取自设计者手调的 v4 ——
+ * 三条定价来路并入 x170 合流下行道、议价回边沿左缘绕行,见 diagram 里逐段注记。
*/
import { processPackageSchema, triggerConfigSchema } from '@contracts';
import type { ProcessPackage } from '@contracts';
@@ -215,101 +215,123 @@ export const MVP_PACKAGE: ProcessPackage = processPackageSchema.parse({
],
variables: [],
/*
- * 手绘几何存证 —— 呈现以它为真相。顺序流全是真边,零交叉:
- * 顶车道 y30:E3 直接寻源(A1 北口 → A3 北口,跨过 A2)
- * 带 0(y60–100) start → A1 → A2 → A3
- * E4 直接定价:A1 南口 x130 直落 A4 北口(x130 在所有横车道的左端之外)
- * 车道 y190:E6 选型后定价(A2 南口 x310 落下,西行,x160 进 A4 北口)
- * 车道 y230:E7 供应商底价表(A3 东探 x610 下行,西扫,x200 进 A4 北口)
- * 带 1(y310–350) A4 → A5 → A6 → end_won;E8/E10 在 A4–A5 缝隙里一上一下对开
- * 车道 y380:E12 有异议(A6 南口 x500 落下,西扫,x160 上顶 A4 南口)
- * E13 拒绝/超时:A6 南口 x520 下行右拐进 A7;带 2(y410+) A7 → end_arch
+ * 手绘几何存证 —— 呈现以它为真相。本几何取自设计者手调的 v4(2026-07-28,
+ * id 经修复对齐编号;整体较初版右下移 10px),顺序流全是真边:
+ * 顶车道 y40:E3 直接寻源(A1 北口 → A3 北口,跨过 A2)
+ * 带 0(y70–110) start → A1 → A2 → A3
+ * 合流下行道 x170:E4 直落、E6(y210 西行)、E7(y240 西行)三条定价来路
+ * 并入同一条下行道,共同扎进 A4 北口 —— 视觉即「三路汇于定价」
+ * 带 1(y320–360) A4 → A5 → A6 → end_won;E8 提审 / E9 通过走缝隙 y340
+ * E10 不通过:带下 y410 折返,上顶 A4 南口
+ * E12 有异议:与 E13 共干(x530 下行至 y440),再沿左缘 x80 上行,进 A4 西口
+ * E13 拒绝/超时:共干后右行进 A7;带 2(y420+) A7 → end_arch
*/
diagram: {
manual: true,
rows: [],
anchors: [],
nodes: [
- { id: 'start', kind: 'start', label: '客户RFQ询价', x: 30, y: 70, lx: 44, ly: 104 },
- { id: 'A1', kind: 'activity', label: '客户RFQ受理', code: 'A1', x: 110, y: 60 },
- { id: 'A2', kind: 'activity', label: '替代选型', code: 'A2', x: 290, y: 60 },
- { id: 'A3', kind: 'activity', label: '寻源询价', code: 'A3', x: 470, y: 60 },
- { id: 'A4', kind: 'activity', label: '成本定价', code: 'A4', x: 110, y: 310 },
- { id: 'A5', kind: 'activity', label: '定价审批', code: 'A5', owner: 'PM', flavor: 'approval', x: 290, y: 310 },
- { id: 'A6', kind: 'activity', label: '报价议价', code: 'A6', x: 470, y: 310 },
- { id: 'A7', kind: 'activity', label: '情报归档', code: 'A7', x: 630, y: 410 },
- { id: 'end_won', kind: 'end', label: '转订单履约', x: 630, y: 320, lx: 640, ly: 352 },
- { id: 'end_arch', kind: 'end-bad', label: '归档闭环', x: 790, y: 420, lx: 800, ly: 452 },
+ { id: 'start', kind: 'start', label: '客户RFQ询价', x: 40, y: 80, lx: 54, ly: 112 },
+ { id: 'A1', kind: 'activity', label: '客户RFQ受理', code: 'A1', x: 120, y: 70 },
+ { id: 'A2', kind: 'activity', label: '替代选型', code: 'A2', x: 300, y: 70 },
+ { id: 'A3', kind: 'activity', label: '寻源询价', code: 'A3', x: 480, y: 70 },
+ { id: 'A4', kind: 'activity', label: '成本定价', code: 'A4', x: 120, y: 320 },
+ { id: 'A5', kind: 'activity', label: '定价审批', code: 'A5', owner: 'PM', flavor: 'approval', x: 300, y: 320 },
+ { id: 'A6', kind: 'activity', label: '报价议价', code: 'A6', x: 480, y: 320 },
+ { id: 'A7', kind: 'activity', label: '情报归档', code: 'A7', x: 640, y: 420 },
+ { id: 'end_won', kind: 'end', label: '转订单履约', x: 640, y: 330, lx: 650, ly: 360 },
+ { id: 'end_arch', kind: 'end-bad', label: '归档闭环', x: 800, y: 430, lx: 810, ly: 460 },
],
edges: [
- { from: 'start', to: 'A1', points: [{ x: 50, y: 80 }, { x: 110, y: 80 }] },
- { from: 'A1', to: 'A2', label: '需要选型', points: [{ x: 210, y: 80 }, { x: 290, y: 80 }] },
- // E3 顶车道:跨过 A2 直达 A3 北口
+ { from: 'start', to: 'A1', points: [{ x: 60, y: 90 }, { x: 120, y: 90 }] },
+ { from: 'A1', to: 'A2', label: '需要选型', lx: 260, ly: 78, points: [{ x: 220, y: 90 }, { x: 300, y: 90 }] },
{
from: 'A1',
to: 'A3',
label: '直接寻源',
+ lx: 350,
+ ly: 28,
points: [
- { x: 160, y: 60 },
- { x: 160, y: 30 },
- { x: 520, y: 30 },
- { x: 520, y: 60 },
+ { x: 170, y: 70 },
+ { x: 170, y: 40 },
+ { x: 530, y: 40 },
+ { x: 530, y: 70 },
],
},
- // E4 直落:x130 在 E6(x160 起)与 E7(x200 起)两条横车道左端之外,零交叉
- { from: 'A1', to: 'A4', label: '直接定价', lx: 88, ly: 200, points: [{ x: 130, y: 100 }, { x: 130, y: 310 }] },
- { from: 'A2', to: 'A3', label: '仍需寻源', points: [{ x: 390, y: 80 }, { x: 470, y: 80 }] },
- // E6 车道 y190:A2 南口下行、西行、进 A4 北口
+ { from: 'A1', to: 'A4', label: '直接定价', lx: 200, ly: 140, points: [{ x: 170, y: 110 }, { x: 170, y: 320 }] },
+ { from: 'A2', to: 'A3', label: '仍需寻源', lx: 440, ly: 78, points: [{ x: 400, y: 90 }, { x: 480, y: 90 }] },
{
from: 'A2',
to: 'A4',
label: '选型后定价',
- lx: 235,
- ly: 182,
+ lx: 260,
+ ly: 200,
points: [
- { x: 310, y: 100 },
- { x: 310, y: 190 },
- { x: 160, y: 190 },
- { x: 160, y: 310 },
+ { x: 350, y: 110 },
+ { x: 350, y: 210 },
+ { x: 170, y: 210 },
+ { x: 170, y: 320 },
],
},
- // E7 车道 y230:A3 东探绕行(x610),在 E6 之下、A5 上行线之上零交叉扫回
{
from: 'A3',
to: 'A4',
label: '供应商底价表',
- lx: 420,
- ly: 222,
+ lx: 480,
+ ly: 230,
points: [
- { x: 570, y: 80 },
- { x: 610, y: 80 },
- { x: 610, y: 230 },
- { x: 200, y: 230 },
- { x: 200, y: 310 },
+ { x: 530, y: 110 },
+ { x: 530, y: 240 },
+ { x: 170, y: 240 },
+ { x: 170, y: 320 },
],
},
- // E8/E10:A4–A5 缝隙里一上一下对开(y320 提审,y340 退回)
- { from: 'A4', to: 'A5', label: '报价草案提审', lx: 250, ly: 312, points: [{ x: 210, y: 320 }, { x: 290, y: 320 }] },
- { from: 'A5', to: 'A6', label: '通过', tone: 'ok', points: [{ x: 390, y: 330 }, { x: 470, y: 330 }] },
- { from: 'A5', to: 'A4', label: '不通过', tone: 'bad', lx: 250, ly: 352, points: [{ x: 290, y: 340 }, { x: 210, y: 340 }] },
- { from: 'A6', to: 'end_won', label: '成交', tone: 'ok', points: [{ x: 570, y: 330 }, { x: 630, y: 330 }] },
- // E12 车道 y380:A6 南口西扫,上顶 A4 南口
+ { from: 'A4', to: 'A5', label: '报价草案提审', lx: 260, ly: 328, points: [{ x: 220, y: 340 }, { x: 300, y: 340 }] },
+ { from: 'A5', to: 'A6', label: '通过', tone: 'ok', lx: 440, ly: 328, points: [{ x: 400, y: 340 }, { x: 480, y: 340 }] },
+ {
+ from: 'A5',
+ to: 'A4',
+ label: '不通过',
+ tone: 'bad',
+ lx: 250,
+ ly: 400,
+ points: [
+ { x: 350, y: 360 },
+ { x: 350, y: 410 },
+ { x: 170, y: 410 },
+ { x: 170, y: 360 },
+ ],
+ },
+ { from: 'A6', to: 'end_won', label: '成交', tone: 'ok', lx: 610, ly: 328, points: [{ x: 580, y: 340 }, { x: 640, y: 340 }] },
{
from: 'A6',
to: 'A4',
label: '有异议',
tone: 'bad',
- lx: 330,
- ly: 372,
+ lx: 350,
+ ly: 428,
points: [
- { x: 500, y: 350 },
- { x: 500, y: 380 },
- { x: 160, y: 380 },
- { x: 160, y: 350 },
+ { x: 530, y: 360 },
+ { x: 530, y: 440 },
+ { x: 80, y: 440 },
+ { x: 80, y: 340 },
+ { x: 120, y: 340 },
],
},
- { from: 'A6', to: 'A7', label: '拒绝/超时', tone: 'bad', lx: 560, ly: 405, points: [{ x: 520, y: 350 }, { x: 520, y: 430 }, { x: 630, y: 430 }] },
- { from: 'A7', to: 'end_arch', label: '归档闭环', points: [{ x: 730, y: 430 }, { x: 790, y: 430 }] },
+ {
+ from: 'A6',
+ to: 'A7',
+ label: '拒绝/超时',
+ tone: 'bad',
+ lx: 580,
+ ly: 430,
+ points: [
+ { x: 530, y: 360 },
+ { x: 530, y: 440 },
+ { x: 640, y: 440 },
+ ],
+ },
+ { from: 'A7', to: 'end_arch', label: '归档闭环', lx: 770, ly: 428, points: [{ x: 740, y: 440 }, { x: 800, y: 440 }] },
],
},
});
diff --git a/apps/web/src/features/gov-process/internal/panel.tsx b/apps/web/src/features/gov-process/internal/panel.tsx
index bbf5b4b..db50eeb 100644
--- a/apps/web/src/features/gov-process/internal/panel.tsx
+++ b/apps/web/src/features/gov-process/internal/panel.tsx
@@ -939,7 +939,7 @@ function FlowLab({
onClick={() => { setSelEdge(selEdge === i ? null : i); setSel(null); }}
>
{e.code ?? `边${i + 1}`}
- {e.from}→{e.to}
+ {e.label ?? ''}
))}
diff --git a/apps/web/src/shared/gov/flow/flow-editor-core.ts b/apps/web/src/shared/gov/flow/flow-editor-core.ts
index 174d48c..d843d7f 100644
--- a/apps/web/src/shared/gov/flow/flow-editor-core.ts
+++ b/apps/web/src/shared/gov/flow/flow-editor-core.ts
@@ -38,7 +38,7 @@ import {
type FlowNodeKind,
type FlowTone,
} from "./flow-layout.ts";
-import { cleanPoints, mintNodeId, orderActivityIds, seedManualGraph, snap, swapIdTokens, type OrderNode } from "./manual-flow.ts";
+import { cleanPoints, mintNodeId, seedManualGraph, snap } from "./manual-flow.ts";
import { arrowHeadPoints, CAPTION_STYLE, FLOW_MONO, paintNode, svgEl, TONE_COLOR } from "./flow-node-paint.ts";
/**
@@ -809,51 +809,14 @@ export function createFlowEditor(initial: FlowGraph | null | undefined, options:
}
}
- const renumberAll = () => {
- const shapes = elementRegistry
- .getAll()
- .filter((el: Any) => el.parent && !el.waypoints && !el.labelTarget && el.businessObject?.id);
- const nodes: OrderNode[] = shapes.map((el: Any) => ({
- id: el.businessObject.id,
- kind: el.businessObject.kind,
- x: el.x + el.width / 2,
- y: el.y + el.height / 2,
- }));
- const edges = elementRegistry
- .getAll()
- .filter((el: Any) => el.waypoints && el.parent && el.source?.businessObject?.id && el.target?.businessObject?.id)
- .map((el: Any) => ({ from: el.source.businessObject.id, to: el.target.businessObject.id }));
- const mapping = orderActivityIds(nodes, edges);
- if (mapping.size === 0) return;
- const changed: Any[] = [];
- for (const el of shapes) {
- const bo = el.businessObject as FlowNode;
- let touched = false;
- if (mapping.has(bo.id)) {
- bo.id = mapping.get(bo.id)!;
- touched = true;
- }
- if (bo.to && mapping.has(bo.to)) {
- bo.to = mapping.get(bo.to)!;
- touched = true;
- }
- if (bo.basis) {
- const swapped = swapIdTokens(bo.basis, mapping);
- if (swapped !== bo.basis) {
- bo.basis = swapped;
- touched = true;
- }
- }
- if (touched) {
- changed.push(el);
- const label = labelOf(el);
- if (label) changed.push(label);
- }
- }
- if (changed.length) eventBus.fire("elements.changed", { elements: changed });
- };
- renumberAll();
- eventBus.on("commandStack.changed", renumberAll);
+ /*
+ * **不自动重排编号**(2026-07-28 第四轮拔除)。
+ * 旧机制「几何即排序把手」在卡点时代成立 —— 回跳画成牌子,图无环,拓扑重排稳定;
+ * 回跳成真边后图**有环**,破环顺序会把在座节点的 id 转圈重派(实测:成本定价
+ * A4→A6、审批 A4、议价 A5),而 id 是**节点身份**:在途工作流按它钉定义、
+ * 边映射按它寻址、异常按它定位 —— 身份不许因挪动布局而漂移。
+ * 编号在落子时铸定(mintNodeId 取下一个空号),此后恒定;想换号,删了重画。
+ */
const serialize = (): { graph: FlowGraph; idMap: Record } => {
// 画布是无限域(可有负坐标)——先求整体包围,统一平移到非负(保相对几何/正交),再吸附珊格。
diff --git a/apps/web/src/shared/gov/flow/manual-flow.ts b/apps/web/src/shared/gov/flow/manual-flow.ts
index 76f3688..b69bfbe 100644
--- a/apps/web/src/shared/gov/flow/manual-flow.ts
+++ b/apps/web/src/shared/gov/flow/manual-flow.ts
@@ -133,84 +133,7 @@ const ID_PREFIX: Partial> = {
/* ---- 活动自动顺序编号:沿流向拓扑序,几何 (y,x) 决胜 ---- */
-export interface OrderNode {
- id: string;
- kind: FlowNodeKind;
- /** 节点中心(决胜用)。 */
- x: number;
- y: number;
-}
-/**
- * 计算活动的规范编号 A1..An:从入度 0 的节点(起始)沿连线做拓扑遍历,
- * 同时就绪者按 (y,x) 取先(上面的先、左边的先)——汇合点等所有来路编号完才轮到,
- * 所以网关分支链先占号、汇后主线随后,与剧本世界的编号纪律同构;
- * 几何即排序把手:想换号,挪节点。环用 (剩余入度,y,x) 最小者破;
- * 不可达的活动排在最后。只返回**有变化**的 旧id→新id 映射。
- */
-export function orderActivityIds(nodes: OrderNode[], edges: Array<{ from: string; to: string }>): Map {
- const byId = new Map(nodes.map((n) => [n.id, n]));
- const indeg = new Map(nodes.map((n) => [n.id, 0]));
- const out = new Map();
- for (const e of edges) {
- if (!byId.has(e.from) || !byId.has(e.to) || e.from === e.to) continue;
- out.set(e.from, [...(out.get(e.from) ?? []), e.to]);
- indeg.set(e.to, (indeg.get(e.to) ?? 0) + 1);
- }
- const geo = (id: string): [number, number] => {
- const n = byId.get(id)!;
- return [n.y, n.x];
- };
- const byGeo = (a: string, b: string) => geo(a)[0] - geo(b)[0] || geo(a)[1] - geo(b)[1];
-
- const visited = new Set();
- const ready = new Set(nodes.filter((n) => (indeg.get(n.id) ?? 0) === 0).map((n) => n.id));
- const mapping = new Map();
- let seq = 0;
-
- const visit = (id: string) => {
- visited.add(id);
- ready.delete(id);
- const node = byId.get(id)!;
- if (node.kind === "activity") mapping.set(id, `A${++seq}`);
- for (const t of out.get(id) ?? []) {
- indeg.set(t, (indeg.get(t) ?? 1) - 1);
- if ((indeg.get(t) ?? 0) <= 0 && !visited.has(t)) ready.add(t);
- }
- };
-
- while (visited.size < nodes.length) {
- const candidates = [...ready].filter((id) => !visited.has(id));
- if (candidates.length > 0) {
- visit(candidates.sort(byGeo)[0]!);
- } else {
- // 环/汇合死锁:挑未访问中 (剩余入度, y, x) 最小者破环。
- const rest = nodes.filter((n) => !visited.has(n.id)).map((n) => n.id);
- rest.sort((a, b) => (indeg.get(a) ?? 0) - (indeg.get(b) ?? 0) || byGeo(a, b));
- visit(rest[0]!);
- }
- }
-
- for (const [oldId, newId] of [...mapping]) {
- if (oldId === newId) mapping.delete(oldId);
- }
- return mapping;
-}
-
-/** 文本里的 id 引用按映射换号:占位符两段式(防级联),长 id 先换(防 A10 被 A1 误伤)。 */
-export function swapIdTokens(text: string, mapping: ReadonlyMap): string {
- const pairs = [...mapping.entries()].filter(([from, to]) => from !== to).sort((a, b) => b[0].length - a[0].length);
- let outText = text;
- pairs.forEach(([from], i) => {
- outText = outText.split(from).join(`⟦${i}⟧`);
- });
- pairs.forEach(([, to], i) => {
- outText = outText.split(`⟦${i}⟧`).join(to);
- });
- return outText;
-}
-
-/** 铸新编号:前缀取未用最小号;起/止先用 S/E,再 S2/E2…;避开 reserved(下钻 operations 键)。 */
export function mintNodeId(kind: FlowNodeKind, graph: FlowGraph, reserved: ReadonlySet): string {
const used = new Set([...graph.nodes.map((n) => n.id), ...reserved]);
if (kind === "start" || kind === "end") {