[F7] 规则链列表/编辑页(DAG 画布整合,决策 5 双入口)
整合 F1 DagCanvas + F2 DagNodePanel + F3 DagPropertyPanel + F8 dag-converter
为完整的规则链 v2 编辑体验。
新增:
- apps/web-antd/src/views/iot/rule/chain/api/rule-chain.ts
- CRUD + enable/disable/deploy/debug/copy API 封装
- apps/web-antd/src/views/iot/rule/chain/stores/rule-chain.ts
- Pinia store: meta + nodes + edges + dirty guard + save/deploy 区分新建/更新
- apps/web-antd/src/views/iot/rule/chain/list.vue
- 4 维筛选(name/subsystem/type/status)+ 分页 20/50/100
- 启用/禁用乐观 UI + 调试切换 Modal 确认(评审 B8)
- WARNING 状态红 Badge + Tooltip 物模型变更原因(评审 E4)
- 双入口 Banner Alert 链到 v1 scene 页(决策 5)
- hasAccessByCodes iot:rule:{update,delete} 权限
- apps/web-antd/src/views/iot/rule/chain/edit.vue
- 三栏布局:DagNodePanel(220) + DagCanvas + DagPropertyPanel(320)
- drop 处理: handleDragOver preventDefault / screenToFlowCoordinate /
newTempId 新节点临时 ID
- nodeClick → selectedNodeStore.setCurrent; paneClick → clear
- onBeforeRouteLeave dirty 拦截 + Modal 确认
- readonly 模式: status=ENABLED 默认只读,可"解锁编辑"
- 发布: save(若 dirty) → deploy API(Modal 前置确认)
- 创建后 router.replace 含真实 ID
- apps/web-antd/src/views/iot/rule/chain/__tests__/rule-chain-store.spec.ts (10 用例)
修改:
- apps/web-antd/src/router/routes/modules/iot.ts
追加 /iot/rule/chain (顶级) + /iot/rule/chain/edit/:id? (hideInMenu detail)
- locales/langs/{zh-CN,en-US}/page.json 补 iot.ruleChain.* 约 80 键
Known Pitfalls 落地:
- drop 兼容: handleDragOver 调 e.preventDefault + dropEffect='copy'(Firefox)
- 临时 ID: newTempId 生成 new_<uuid>,isTempId 识别 INSERT(F8 约定)
- dirty guard: onBeforeRouteLeave 拦截离开
- readonly: status=ENABLED 已发布默认只读,可解锁重新编辑
- 画布双击 nodeDblclick 已透传(DagPropertyPanel 可选聚焦)
决策 5 双入口落实:
- 现有 /iot/rule/scene/* (v1 表单) 完全保留
- 新增 /iot/rule/chain/* (v2 DAG)
- list.vue 顶部 Alert 给用户两入口引导
质检:
- pnpm test:unit src/views/iot/rule/chain → 58/58 通过(累计 F1-F8 测试)
- pnpm lint F7 files → 0 errors
- pnpm check:type chain → 0 errors
后端 B2 API 契约:
- GET /iot/rule-chain/page / get?id=
- POST /iot/rule-chain/create PUT update DELETE delete?id=
- PUT enable / disable / deploy / debug
- POST copy?id=
- GET /iot/subsystem/simple-list (F9 提供,F7 筛选器复用)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -304,6 +304,88 @@
|
||||
"history": "History",
|
||||
"noHistory": "No history records"
|
||||
}
|
||||
},
|
||||
"ruleChain": {
|
||||
"list": {
|
||||
"title": "Rule Chain List"
|
||||
},
|
||||
"edit": {
|
||||
"title": "Edit Rule Chain",
|
||||
"namePlaceholder": "Enter rule chain name",
|
||||
"nameRequired": "Rule chain name is required",
|
||||
"loadFailed": "Failed to load rule chain, please retry",
|
||||
"saveFailed": "Save failed, please retry",
|
||||
"unsavedTitle": "Unsaved Changes",
|
||||
"unsavedContent": "Leaving this page will discard unsaved changes. Continue?",
|
||||
"unsavedLeave": "Leave",
|
||||
"unsavedBadge": "Unsaved",
|
||||
"unlockTip": "This rule chain is enabled. Click to unlock for editing.",
|
||||
"dropHint": "Drag nodes to canvas to start building"
|
||||
},
|
||||
"v1Banner": {
|
||||
"message": "Scene Rules (v1) Migrated",
|
||||
"description": "v2 Rule Chain DAG is the new orchestration entry. v1 Scene Rules page remains available during the gradual rollout.",
|
||||
"link": "Go to v1 Scene Rules"
|
||||
},
|
||||
"field": {
|
||||
"name": "Name",
|
||||
"type": "Type",
|
||||
"subsystem": "Subsystem",
|
||||
"bindScope": "Bind Scope",
|
||||
"product": "Product",
|
||||
"device": "Device",
|
||||
"priority": "Priority",
|
||||
"status": "Status",
|
||||
"debugMode": "Debug Mode",
|
||||
"version": "Version",
|
||||
"updateTime": "Updated At",
|
||||
"actions": "Actions"
|
||||
},
|
||||
"filter": {
|
||||
"namePlaceholder": "Search name",
|
||||
"subsystemPlaceholder": "All Subsystems",
|
||||
"typePlaceholder": "All Types",
|
||||
"statusPlaceholder": "All Status"
|
||||
},
|
||||
"status": {
|
||||
"enabled": "Enabled",
|
||||
"disabled": "Disabled",
|
||||
"warning": "Warning",
|
||||
"warningHint": "Model changes caused some rules to fail. Please check the rule chain configuration."
|
||||
},
|
||||
"type": {
|
||||
"scene": "Scene Linkage",
|
||||
"data": "Data Forwarding",
|
||||
"custom": "Custom"
|
||||
},
|
||||
"debug": {
|
||||
"confirmTitle": "Enable Debug Mode",
|
||||
"confirmContent": "Debug mode records input/output for each node and may produce large logs affecting performance. Confirm?",
|
||||
"toggleSuccess": "Debug mode toggled",
|
||||
"toggleFailed": "Toggle failed, please retry"
|
||||
},
|
||||
"action": {
|
||||
"create": "New Rule Chain",
|
||||
"enable": "Enable",
|
||||
"disable": "Disable",
|
||||
"enableSuccess": "Enabled successfully",
|
||||
"disableSuccess": "Disabled successfully",
|
||||
"statusChangeFailed": "Operation failed, please retry",
|
||||
"deleteConfirm": "Delete this rule chain? This action cannot be undone.",
|
||||
"deleteSuccess": "Deleted successfully",
|
||||
"deleteFailed": "Delete failed, please retry",
|
||||
"copy": "Copy",
|
||||
"copySuccess": "Copied successfully",
|
||||
"copyFailed": "Copy failed, please retry",
|
||||
"deploy": "Deploy",
|
||||
"deployConfirmTitle": "Confirm Deploy",
|
||||
"deployConfirmContent": "After deploying, the rule chain will take effect immediately at runtime. Please confirm the configuration is correct.",
|
||||
"deploySuccess": "Deployed successfully",
|
||||
"deployFailed": "Deploy failed, please retry",
|
||||
"saveSuccess": "Saved successfully",
|
||||
"unlock": "Unlock for Editing",
|
||||
"back": "Back to List"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user