PageView Spec
表达页面视图的定义语义。appRef 指向所属 App,不存在时安装器会自动创建同名 App。
定位与自然键
- 自然键:
appName + route。AppDefinitionWriteService.upsertPageView先按appRef.name定位 App,再按route定位同一 App 下的页面。 appRef.name为空时直接返回UNCHANGED,不会创建页面。
PageViewSpecDTO
| 字段 | 类型 | 说明 |
|---|---|---|
appRef | ResourceRefDTO | 所属应用引用,安装器按 appRef.name 解析或创建 App |
name | string | 页面名称 |
displayName | string | 页面显示名称 |
description | string | 未使用。写入服务不消费该字段。 |
route | string | 页面路由,与 appName 组成自然键 |
sortOrder | integer | 页面排序 |
schemaVersion | string | Schema 版本,为空时默认 1.0 |
showInMenu | boolean | 是否显示在菜单中 |
icon | string | 页面图标 |
root | PageWidgetNodeSpecDTO | 页面布局根节点,描述 widget 树结构 |
widgets | List<PageWidgetSpecDTO> | 页面 widget 列表,平铺定义每个 widget 的详细配置 |
子结构
ResourceRefDTO(appRef)
| 字段 | 类型 | 说明 |
|---|---|---|
kind | string | 未使用。appRef 仅消费 name。 |
name | string | App 自然键,用于定位或创建 App |
apiName | string | 未使用。appRef 仅消费 name。 |
PageWidgetNodeSpecDTO
页面布局树节点,表达 widget 的嵌套层级。
| 字段 | 类型 | 说明 |
|---|---|---|
widgetId | string | Widget 标识,与 widgets 列表中的 widgetId 对应 |
type | string | 节点类型。DASHBOARD_ROOT / ROOT / PAGE_ROOT / CONTAINER 归一化为 Container |
children | List<string> | 子节点 widgetId 列表 |
PageWidgetSpecDTO
| 字段 | 类型 | 说明 |
|---|---|---|
widgetId | string | Widget 标识,需在 root 树中被引用才能渲染 |
type | string | Widget 类型,写入时归一化为运行时类型 |
position | WidgetPositionDTO | 布局位置信息,序列化为 JSON 写入 position_json |
props | Object | 组件属性,可为对象或数组,序列化为 JSON |
bindings | Object | 数据绑定配置,可为对象或数组,序列化为 JSON |
filterBindings | List<WidgetFilterBindingDTO> | 过滤绑定配置列表,序列化为 JSON |
linkages | Object | 联动配置,可为对象或数组,序列化为 JSON |
Widget 类型归一化
后端 AppPageServiceImpl.normalizeWidgetType 在安装时将输入类型映射为运行时类型:
| 输入类型 | 运行时类型 | 说明 |
|---|---|---|
STAT_CARD | Card | 统计卡片 |
KPI_CARD | Card | KPI 卡片 |
CARD | Card | 普通卡片 |
CHART | Chart / GeoMap | 当 props.chartType == "MAP" 时映射为 GeoMap,否则为 Chart |
MAP / GEO_MAP | GeoMap | 地图 |
TABLE / DATA_TABLE | DataTable | 数据表格 |
GANTT | Gantt | 甘特图 |
TIMELINE | Timeline | 时间线 |
TEXT | Text | 文本 |
CONTAINER | Container | 容器 |
| 其他 | 原值保留 | 未命中上述映射时保持原类型字符串 |
WidgetPositionDTO
全部字段已消费,序列化为 JSON。
| 字段 | 类型 | 说明 |
|---|---|---|
h | Object | 高度 |
w | Object | 宽度 |
span | integer | 栅格跨度 |
stackOnMobile | boolean | 是否在移动端堆叠 |
WidgetFilterBindingDTO
全部字段已消费,序列化为 JSON。
| 字段 | 类型 | 说明 |
|---|---|---|
consumeAs | string | 消费方式:time_range 或 filter |
filterKey | string | 筛选器 widget 的 filterKey |
targetField | string | 目标字段 |
示例
appRef:
name: Manufacturing
name: production_dashboard
route: /production/dashboard
schemaVersion: "1.0"
showInMenu: true
icon: LayoutDashboard
root:
widgetId: root
type: CONTAINER
children:
- total_output_card
- yield_chart
- work_order_table
widgets:
- widgetId: total_output_card
type: STAT_CARD
position:
span: 6
props:
title: 今日产量
metricRef:
kind: Metric
name: total_output
- widgetId: yield_chart
type: CHART
position:
span: 12
props:
chartType: BAR
metricRef:
kind: Metric
name: yield_rate
- widgetId: work_order_table
type: TABLE
position:
span: 12
bindings:
objectRef:
kind: ObjectType
name: work_order消费位置
foundry-app-biz:AppDefinitionWriteService.upsertPageView按appRef.name解析或创建 App,再按appName + route定位页面。foundry-app-biz:AppPageServiceImpl.upsertPageBySemanticKey将PageViewSpecDTO转换为PageUpsertReqDTO并写入 App / PageView runtime 表。foundry-app-biz:AppDomainProjectionAdapter调用appDefinitionApi.upsertPageView。
相关文档
- 核心概念 — ResourceRef 解析规则