fix(strategy-map): 三处缺陷——D1 完备度/摘要路由先注册(修 /completeness/objectives 422)、D2 连线增删显式 flag_modified(修 DELETE 200 不落库)、D3 拖拽命中改 rect 判定(修窄屏知识面板遮挡导致拖拽失效)
ci/woodpecker/push/main Pipeline was successful

This commit is contained in:
wecom-fullstack
2026-10-20 20:35:28 +08:00
parent 86e24c6310
commit 790be2d6b1
3 changed files with 23 additions and 4 deletions
+6
View File
@@ -558,6 +558,8 @@ def add_connection(map_id: int, data: dict, db: Session = Depends(get_db), entit
"label": data.get("label", ""),
})
m.canvas_data["connections"] = conns
from sqlalchemy.orm.attributes import flag_modified
flag_modified(m, "canvas_data") # 同上:JSON 列需显式标脏才能落库
db.commit()
# updated_at: 供前端采纳为新基准(并发保护 base_updated_at),避免自伤 409
return {"connections": conns, "updated_at": _stamp(m.updated_at)}
@@ -580,6 +582,10 @@ def delete_connection_by_key(map_id: int, data: dict, db: Session = Depends(get_
raise HTTPException(404, "连线不存在")
m.canvas_data["connections"] = new_conns
# JSON 列就地/换列表赋值不会被 ORM 自动标记为 dirty ⇒ 必须显式 flag_modified,
# 否则接口返回 200 且响应列表已减 1,但 commit 不 flush,重读仍是旧值(删连线变哑弹)。
from sqlalchemy.orm.attributes import flag_modified
flag_modified(m, "canvas_data")
db.commit()
return {"connections": new_conns, "removed": {"from": from_id, "to": to_id},
"updated_at": _stamp(m.updated_at)}
+4 -2
View File
@@ -40,6 +40,10 @@ app.include_router(auth.router)
app.include_router(kpis.router)
app.include_router(kpi_governance.router)
app.include_router(templates.router)
# ⚠️ 顺序要求:完备度/摘要条路由必须先于 maps/objectives 等「/{map_id}/...」通配路由注册,
# 否则 /maps/completeness/objectives 会被 /{map_id}/objectives 抢先匹配(map_id="completeness" → 422)。
app.include_router(map_completeness.router) # 战略地图数据完备度(口径 CMA-CALIBER-MAP-COMPLETENESS-20261018 v1.0)
app.include_router(map_summary.router) # 战略地图摘要条(收入分线/新式毛利率/管理指标 · 口径 CMA-A1 终稿)
app.include_router(maps.router)
app.include_router(dashboard.router)
app.include_router(data.router)
@@ -56,8 +60,6 @@ app.include_router(action_plans.router)
app.include_router(alignment.router)
app.include_router(org.router)
app.include_router(objectives.router)
app.include_router(map_completeness.router) # 战略地图数据完备度(口径 CMA-CALIBER-MAP-COMPLETENESS-20261018 v1.0)
app.include_router(map_summary.router) # 战略地图摘要条(收入分线/新式毛利率/管理指标 · 口径 CMA-A1 终稿)
app.include_router(versions.router)
app.include_router(budget.router)
app.include_router(value_sources.router)
+13 -2
View File
@@ -994,10 +994,21 @@ function onTreeDragStart(payload: { dimKey: string; index: number; obj: any }) {
}
function onTreeDragOver(e: DragEvent) {
if (!treeDragSource.value) return
const el = document.elementFromPoint(e.clientX, e.clientY)?.closest('[data-node-key]') as HTMLElement | null
const key = el?.getAttribute('data-node-key') || null
// 命中判定改用节点 rect 包含判断:elementFromPoint 会被覆盖层(窄屏时的知识面板 .kp-panel、
// 连线 SVG 等)挡住 ⇒ 拖拽在窄屏下永远取不到目标节点。rect 判定与层级无关。
const key = hitTestNodeKey(e.clientX, e.clientY)
dragConnectTarget.value = key && key !== treeDragSource.value.key ? key : null
}
function hitTestNodeKey(x: number, y: number): string | null {
const nodes = document.querySelectorAll('[data-node-key]') as NodeListOf<HTMLElement>
for (const el of Array.from(nodes)) {
const r = el.getBoundingClientRect()
if (r.width > 0 && r.height > 0 && x >= r.left && x <= r.right && y >= r.top && y <= r.bottom) {
return el.getAttribute('data-node-key')
}
}
return null
}
function onTreeDragLeave(e: DragEvent) {
const related = (e as any).relatedTarget as Node | null
const box = scrollWrapRef.value