diff --git a/.trae/rules/project_rules.md b/.trae/rules/project_rules.md new file mode 100644 index 0000000000000000000000000000000000000000..1ab899b4fd492e54304701b136b14706618c0a9c --- /dev/null +++ b/.trae/rules/project_rules.md @@ -0,0 +1,78 @@ +### 项目概述 +本项目为可视化低代码平台,旨在通过元数据驱动的方式实现应用的快速构建与渲染。其核心设计目标是将应用的结构、行为和样式抽象为可配置的元数据,从而实现无需编写代码即可完成应用开发。 + +项目基于 .NET 9.0、Abp 和 Blazor,采用模块化分层架构,前端采用 Blazor Auto 模式,后端采用 .NET 9.0 Web API 技术。 + +#### 设计引擎和渲染引擎 +设计引擎(DesignEngine)和渲染引擎(RenderEngine)是系统的两大核心模块,二者通过共享的 Common 模块进行协作。 + +设计引擎:提供可视化编辑界面,允许用户拖拽组件、配置属性、设置数据源和事件。其输出为结构化的元数据文件(JSON),存储于 meta 目录。 +渲染引擎:读取 meta 目录中的元数据,在运行时动态生成 Blazor 组件树,实现应用的展示与交互。 +两者通过 Common 模块中的元数据 Schema 保持契约一致,确保设计时与运行时的行为统一。 + +#### 核心概念 +* 元数据 +在低代码平台中,元数据是驱动系统配置、设计与渲染的核心。它通过结构化的JSON文件进行序列化存储,并在设计引擎与渲染引擎之间传递,实现“一次设计,多端运行”的能力。本文深入分析元数据的设计原理、继承体系、存储结构、合并机制与生命周期管理,揭示其作为系统配置中枢的关键作用。 + +* 应用 +在低代码平台中,“应用”(App)是最顶层的容器,代表一个完整的、可独立运行和部署的业务系统。它不仅定义了系统的名称、标识、图标、描述等基本信息,还通过元数据配置决定了其支持的平台类型和当前的发布状态。每个应用都拥有唯一的标识(Id),并作为组织和管理其内部页面、菜单、数据源等资源的逻辑边界。 + +应用的生命周期由设计引擎(DesignEngine)管理,其运行时表现则由渲染引擎(RenderEngine)负责。设计引擎允许开发者通过可视化界面进行应用的构建和修改,而渲染引擎则将这些元数据转换为最终用户可交互的前端界面。 + +应用的元数据结构基于 AppSchemaBase 抽象类定义,该类继承自 MetaSchemaBase,并包含了一系列核心属性。 + +* 页面 +低代码平台中“页面”作为用户界面基本单元的建模方式。基于 PageSchemaBase 和 PagePropertySchema 等核心类,详细解释页面的类型、布局配置、事件处理机制、组件树结构以及状态管理,阐述页面在设计引擎中的拖拽构建过程和在渲染引擎中的动态加载与渲染流程。 + +* 组件 +“组件”是低代码平台中可复用的UI元素,其设计遵循模块化、可配置和可扩展的原则。组件在设计时通过元数据定义其结构、属性、样式和事件,在运行时根据配置动态渲染。系统通过分层架构将设计时与运行时逻辑分离,确保灵活性与性能。 + +组件的核心实现基于 ComponentSchemaBase 类,并通过设计时专用的 ComponentPartsSchema 扩展支持拖拽、选中状态等交互功能。属性、样式和事件均采用独立的模式进行管理,便于动态配置与持久化。 + +* 数据源 +数据源(DataSource)是低代码平台中实现数据连接与抽象的核心模块。它为前端组件提供统一的数据访问接口,支持多种数据来源,包括数据库、API接口和静态选项。 + +* 菜单 +菜单功能的核心数据结构由 MenuSchema 类定义,该类继承自 MetaSchemaBase,用于描述菜单项的组织方式和行为特性。 + +### 元数据 +元数据的定义包含在项目 H.LowCode.MetaSchema (基础元数据据结构定义)、H.LowCode.MetaSchema.DesignEngine (基于 H.LowCode.MetaSchema,扩展出设计引擎特有属性)、H.LowCode.Schema.RenderEngine (基于 H.LowCode.MetaSchema,包含渲染引擎特有属性)。 +设计引擎通过可视化界面设计并使用 H.LowCode.MetaSchema.DesignEngine 项目中的元数据定义序列化生成 json 文件,然后右渲染引擎将 json 反序列化为 H.LowCode.MetaSchema.RenderEngine 中的元数据定义,再绑定到页面中渲染出页面。 + +#### 主要的元数据定义 +* AppSchemaBase:应用的元数据定义,包含应用的名称、标识、图标、描述等基本信息。 +* PageSchemaBase:页面的元数据定义,包含页面的类型、布局配置、事件处理机制、组件树结构以及状态管理。 +* * PagePartsSchema: 设计时页面的元数据定义 +* * PageSchema: 运行时页面的元数据定义 +* ComponentSchemaBase:组件的元数据定义,包含组件的结构、属性、样式和事件。 +* * ComponentPartsSchema: 设计时组件定义 +* * ComponentSchema: 运行时组件定义 +* MenuSchema:菜单的元数据定义,包含菜单项的组织方式和行为特性。 + +### 设计引擎 +#### 启动项目 +设计引擎启动项目 H.LowCode.DesignEngine.Host + +#### 物料 +物料的管理对应 H.LowCode.PartsDesignEngine 项目, 物料主要包含组件、主题等,物料的元数据定义在 H.LowCode.MetaSchema.DesignEngine 项目中。 + +#### 页面设计器 +页面设计器用于设计页面,基于已有物料进行拖拽、配置、事件绑定等操作,最终生成页面的元数据文件。 + +页面设计器位于 H.LowCode.DesignEngine 项目的 DesignPage 页面,包含 ComponentPanel(物料库)、DesignPanel(设计区域)、SettingPanel(配置面板)三个部分。 +* 物料库:提供组件等物料的列表,可拖拽到设计区域。 +* 设计区域:可视化编辑页面,支持组件的添加、删除、移动和调整大小。 + * * DesignPanel 包含多个 DraggableContainer,此组件为一个可拖拽组件容器,用于放置可拖拽组件 DraggableItem。 + * * DraggableItem 作为可拖拽组件,用于包裹真实组件,使所有组件具备可拖拽能力。 + * * DraggableItem 包裹的是 DraggableItem 组件,DraggableItem 组件的子组件为真实组件,例如 Button、Input 等。DraggableItem 将组件元数据动态渲染为真实组件,从而实现基于 json 元数据动态渲染页面的效果。 +* 配置面板:对选中的组件进行属性、样式和事件的配置。 + +### 渲染引擎 +#### 启动项目 +设计引擎启动项目 H.LowCode.DesignEngine.Host + +#### 页面渲染 +渲染引擎负责根据页面的元数据文件,动态生成 Blazor 组件树,并在前端页面中渲染出来。渲染引擎位于 H.LowCode.RenderEngine 项目中,主要负责以下几个方面的功能: +* 元数据解析:读取页面的元数据文件,解析出组件、样式、事件等信息。 +* 组件渲染:根据解析出的元数据,动态创建 Blazor 组件实例,并将其添加到组件树中。 +* 事件处理:为组件添加事件处理逻辑,确保用户交互能够正确响应。 diff --git a/meta/apps/caseapp/caseapp.json b/meta/apps/caseapp/caseapp.json index 2ad84ce16fa7b148d243440656c15cab592e1e95..ce6c8b47afb13245a247302210b6995292b47b7a 100644 --- a/meta/apps/caseapp/caseapp.json +++ b/meta/apps/caseapp/caseapp.json @@ -1 +1 @@ -{"id":"caseapp","n":"用例系统","desc":"展示典型页面案例","pub":0,"platform":[0,2],"createdTime":"0001-01-01T00:00:00","modifiedTime":"2025-01-02T15:03:41.2355394Z"} \ No newline at end of file +{"id":"caseapp","n":"用例系统","desc":"展示典型页面案例 (参考 amis 示例)","platform":[0,2],"mt":"2025-05-29T16:49:31.1628431Z"} \ No newline at end of file diff --git a/meta/apps/caseapp/page/2qceiqni.json b/meta/apps/caseapp/page/2qceiqni.json index fda21bf0728d3b6f84fcb6ee27bf26f2db105c4d..29f306fc8743def6e53a3ee952b376fcb82aa6c1 100644 --- a/meta/apps/caseapp/page/2qceiqni.json +++ b/meta/apps/caseapp/page/2qceiqni.json @@ -1 +1 @@ -{"comps":[],"aid":"caseapp","id":"2qceiqni","n":"主从表单","order":10,"pt":1,"pageprop":{"playout":2,"ds":{}},"ds":{"dst":1,"dsv":"tb_test1"},"modifiedTime":"2025-04-03T02:10:46.3663146Z"} \ No newline at end of file +{"comps":[],"aid":"caseapp","id":"2qceiqni","n":"主从表单","order":10,"pt":1,"pageprop":{"playout":2,"ds":{}},"ds":{"dst":1,"dsv":"tb_test1"},"mt":"2025-05-26T15:30:43.9836585Z"} \ No newline at end of file diff --git a/meta/apps/caseapp/page/2qme5ln5e.json b/meta/apps/caseapp/page/2qme5ln5e.json index a9032f2417a7c6a825b8c1382a4b9788b449d1b9..3a1d3f6596ae249f068c3cdf75188010de6e6f8c 100644 --- a/meta/apps/caseapp/page/2qme5ln5e.json +++ b/meta/apps/caseapp/page/2qme5ln5e.json @@ -1 +1,544 @@ -{"comps":[],"aid":"caseapp","id":"2qme5ln5e","n":"分组表单","order":3,"pt":1,"pageprop":{"playout":2,"ds":{}},"ds":{"dst":1,"dsv":"tb_test1"},"modifiedTime":"2025-04-03T02:09:16.5141165Z"} \ No newline at end of file +{ + "comps": [ + { + "compid": "fmiwu412", + "libid": "antdesign", + "cn": "Card", + "ct": 1, + "frag": { + "dt": "AntDesign.Card, AntDesign", + "t": "AntDesign.Card, AntDesign", + "attrs": [] + }, + "attrdefgroups": [ + { + "gn": "基础属性", + "attrdefs": [ + { + "disn": "标题", + "pt": 1, + "desc": "卡片标题", + "dftval": "", + "attrn": "Title", + "attrt": "System.String", + "attrv": "基本信息" + } + ] + } + ], + "childs": [ + { + "compid": "52391a70", + "libid": "antdesign", + "cn": "Input", + "ct": 1, + "frag": { + "dt": "AntDesign.Input`1[System.String], AntDesign", + "t": "AntDesign.Input`1[System.String], AntDesign", + "valt": "System.String", + "attrs": [ + { + "attrn": "TValue", + "attrt": "System.String" + } + ] + }, + "ds": { + "dsgt": 1 + }, + "attrdefgroups": [ + { + "gn": "基础属性", + "attrdefs": [ + { + "disn": "输入提示", + "pt": 1, + "desc": "组件输入时的 Placeholder 提示", + "dftval": "", + "attrn": "Placeholder", + "attrt": "System.String", + "attrv": "请输入姓名" + } + ] + } + ], + "childs": [], + "order": 1, + "pub": 1, + "mt": "2025-01-15T10:00:00.0000000Z", + "id": "basic_name", + "pid": "basic_info_card", + "n": "f_name", + "lb": "姓名", + "stl": { + "itemh": 85, + "labelw": 180, + "display": "inline", + "pos": "static" + }, + "ev": {} + }, + { + "compid": "52391a70", + "libid": "antdesign", + "cn": "Input", + "ct": 1, + "frag": { + "dt": "AntDesign.Input`1[System.String], AntDesign", + "t": "AntDesign.Input`1[System.String], AntDesign", + "valt": "System.String", + "attrs": [ + { + "attrn": "TValue", + "attrt": "System.String" + } + ] + }, + "ds": { + "dsgt": 1 + }, + "attrdefgroups": [ + { + "gn": "基础属性", + "attrdefs": [ + { + "disn": "输入提示", + "pt": 1, + "desc": "组件输入时的 Placeholder 提示", + "dftval": "", + "attrn": "Placeholder", + "attrt": "System.String", + "attrv": "请输入邮箱" + } + ] + } + ], + "childs": [], + "order": 2, + "pub": 1, + "mt": "2025-01-15T10:00:00.0000000Z", + "id": "basic_email", + "pid": "basic_info_card", + "n": "f_email", + "lb": "邮箱", + "stl": { + "itemh": 85, + "labelw": 180, + "display": "inline", + "pos": "static" + }, + "ev": {} + }, + { + "compid": "52391a70", + "libid": "antdesign", + "cn": "Input", + "ct": 1, + "frag": { + "dt": "AntDesign.Input`1[System.String], AntDesign", + "t": "AntDesign.Input`1[System.String], AntDesign", + "valt": "System.String", + "attrs": [ + { + "attrn": "TValue", + "attrt": "System.String" + } + ] + }, + "ds": { + "dsgt": 1 + }, + "attrdefgroups": [ + { + "gn": "基础属性", + "attrdefs": [ + { + "disn": "输入提示", + "pt": 1, + "desc": "组件输入时的 Placeholder 提示", + "dftval": "", + "attrn": "Placeholder", + "attrt": "System.String", + "attrv": "请输入手机号" + } + ] + } + ], + "childs": [], + "order": 3, + "pub": 1, + "mt": "2025-01-15T10:00:00.0000000Z", + "id": "basic_phone", + "pid": "basic_info_card", + "n": "f_phone", + "lb": "手机号", + "stl": { + "itemh": 85, + "labelw": 180, + "display": "inline", + "pos": "static" + }, + "ev": {} + } + ], + "order": 1, + "pub": 1, + "mt": "2025-01-15T10:00:00.0000000Z", + "id": "basic_info_card", + "pid": "", + "n": "basic_info", + "lb": "基本信息", + "stl": { + "itemh": 300, + "labelw": 0, + "display": "block", + "pos": "static" + }, + "ev": {} + }, + { + "compid": "fmiwu412", + "libid": "antdesign", + "cn": "Card", + "ct": 1, + "frag": { + "dt": "AntDesign.Card, AntDesign", + "t": "AntDesign.Card, AntDesign", + "attrs": [] + }, + "attrdefgroups": [ + { + "gn": "基础属性", + "attrdefs": [ + { + "disn": "标题", + "pt": 1, + "desc": "卡片标题", + "dftval": "", + "attrn": "Title", + "attrt": "System.String", + "attrv": "工作信息" + } + ] + } + ], + "childs": [ + { + "compid": "52391a70", + "libid": "antdesign", + "cn": "Input", + "ct": 1, + "frag": { + "dt": "AntDesign.Input`1[System.String], AntDesign", + "t": "AntDesign.Input`1[System.String], AntDesign", + "valt": "System.String", + "attrs": [ + { + "attrn": "TValue", + "attrt": "System.String" + } + ] + }, + "ds": { + "dsgt": 1 + }, + "attrdefgroups": [ + { + "gn": "基础属性", + "attrdefs": [ + { + "disn": "输入提示", + "pt": 1, + "desc": "组件输入时的 Placeholder 提示", + "dftval": "", + "attrn": "Placeholder", + "attrt": "System.String", + "attrv": "请输入公司名称" + } + ] + } + ], + "childs": [], + "order": 1, + "pub": 1, + "mt": "2025-01-15T10:00:00.0000000Z", + "id": "work_company", + "pid": "work_info_card", + "n": "f_company", + "lb": "公司名称", + "stl": { + "itemh": 85, + "labelw": 180, + "display": "inline", + "pos": "static" + }, + "ev": {} + }, + { + "compid": "52391a70", + "libid": "antdesign", + "cn": "Input", + "ct": 1, + "frag": { + "dt": "AntDesign.Input`1[System.String], AntDesign", + "t": "AntDesign.Input`1[System.String], AntDesign", + "valt": "System.String", + "attrs": [ + { + "attrn": "TValue", + "attrt": "System.String" + } + ] + }, + "ds": { + "dsgt": 1 + }, + "attrdefgroups": [ + { + "gn": "基础属性", + "attrdefs": [ + { + "disn": "输入提示", + "pt": 1, + "desc": "组件输入时的 Placeholder 提示", + "dftval": "", + "attrn": "Placeholder", + "attrt": "System.String", + "attrv": "请输入职位" + } + ] + } + ], + "childs": [], + "order": 2, + "pub": 1, + "mt": "2025-01-15T10:00:00.0000000Z", + "id": "work_position", + "pid": "work_info_card", + "n": "f_position", + "lb": "职位", + "stl": { + "itemh": 85, + "labelw": 180, + "display": "inline", + "pos": "static" + }, + "ev": {} + }, + { + "compid": "52391a70", + "libid": "antdesign", + "cn": "Input", + "ct": 1, + "frag": { + "dt": "AntDesign.Input`1[System.String], AntDesign", + "t": "AntDesign.Input`1[System.String], AntDesign", + "valt": "System.String", + "attrs": [ + { + "attrn": "TValue", + "attrt": "System.String" + } + ] + }, + "ds": { + "dsgt": 1 + }, + "attrdefgroups": [ + { + "gn": "基础属性", + "attrdefs": [ + { + "disn": "输入提示", + "pt": 1, + "desc": "组件输入时的 Placeholder 提示", + "dftval": "", + "attrn": "Placeholder", + "attrt": "System.String", + "attrv": "请输入部门" + } + ] + } + ], + "childs": [], + "order": 3, + "pub": 1, + "mt": "2025-01-15T10:00:00.0000000Z", + "id": "work_department", + "pid": "work_info_card", + "n": "f_department", + "lb": "部门", + "stl": { + "itemh": 85, + "labelw": 180, + "display": "inline", + "pos": "static" + }, + "ev": {} + } + ], + "order": 2, + "pub": 1, + "mt": "2025-01-15T10:00:00.0000000Z", + "id": "work_info_card", + "pid": "", + "n": "work_info", + "lb": "工作信息", + "stl": { + "itemh": 300, + "labelw": 0, + "display": "block", + "pos": "static" + }, + "ev": {} + }, + { + "compid": "fmiwu412", + "libid": "antdesign", + "cn": "Card", + "ct": 1, + "frag": { + "dt": "AntDesign.Card, AntDesign", + "t": "AntDesign.Card, AntDesign", + "attrs": [] + }, + "attrdefgroups": [ + { + "gn": "基础属性", + "attrdefs": [ + { + "disn": "标题", + "pt": 1, + "desc": "卡片标题", + "dftval": "", + "attrn": "Title", + "attrt": "System.String", + "attrv": "其他信息" + } + ] + } + ], + "childs": [ + { + "compid": "evuqdwzl", + "libid": "antdesign", + "cn": "Radio", + "ct": 1, + "frag": { + "dt": "AntDesign.RadioGroup`1[System.String], AntDesign", + "t": "AntDesign.RadioGroup`1[System.String], AntDesign", + "valt": "System.String", + "attrs": [ + { + "attrn": "TValue", + "attrt": "System.String" + } + ] + }, + "attrdefgroups": [ + { + "gn": "基础属性", + "attrdefs": [ + { + "disn": "选项", + "pt": 9, + "desc": "单选框选项", + "dftval": "", + "attrn": "Options", + "attrt": "System.String", + "attrv": "男,女" + } + ] + } + ], + "childs": [], + "order": 1, + "pub": 1, + "mt": "2025-01-15T10:00:00.0000000Z", + "id": "other_gender", + "pid": "other_info_card", + "n": "f_gender", + "lb": "性别", + "stl": { + "itemh": 85, + "labelw": 180, + "display": "inline", + "pos": "static" + }, + "ev": {} + }, + { + "compid": "nwepem4i", + "libid": "antdesign", + "cn": "Switch", + "ct": 1, + "frag": { + "dt": "AntDesign.Switch, AntDesign", + "t": "AntDesign.Switch, AntDesign", + "valt": "System.Boolean", + "attrs": [] + }, + "attrdefgroups": [ + { + "gn": "基础属性", + "attrdefs": [ + { + "disn": "默认值", + "pt": 6, + "desc": "开关默认状态", + "dftval": false, + "attrn": "DefaultValue", + "attrt": "System.Boolean", + "attrv": false + } + ] + } + ], + "childs": [], + "order": 2, + "pub": 1, + "mt": "2025-01-15T10:00:00.0000000Z", + "id": "other_active", + "pid": "other_info_card", + "n": "f_active", + "lb": "是否激活", + "stl": { + "itemh": 85, + "labelw": 180, + "display": "inline", + "pos": "static" + }, + "ev": {} + } + ], + "order": 3, + "pub": 1, + "mt": "2025-01-15T10:00:00.0000000Z", + "id": "other_info_card", + "pid": "", + "n": "other_info", + "lb": "其他信息", + "stl": { + "itemh": 200, + "labelw": 0, + "display": "block", + "pos": "static" + }, + "ev": {} + } + ], + "aid": "caseapp", + "id": "2qme5ln5e", + "n": "分组表单", + "order": 3, + "pt": 1, + "pageprop": { + "playout": 2, + "ds": {} + }, + "ds": { + "dst": 1, + "dsv": "tb_test1" + }, + "mt": "2025-01-15T10:00:00.0000000Z" +} \ No newline at end of file diff --git a/meta/apps/caseapp/page/5kicsevr.json b/meta/apps/caseapp/page/5kicsevr.json index b1ae9f92b995b443b00d455a656e57553475a043..1c79113559e99a25ab4fc2b8f51f4a593f06516d 100644 --- a/meta/apps/caseapp/page/5kicsevr.json +++ b/meta/apps/caseapp/page/5kicsevr.json @@ -1 +1,426 @@ -{"comps":[],"aid":"caseapp","id":"5kicsevr","n":"页面分栏表单","order":8,"pt":1,"pageprop":{"playout":3,"ds":{}},"ds":{"dst":1,"dsv":"tb_test1"},"modifiedTime":"2025-04-03T02:10:33.5454698Z"} \ No newline at end of file +{ + "comps": [ + { + "compid": "52391a70", + "libid": "antdesign", + "cn": "Input", + "ct": 1, + "frag": { + "dt": "AntDesign.Input`1[System.String], AntDesign", + "t": "AntDesign.Input`1[System.String], AntDesign", + "valt": "System.String", + "attrs": [ + { + "attrn": "TValue", + "attrt": "System.String" + } + ] + }, + "ds": { + "dsgt": 1 + }, + "attrdefgroups": [ + { + "gn": "基础属性", + "attrdefs": [ + { + "disn": "是否禁用", + "pt": 6, + "desc": "", + "dftval": false, + "attrn": "Disabled", + "attrt": "System.Boolean", + "attrv": false + }, + { + "disn": "最大长度", + "pt": 2, + "desc": "字段输入的最大长度,为0时表示不限制长度", + "dftval": 0, + "attrn": "MaxLength", + "attrt": "System.Int32", + "attrv": 0 + }, + { + "disn": "输入提示", + "pt": 1, + "desc": "组件输入时的 Placeholder 提示", + "dftval": "", + "attrn": "Placeholder", + "attrt": "System.String", + "attrv": "请输入姓名" + } + ] + } + ], + "childs": [], + "order": 1, + "pub": 0, + "mt": "2025-05-26T15:30:32.0346739Z", + "id": "comp_name", + "pid": "", + "n": "姓名", + "lb": "姓名", + "stl": { + "width": "100%", + "marginBottom": "16px" + }, + "ev": {}, + "desc": "用户姓名输入框" + }, + { + "compid": "52391a70", + "libid": "antdesign", + "cn": "Input", + "ct": 1, + "frag": { + "dt": "AntDesign.Input`1[System.String], AntDesign", + "t": "AntDesign.Input`1[System.String], AntDesign", + "valt": "System.String", + "attrs": [ + { + "attrn": "TValue", + "attrt": "System.String" + } + ] + }, + "ds": { + "dsgt": 1 + }, + "attrdefgroups": [ + { + "gn": "基础属性", + "attrdefs": [ + { + "disn": "是否禁用", + "pt": 6, + "desc": "", + "dftval": false, + "attrn": "Disabled", + "attrt": "System.Boolean", + "attrv": false + }, + { + "disn": "最大长度", + "pt": 2, + "desc": "字段输入的最大长度,为0时表示不限制长度", + "dftval": 0, + "attrn": "MaxLength", + "attrt": "System.Int32", + "attrv": 11 + }, + { + "disn": "输入提示", + "pt": 1, + "desc": "组件输入时的 Placeholder 提示", + "dftval": "", + "attrn": "Placeholder", + "attrt": "System.String", + "attrv": "请输入手机号" + } + ] + } + ], + "childs": [], + "order": 2, + "pub": 0, + "mt": "2025-05-26T15:30:32.0346739Z", + "id": "comp_phone", + "pid": "", + "n": "手机号", + "lb": "手机号", + "stl": { + "width": "100%", + "marginBottom": "16px" + }, + "ev": {}, + "desc": "用户手机号输入框" + }, + { + "compid": "52391a70", + "libid": "antdesign", + "cn": "Input", + "ct": 1, + "frag": { + "dt": "AntDesign.Input`1[System.String], AntDesign", + "t": "AntDesign.Input`1[System.String], AntDesign", + "valt": "System.String", + "attrs": [ + { + "attrn": "TValue", + "attrt": "System.String" + } + ] + }, + "ds": { + "dsgt": 1 + }, + "attrdefgroups": [ + { + "gn": "基础属性", + "attrdefs": [ + { + "disn": "是否禁用", + "pt": 6, + "desc": "", + "dftval": false, + "attrn": "Disabled", + "attrt": "System.Boolean", + "attrv": false + }, + { + "disn": "最大长度", + "pt": 2, + "desc": "字段输入的最大长度,为0时表示不限制长度", + "dftval": 0, + "attrn": "MaxLength", + "attrt": "System.Int32", + "attrv": 0 + }, + { + "disn": "输入提示", + "pt": 1, + "desc": "组件输入时的 Placeholder 提示", + "dftval": "", + "attrn": "Placeholder", + "attrt": "System.String", + "attrv": "请输入邮箱" + } + ] + } + ], + "childs": [], + "order": 3, + "pub": 0, + "mt": "2025-05-26T15:30:32.0346739Z", + "id": "comp_email", + "pid": "", + "n": "邮箱", + "lb": "邮箱", + "stl": { + "width": "100%", + "marginBottom": "16px" + }, + "ev": {}, + "desc": "用户邮箱输入框" + }, + { + "compid": "52391a70", + "libid": "antdesign", + "cn": "Input", + "ct": 1, + "frag": { + "dt": "AntDesign.Input`1[System.String], AntDesign", + "t": "AntDesign.Input`1[System.String], AntDesign", + "valt": "System.String", + "attrs": [ + { + "attrn": "TValue", + "attrt": "System.String" + } + ] + }, + "ds": { + "dsgt": 1 + }, + "attrdefgroups": [ + { + "gn": "基础属性", + "attrdefs": [ + { + "disn": "是否禁用", + "pt": 6, + "desc": "", + "dftval": false, + "attrn": "Disabled", + "attrt": "System.Boolean", + "attrv": false + }, + { + "disn": "最大长度", + "pt": 2, + "desc": "字段输入的最大长度,为0时表示不限制长度", + "dftval": 0, + "attrn": "MaxLength", + "attrt": "System.Int32", + "attrv": 0 + }, + { + "disn": "输入提示", + "pt": 1, + "desc": "组件输入时的 Placeholder 提示", + "dftval": "", + "attrn": "Placeholder", + "attrt": "System.String", + "attrv": "请输入公司名称" + } + ] + } + ], + "childs": [], + "order": 4, + "pub": 0, + "mt": "2025-05-26T15:30:32.0346739Z", + "id": "comp_company", + "pid": "", + "n": "公司", + "lb": "公司", + "stl": { + "width": "100%", + "marginBottom": "16px" + }, + "ev": {}, + "desc": "用户公司输入框" + }, + { + "compid": "52391a70", + "libid": "antdesign", + "cn": "Input", + "ct": 1, + "frag": { + "dt": "AntDesign.Input`1[System.String], AntDesign", + "t": "AntDesign.Input`1[System.String], AntDesign", + "valt": "System.String", + "attrs": [ + { + "attrn": "TValue", + "attrt": "System.String" + } + ] + }, + "ds": { + "dsgt": 1 + }, + "attrdefgroups": [ + { + "gn": "基础属性", + "attrdefs": [ + { + "disn": "是否禁用", + "pt": 6, + "desc": "", + "dftval": false, + "attrn": "Disabled", + "attrt": "System.Boolean", + "attrv": false + }, + { + "disn": "最大长度", + "pt": 2, + "desc": "字段输入的最大长度,为0时表示不限制长度", + "dftval": 0, + "attrn": "MaxLength", + "attrt": "System.Int32", + "attrv": 0 + }, + { + "disn": "输入提示", + "pt": 1, + "desc": "组件输入时的 Placeholder 提示", + "dftval": "", + "attrn": "Placeholder", + "attrt": "System.String", + "attrv": "请输入职位" + } + ] + } + ], + "childs": [], + "order": 5, + "pub": 0, + "mt": "2025-05-26T15:30:32.0346739Z", + "id": "comp_position", + "pid": "", + "n": "职位", + "lb": "职位", + "stl": { + "width": "100%", + "marginBottom": "16px" + }, + "ev": {}, + "desc": "用户职位输入框" + }, + { + "compid": "52391a70", + "libid": "antdesign", + "cn": "Input", + "ct": 1, + "frag": { + "dt": "AntDesign.Input`1[System.String], AntDesign", + "t": "AntDesign.Input`1[System.String], AntDesign", + "valt": "System.String", + "attrs": [ + { + "attrn": "TValue", + "attrt": "System.String" + } + ] + }, + "ds": { + "dsgt": 1 + }, + "attrdefgroups": [ + { + "gn": "基础属性", + "attrdefs": [ + { + "disn": "是否禁用", + "pt": 6, + "desc": "", + "dftval": false, + "attrn": "Disabled", + "attrt": "System.Boolean", + "attrv": false + }, + { + "disn": "最大长度", + "pt": 2, + "desc": "字段输入的最大长度,为0时表示不限制长度", + "dftval": 0, + "attrn": "MaxLength", + "attrt": "System.Int32", + "attrv": 0 + }, + { + "disn": "输入提示", + "pt": 1, + "desc": "组件输入时的 Placeholder 提示", + "dftval": "", + "attrn": "Placeholder", + "attrt": "System.String", + "attrv": "请输入地址" + } + ] + } + ], + "childs": [], + "order": 6, + "pub": 0, + "mt": "2025-05-26T15:30:32.0346739Z", + "id": "comp_address", + "pid": "", + "n": "地址", + "lb": "地址", + "stl": { + "width": "100%", + "marginBottom": "16px" + }, + "ev": {}, + "desc": "用户地址输入框" + } + ], + "aid": "caseapp", + "id": "5kicsevr", + "n": "页面分栏表单", + "order": 8, + "pt": 1, + "pageprop": { + "playout": 3, + "ds": {} + }, + "ds": { + "dst": 1, + "dsv": "tb_test1" + }, + "mt": "2025-05-26T15:30:32.0346739Z" +} \ No newline at end of file diff --git a/meta/apps/caseapp/page/fhumgxyk.json b/meta/apps/caseapp/page/fhumgxyk.json index b90f0c62cea7a03c0ff4922cf781c66f8a336e8d..7b64d102921d0a7a265143e41e91bea0aa9bf08d 100644 --- a/meta/apps/caseapp/page/fhumgxyk.json +++ b/meta/apps/caseapp/page/fhumgxyk.json @@ -1 +1 @@ -{"comps":[{"compid":"52391a70","libid":"antdesign","cn":"Input","ct":1,"frag":{"dt":"AntDesign.Input\u00601[System.String], AntDesign","t":"AntDesign.Input\u00601[System.String], AntDesign","valt":"System.String","attrs":[{"attrn":"TValue","attrt":"System.String"}]},"ds":{"dsgt":1},"attrdefgroups":[{"gn":"基础属性","attrdefs":[{"disn":"是否禁用","pt":6,"desc":"","dftval":false,"attrn":"Disabled","attrt":"System.Boolean","attrv":false},{"disn":"最大长度","pt":2,"desc":"字段输入的最大长度,为0时表示不限制长度","dftval":0,"attrn":"MaxLength","attrt":"System.Int32","attrv":20},{"disn":"输入提示","pt":1,"desc":"组件输入时的 Placeholder 提示","dftval":"","attrn":"Placeholder","attrt":"System.String","attrv":""}]}],"childs":[],"order":10,"pub":1,"mt":"2025-02-24T15:36:15.8037414Z","id":"0bd406f9","pid":"lyawwbh9f","n":"f_field1","lb":"输入框1","stl":{"itemh":85,"labelw":180,"display":"inline","pos":"static"},"ev":{},"desc":"111"},{"compid":"52391a70","libid":"antdesign","cn":"Input","ct":1,"frag":{"dt":"AntDesign.Input\u00601[System.String], AntDesign","t":"AntDesign.Input\u00601[System.String], AntDesign","valt":"System.String","attrs":[{"attrn":"TValue","attrt":"System.String"}]},"ds":{},"attrdefgroups":[{"gn":"基础属性","attrdefs":[{"disn":"是否禁用","pt":6,"desc":"","dftval":false,"attrn":"Disabled","attrt":"System.Boolean","attrv":true},{"disn":"最大长度","pt":2,"desc":"字段输入的最大长度,为0时表示不限制长度","dftval":0,"attrn":"MaxLength","attrt":"System.Int32","attrv":0},{"disn":"输入提示","pt":1,"desc":"组件输入时的 Placeholder 提示","dftval":"","attrn":"Placeholder","attrt":"System.String","attrv":"xxx"}]}],"childs":[],"order":10,"pub":1,"mt":"2025-02-24T15:36:15.8037414Z","id":"299f6803","pid":"lyawwbh9f","n":"f_field3","lb":"输入框2","stl":{"itemh":85,"labelw":180,"display":"inline","pos":"static"},"ev":{},"desc":"222"},{"compid":"evuqdwzl","libid":"antdesign","cn":"Radio","ct":1,"frag":{"dt":"AntDesign.RadioGroup\u00601[System.String], AntDesign","t":"AntDesign.RadioGroup\u00601[System.String], AntDesign","attrs":[{"attrn":"TValue","attrt":"System.String"}]},"ds":{"dsfrag":{"t":"AntDesign.Radio\u00601[System.String], AntDesign","attrs":[{"attrn":"Value"}]},"dsgt":1,"dst":8,"fxopds":[{"l":"选项1","v":"op1"},{"l":"选项2","v":"op2"},{"l":"选项3","v":"op3"},{"l":"选项4","v":"op4"}]},"attrdefgroups":[],"childs":[],"order":13,"pub":1,"mt":"2025-03-01T02:58:56.1519656Z","id":"vjolyn1r","pid":"zkgldg5b","n":"f_field6","lb":"单选框","sptds":true,"stl":{"itemh":85,"labelw":180,"display":"inline","pos":"static"},"ev":{}},{"compid":"vdcoqln1z","libid":"antdesign","cn":"Checkbox","ct":1,"frag":{"dt":"AntDesign.CheckboxGroup\u00601[System.String], AntDesign","t":"AntDesign.CheckboxGroup\u00601[System.String], AntDesign","valt":"System.String[]","attrs":[]},"ds":{"dsfrag":{"t":"AntDesign.Checkbox, AntDesign","attrs":[{"attrn":"Label"}]},"dsgt":1,"dst":8,"fxopds":[{"l":"选项11","v":"ck1"},{"l":"选项22","v":"ck2"},{"l":"选项33","v":"字段8"}]},"attrdefgroups":[],"childs":[],"order":14,"pub":1,"mt":"2025-02-24T15:37:04.5563097Z","id":"4trfp5bk","pid":"zkgldg5b","n":"f_field8","lb":"复选框","sptds":true,"stl":{"itemh":85,"labelw":180,"display":"inline","pos":"static"},"ev":{}},{"compid":"7bab5a19","libid":"antdesign","cn":"DatePicker","ct":1,"frag":{"dt":"AntDesign.DatePicker\u00601[[System.Nullable\u00601[[System.DateTime]]]], AntDesign","t":"AntDesign.DatePicker\u00601[[System.Nullable\u00601[[System.DateTime]]]], AntDesign","valt":"System.Nullable\u00601[System.DateTime]","attrs":[]},"ds":{"dsgt":1},"attrdefgroups":[],"childs":[],"order":15,"pub":1,"mt":"2025-02-24T15:59:32.6799272Z","id":"vdyv8q2ay","pid":"zkgldg5b","n":"f_field10","lb":"日期选择器","stl":{"itemh":85,"labelw":180,"display":"inline","pos":"static"},"ev":{}},{"compid":"oikgmvkm","libid":"antdesign","cn":"TimePicker","ct":1,"frag":{"dt":"AntDesign.TimePicker\u00601[[System.Nullable\u00601[[System.DateTime]]]], AntDesign","t":"AntDesign.TimePicker\u00601[[System.Nullable\u00601[[System.DateTime]]]], AntDesign","valt":"System.Nullable\u00601[System.DateTime]","attrs":[]},"ds":{},"attrdefgroups":[],"childs":[],"order":16,"pub":1,"mt":"2025-03-05T15:31:24.9654966Z","id":"itnmgtzg","pid":"zkgldg5b","n":"f_field13","lb":"时间选择器","stl":{"itemh":85,"labelw":180,"display":"inline","pos":"static"},"ev":{}},{"compid":"5icgyefr","libid":"antdesign","cn":"TextArea","ct":1,"frag":{"dt":"AntDesign.TextArea, AntDesign","t":"AntDesign.TextArea, AntDesign","valt":"System.String","attrs":[]},"ds":{"dsgt":1},"attrdefgroups":[],"childs":[],"order":12,"pub":1,"mt":"2025-02-24T15:36:40.7389762Z","id":"ibgtanur","pid":"ongkggvjy","n":"f_field7","lb":"文本框","stl":{"itemh":85,"labelw":180,"display":"inline","pos":"static"},"ev":{}},{"compid":"9xulbbf5u","libid":"antdesign","cn":"Select","ct":1,"frag":{"dt":"AntDesign.Select\u00602[[System.String],[System.String]], antdesign","t":"AntDesign.Select\u00602[[System.String],[System.String]], antdesign","valt":"System.String","attrs":[]},"ds":{},"attrdefgroups":[],"childs":[],"order":17,"pub":1,"mt":"2025-03-05T15:31:30.1523166Z","id":"c9acpmcp","pid":"ongkggvjy","n":"f_field11","lb":"选择器","sptds":true,"stl":{"itemh":85,"labelw":180,"display":"inline","pos":"static"},"ev":{}},{"compid":"nwepem4i","libid":"antdesign","cn":"Switch","ct":1,"frag":{"dt":"AntDesign.Switch, AntDesign","t":"AntDesign.Switch, AntDesign","valt":"System.Boolean","attrs":[]},"ds":{},"attrdefgroups":[],"childs":[],"order":19,"pub":1,"mt":"2025-03-05T15:31:40.4314786Z","id":"cgfb0e64","pid":"ongkggvjy","n":"f_field9","lb":"开关","stl":{"itemh":85,"labelw":180,"display":"inline","pos":"static"},"ev":{}}],"aid":"caseapp","id":"fhumgxyk","n":"基础表单","order":1,"pt":1,"pageprop":{"playout":3,"ds":{}},"ds":{"dst":1,"dsv":"tb_test1"},"modifiedTime":"2025-04-03T02:17:22.7305035Z"} \ No newline at end of file +{"comps":[{"libid":"antdesign","compid":"52391a70","cn":"Input","ct":1,"frag":{"dt":"AntDesign.Input`1[System.String], AntDesign","t":"AntDesign.Input`1[System.String], AntDesign","childs":[],"valt":"System.String","attrs":[{"attrn":"TValue","attrt":"System.String"}]},"ds":{"dsgt":1},"attrdefgroups":[{"gn":"基础属性","attrdefs":[{"disn":"是否禁用","pt":6,"desc":"","dftval":false,"attrn":"Disabled","attrt":"System.Boolean","attrv":false},{"disn":"最大长度","pt":2,"desc":"字段输入的最大长度,为0时表示不限制长度","dftval":0,"attrn":"MaxLength","attrt":"System.Int32","attrv":20},{"disn":"输入提示","pt":1,"desc":"组件输入时的 Placeholder 提示","dftval":"","attrn":"Placeholder","attrt":"System.String","attrv":""}]}],"childs":[],"evdefs":[],"stydefs":[],"order":10,"pub":1,"mt":"2025-02-24T15:36:15.8037414Z","id":"0bd406f9","pid":"lyawwbh9f","n":"f_field1","lb":"输入框1","stl":{"itemw":4,"itemh":85,"labelw":180},"valrules":[{"id":"648ea2de-8c82-414b-b669-3b581ab9a11c","cid":"0bd406f9","type":1,"errmsg":"必填111","trigger":1,"enabled":true,"order":1}],"desc":"111","v":"0.0.1"},{"libid":"antdesign","compid":"52391a70","cn":"Input","ct":1,"frag":{"dt":"AntDesign.Input`1[System.String], AntDesign","t":"AntDesign.Input`1[System.String], AntDesign","childs":[],"valt":"System.String","attrs":[{"attrn":"TValue","attrt":"System.String"}]},"ds":{},"attrdefgroups":[{"gn":"基础属性","attrdefs":[{"disn":"是否禁用","pt":6,"desc":"","dftval":false,"attrn":"Disabled","attrt":"System.Boolean","attrv":true},{"disn":"最大长度","pt":2,"desc":"字段输入的最大长度,为0时表示不限制长度","dftval":0,"attrn":"MaxLength","attrt":"System.Int32","attrv":0},{"disn":"输入提示","pt":1,"desc":"组件输入时的 Placeholder 提示","dftval":"","attrn":"Placeholder","attrt":"System.String","attrv":"xxx"}]}],"childs":[],"evdefs":[],"stydefs":[],"order":10,"pub":1,"mt":"2025-02-24T15:36:15.8037414Z","id":"299f6803","pid":"lyawwbh9f","n":"f_field3","lb":"输入框2","stl":{"itemw":4,"itemh":85,"labelw":180},"valrules":[],"desc":"222","v":"0.0.1"},{"libid":"antdesign","compid":"evuqdwzl","cn":"Radio","ct":1,"frag":{"dt":"AntDesign.RadioGroup`1[System.String], AntDesign","t":"AntDesign.RadioGroup`1[System.String], AntDesign","childs":[],"valt":"System.String","attrs":[{"attrn":"TValue","attrt":"System.String"}]},"ds":{"dsfrag":{"t":"AntDesign.Radio`1[System.String], AntDesign","childs":[],"attrs":[{"attrn":"Value"}]},"dsgt":1,"dst":8,"fxopds":[{"l":"选项1","v":"op1"},{"l":"选项2","v":"op2"},{"l":"选项3","v":"op3"},{"l":"选项4","v":"op4"}]},"attrdefgroups":[],"childs":[],"evdefs":[],"stydefs":[],"order":13,"pub":1,"mt":"2025-03-01T02:58:56.1519656Z","id":"vjolyn1r","pid":"zkgldg5b","n":"f_field6","lb":"单选框3","sptds":true,"stl":{"itemw":4,"itemh":85,"labelw":180},"v":"0.0.1"},{"libid":"antdesign","compid":"vdcoqln1z","cn":"Checkbox","ct":1,"frag":{"dt":"AntDesign.CheckboxGroup`1[System.String], AntDesign","t":"AntDesign.CheckboxGroup`1[System.String], AntDesign","childs":[],"valt":"System.String[]","attrs":[]},"ds":{"dsfrag":{"t":"AntDesign.Checkbox, AntDesign","childs":[],"attrs":[{"attrn":"Label"}]},"dsgt":1,"dst":8,"fxopds":[{"l":"选项11","v":"ck1"},{"l":"选项22","v":"ck2"},{"l":"选项33","v":"字段8"}]},"attrdefgroups":[],"childs":[],"evdefs":[],"stydefs":[],"order":14,"pub":1,"mt":"2025-02-24T15:37:04.5563097Z","id":"4trfp5bk","pid":"zkgldg5b","n":"f_field8","lb":"复选框4","sptds":true,"stl":{"itemw":4,"itemh":85,"labelw":180},"v":"0.0.1"},{"libid":"antdesign","compid":"7bab5a19","cn":"DatePicker","ct":1,"frag":{"dt":"AntDesign.DatePicker`1[[System.Nullable`1[[System.DateTime]]]], AntDesign","t":"AntDesign.DatePicker`1[[System.Nullable`1[[System.DateTime]]]], AntDesign","childs":[],"valt":"System.Nullable`1[System.DateTime]","attrs":[]},"ds":{"dsgt":1},"attrdefgroups":[],"childs":[],"sptevs":["OnClick","OnExpand"],"evdefs":[],"stydefs":[],"order":15,"pub":1,"mt":"2025-02-24T15:59:32.6799272Z","id":"vdyv8q2ay","pid":"zkgldg5b","n":"f_field10","lb":"日期选择器5","stl":{"itemw":4,"itemh":85,"labelw":180},"v":"0.0.1"},{"libid":"antdesign","compid":"oikgmvkm","cn":"TimePicker","ct":1,"frag":{"dt":"AntDesign.TimePicker`1[[System.Nullable`1[[System.DateTime]]]], AntDesign","t":"AntDesign.TimePicker`1[[System.Nullable`1[[System.DateTime]]]], AntDesign","childs":[],"valt":"System.Nullable`1[System.DateTime]","attrs":[]},"ds":{},"attrdefgroups":[],"childs":[],"evdefs":[],"stydefs":[],"order":16,"pub":1,"mt":"2025-03-05T15:31:24.9654966Z","id":"itnmgtzg","pid":"zkgldg5b","n":"f_field13","lb":"时间选择器6","stl":{"itemw":4,"itemh":85,"labelw":180},"v":"0.0.1"},{"libid":"antdesign","compid":"5icgyefr","cn":"TextArea","ct":1,"frag":{"dt":"AntDesign.TextArea, AntDesign","t":"AntDesign.TextArea, AntDesign","childs":[],"valt":"System.String","attrs":[]},"ds":{"dsgt":1},"attrdefgroups":[],"childs":[],"evdefs":[],"stydefs":[],"order":12,"pub":1,"mt":"2025-02-24T15:36:40.7389762Z","id":"ibgtanur","pid":"ongkggvjy","n":"f_field7","lb":"文本框7","stl":{"itemw":4,"itemh":85,"labelw":180},"v":"0.0.1"},{"libid":"antdesign","compid":"9xulbbf5u","cn":"Select","ct":1,"frag":{"dt":"AntDesign.Select`2[[System.String],[System.String]], antdesign","t":"AntDesign.Select`2[[System.String],[System.String]], antdesign","childs":[],"valt":"System.String","attrs":[]},"ds":{},"attrdefgroups":[],"childs":[],"evdefs":[],"stydefs":[],"order":17,"pub":1,"mt":"2025-03-05T15:31:30.1523166Z","id":"c9acpmcp","pid":"ongkggvjy","n":"f_field11","lb":"选择器8","sptds":true,"stl":{"itemw":4,"itemh":85,"labelw":180},"v":"0.0.1"},{"libid":"antdesign","compid":"nwepem4i","cn":"Switch","ct":1,"frag":{"dt":"AntDesign.Switch, AntDesign","t":"AntDesign.Switch, AntDesign","childs":[],"valt":"System.Boolean","attrs":[]},"ds":{},"attrdefgroups":[],"childs":[],"evdefs":[],"stydefs":[],"order":19,"pub":1,"mt":"2025-03-05T15:31:40.4314786Z","id":"cgfb0e64","pid":"ongkggvjy","n":"f_field9","lb":"开关9","stl":{"itemw":4,"itemh":85,"labelw":180},"v":"0.0.1"}],"sptevs":["OnLoad"],"aid":"caseapp","id":"fhumgxyk","n":"基础表单","order":1,"pt":1,"pageprop":{"playout":3,"ds":{}},"ds":{"dst":1,"dsv":"tb_test1"},"mt":"2025-10-26T15:04:35.7776707Z"} \ No newline at end of file diff --git a/meta/apps/caseapp/page/g0qcqxzd.json b/meta/apps/caseapp/page/g0qcqxzd.json index ebe8316c74d2900602c349b04db63b457594149c..357ab96acbdfb880f04c520283d5c08fd156bbcc 100644 --- a/meta/apps/caseapp/page/g0qcqxzd.json +++ b/meta/apps/caseapp/page/g0qcqxzd.json @@ -1 +1 @@ -{"comps":[{"compid":"f2b54b4c","libid":"antdesign","cn":"Table","ct":1,"frag":{"dt":"H.LowCode.Components.Defaults.LcTable, H.LowCode.Components.Defaults","t":"H.LowCode.Components.Defaults.LcTable, H.LowCode.Components.Defaults","attrs":[]},"ds":{"dsgt":2,"dsv":"{\"tcols\":[{\"id\":\"i79talu1\",\"n\":\"No\",\"t\":\"学号\"},{\"id\":\"vwvoqrn1s\",\"n\":\"Name\",\"t\":\"姓名\"},{\"id\":\"ap0ceewr\",\"n\":\"Age\",\"t\":\"年龄\"},{\"id\":\"ck9b6mez\",\"n\":\"Class\",\"t\":\"班级\"}],\"searchs\":[],\"btns\":[]}"},"attrdefgroups":[],"childs":[],"order":30,"pub":1,"mt":"2025-05-22T14:26:07.7475675Z","id":"fqmcwygx","pid":"nupedwmm3","n":"Table_926","lb":"表格-A","hlb":true,"sptds":true,"stl":{"itemw":24,"itemh":300,"labelw":180},"ev":{}}],"aid":"caseapp","id":"g0qcqxzd","n":"基础列表","order":31,"pt":2,"pageprop":{"playout":2,"ds":{}},"ds":{},"mt":"2025-05-24T11:36:58.9214723Z"} \ No newline at end of file +{"comps":[{"compid":"f2b54b4c","libid":"antdesign","cn":"Table","ct":1,"frag":{"dt":"H.LowCode.Components.Defaults.LcTable, H.LowCode.Components.Defaults","t":"H.LowCode.Components.Defaults.LcTable, H.LowCode.Components.Defaults","attrs":[]},"ds":{"dsgt":2,"dst":1,"dsid":"qgzhc7w3z","dsn":"tb_test1","dsv":"{\"tcols\":[{\"id\":\"i79talu1\",\"n\":\"f_field1\",\"t\":\"输入框1\"},{\"id\":\"vwvoqrn1s\",\"n\":\"f_field3\",\"t\":\"输入框2\"},{\"id\":\"ap0ceewr\",\"n\":\"f_field6\",\"t\":\"单选框3\"},{\"id\":\"ck9b6mez\",\"n\":\"Class\",\"t\":\"班级\"},{\"id\":\"es0qoauj\",\"n\":\"f_field10\",\"t\":\"日期选择5\"},{\"id\":\"t910chps\",\"n\":\"f_id\",\"t\":\"Id\",\"pk\":true}],\"searchs\":[],\"tbtns\":[{\"id\":\"wpnm70fe\",\"n\":\"create\",\"t\":\"新增\",\"bt\":1,\"sptevs\":[\"OnClick\"],\"evs\":[{\"en\":\"OnClick\",\"eht\":10,\"etid\":\"fhumgxyk\",\"eta\":\"14\"}]},{\"id\":\"2qsecnfo\",\"n\":\"deleteSelections\",\"t\":\"删除选中\",\"sptevs\":[\"OnClick\"]}],\"rbtns\":[{\"id\":\"za8gxxdz\",\"n\":\"edit\",\"t\":\"编辑\",\"sptevs\":[\"OnClick\"],\"evs\":[{\"en\":\"OnClick\",\"eht\":10,\"etid\":\"fhumgxyk\",\"eta\":\"14\",\"eventArgs\":{\"param1\":\"111\"},\"rowparams\":{\"id\":\"f_id\"}}]},{\"id\":\"b17d3nrc\",\"n\":\"del\",\"t\":\"删除\",\"sptevs\":[\"OnClick\"],\"evs\":[{\"en\":\"OnClick\",\"eht\":40,\"edat\":20}]},{\"id\":\"vwrounbq\",\"n\":\"editRow\",\"t\":\"行内编辑\",\"sptevs\":[\"OnClick\"],\"evs\":[{\"en\":\"OnClick\",\"eht\":40,\"edat\":10}]}]}"},"attrdefgroups":[],"childs":[],"order":30,"pub":1,"mt":"2025-05-22T14:26:07.7475675Z","id":"fqmcwygx","pid":"nupedwmm3","n":"Table_926","lb":"表格-A","hlb":true,"sptds":true,"stl":{"itemw":24,"itemh":300,"labelw":180}}],"sptevs":["OnLoad"],"aid":"caseapp","id":"g0qcqxzd","n":"基础列表","order":31,"pt":2,"pageprop":{"playout":2,"ds":{}},"ds":{},"mt":"2025-09-26T16:52:21.2061257Z"} \ No newline at end of file diff --git a/meta/apps/caseapp/page/gndz2vecz.json b/meta/apps/caseapp/page/gndz2vecz.json index 20f9a5aa3adb72f27420bae769e8729b5b47240d..f9e0af51a43be34ac211b5a4f4548427aeaf469c 100644 --- a/meta/apps/caseapp/page/gndz2vecz.json +++ b/meta/apps/caseapp/page/gndz2vecz.json @@ -1 +1,152 @@ -{"comps":[],"aid":"caseapp","id":"gndz2vecz","n":"多标签页表单","order":4,"pt":1,"pageprop":{"playout":2,"ds":{}},"ds":{"dst":1,"dsv":"tb_test1"},"modifiedTime":"2025-04-03T02:09:28.3110543Z"} \ No newline at end of file +{ + "comps": [ + { + "libid": "antdesign", + "compid": "jmmybvkua", + "cn": "Tabs", + "ct": 1, + "frag": { + "dt": "AntDesign.Tabs, AntDesign", + "t": "AntDesign.Tabs, AntDesign", + "childs": [ + { + "dt": "AntDesign.TabPane, AntDesign", + "t": "AntDesign.TabPane, AntDesign", + "childs": [], + "attrs": [ + { + "attrn": "Key", + "attrt": "System.String", + "attrv": "tab1" + }, + { + "attrn": "Tab", + "attrt": "System.String", + "attrv": "标签页1" + } + ], + "content": "$(DraggableContainer)" + }, + { + "dt": "AntDesign.TabPane, AntDesign", + "t": "AntDesign.TabPane, AntDesign", + "childs": [], + "attrs": [ + { + "attrn": "Key", + "attrt": "System.String", + "attrv": "tab2" + }, + { + "attrn": "Tab", + "attrt": "System.String", + "attrv": "标签页2" + } + ], + "content": "$(DraggableContainer)" + } + ], + "attrs": [] + }, + "ds": {}, + "attrdefgroups": [ + { + "gn": "基础属性", + "attrdefs": [ + { + "disn": "默认激活标签", + "pt": 1, + "desc": "默认激活的标签页键值", + "dftval": "tab1", + "attrn": "DefaultActiveKey", + "attrt": "System.String" + }, + { + "disn": "标签位置", + "pt": 1, + "desc": "标签页的位置", + "dftval": "Top", + "attrn": "TabPosition", + "attrt": "AntDesign.TabPosition" + }, + { + "disn": "标签大小", + "pt": 1, + "desc": "标签页的大小", + "dftval": "Default", + "attrn": "Size", + "attrt": "AntDesign.TabSize" + }, + { + "disn": "是否动画", + "pt": 6, + "desc": "是否使用动画效果", + "dftval": true, + "attrn": "Animated", + "attrt": "System.Boolean" + } + ] + } + ], + "childs": [ + { + "compid": "iatnu5wu", + "frag": { + "childs": [], + "attrs": [] + }, + "ds": {}, + "attrdefgroups": [], + "childs": [], + "evdefs": [], + "stydefs": [], + "id": "container-f6miynet-1853782221", + "pid": "f6miynet", + "hlb": true, + "container": true, + "incontainer": true, + "stl": { + "itemw": 4, + "itemh": 85, + "labelw": 180, + "dfstl": "height:100%; width:100%;" + }, + "v": "0.0.1" + } + ], + "evdefs": [], + "stydefs": [], + "order": 33, + "pub": 1, + "mt": "2025-10-18T13:14:02.3929554Z", + "id": "f6miynet", + "pid": "qajaczud", + "n": "Tabs_512", + "lb": "标签页-A", + "hlb": true, + "stl": { + "itemw": 4, + "itemh": 200, + "labelw": 180 + }, + "v": "0.0.1" + } + ], + "sptevs": [ + "OnLoad" + ], + "aid": "caseapp", + "id": "gndz2vecz", + "n": "多标签页表单", + "order": 4, + "pt": 1, + "pageprop": { + "playout": 2, + "ds": {} + }, + "ds": { + "dst": 1, + "dsv": "tb_test1" + }, + "mt": "2025-10-22T16:47:17.4378959Z" +} \ No newline at end of file diff --git a/meta/apps/caseapp/page/pl3juvaok.json b/meta/apps/caseapp/page/pl3juvaok.json index c4c050d79cdb354ef348a43c9d56d2171f9a8b3c..6a7b50077ed8ed2a8999aa85d6e3bb767e9b3545 100644 --- a/meta/apps/caseapp/page/pl3juvaok.json +++ b/meta/apps/caseapp/page/pl3juvaok.json @@ -1 +1 @@ -{"comps":[],"aid":"caseapp","id":"pl3juvaok","n":"校验表单","order":2,"pt":1,"pageprop":{"playout":2,"ds":{}},"ds":{"dst":1,"dsv":"tb_test1"},"modifiedTime":"2025-04-03T02:09:07.8151933Z"} \ No newline at end of file +{"comps":[],"aid":"caseapp","id":"pl3juvaok","n":"校验表单","order":2,"pt":1,"pageprop":{"playout":2,"ds":{}},"ds":{"dst":1,"dsv":"tb_test1"},"mt":"2025-05-26T15:29:46.9891744Z"} \ No newline at end of file diff --git a/meta/apps/caseapp/page/xjvks1d3f.json b/meta/apps/caseapp/page/xjvks1d3f.json index ee74204fb5ddaa03553b465c39952b6df896d2d0..4ad5204f8913aade9e3ba05b95f77f2a2270fdb3 100644 --- a/meta/apps/caseapp/page/xjvks1d3f.json +++ b/meta/apps/caseapp/page/xjvks1d3f.json @@ -1 +1 @@ -{"comps":[],"aid":"caseapp","id":"xjvks1d3f","n":"表格样式表单","order":9,"pt":1,"pageprop":{"playout":2,"ds":{}},"ds":{"dst":1,"dsv":"tb_test1"},"modifiedTime":"2025-04-03T02:10:39.9091503Z"} \ No newline at end of file +{"comps":[],"aid":"caseapp","id":"xjvks1d3f","n":"表格样式表单","order":9,"pt":1,"pageprop":{"playout":2,"ds":{}},"ds":{"dst":1,"dsv":"tb_test1"},"mt":"2025-05-26T15:30:36.669071Z"} \ No newline at end of file diff --git a/meta/apps/testapp/page/ajzc8ywaa.json b/meta/apps/testapp/page/ajzc8ywaa.json index 48e4934c8ea0c1e712b559e27162bd3d2cdb4639..3b884cbd919857022be8f8c479c7c2da8253666c 100644 --- a/meta/apps/testapp/page/ajzc8ywaa.json +++ b/meta/apps/testapp/page/ajzc8ywaa.json @@ -1,26 +1 @@ -{ - "aid": "testapp", - "id": "ajzc8ywaa", - "n": "页面1", - "order": 3, - "pt": 0, - "pubstatus": false, - "comps": [ - - ], - "pageprop": { - "playout": 2 - }, - "ds": { - "order": 0, - "type": 0, - "pubstatus": false, - "fields": [], - "ops": [], - "createdTime": "0001-01-01T00:00:00", - "modifiedTime": "0001-01-01T00:00:00" - }, - "i18n": {}, - "createdTime": "0001-01-01T00:00:00", - "modifiedTime": "2024-10-13T09:21:54.2980288Z" -} \ No newline at end of file +{"comps":[],"aid":"testapp","id":"ajzc8ywaa","n":"页面1","order":3,"pageprop":{"playout":2,"ds":{}},"ds":{},"mt":"2025-05-26T15:29:15.2677174Z"} \ No newline at end of file diff --git a/meta/apps/testapp/page/ehduqxwzm.json b/meta/apps/testapp/page/ehduqxwzm.json index 003333d9b9c831eb402e60f342259501264cdf89..765d18c74d78aea75143dc3f4e328abcdefea134 100644 --- a/meta/apps/testapp/page/ehduqxwzm.json +++ b/meta/apps/testapp/page/ehduqxwzm.json @@ -1,26 +1 @@ -{ - "aid": "testapp", - "id": "ehduqxwzm", - "n": "页面3", - "order": 5, - "pt": 0, - "pubstatus": false, - "comps": [ - - ], - "pageprop": { - "playout": 2 - }, - "ds": { - "order": 0, - "type": 0, - "pubstatus": false, - "fields": [], - "ops": [], - "createdTime": "0001-01-01T00:00:00", - "modifiedTime": "0001-01-01T00:00:00" - }, - "i18n": {}, - "createdTime": "0001-01-01T00:00:00", - "modifiedTime": "2024-10-13T09:22:10.8343157Z" -} \ No newline at end of file +{"comps":[],"aid":"testapp","id":"ehduqxwzm","n":"页面3","order":5,"pageprop":{"playout":2,"ds":{}},"ds":{},"mt":"2025-05-26T15:29:19.2339683Z"} \ No newline at end of file diff --git a/meta/apps/testapp/page/g0qcqxzd.json b/meta/apps/testapp/page/g0qcqxzd.json index 134801e8c77808518e82dbd9355372d0449eb6f3..1f9b5e3992934cb8198894751e18588c3701d47d 100644 --- a/meta/apps/testapp/page/g0qcqxzd.json +++ b/meta/apps/testapp/page/g0qcqxzd.json @@ -1 +1 @@ -{"aid":"testapp","id":"g0qcqxzd","n":"页面11","order":0,"pt":0,"pubstatus":false,"comps":[],"pageprop":{"playout":2},"ds":{"order":0,"type":0,"pubstatus":false,"fields":[],"ops":[],"createdTime":"0001-01-01T00:00:00","modifiedTime":"0001-01-01T00:00:00"},"i18n":{},"createdTime":"0001-01-01T00:00:00","modifiedTime":"2024-10-13T08:10:20.0733139Z"} \ No newline at end of file +{"comps":[],"aid":"testapp","id":"g0qcqxzd","n":"页面11","pageprop":{"playout":2,"ds":{}},"ds":{},"mt":"2025-05-26T15:29:01.5525837Z"} \ No newline at end of file diff --git a/meta/apps/testapp/page/wjrxq0ft.json b/meta/apps/testapp/page/wjrxq0ft.json index 3ec06f988a9a95ce48153f0574624db1b5c18524..dde26e494410dce19e3ec0be20e8258fa22b65c8 100644 --- a/meta/apps/testapp/page/wjrxq0ft.json +++ b/meta/apps/testapp/page/wjrxq0ft.json @@ -1,26 +1 @@ -{ - "aid": "testapp", - "id": "wjrxq0ft", - "n": "组件嵌套", - "order": 1, - "pt": 0, - "pubstatus": false, - "comps": [ - - ], - "pageprop": { - "playout": 2 - }, - "ds": { - "order": 0, - "type": 0, - "pubstatus": false, - "fields": [], - "ops": [], - "createdTime": "0001-01-01T00:00:00", - "modifiedTime": "0001-01-01T00:00:00" - }, - "i18n": {}, - "createdTime": "0001-01-01T00:00:00", - "modifiedTime": "2024-10-13T09:21:35.1783317Z" -} \ No newline at end of file +{"comps":[],"aid":"testapp","id":"wjrxq0ft","n":"组件嵌套","order":1,"pageprop":{"playout":2,"ds":{}},"ds":{},"mt":"2025-05-26T15:29:06.9549831Z"} \ No newline at end of file diff --git a/meta/apps/testapp/page/xvdr8b6l.json b/meta/apps/testapp/page/xvdr8b6l.json index 9e5b6c18381f3feddb283297b65377f84b7d9595..c2a561c1e51c5182fb49a5d55516d671b63c06d6 100644 --- a/meta/apps/testapp/page/xvdr8b6l.json +++ b/meta/apps/testapp/page/xvdr8b6l.json @@ -1,26 +1 @@ -{ - "aid": "testapp", - "id": "xvdr8b6l", - "n": "页面1", - "order": 2, - "pt": 0, - "pubstatus": false, - "comps": [ - - ], - "pageprop": { - "playout": 3 - }, - "ds": { - "order": 0, - "type": 1, - "pubstatus": false, - "fields": [], - "ops": [], - "createdTime": "0001-01-01T00:00:00", - "modifiedTime": "0001-01-01T00:00:00" - }, - "i18n": {}, - "createdTime": "0001-01-01T00:00:00", - "modifiedTime": "2024-10-13T09:20:24.737612Z" -} \ No newline at end of file +{"comps":[],"aid":"testapp","id":"xvdr8b6l","n":"页面1","order":2,"pageprop":{"playout":3,"ds":{}},"ds":{},"mt":"2025-05-26T15:29:10.6464264Z"} \ No newline at end of file diff --git a/meta/apps/testapp/testapp.json b/meta/apps/testapp/testapp.json index b0b9578082dcd55ee1480287e3a814b528a74b49..2eb16453876901e4167b3349f680e25384529aaf 100644 --- a/meta/apps/testapp/testapp.json +++ b/meta/apps/testapp/testapp.json @@ -1 +1 @@ -{"id":"testapp","n":"测试系统","desc":"测试不同页面设计场景","state":0} \ No newline at end of file +{"id":"testapp","n":"测试系统","desc":"测试组件、页面不同设计场景","platform":[0],"mt":"2025-05-29T16:43:23.7831823Z"} \ No newline at end of file diff --git a/meta/parts/componentParts/antdesign/7bab5a19.json b/meta/parts/componentParts/antdesign/7bab5a19.json index a1bd26b610db3d9459ce8430f3d1811d90990670..50671dc7965b219a5fa3c67b13721ed96a09defe 100644 --- a/meta/parts/componentParts/antdesign/7bab5a19.json +++ b/meta/parts/componentParts/antdesign/7bab5a19.json @@ -23,5 +23,5 @@ "display": "inline", "pos": "static" }, - "ev": {} + "sptevs": ["OnClick", "OnExpand"] } \ No newline at end of file diff --git a/meta/parts/componentParts/antdesign/antdesign.json b/meta/parts/componentParts/antdesign/antdesign.json index 81d302930fe5db44032795b9a13879242e51dbda..60fe0fa9c19ef15ed6e76cdceee913fc0b6963db 100644 --- a/meta/parts/componentParts/antdesign/antdesign.json +++ b/meta/parts/componentParts/antdesign/antdesign.json @@ -1,11 +1 @@ -{ - "libid": "antdesign", - "libname": "antdesign", - "pub": 0, - "desc": "1112222", - "platform": [ - 0 - ], - "createdTime": "0001-01-01T00:00:00", - "modifiedTime": "2025-01-01T16:42:13.8203228Z" -} \ No newline at end of file +{"libid":"antdesign","libname":"antdesign","desc":"antdesign 风格的基础组件库","platform":[0],"modifiedTime":"2025-10-12T12:12:29.9587419Z"} \ No newline at end of file diff --git a/meta/parts/componentParts/antdesign/f2b54b4c.json b/meta/parts/componentParts/antdesign/f2b54b4c.json index b6a7693d2057339153d88e2fddf32151a77e2885..a2059264092900aaa4c7af86370d11519c3722ef 100644 --- a/meta/parts/componentParts/antdesign/f2b54b4c.json +++ b/meta/parts/componentParts/antdesign/f2b54b4c.json @@ -1,4 +1,4 @@ -{ +{ "compid": "f2b54b4c", "libid": "antdesign", "cn": "Table", @@ -16,7 +16,8 @@ "hlb": true, "sptds": true, "ds": { - "dsgt":2 + "dsgt":2, + "dsv": "{\"tbtns\":[{\"id\":\"wpnm70fe\",\"n\":\"create\",\"t\":\"新增\",\"bt\":1,\"tgId\":\"xxx\"},{\"id\":\"2qsecnfo\",\"n\":\"deleteSelections\",\"t\":\"删除选中\",\"tgId\":\"xxx\"}],\"rbtns\":[{\"id\":\"delete_row\",\"n\":\"delete\",\"t\":\"删除\",\"bt\":0,\"disabled\":false,\"order\":1,\"sptevs\":[\"OnClick\"],\"evs\":[{\"en\":\"OnClick\",\"eht\":40,\"edat\":20}]}]}" }, "stl": { "itemw": 24, diff --git a/meta/parts/componentParts/antdesign/fmiwu412.json b/meta/parts/componentParts/antdesign/fmiwu412.json index e822ae558833146b0699e457bd5caa686a0d4293..e513eed27331ff5fcff201c38a7655f8fef72b02 100644 --- a/meta/parts/componentParts/antdesign/fmiwu412.json +++ b/meta/parts/componentParts/antdesign/fmiwu412.json @@ -1 +1,104 @@ -{"cn":"Card","ct":1,"attrdefgroups":[],"childs":[],"sptds":false,"order":34,"pub":1,"mt":"2025-03-05T15:32:20.4958136Z","id":"12nblk6r","libid":"antdesign","compid":"fmiwu412","lb":"卡片-A","container":false,"stl":{"itemh":85,"labelw":180,"display":"inline","pos":"static"},"ev":{},"ds":{"dst":0}} \ No newline at end of file +{ + "cn": "Card", + "ct": 1, + "frag": { + "dt": "AntDesign.Card, AntDesign", + "attrs": [] + }, + "attrdefgroups": [ + { + "gn": "基础属性", + "attrdefs": [ + { + "attrn": "Title", + "disn": "标题", + "attrt": "System.String", + "dftval": "", + "desc": "卡片标题", + "pt": 1 + }, + { + "attrn": "Size", + "disn": "尺寸", + "attrt": "AntDesign.CardSize", + "dftval": "Default", + "desc": "卡片尺寸", + "pt": 1 + }, + { + "attrn": "Bordered", + "disn": "显示边框", + "attrt": "System.Boolean", + "dftval": true, + "desc": "是否显示边框", + "pt": 6 + }, + { + "attrn": "Hoverable", + "disn": "悬浮效果", + "attrt": "System.Boolean", + "dftval": false, + "desc": "鼠标悬浮时是否显示阴影", + "pt": 6 + }, + { + "attrn": "Loading", + "disn": "加载状态", + "attrt": "System.Boolean", + "dftval": false, + "desc": "是否显示加载状态", + "pt": 6 + } + ] + }, + { + "gn": "样式属性", + "attrdefs": [ + { + "attrn": "Style", + "disn": "自定义样式", + "attrt": "System.String", + "dftval": "", + "desc": "自定义CSS样式", + "pt": 1 + }, + { + "attrn": "BodyStyle", + "disn": "内容区样式", + "attrt": "System.String", + "dftval": "", + "desc": "卡片内容区域的自定义样式", + "pt": 1 + }, + { + "attrn": "HeadStyle", + "disn": "头部样式", + "attrt": "System.String", + "dftval": "", + "desc": "卡片头部的自定义样式", + "pt": 1 + } + ] + } + ], + "childs": [], + "sptds": false, + "order": 34, + "pub": 1, + "mt": "2025-03-05T15:32:20.4958136Z", + "id": "12nblk6r", + "libid": "antdesign", + "compid": "fmiwu412", + "lb": "卡片-A", + "container": false, + "stl": { + "itemh": 85, + "labelw": 180, + "display": "inline", + "pos": "static" + }, + "ev": {}, + "ds": { + "dst": 0 + } +} \ No newline at end of file diff --git a/meta/parts/componentParts/antdesign/jmmybvkua.json b/meta/parts/componentParts/antdesign/jmmybvkua.json index c50ff89aaa7f656ff4475907e5447015fdfeb9a9..1cee315e1b1c6cb26d50d82a9dd471a8338161f7 100644 --- a/meta/parts/componentParts/antdesign/jmmybvkua.json +++ b/meta/parts/componentParts/antdesign/jmmybvkua.json @@ -1 +1 @@ -{"cn":"Tabs","ct":1,"attrdefgroups":[],"childs":[],"sptds":false,"order":33,"pub":1,"mt":"2025-03-05T15:32:15.4797235Z","id":"iu1nxkgtk","libid":"antdesign","compid":"jmmybvkua","lb":"标签页-A","container":false,"stl":{"itemh":85,"labelw":180,"display":"inline","pos":"static"},"ev":{},"ds":{"dst":0}} \ No newline at end of file +{"compid":"jmmybvkua","libid":"antdesign","cn":"Tabs","ct":1,"frag":{"dt":"AntDesign.Tabs, AntDesign","childs":[{"dt":"AntDesign.TabPane, AntDesign","childs":[],"attrs":[{"attrn":"Key","attrt":"System.String","attrv":"tab1"},{"attrn":"Tab","attrt":"System.String","attrv":"标签页1"}],"content":"$(DraggableContainer)"},{"dt":"AntDesign.TabPane, AntDesign","childs":[],"attrs":[{"attrn":"Key","attrt":"System.String","attrv":"tab2"},{"attrn":"Tab","attrt":"System.String","attrv":"标签页2"}],"content":"$(DraggableContainer)"}],"attrs":[]},"ds":{},"attrdefgroups":[{"gn":"基础属性","attrdefs":[{"disn":"默认激活标签","pt":1,"desc":"默认激活的标签页键值","dftval":"tab1","attrn":"DefaultActiveKey","attrt":"System.String"},{"disn":"标签位置","pt":1,"desc":"标签页的位置","dftval":"Top","attrn":"TabPosition","attrt":"AntDesign.TabPosition"},{"disn":"标签大小","pt":1,"desc":"标签页的大小","dftval":"Default","attrn":"Size","attrt":"AntDesign.TabSize"},{"disn":"是否动画","pt":6,"desc":"是否使用动画效果","dftval":true,"attrn":"Animated","attrt":"System.Boolean"}]}],"childs":[],"evdefs":[],"stydefs":[],"order":33,"pub":1,"mt":"2025-10-18T13:14:02.3929554Z","id":"iu1nxkgtk","lb":"标签页-A","hlb":true,"stl":{"itemw":4,"itemh":200,"labelw":180}} \ No newline at end of file diff --git a/meta/parts/componentParts/common/common.json b/meta/parts/componentParts/common/common.json new file mode 100644 index 0000000000000000000000000000000000000000..1ddaa76a4caa3b8515b1733a76acf5b8197b532d --- /dev/null +++ b/meta/parts/componentParts/common/common.json @@ -0,0 +1 @@ +{"libid":"common","libname":"common","desc":"常用组件库,如行政区划、组织用户等","platform":[0],"modifiedTime":"2025-10-12T12:38:38.3811663Z"} \ No newline at end of file diff --git a/meta/parts/componentParts/common/lybwuphn6.json b/meta/parts/componentParts/common/lybwuphn6.json new file mode 100644 index 0000000000000000000000000000000000000000..38de5c8f7083e983125a7cef79cf7a4a2d33a674 --- /dev/null +++ b/meta/parts/componentParts/common/lybwuphn6.json @@ -0,0 +1 @@ +{"compid":"lybwuphn6","libid":"common","cn":"region","ct":2,"ds":{},"attrdefgroups":[],"childs":[],"evdefs":[],"stydefs":[],"mt":"2025-10-12T14:11:50.0909771Z","id":"76g2ae5m","n":"region","lb":"行政区划组件","stl":{"itemw":4,"itemh":85,"labelw":180}} \ No newline at end of file diff --git a/meta/parts/componentParts/common/qpqayjuhb.json b/meta/parts/componentParts/common/qpqayjuhb.json new file mode 100644 index 0000000000000000000000000000000000000000..9417c47b373cfc5fb819740af005a075293f13ef --- /dev/null +++ b/meta/parts/componentParts/common/qpqayjuhb.json @@ -0,0 +1 @@ +{"compid":"qpqayjuhb","libid":"common","cn":"userselect","ct":2,"frag":{"attrs":[]},"ds":{},"attrdefgroups":[],"childs":[],"evdefs":[],"stydefs":[],"mt":"2025-10-12T14:12:11.9143366Z","id":"t2f1qecpq","lb":"用户选择组件","stl":{"itemw":4,"itemh":85,"labelw":180}} \ No newline at end of file diff --git a/src/RenderEngine/H.LowCode.RenderEngine.Application.Contracts/DataAppServices/IFormDataAppService.cs b/src/Common/H.LowCode.Application.Contracts/AppServices/IFormDataAppService.cs similarity index 55% rename from src/RenderEngine/H.LowCode.RenderEngine.Application.Contracts/DataAppServices/IFormDataAppService.cs rename to src/Common/H.LowCode.Application.Contracts/AppServices/IFormDataAppService.cs index d1559398fb04456fb3fdccc84b37f113e456a419..456343ccd94a9e1be6e43149b122e7f98ef466cf 100644 --- a/src/RenderEngine/H.LowCode.RenderEngine.Application.Contracts/DataAppServices/IFormDataAppService.cs +++ b/src/Common/H.LowCode.Application.Contracts/AppServices/IFormDataAppService.cs @@ -1,13 +1,13 @@ using Volo.Abp.Http; using Volo.Abp.Application.Services; -namespace H.LowCode.RenderEngine.Application.Contracts; +namespace H.LowCode.Application.Contracts; public interface IFormDataAppService : IApplicationService { - Task SaveAsync(FormDataDTO dto); + Task SaveAsync(FormDataDto dto); - Task GetAsync(string appId, string pageId, string id); + Task GetAsync(string appId, string pageId, string id); Task DeleteAsync(string appId, string pageId, string id); } \ No newline at end of file diff --git a/src/Common/H.LowCode.Application.Contracts/AppServices/ITableDataAppService.cs b/src/Common/H.LowCode.Application.Contracts/AppServices/ITableDataAppService.cs new file mode 100644 index 0000000000000000000000000000000000000000..efbf62f92de48aba45ce6940ae65bccfb421d0da --- /dev/null +++ b/src/Common/H.LowCode.Application.Contracts/AppServices/ITableDataAppService.cs @@ -0,0 +1,28 @@ +using Volo.Abp; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Application.Services; +using System.Collections.Generic; +using System.Threading.Tasks; + +namespace H.LowCode.Application.Contracts; + +/// +/// 列表数据查询 +/// +public interface ITableDataAppService : IApplicationService +{ + /// + /// 获取表格数据 + /// + Task>> GetListAsync(TableDataInput request); + + /// + /// 删除数据 + /// + Task DeleteAsync(TableDataDeleteInput request); + + /// + /// 更新数据 + /// + Task UpdateAsync(TableDataUpdateInput request); +} diff --git a/src/RenderEngine/H.LowCode.RenderEngine.Application.Contracts/DataDTOs/DataDTOBase.cs b/src/Common/H.LowCode.Application.Contracts/Dtos/DataDtoBase.cs similarity index 77% rename from src/RenderEngine/H.LowCode.RenderEngine.Application.Contracts/DataDTOs/DataDTOBase.cs rename to src/Common/H.LowCode.Application.Contracts/Dtos/DataDtoBase.cs index 872c454eb0b0c8dd61304b7000a64d0b86adac95..263b3239b8c2095635c109b64c1c016dfa358053 100644 --- a/src/RenderEngine/H.LowCode.RenderEngine.Application.Contracts/DataDTOs/DataDTOBase.cs +++ b/src/Common/H.LowCode.Application.Contracts/Dtos/DataDtoBase.cs @@ -4,9 +4,9 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace H.LowCode.RenderEngine.Application.Contracts; +namespace H.LowCode.Application.Contracts; -public abstract class DataDTOBase +public abstract class DataDtoBase { public DateTime CreatedTime { get; set; } diff --git a/src/RenderEngine/H.LowCode.RenderEngine.Application.Contracts/DataDTOs/FormDataDTO.cs b/src/Common/H.LowCode.Application.Contracts/Dtos/FormDataDto.cs similarity index 58% rename from src/RenderEngine/H.LowCode.RenderEngine.Application.Contracts/DataDTOs/FormDataDTO.cs rename to src/Common/H.LowCode.Application.Contracts/Dtos/FormDataDto.cs index 0e2e4683affabc51cfa10047a5e39a48e5b5c7f7..927e53c89009d477d06c006fa2d94d712e7aea03 100644 --- a/src/RenderEngine/H.LowCode.RenderEngine.Application.Contracts/DataDTOs/FormDataDTO.cs +++ b/src/Common/H.LowCode.Application.Contracts/Dtos/FormDataDto.cs @@ -1,22 +1,22 @@ -using H.LowCode.MetaSchema; +using H.LowCode.MetaSchema; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -namespace H.LowCode.RenderEngine.Application.Contracts; +namespace H.LowCode.Application.Contracts; -public class FormDataDTO : DataDTOBase +public class FormDataDto : DataDtoBase { public string Name { get; set; } - public IList Fields { get; set; } + public IList Fields { get; set; } public IList ValidationRules { get; set; } = []; } -public class FormFieldDTO +public class FormFieldDto { public string Name { get; set; } @@ -32,14 +32,21 @@ public class FormFieldDTO get { if (string.IsNullOrEmpty(TypeName)) - return new InvalidDataException($"TypeName is null or empty, field={this.ToJson()}"); + throw new InvalidDataException($"TypeName is null or empty, field={this.ToJson()}"); var type = Type.GetType(TypeName); if (type == null) throw new InvalidDataException($"Type '{TypeName}' not found, field={this.ToJson()}"); - var realValue = _value.ConvertToRealType(type); - return realValue; + try + { + var realValue = _value.ConvertToRealType(type); + return realValue; + } + catch (Exception ex) + { + throw new InvalidDataException($"Failed to convert value '{_value}' to type '{TypeName}', field={this.ToJson()}", ex); + } } set { diff --git a/src/Common/H.LowCode.Application.Contracts/Dtos/TableDataDeleteInput.cs b/src/Common/H.LowCode.Application.Contracts/Dtos/TableDataDeleteInput.cs new file mode 100644 index 0000000000000000000000000000000000000000..25b23402d41358039264ac0f627d2c7e516b756b --- /dev/null +++ b/src/Common/H.LowCode.Application.Contracts/Dtos/TableDataDeleteInput.cs @@ -0,0 +1,34 @@ +using System; + +namespace H.LowCode.Application.Contracts; + +/// +/// 表格数据删除请求参数 +/// +public class TableDataDeleteInput +{ + /// + /// 应用ID + /// + public string AppId { get; set; } + + /// + /// 页面ID + /// + public string PageId { get; set; } + + /// + /// 数据源ID + /// + public string DataSourceId { get; set; } + + /// + /// 要删除的记录ID + /// + public string Id { get; set; } + + /// + /// 要删除的记录数据(包含主键等信息) + /// + public Dictionary RowData { get; set; } +} \ No newline at end of file diff --git a/src/Common/H.LowCode.Application.Contracts/Dtos/TableDataInput.cs b/src/Common/H.LowCode.Application.Contracts/Dtos/TableDataInput.cs new file mode 100644 index 0000000000000000000000000000000000000000..0d826e138e1503b111c08916cb0024ff2db94f81 --- /dev/null +++ b/src/Common/H.LowCode.Application.Contracts/Dtos/TableDataInput.cs @@ -0,0 +1,30 @@ +using System; +using Volo.Abp.Application.Dtos; + +namespace H.LowCode.Application.Contracts; + +/// +/// 表格数据请求参数 +/// +public class TableDataInput : PagedAndSortedResultRequestDto +{ + /// + /// 应用ID + /// + public string AppId { get; set; } + + /// + /// 页面ID + /// + public string PageId { get; set; } + + /// + /// 数据源ID + /// + public string DataSourceId { get; set; } + + /// + /// 筛选条件 + /// + public Dictionary Filters { get; set; } +} \ No newline at end of file diff --git a/src/Common/H.LowCode.Application.Contracts/Dtos/TableDataUpdateInput.cs b/src/Common/H.LowCode.Application.Contracts/Dtos/TableDataUpdateInput.cs new file mode 100644 index 0000000000000000000000000000000000000000..96deba55c89661253ade49418e7b2894d27cb3d6 --- /dev/null +++ b/src/Common/H.LowCode.Application.Contracts/Dtos/TableDataUpdateInput.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; + +namespace H.LowCode.Application.Contracts; + +/// +/// 表格数据更新请求参数 +/// +public class TableDataUpdateInput +{ + /// + /// 应用ID + /// + public string AppId { get; set; } + + /// + /// 页面ID + /// + public string PageId { get; set; } + + /// + /// 数据源ID + /// + public string DataSourceId { get; set; } + + /// + /// 主键值 + /// + public string Id { get; set; } + + /// + /// 行数据 + /// + public Dictionary RowData { get; set; } + + /// + /// 更新的字段数据 + /// + public Dictionary UpdateData { get; set; } +} \ No newline at end of file diff --git a/src/Common/H.LowCode.Application.Contracts/H.LowCode.Application.Contracts.csproj b/src/Common/H.LowCode.Application.Contracts/H.LowCode.Application.Contracts.csproj new file mode 100644 index 0000000000000000000000000000000000000000..8e75a154a3de61e7377645b2a10bc6e3e9b6bfb2 --- /dev/null +++ b/src/Common/H.LowCode.Application.Contracts/H.LowCode.Application.Contracts.csproj @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/src/RenderEngine/H.LowCode.RenderEngine.Domain/DataDomainServices/TableDataDomainService.cs b/src/Common/H.LowCode.Application.Contracts/LowCodeApplicationContractsModule.cs similarity index 34% rename from src/RenderEngine/H.LowCode.RenderEngine.Domain/DataDomainServices/TableDataDomainService.cs rename to src/Common/H.LowCode.Application.Contracts/LowCodeApplicationContractsModule.cs index f7f94bfff0bbecce6dba030845e933a072d3418f..5773f734bc1417529c13e00afa105d18a0a781e0 100644 --- a/src/RenderEngine/H.LowCode.RenderEngine.Domain/DataDomainServices/TableDataDomainService.cs +++ b/src/Common/H.LowCode.Application.Contracts/LowCodeApplicationContractsModule.cs @@ -1,15 +1,17 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Reflection; using System.Text; using System.Threading.Tasks; -using Volo.Abp.Domain.Services; +using Volo.Abp.Modularity; +using Volo.Abp.Validation; -namespace H.LowCode.RenderEngine.Domain; +namespace H.LowCode.Application.Contracts; -public class TableDataDomainService : DomainService, ITableDataDomainService +public class LowCodeApplicationContractsModule : AbpModule { - public TableDataDomainService(ITableDataRepository tableDataRepository) + public override void ConfigureServices(ServiceConfigurationContext context) { } diff --git a/src/Common/H.LowCode.ComponentBase/ComponentBaseModule.cs b/src/Common/H.LowCode.ComponentBase/ComponentBaseModule.cs new file mode 100644 index 0000000000000000000000000000000000000000..e84537bc183710fa0bdc80f42b7377495d9a48a1 --- /dev/null +++ b/src/Common/H.LowCode.ComponentBase/ComponentBaseModule.cs @@ -0,0 +1,11 @@ +using Volo.Abp.Modularity; + +namespace H.LowCode.ComponentBase; + +public class ComponentBaseModule : AbpModule +{ + public override void ConfigureServices(ServiceConfigurationContext context) + { + // 基础组件模块配置 + } +} \ No newline at end of file diff --git a/src/Common/H.LowCode.ComponentBase/H.LowCode.ComponentBase.csproj b/src/Common/H.LowCode.ComponentBase/H.LowCode.ComponentBase.csproj index a1feb814f2d97a56229649b57bc4d9ca90e23698..c16f211d4ca461544b789493659b4276a419560c 100644 --- a/src/Common/H.LowCode.ComponentBase/H.LowCode.ComponentBase.csproj +++ b/src/Common/H.LowCode.ComponentBase/H.LowCode.ComponentBase.csproj @@ -1,6 +1,6 @@  - + @@ -8,12 +8,15 @@ - - + + + + + diff --git a/src/Common/H.LowCode.ComponentBase/LowCodeComponentBase.cs b/src/Common/H.LowCode.ComponentBase/LowCodeComponentBase.cs index efd56df02229ed5188a60597c7a9b2b12d1172d5..3fb0806e3cf2098430540debeebdd8498b74a889 100644 --- a/src/Common/H.LowCode.ComponentBase/LowCodeComponentBase.cs +++ b/src/Common/H.LowCode.ComponentBase/LowCodeComponentBase.cs @@ -1,6 +1,5 @@ using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.WebUtilities; -using System; using System.Diagnostics.CodeAnalysis; using Volo.Abp.AspNetCore.Components; @@ -15,7 +14,12 @@ public abstract class LowCodeComponentBase : AbpComponentBase private LowCodeAppState LowCodeAppState { get; set; } [Inject] - private NavigationManager NavigationManager { get; set; } + protected NavigationManager NavigationManager { get; set; } + + /// + /// 组件状态标识 (用于 ShouldRender 判断) + /// + protected string StateKey { get; set; } /// /// diff --git a/src/Common/H.LowCode.ComponentBase/LowCodeComponentBaseModule.cs b/src/Common/H.LowCode.ComponentBase/LowCodeComponentBaseModule.cs index 7111c897c4b28bb2a3d5c3079b4d2de527b69232..050786d572b07380bf80d555ead281fad5cd3065 100644 --- a/src/Common/H.LowCode.ComponentBase/LowCodeComponentBaseModule.cs +++ b/src/Common/H.LowCode.ComponentBase/LowCodeComponentBaseModule.cs @@ -1,11 +1,4 @@ -using H.Util.Blazor; -using Microsoft.Extensions.DependencyInjection; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Volo.Abp.Modularity; +using Volo.Abp.Modularity; namespace H.LowCode.ComponentBase; @@ -13,8 +6,6 @@ public class LowCodeComponentBaseModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) { - //状态管理 - context.Services.AddScoped(typeof(ComponentState<>)); - context.Services.AddScoped(typeof(ComponentState<,>)); + } } diff --git a/src/Common/H.LowCode.ComponentBase/LowCodeLayoutComponentBase.cs b/src/Common/H.LowCode.ComponentBase/LowCodeLayoutComponentBase.cs index 80d7f9a141fcb17821dfe1b861cd6fce8ddff394..8f392844a894edfa018db885c8c68c7dfffb6d77 100644 --- a/src/Common/H.LowCode.ComponentBase/LowCodeLayoutComponentBase.cs +++ b/src/Common/H.LowCode.ComponentBase/LowCodeLayoutComponentBase.cs @@ -1,9 +1,5 @@ using Microsoft.AspNetCore.Components; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace H.LowCode.ComponentBase; diff --git a/src/Common/H.LowCode.ComponentBase/LowCodePageComponentBase.cs b/src/Common/H.LowCode.ComponentBase/LowCodePageComponentBase.cs index 266b1cac2caadb2ddcc17c3999fb0ef7b98fc4f5..0a5839d3d5d2c79e5fa19df3dfc27662be4e178d 100644 --- a/src/Common/H.LowCode.ComponentBase/LowCodePageComponentBase.cs +++ b/src/Common/H.LowCode.ComponentBase/LowCodePageComponentBase.cs @@ -1,9 +1,5 @@ using Microsoft.AspNetCore.Components; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using Microsoft.Extensions.Logging; namespace H.LowCode.ComponentBase; @@ -12,6 +8,13 @@ namespace H.LowCode.ComponentBase; /// public abstract class LowCodePageComponentBase : LowCodeComponentBase { + protected override async Task OnInitializedAsync() + { + await base.OnInitializedAsync(); + + Logger.LogInformation($"渲染模式: {RendererInfo.Name}, path=/{NavigationManager.ToBaseRelativePath(NavigationManager.Uri)}"); + } + protected static T GetQueryValue(string name) { return default; diff --git a/src/Common/H.LowCode.Components.Defaults/Components/LcCard.razor b/src/Common/H.LowCode.Components.Defaults/Components/LcCard.razor index f879b1c271115bcc97ac93068749f509d7e6939b..49b67aedaeccfbdc0535a7b854d44ed7a13e1969 100644 --- a/src/Common/H.LowCode.Components.Defaults/Components/LcCard.razor +++ b/src/Common/H.LowCode.Components.Defaults/Components/LcCard.razor @@ -6,7 +6,7 @@ @* More *@ @* *@ @* *@ -@* { component.Style.DefaultStyle="min-height:90px; height:auto; background: #f4f7fa;";})"> *@ +@* { component.Style.DefaultStyle="min-height:90px; height:auto; background: #f4f7fa;";})"> *@ @* *@ @* *@ diff --git a/src/Common/H.LowCode.Components.Defaults/Components/LcFlex.razor b/src/Common/H.LowCode.Components.Defaults/Components/LcFlex.razor index 370b4c5d8b5f0eb8108351e0bf8259bb60507ac1..9988233dfc58b4582490371f41a8784ebe72fece 100644 --- a/src/Common/H.LowCode.Components.Defaults/Components/LcFlex.razor +++ b/src/Common/H.LowCode.Components.Defaults/Components/LcFlex.razor @@ -2,7 +2,7 @@ @* @inherits LowCodeComponentBase *@ @* *@ -@* *@ +@* *@ @* *@ @* @code { *@ diff --git a/src/Common/H.LowCode.Components.Defaults/Components/LcGrid.razor b/src/Common/H.LowCode.Components.Defaults/Components/LcGrid.razor index 0437cdfaa1d3dbd991dd62a498fbaf09905b8e7e..24e4592dfe0c2dbe2905c41cb0c41ecd13c819cd 100644 --- a/src/Common/H.LowCode.Components.Defaults/Components/LcGrid.razor +++ b/src/Common/H.LowCode.Components.Defaults/Components/LcGrid.razor @@ -10,7 +10,7 @@ @* { *@ @* string key = $"gridcontainer-{rr}-{c}"; *@ @* *@ -@* *@ +@* *@ @* *@ @* } *@ @* *@ diff --git a/src/Common/H.LowCode.Components.Defaults/Components/LcTable.razor b/src/Common/H.LowCode.Components.Defaults/Components/LcTable.razor index 2db38b9381655201ebc6b8bb77ac80f6a27f3e2b..24ad89a2deab9b5dc1b250a6625d83394cb8c1e5 100644 --- a/src/Common/H.LowCode.Components.Defaults/Components/LcTable.razor +++ b/src/Common/H.LowCode.Components.Defaults/Components/LcTable.razor @@ -1,20 +1,16 @@ -@namespace H.LowCode.Components.Defaults +@namespace H.LowCode.Components.Defaults @inherits LowCodeComponentBase @inject IJSRuntime JS +@inject ITableDataAppService TableDataAppService - @if(_tableSchema.Buttons.Count == 0) + @foreach (var topBtn in _tableSchema.TopButtons) { - - - } - @foreach (var btn in _tableSchema.Buttons) - { - + } @@ -25,19 +21,37 @@ var column = _tableSchema.Columns.FirstOrDefault(t => string.Equals(t.Name, key, StringComparison.OrdinalIgnoreCase)); if (column != null) { - + + @{ + var primaryKeyColumn = _tableSchema.Columns.FirstOrDefault(t => t.IsPrimaryKey); + var primaryKeyValue = primaryKeyColumn != null && row.ContainsKey(primaryKeyColumn.Name) + ? row[primaryKeyColumn.Name]?.ToString() : null; + var isEditing = !string.IsNullOrEmpty(primaryKeyValue) && _editingRows.ContainsKey(primaryKeyValue); + } + @if (isEditing && !column.IsPrimaryKey) + { + + } + else + { + @row[key] + } + } } - - - - 编辑 - - - 删除 - - - + @if (_tableSchema.RowButtons != null && _tableSchema.RowButtons.Any()) + { + + + @foreach (var rowBtn in _tableSchema.RowButtons) + { + + @rowBtn.Title + + } + + + }
@@ -45,6 +59,9 @@ [Parameter] public ComponentDataSourceSchemaBase DataSource { get; set; } + [CascadingParameter(Name = "pageCascading")] + public PageCascadingModel PageCascading { get; set; } + private TablePropertySchema _tableSchema = new(); private List> _data; @@ -55,17 +72,42 @@ int _pageSize = 10; int _total = 0; + // 编辑状态管理 + private Dictionary> _editingRows = new(); + private Dictionary> _originalRows = new(); + protected override async Task OnInitializedAsync() + { + await base.OnInitializedAsync(); + + Init(); + await LoadDataAsync(); + } + + protected override bool ShouldRender() + { + //if (StateKey == DataSource.StateKey) + // return false; + + Init(); + return true; + } + + private void Init() { _tableSchema = GetTableSchemaAsync(); - _data = await GetTableDataAsync(1, 50); - _total = 50; + StateKey = DataSource.StateKey; } public async Task OnChange(QueryModel> queryModel) { - await Task.Delay(1); - Console.WriteLine(queryModel.ToJson()); + _pageIndex = queryModel.PageIndex; + _pageSize = queryModel.PageSize; + + // 重新加载数据 + await LoadDataAsync(); + + StateHasChanged(); } private TablePropertySchema GetTableSchemaAsync() @@ -73,68 +115,443 @@ var dataSource = DataSource?.DataSourceValue; if (dataSource.IsNullOrWhiteSpace() || dataSource.Trim().Equals("[]")) { - var tableSchema = new TablePropertySchema(); + var defaultTableSchema = new TablePropertySchema(); + defaultTableSchema.Columns = new List() + { + new() { Name = "_temp", Title = "(待添加列)" } + }; + return defaultTableSchema; + } + + var tableSchema = dataSource.FromJson(); + if(tableSchema.Columns.Any() == false) + { tableSchema.Columns = new List() { new() { Name = "_temp", Title = "(待添加列)" } }; - return tableSchema; } - return dataSource.FromJson(); + Logger.LogWarning($"列表列头: {tableSchema.Columns.ToJson()}"); + + return tableSchema; + } + + private async Task LoadDataAsync() + { + var request = new TableDataInput + { + AppId = PageCascading?.AppId, + PageId = PageCascading?.PageId, + DataSourceId = DataSource?.DataSourceId, + SkipCount = (_pageIndex - 1) * _pageSize, + MaxResultCount = _pageSize, + Filters = new Dictionary() + }; + + try + { + var result = await TableDataAppService.GetListAsync(request); + _data = result.Items.ToList(); + _total = (int)result.TotalCount; + } + catch (Exception ex) + { + // 出错时使用空数据 + _data = new List>(); + _total = 0; + } } - public async Task>> GetTableDataAsync(int pageIndex, int pageSize) + public async Task ButtonActionAsync(TableButtonSchema btn, Dictionary rowData = null) { - await Task.Delay(100); - var list = new List>(); - for (int i = 0; i < 3; i++) + foreach(var e in btn.Events) { - Dictionary row = new Dictionary(); - foreach (var col in _tableSchema.Columns) + if (e.EventHandlerType == EventTargetTypeEnum.None) + continue; + + if (e.EventHandlerType == EventTargetTypeEnum.Page) + { + if (string.IsNullOrEmpty(e.EventTargetId)) + continue; + + if (string.IsNullOrEmpty(e.EventTargetAction)) + continue; + + var pageHandler = e.EventTargetAction.ToEnum(); + switch (pageHandler) + { + case EventPageHandlerTypeEnum.Refresh: + + break; + case EventPageHandlerTypeEnum.Modal: + await ButtonActionToWithModalAsync(e, rowData); + break; + case EventPageHandlerTypeEnum.Self: + await ButtonActionToWithSelfAsync(e, rowData); + break; + case EventPageHandlerTypeEnum.Blank: + await ButtonActionToWithBlankAsync(e, rowData); + break; + default: + break; + } + } + else if (e.EventHandlerType == EventTargetTypeEnum.Custom) { - row.Add(col.Name, string.Empty); + if (e.EventCustomLanguage == EventCustomLanguageEnum.None + || string.IsNullOrEmpty(e.EventCustomScript)) + continue; + + await JS.InvokeVoidAsync("eval", e.EventCustomScript); + } + else if (e.EventHandlerType == EventTargetTypeEnum.Data) + { + await HandleDataActionAsync(e.EventDataActionType, rowData); } - list.Add(row); } - return list; } - public async Task CreateAsync() + private async Task ButtonActionToWithModalAsync(EventSchema e, Dictionary rowData = null) { - await Task.Delay(100); + } - public async Task EditAsync(Dictionary row) + private async Task ButtonActionToWithSelfAsync(EventSchema e, Dictionary rowData = null) { - string primaryKey = _tableSchema.Columns.FirstOrDefault(t => t.IsPrimaryKey)?.Name; - await Task.Delay(100); + + } + + private async Task ButtonActionToWithBlankAsync(EventSchema e, Dictionary rowData = null) + { + string pageUrl = string.Empty; + if (IsDesign) + pageUrl = $"/designer/{PageCascading.AppId}/{e.EventTargetId}"; + else + pageUrl = $"/{PageCascading.AppId}/{e.EventTargetId}"; + + // 添加URL参数 + pageUrl = BuildUrlWithParameters(pageUrl, e, rowData); + + await JS.InvokeVoidAsync("open", pageUrl, "_blank"); } - private async Task DeleteAsync(Dictionary row) + private string BuildUrlWithParameters(string baseUrl, EventSchema eventSchema, Dictionary rowData) { - await Task.Delay(100); + var parameters = new List(); + + // 添加事件配置中的参数 + if (eventSchema.EventArgs != null && eventSchema.EventArgs.Any()) + { + foreach (var arg in eventSchema.EventArgs) + { + parameters.Add($"{arg.Key}={Uri.EscapeDataString(arg.Value?.ToString() ?? "")}"); + } + } + + // 添加行数据参数(根据配置映射) + if (rowData != null && rowData.Any() && eventSchema.RowDataParams != null && eventSchema.RowDataParams.Any()) + { + foreach (var paramMapping in eventSchema.RowDataParams) + { + var urlParamName = paramMapping.Key; + var rowFieldName = paramMapping.Value; + + // 检查行数据中是否包含指定字段 + if (rowData.ContainsKey(rowFieldName)) + { + // 避免与EventArgs中的参数重复 + if (eventSchema.EventArgs == null || !eventSchema.EventArgs.ContainsKey(urlParamName)) + { + parameters.Add($"{urlParamName}={Uri.EscapeDataString(rowData[rowFieldName]?.ToString() ?? "")}"); + } + } + } + } + + if (parameters.Any()) + { + var separator = baseUrl.Contains("?") ? "&" : "?"; + return $"{baseUrl}{separator}{string.Join("&", parameters)}"; + } + + return baseUrl; } - public async Task DeleteSelectedAsync() + private async Task HandleDataActionAsync(EventDataActionTypeEnum actionType, Dictionary rowData) { - await Task.Delay(100); + switch (actionType) + { + case EventDataActionTypeEnum.EditRow: + await EditRowAsync(rowData); + break; + case EventDataActionTypeEnum.DeleteRow: + await DeleteRowAsync(rowData); + break; + case EventDataActionTypeEnum.SaveRow: + await SaveRowAsync(rowData); + break; + case EventDataActionTypeEnum.CancelEdit: + await CancelEditAsync(rowData); + break; + case EventDataActionTypeEnum.AddRow: + await AddRowAsync(); + break; + case EventDataActionTypeEnum.RefreshData: + await RefreshDataAsync(); + break; + default: + break; + } } - public async Task ButtonActionAsync(string id) + private async Task EditRowAsync(Dictionary rowData) { - await Task.Delay(100); - var btn = _tableSchema.Buttons.First(t => t.Id == id); - if (btn.ActionType == ActionTypeEnum.Blank) + try + { + // 获取主键字段 + var primaryKeyColumn = _tableSchema.Columns.FirstOrDefault(t => t.IsPrimaryKey); + if (primaryKeyColumn == null) + { + Logger.LogWarning("编辑失败: 未找到主键字段"); + return; + } + + // 获取主键值 + if (!rowData.ContainsKey(primaryKeyColumn.Name)) + { + Logger.LogWarning($"编辑失败: 行数据中未找到主键字段 {primaryKeyColumn.Name}"); + return; + } + + var primaryKeyValue = rowData[primaryKeyColumn.Name]?.ToString(); + if (string.IsNullOrEmpty(primaryKeyValue)) + { + Logger.LogWarning("编辑失败: 主键值为空"); + return; + } + + // 如果已经在编辑状态,则不重复进入编辑 + if (_editingRows.ContainsKey(primaryKeyValue)) + { + return; + } + + // 保存原始数据副本 + _originalRows[primaryKeyValue] = new Dictionary(rowData); + + // 创建编辑数据副本 + _editingRows[primaryKeyValue] = new Dictionary(rowData); + + StateHasChanged(); + } + catch (Exception ex) { - string pageUrl = string.Empty; - if (IsDesign) - pageUrl = $"/designer/caseapp/{btn.TargetId}"; - else - pageUrl = $"/caseapp/{btn.TargetId}"; + Logger.LogWarning($"编辑行失败: {ex.Message}"); + } - await JS.InvokeVoidAsync("open", pageUrl, "_blank"); - // await this.RedirectPageAsync(pageUrl); + await Task.CompletedTask; + } + + private async Task DeleteRowAsync(Dictionary row) + { + try + { + // 获取主键字段 + var primaryKeyColumn = _tableSchema.Columns.FirstOrDefault(t => t.IsPrimaryKey); + if (primaryKeyColumn == null) + { + Logger.LogWarning("删除失败: 未找到主键字段"); + return; + } + + // 获取主键值 + if (!row.ContainsKey(primaryKeyColumn.Name)) + { + Logger.LogWarning($"删除失败: 行数据中未找到主键字段 {primaryKeyColumn.Name}"); + return; + } + + var primaryKeyValue = row[primaryKeyColumn.Name]?.ToString(); + if (string.IsNullOrEmpty(primaryKeyValue)) + { + Logger.LogWarning("删除失败: 主键值为空"); + return; + } + + // 构建删除请求 + var deleteRequest = new TableDataDeleteInput + { + AppId = PageCascading?.AppId, + PageId = PageCascading?.PageId, + DataSourceId = DataSource?.DataSourceId, + Id = primaryKeyValue, + RowData = row + }; + + // 调用删除服务 + await TableDataAppService.DeleteAsync(deleteRequest); + + // 删除成功后重新加载数据 + await LoadDataAsync(); + } + catch (Exception ex) + { + Logger.LogWarning($"删除失败: {ex.Message}"); + } + } + + private async Task SaveRowAsync(Dictionary rowData) + { + try + { + // 获取主键字段 + var primaryKeyColumn = _tableSchema.Columns.FirstOrDefault(t => t.IsPrimaryKey); + if (primaryKeyColumn == null) + { + Logger.LogWarning("保存失败: 未找到主键字段"); + return; + } + + // 获取主键值 + if (!rowData.ContainsKey(primaryKeyColumn.Name)) + { + Logger.LogWarning($"保存失败: 行数据中未找到主键字段 {primaryKeyColumn.Name}"); + return; + } + + var primaryKeyValue = rowData[primaryKeyColumn.Name]?.ToString(); + if (string.IsNullOrEmpty(primaryKeyValue)) + { + Logger.LogWarning("保存失败: 主键值为空"); + return; + } + + // 检查是否在编辑状态 + if (!_editingRows.ContainsKey(primaryKeyValue)) + { + Logger.LogWarning("保存失败: 该行不在编辑状态"); + return; + } + + var editingData = _editingRows[primaryKeyValue]; + var originalData = _originalRows[primaryKeyValue]; + + // 找出变更的字段 + var updateData = new Dictionary(); + foreach (var kvp in editingData) + { + if (!originalData.ContainsKey(kvp.Key) || + !Equals(originalData[kvp.Key], kvp.Value)) + { + updateData[kvp.Key] = kvp.Value; + } + } + + // 如果有变更,则调用更新服务 + if (updateData.Any()) + { + var updateRequest = new TableDataUpdateInput + { + AppId = PageCascading?.AppId, + PageId = PageCascading?.PageId, + DataSourceId = DataSource?.DataSourceId, + Id = primaryKeyValue, + RowData = originalData, + UpdateData = updateData + }; + + await TableDataAppService.UpdateAsync(updateRequest); + + // 更新本地数据 + var dataIndex = _data.FindIndex(d => d.ContainsKey(primaryKeyColumn.Name) && + d[primaryKeyColumn.Name]?.ToString() == primaryKeyValue); + if (dataIndex >= 0) + { + _data[dataIndex] = new Dictionary(editingData); + } + } + + // 退出编辑状态 + _editingRows.Remove(primaryKeyValue); + _originalRows.Remove(primaryKeyValue); + + StateHasChanged(); + } + catch (Exception ex) + { + Logger.LogWarning($"保存行失败: {ex.Message}"); + } + } + + private async Task CancelEditAsync(Dictionary rowData) + { + try + { + // 获取主键字段 + var primaryKeyColumn = _tableSchema.Columns.FirstOrDefault(t => t.IsPrimaryKey); + if (primaryKeyColumn == null) + { + Logger.LogWarning("取消编辑失败: 未找到主键字段"); + return; + } + + // 获取主键值 + if (!rowData.ContainsKey(primaryKeyColumn.Name)) + { + Logger.LogWarning($"取消编辑失败: 行数据中未找到主键字段 {primaryKeyColumn.Name}"); + return; + } + + var primaryKeyValue = rowData[primaryKeyColumn.Name]?.ToString(); + if (string.IsNullOrEmpty(primaryKeyValue)) + { + Logger.LogWarning("取消编辑失败: 主键值为空"); + return; + } + + // 检查是否在编辑状态 + if (!_editingRows.ContainsKey(primaryKeyValue)) + { + Logger.LogWarning("取消编辑失败: 该行不在编辑状态"); + return; + } + + // 清除编辑状态 + _editingRows.Remove(primaryKeyValue); + _originalRows.Remove(primaryKeyValue); + + StateHasChanged(); + } + catch (Exception ex) + { + Logger.LogWarning($"取消编辑失败: {ex.Message}"); + } + + await Task.CompletedTask; + } + + private async Task AddRowAsync() + { + // TODO: 实现添加行功能 + } + + private async Task RefreshDataAsync() + { + try + { + // 清除所有编辑状态 + _editingRows.Clear(); + _originalRows.Clear(); + + // 重新加载数据 + await LoadDataAsync(); + + StateHasChanged(); + } + catch (Exception ex) + { + Logger.LogWarning($"刷新数据失败: {ex.Message}"); } } } diff --git a/src/Common/H.LowCode.Components.Defaults/Components/LcTabs.razor b/src/Common/H.LowCode.Components.Defaults/Components/LcTabs.razor index 830ed95e70c4c0311cc79e25d4a0a3fe5071ba63..60ec08c645578420f937a46030ecd6e3c4e3af98 100644 --- a/src/Common/H.LowCode.Components.Defaults/Components/LcTabs.razor +++ b/src/Common/H.LowCode.Components.Defaults/Components/LcTabs.razor @@ -6,7 +6,7 @@ @* { *@ @* string key = $"tab-{i}"; *@ @* *@ -@* *@ +@* *@ @* *@ @* } *@ @* *@ diff --git a/src/Common/H.LowCode.Components.Defaults/H.LowCode.Components.Defaults.csproj b/src/Common/H.LowCode.Components.Defaults/H.LowCode.Components.Defaults.csproj index 8657411c861c52726adb53d2b4bc1581269398a5..e7c10c8dfbcd9e6b2c0962341ce1aaced3733520 100644 --- a/src/Common/H.LowCode.Components.Defaults/H.LowCode.Components.Defaults.csproj +++ b/src/Common/H.LowCode.Components.Defaults/H.LowCode.Components.Defaults.csproj @@ -1,6 +1,6 @@  - + @@ -8,13 +8,19 @@ - + + + + + + + diff --git a/src/Common/H.LowCode.Components.Defaults/LowCodeDefaultComponentModule.cs b/src/Common/H.LowCode.Components.Defaults/LowCodeDefaultComponentModule.cs index 9ad9668494d1907d269b90f3cd1d26d60aa67f12..0b660ff0be5519c909d3f57f7e22f1633e09c07d 100644 --- a/src/Common/H.LowCode.Components.Defaults/LowCodeDefaultComponentModule.cs +++ b/src/Common/H.LowCode.Components.Defaults/LowCodeDefaultComponentModule.cs @@ -1,8 +1,10 @@ -using Microsoft.Extensions.DependencyInjection; +using H.LowCode.ComponentBase; +using Microsoft.Extensions.DependencyInjection; using Volo.Abp.Modularity; namespace H.LowCode.Components.Defaults; +[DependsOn(typeof(ComponentBaseModule))] public class LowCodeDefaultComponentModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) diff --git a/src/Common/H.LowCode.Components.Defaults/_Imports.razor b/src/Common/H.LowCode.Components.Defaults/_Imports.razor index 64b7a668ef7b2ece90de2b8a5eb365051b36393f..79bf098f2e81f58c0a6945c154a144ab4de8b95d 100644 --- a/src/Common/H.LowCode.Components.Defaults/_Imports.razor +++ b/src/Common/H.LowCode.Components.Defaults/_Imports.razor @@ -1,10 +1,12 @@ @using System @using System.ComponentModel.DataAnnotations +@using Microsoft.Extensions.Logging @using System.Text.Json @using Microsoft.AspNetCore.Components.Web @using Microsoft.JSInterop @using AntDesign @using AntDesign.TableModels +@using H.LowCode.Application.Contracts @using H.LowCode.ComponentBase @using H.LowCode.MetaSchema @using H.Util.Blazor \ No newline at end of file diff --git a/src/Common/H.LowCode.Configuration/H.LowCode.Configuration.csproj b/src/Common/H.LowCode.Configuration/H.LowCode.Configuration.csproj index e9d821c821b63ae259be7b984b4073911a7d267f..8cad3c7dcd92b3cadff820b495362028246352eb 100644 --- a/src/Common/H.LowCode.Configuration/H.LowCode.Configuration.csproj +++ b/src/Common/H.LowCode.Configuration/H.LowCode.Configuration.csproj @@ -1,5 +1,5 @@  - + diff --git a/src/Common/H.LowCode.Entity/Extensions/ReflectionExtensions.cs b/src/Common/H.LowCode.Entity/Extensions/ReflectionExtensions.cs index 7627877fb2038ddb87677817f341f522db65c68e..0324af1364d046bc5ef60c2407854e6eb46f557f 100644 --- a/src/Common/H.LowCode.Entity/Extensions/ReflectionExtensions.cs +++ b/src/Common/H.LowCode.Entity/Extensions/ReflectionExtensions.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Reflection; diff --git a/src/Common/H.LowCode.Entity/H.LowCode.Entity.csproj b/src/Common/H.LowCode.Entity/H.LowCode.Entity.csproj index 0d6052fec2781ed3c901a3fd478c9a025011360b..1ff73c734ce6a998d81374cb48ce336c55e76b3c 100644 --- a/src/Common/H.LowCode.Entity/H.LowCode.Entity.csproj +++ b/src/Common/H.LowCode.Entity/H.LowCode.Entity.csproj @@ -1,10 +1,10 @@  - + - - + + diff --git a/src/Common/H.LowCode.MetaSchema.DesignEngine/ComponentPartsSchema.cs b/src/Common/H.LowCode.MetaSchema.DesignEngine/ComponentPartsSchema.cs index a371b8a4d126290804dabb73d82b69bac85f4ae8..b9159b30d3c166e4fdc553f0535ce5a2041e0b2c 100644 --- a/src/Common/H.LowCode.MetaSchema.DesignEngine/ComponentPartsSchema.cs +++ b/src/Common/H.LowCode.MetaSchema.DesignEngine/ComponentPartsSchema.cs @@ -1,4 +1,4 @@ -using H.Util.Ids; +using H.Util.Ids; using System.Text.Json.Serialization; namespace H.LowCode.MetaSchema.DesignEngine; @@ -6,23 +6,24 @@ namespace H.LowCode.MetaSchema.DesignEngine; public class ComponentPartsSchema : ComponentSchemaBase { /// - /// 组件物料Id + /// 组件库Id /// - /// 一类组件唯一Id - [JsonPropertyName("compid")] - public string ComponentId { get; set; } = ShortIdGenerator.Generate(); + [JsonPropertyName("libid")] + public string? LibraryId { get; set; } /// - /// 组件库Id + /// 组件物料Id /// - [JsonPropertyName("libid")] - public string LibraryId { get; set; } + /// 一类组件唯一Id + [JsonPropertyName("compid")] + public required string ComponentId { get; set; } /// - /// 组件 Name + /// 组件物料Name /// + /// 一类组件唯一Name [JsonPropertyName("cn")] - public string ComponentName { get; set; } + public string? ComponentName { get; set; } /// /// 组件类型:1-原子组件 2-组合组件 @@ -34,10 +35,10 @@ public class ComponentPartsSchema : ComponentSchemaBase /// 组件渲染 Fragment /// [JsonPropertyName("frag")] - public ComponentPartsFragmentSchema Fragment { get; set; } + public ComponentPartsFragmentSchema? Fragment { get; set; } [JsonPropertyName("ds")] - public ComponentPartsDataSourceSchema DataSource { get; set; } = new(); + public ComponentPartsDataSourceSchema? DataSource { get; set; } = new(); /// /// Attribute定义分组 @@ -51,6 +52,24 @@ public class ComponentPartsSchema : ComponentSchemaBase [JsonPropertyName("childs")] public IList Childrens { get; set; } = []; + /// + /// 组件支持的事件 + /// + [JsonPropertyName("sptevs")] + public string[]? SupportEvents { get; set; } + + /// + /// 事件定义 + /// + [JsonPropertyName("evdefs")] + public List EventDefines { get; set; } = []; + + /// + /// 样式定义 + /// + [JsonPropertyName("stydefs")] + public List StyleDefines { get; set; } = []; + [JsonPropertyName("order")] public int Order { get; set; } @@ -71,7 +90,7 @@ public class ComponentPartsSchema : ComponentSchemaBase public ComponentDesignStateSchema DesignState { get; set; } = new(); [JsonIgnore] - public Action Refresh { get; set; } + public Action? Refresh { get; set; } public void RefreshState() { @@ -132,9 +151,10 @@ public class ComponentPartsSchema : ComponentSchemaBase return; } - //TODO + //基础属性合并 //this.Fragment = componentPartsDefine.Fragment; //this.Style = componentPartsDefine.Style; + this.SupportEvents = componentPartsDefine.SupportEvents; //属性合并 if (componentPartsDefine.AttributeDefineGroups != null) diff --git a/src/Common/H.LowCode.MetaSchema.DesignEngine/DataSourceSchemas/ComponentPartsDataSourceSchema.cs b/src/Common/H.LowCode.MetaSchema.DesignEngine/DataSourceSchemas/ComponentPartsDataSourceSchema.cs index 6eb61a3373db89ea19fb9a27abf97e44f6ea6d33..031a452ef2ea96ad57e0896867c36a44b91d3980 100644 --- a/src/Common/H.LowCode.MetaSchema.DesignEngine/DataSourceSchemas/ComponentPartsDataSourceSchema.cs +++ b/src/Common/H.LowCode.MetaSchema.DesignEngine/DataSourceSchemas/ComponentPartsDataSourceSchema.cs @@ -12,5 +12,5 @@ public class ComponentPartsDataSourceSchema : ComponentDataSourceSchemaBase /// DataSource 渲染的 Fragment /// [JsonPropertyName("dsfrag")] - public ComponentPartsFragmentSchema DataSourceFragment { get; set; } + public ComponentPartsFragmentSchema? DataSourceFragment { get; set; } } diff --git a/src/Common/H.LowCode.MetaSchema.DesignEngine/H.LowCode.MetaSchema.DesignEngine.csproj b/src/Common/H.LowCode.MetaSchema.DesignEngine/H.LowCode.MetaSchema.DesignEngine.csproj index cc6688333b98f940c74f271c4c533718f52ffbb7..a40d73f271cbc80e509d3d2eb81fc508a08ccf43 100644 --- a/src/Common/H.LowCode.MetaSchema.DesignEngine/H.LowCode.MetaSchema.DesignEngine.csproj +++ b/src/Common/H.LowCode.MetaSchema.DesignEngine/H.LowCode.MetaSchema.DesignEngine.csproj @@ -1,6 +1,6 @@  - + diff --git a/src/Common/H.LowCode.MetaSchema.DesignEngine/PagePartsSchema.cs b/src/Common/H.LowCode.MetaSchema.DesignEngine/PagePartsSchema.cs index 8cb99897fc9f4741f03687504fdfa2107d1d4e3a..c945df367e6db9871033538cf3cffedbc71c8ddd 100644 --- a/src/Common/H.LowCode.MetaSchema.DesignEngine/PagePartsSchema.cs +++ b/src/Common/H.LowCode.MetaSchema.DesignEngine/PagePartsSchema.cs @@ -7,4 +7,10 @@ public class PagePartsSchema : PageSchemaBase { [JsonPropertyName("comps")] public IList Components { get; set; } = []; + + /// + /// 组件支持的事件 + /// + [JsonPropertyName("sptevs")] + public string[] SupportEvents { get; } = ["OnLoad"]; } diff --git a/src/Common/H.LowCode.MetaSchema.DesignEngine/PropertySchemas/ComponentDesignStateSchema.cs b/src/Common/H.LowCode.MetaSchema.DesignEngine/PropertySchemas/ComponentDesignStateSchema.cs index 94ccf023d49a27ea9c1e03b5c6fc9e0e81da162c..7205583cc4ab866766865f016de8e84877604fa9 100644 --- a/src/Common/H.LowCode.MetaSchema.DesignEngine/PropertySchemas/ComponentDesignStateSchema.cs +++ b/src/Common/H.LowCode.MetaSchema.DesignEngine/PropertySchemas/ComponentDesignStateSchema.cs @@ -1,9 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System; using System.Text.Json.Serialization; -using System.Threading.Tasks; namespace H.LowCode.MetaSchema.DesignEngine; @@ -17,10 +13,7 @@ public class ComponentDesignStateSchema public bool IsSelected { get; set; } [JsonIgnore] - public double Opacity { get; set; } = 1; - - [JsonIgnore] - public string DragEffectStyle { get; set; } + public string? DragEffectStyle { get; set; } /// /// 是否由组件面板拖拽而来 @@ -29,8 +22,14 @@ public class ComponentDesignStateSchema public bool IsDroppedFromComponentPanel { get; set; } /// - /// 拖拽到后面(true:后面 false:前面) + /// 动画变换样式(用于平滑让位动画) + /// + [JsonIgnore] + public string AnimationTransform { get; set; } = string.Empty; + + /// + /// 是否正在进行让位动画 /// [JsonIgnore] - public bool IsDropedAfter { get; set; } -} + public bool IsAnimating { get; set; } +} \ No newline at end of file diff --git a/src/Common/H.LowCode.MetaSchema.DesignEngine/PropertySchemas/ComponentPartsAttributeDefineGroupSchema.cs b/src/Common/H.LowCode.MetaSchema.DesignEngine/PropertySchemas/ComponentPartsAttributeDefineGroupSchema.cs index 9f4e8ccee81d788f9e2bc85ff66314caa32bd97f..9e7c965d95e4068239d5a1a6126d478c2c6f065a 100644 --- a/src/Common/H.LowCode.MetaSchema.DesignEngine/PropertySchemas/ComponentPartsAttributeDefineGroupSchema.cs +++ b/src/Common/H.LowCode.MetaSchema.DesignEngine/PropertySchemas/ComponentPartsAttributeDefineGroupSchema.cs @@ -11,7 +11,7 @@ namespace H.LowCode.MetaSchema.DesignEngine; public class ComponentPartsAttributeDefineGroupSchema { [JsonPropertyName("gn")] - public string GroupName { get; set; } + public string? GroupName { get; set; } [JsonPropertyName("attrdefs")] public ComponentPartsAttributeDefineSchema[] AttributeDefines { get; set; } = []; diff --git a/src/Common/H.LowCode.MetaSchema.DesignEngine/PropertySchemas/ComponentPartsAttributeDefineSchema.cs b/src/Common/H.LowCode.MetaSchema.DesignEngine/PropertySchemas/ComponentPartsAttributeDefineSchema.cs index 5bc8da307ffdb3243ae0f91658e074effd85720b..76f230e0fe53fa29cd9e7d13450b43c206c6d393 100644 --- a/src/Common/H.LowCode.MetaSchema.DesignEngine/PropertySchemas/ComponentPartsAttributeDefineSchema.cs +++ b/src/Common/H.LowCode.MetaSchema.DesignEngine/PropertySchemas/ComponentPartsAttributeDefineSchema.cs @@ -1,18 +1,11 @@ -using H.LowCode.MetaSchema; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json; using System.Text.Json.Serialization; -using System.Threading.Tasks; namespace H.LowCode.MetaSchema.DesignEngine; public class ComponentPartsAttributeDefineSchema : ComponentAttributeDefineSchemaBase { [JsonPropertyName("disn")] - public string DisplayName { get; set; } + public string? DisplayName { get; set; } /// /// 设置项类型 (用于判断设置项控件渲染) @@ -24,19 +17,34 @@ public class ComponentPartsAttributeDefineSchema : ComponentAttributeDefineSchem public bool IsRequired { get; set; } [JsonPropertyName("desc")] - public string Description { get; set; } + public string? Description { get; set; } [JsonPropertyName("dftval")] - public object DefaultValue { get; set; } + public object? DefaultValue { get; set; } [JsonPropertyName("ops")] - public Dictionary Options { get; set; } + public Dictionary? Options { get; set; } + + /// + /// 是否启用校验 + /// + [JsonPropertyName("enableval")] + public bool IsValidationEnabled { get; set; } + + /// + /// 校验规则 + /// + [JsonPropertyName("valrules")] + public IList? ValidationRules { get; set; } [JsonIgnore] - public string StringValue + public string? StringValue { get { + if (AttributeValue == null) + return null; + return AttributeValue.ConvertToRealType(typeof(string))?.ToString(); } set @@ -53,7 +61,14 @@ public class ComponentPartsAttributeDefineSchema : ComponentAttributeDefineSchem { get { - return (int)AttributeValue.ConvertToRealType(typeof(int)); + if (AttributeValue == null) + return 0; + + var val = AttributeValue.ConvertToRealType(typeof(int)); + if (val == null) + return 0; + + return (int)val; } set { @@ -66,7 +81,14 @@ public class ComponentPartsAttributeDefineSchema : ComponentAttributeDefineSchem { get { - return (bool)AttributeValue.ConvertToRealType(typeof(bool)); + if (AttributeValue == null) + return false; + + var val = AttributeValue.ConvertToRealType(typeof(bool)); + if(val == null) + return false; + + return (bool)val; } set { diff --git a/src/Common/H.LowCode.MetaSchema.DesignEngine/PropertySchemas/ComponentPartsEventDefineSchema.cs b/src/Common/H.LowCode.MetaSchema.DesignEngine/PropertySchemas/ComponentPartsEventDefineSchema.cs new file mode 100644 index 0000000000000000000000000000000000000000..70f3bcd6890e46d55fab88ce8d3a4cae8295d7da --- /dev/null +++ b/src/Common/H.LowCode.MetaSchema.DesignEngine/PropertySchemas/ComponentPartsEventDefineSchema.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json.Serialization; +using System.Threading.Tasks; + +namespace H.LowCode.MetaSchema.DesignEngine; + +public class ComponentPartsEventDefineSchema +{ + /// + /// 事件名称 + /// + [JsonPropertyName("name")] + public string Name { get; set; } + + /// + /// 事件名称 + /// + [JsonPropertyName("en")] + public string EventName { get; set; } + + /// + /// 事件显示名称 + /// + [JsonPropertyName("disn")] + public string DisplayName { get; set; } + + /// + /// 事件描述 + /// + [JsonPropertyName("desc")] + public string Description { get; set; } + + /// + /// 事件分组 + /// + [JsonPropertyName("group")] + public string Group { get; set; } + + /// + /// 事件类型 + /// + [JsonPropertyName("et")] + public string EventType { get; set; } + + /// + /// 事件参数类型 + /// + [JsonPropertyName("pt")] + public string ParameterType { get; set; } + + /// + /// 是否必需 + /// + [JsonPropertyName("required")] + public bool IsRequired { get; set; } + + /// + /// 排序 + /// + [JsonPropertyName("order")] + public int Order { get; set; } +} \ No newline at end of file diff --git a/src/Common/H.LowCode.MetaSchema.DesignEngine/PropertySchemas/ComponentPartsFragmentSchema.cs b/src/Common/H.LowCode.MetaSchema.DesignEngine/PropertySchemas/ComponentPartsFragmentSchema.cs index 932539eed877b4244ff312dde6c10b41623fa1cb..e16c098ba07b8569ccee4430179c5be82f1a70f6 100644 --- a/src/Common/H.LowCode.MetaSchema.DesignEngine/PropertySchemas/ComponentPartsFragmentSchema.cs +++ b/src/Common/H.LowCode.MetaSchema.DesignEngine/PropertySchemas/ComponentPartsFragmentSchema.cs @@ -11,7 +11,7 @@ public class ComponentPartsFragmentSchema : ComponentFragmentSchemaBase /// 默认组件类型名,如 "AntDesign.Input`1[System.String], AntDesign" /// [JsonPropertyName("dt")] - public string DefaultTypeName { get; set; } + public string? DefaultTypeName { get; set; } /// /// 组件类型名 @@ -21,10 +21,10 @@ public class ComponentPartsFragmentSchema : ComponentFragmentSchemaBase /// 组件保存 json 文件时,强制设置 TypeName 为 null /// [JsonPropertyName("t")] - public override string TypeName { get; set; } + public override string? TypeName { get; set; } [JsonPropertyName("childs")] - public ComponentPartsFragmentSchema[] ChildFragments { get; set; } + public ComponentPartsFragmentSchema[] ChildFragments { get; set; } = []; [JsonIgnore] public bool HasChildFragment diff --git a/src/Common/H.LowCode.MetaSchema.DesignEngine/PropertySchemas/ComponentPartsStyleDefineSchema.cs b/src/Common/H.LowCode.MetaSchema.DesignEngine/PropertySchemas/ComponentPartsStyleDefineSchema.cs new file mode 100644 index 0000000000000000000000000000000000000000..337bdf5563b3c5ec0bac6e5f26b58b946773a2cd --- /dev/null +++ b/src/Common/H.LowCode.MetaSchema.DesignEngine/PropertySchemas/ComponentPartsStyleDefineSchema.cs @@ -0,0 +1,83 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.Json.Serialization; +using System.Threading.Tasks; + +namespace H.LowCode.MetaSchema.DesignEngine; + +public class ComponentPartsStyleDefineSchema +{ + /// + /// 样式属性名称 + /// + [JsonPropertyName("sn")] + public string StyleName { get; set; } + + /// + /// 样式显示名称 + /// + [JsonPropertyName("disn")] + public string DisplayName { get; set; } + + /// + /// 样式描述 + /// + [JsonPropertyName("desc")] + public string Description { get; set; } + + /// + /// 样式分组 + /// + [JsonPropertyName("group")] + public string Group { get; set; } + + /// + /// CSS属性名 + /// + [JsonPropertyName("cssprop")] + public string CssProperty { get; set; } + + /// + /// 样式类型 + /// + [JsonPropertyName("st")] + public string StyleType { get; set; } + + /// + /// 默认值 + /// + [JsonPropertyName("dftval")] + public string DefaultValue { get; set; } + + /// + /// 是否必需 + /// + [JsonPropertyName("required")] + public bool IsRequired { get; set; } + + /// + /// 排序 + /// + [JsonPropertyName("order")] + public int Order { get; set; } + + /// + /// 选项配置 + /// + [JsonPropertyName("options")] + public string Options { get; set; } + + /// + /// 控件类型 + /// + [JsonPropertyName("controltype")] + public string ControlType { get; set; } + + /// + /// 单位 + /// + [JsonPropertyName("unit")] + public string Unit { get; set; } +} \ No newline at end of file diff --git a/src/Common/H.LowCode.MetaSchema.DesignEngine/PropertySchemas/ComponentPartsStyleSchema.cs b/src/Common/H.LowCode.MetaSchema.DesignEngine/PropertySchemas/ComponentPartsStyleSchema.cs index b76a45cea2ad272f36bedd3019e4f43ba7aa1334..b9fb9bf155e4a467a46bec3fa7e3a729d1f4d9a5 100644 --- a/src/Common/H.LowCode.MetaSchema.DesignEngine/PropertySchemas/ComponentPartsStyleSchema.cs +++ b/src/Common/H.LowCode.MetaSchema.DesignEngine/PropertySchemas/ComponentPartsStyleSchema.cs @@ -37,11 +37,11 @@ public class ComponentPartsStyleSchema /// 默认样式 /// [JsonPropertyName("dsty")] - public string DefaultStyle { get; set; } + public string? DefaultStyle { get; set; } /// /// 自定义样式 /// [JsonPropertyName("csty")] - public string CustomStyle { get; set; } + public string? CustomStyle { get; set; } } diff --git a/src/Common/H.LowCode.MetaSchema.RenderEngine/ComponentSchema.cs b/src/Common/H.LowCode.MetaSchema.RenderEngine/ComponentSchema.cs index d72c738b65b44c8f1175b745b81c0e476739f103..fd66932fd0f31b7384cac714dc3a2a646b93686b 100644 --- a/src/Common/H.LowCode.MetaSchema.RenderEngine/ComponentSchema.cs +++ b/src/Common/H.LowCode.MetaSchema.RenderEngine/ComponentSchema.cs @@ -1,7 +1,4 @@ -using H.Extensions.System; -using H.Util.Ids; -using System.ComponentModel; -using System.Text.Json.Serialization; +using System.Text.Json.Serialization; namespace H.LowCode.MetaSchema.RenderEngine; @@ -11,7 +8,7 @@ public class ComponentSchema : ComponentSchemaBase /// 组件渲染 Fragment /// [JsonPropertyName("frag")] - public ComponentFragmentSchema Fragment { get; set; } + public ComponentFragmentSchema? Fragment { get; set; } [JsonPropertyName("ds")] public ComponentDataSourceSchema DataSource { get; set; } = new(); @@ -22,13 +19,13 @@ public class ComponentSchema : ComponentSchemaBase /// 此数据通过 ConvertAttributeDefineToFragmentAttribute /// 转换为 Fragment 中的 Attribute 用于组件渲染 [JsonPropertyName("attrdefgroups")] - public ComponentAttributeDefineGroupSchema[] AttributeDefineGroups { get; set; } + public ComponentAttributeDefineGroupSchema[]? AttributeDefineGroups { get; set; } /// /// 将组件自定义属性合并到 Fragment 中 /// [JsonPropertyName("childs")] - public ComponentSchema[] Childrens { get; set; } + public ComponentSchema[]? Childrens { get; set; } public void MergeAttributeDefineToFragment() { diff --git a/src/Common/H.LowCode.MetaSchema.RenderEngine/H.LowCode.MetaSchema.RenderEngine.csproj b/src/Common/H.LowCode.MetaSchema.RenderEngine/H.LowCode.MetaSchema.RenderEngine.csproj index d6dcfa19438071ac53b62e809463dcd8635c8f9c..6e858aec9d5aac198e08a68d94e146cd21381e58 100644 --- a/src/Common/H.LowCode.MetaSchema.RenderEngine/H.LowCode.MetaSchema.RenderEngine.csproj +++ b/src/Common/H.LowCode.MetaSchema.RenderEngine/H.LowCode.MetaSchema.RenderEngine.csproj @@ -1,6 +1,6 @@  - + diff --git a/src/Common/H.LowCode.MetaSchema/AppSchemaBase.cs b/src/Common/H.LowCode.MetaSchema/AppSchemaBase.cs index d3b2d1cc088543c5b789dfa630e50e61995010e5..ee83a9dbf2fcab866993af43e669e3e77f45d575 100644 --- a/src/Common/H.LowCode.MetaSchema/AppSchemaBase.cs +++ b/src/Common/H.LowCode.MetaSchema/AppSchemaBase.cs @@ -1,25 +1,24 @@ -using System.ComponentModel.DataAnnotations; -using System.Text.Json.Serialization; +using System.Text.Json.Serialization; namespace H.LowCode.MetaSchema; public abstract class AppSchemaBase : MetaSchemaBase { - public string Id { get; set; } + public required string Id { get; set; } [JsonPropertyName("n")] - public string Name { get; set; } + public string? Name { get; set; } - public string Icon { get; set; } + public string? Icon { get; set; } [JsonPropertyName("pic")] - public string Picture { get; set; } + public string? Picture { get; set; } [JsonPropertyName("desc")] - public string Description { get; set; } + public string? Description { get; set; } [JsonPropertyName("v")] - public string Version { get; set; } + public string? Version { get; set; } [JsonPropertyName("pub")] public PublishStatusEnum PublishStatus { get; set; } diff --git a/src/Common/H.LowCode.MetaSchema/ComponentSchemaBase.cs b/src/Common/H.LowCode.MetaSchema/ComponentSchemaBase.cs index b5dbc8745439d51ee48fe600ffdf23dea151c6c5..2cf6cca80758ea3bbfce61bde2a203e0319006b9 100644 --- a/src/Common/H.LowCode.MetaSchema/ComponentSchemaBase.cs +++ b/src/Common/H.LowCode.MetaSchema/ComponentSchemaBase.cs @@ -1,25 +1,30 @@ -using H.Util.Ids; using System.Text.Json.Serialization; namespace H.LowCode.MetaSchema; -public abstract class ComponentSchemaBase +public abstract class ComponentSchemaBase : StateHasChangeSchema { /// /// 组件实例Id /// /// 一个页面组件唯一Id [JsonPropertyName("id")] - public string Id { get; set; } = ShortIdGenerator.Generate(); + public required string Id { get; set; } [JsonPropertyName("pid")] - public string ParentId { get; set; } + public string? ParentId { get; set; } + /// + /// 组件Name + /// [JsonPropertyName("n")] - public string Name { get; set; } + public string? Name { get; set; } + /// + /// 组件显示名称 + /// [JsonPropertyName("lb")] - public string Label { get; set; } + public string? Label { get; set; } /// /// 是否隐藏标题 @@ -33,6 +38,12 @@ public abstract class ComponentSchemaBase [JsonPropertyName("container")] public bool IsContainer { get; set; } + /// + /// 是否为内部容器组件 + /// + [JsonPropertyName("incontainer")] + public bool IsInnerContainer { get; set; } + private bool _isSupportDataSource; /// /// 是否支持数据源 @@ -62,11 +73,26 @@ public abstract class ComponentSchemaBase public ComponentStyleSchema Style { get; set; } = new(); /// - /// + /// 事件 /// - [JsonPropertyName("ev")] - public ComponentEventSchema Event { get; set; } = new(); + [JsonPropertyName("evs")] + public IList? Events { get; set; } + + /// + /// 事件消费 + /// + [JsonPropertyName("evcs")] + public IList? EventConsumes { get; set; } + + /// + /// 校验规则 + /// + [JsonPropertyName("valrules")] + public IList? ValidationRules { get; set; } [JsonPropertyName("desc")] - public string Description { get; set; } + public string? Description { get; set; } + + [JsonPropertyName("v")] + public string Version { get; set; } = "0.0.1"; } \ No newline at end of file diff --git a/src/Common/H.LowCode.MetaSchema/DataSourceSchemas/ComponentDataSourceSchema.cs b/src/Common/H.LowCode.MetaSchema/DataSourceSchemas/ComponentDataSourceSchema.cs index 51f92742e0bbc909b8498ba76372c868354ae05f..8265be6bdadbb6c9ee44607248a49c679d076eec 100644 --- a/src/Common/H.LowCode.MetaSchema/DataSourceSchemas/ComponentDataSourceSchema.cs +++ b/src/Common/H.LowCode.MetaSchema/DataSourceSchemas/ComponentDataSourceSchema.cs @@ -3,7 +3,7 @@ using System.Text.Json.Serialization; namespace H.LowCode.MetaSchema; -public abstract class ComponentDataSourceSchemaBase +public abstract class ComponentDataSourceSchemaBase : StateHasChangeSchema { /// /// 数据源分组类型 @@ -18,29 +18,29 @@ public abstract class ComponentDataSourceSchemaBase public ComponentDataSourceTypeEnum DataSourceType { get; set; } [JsonPropertyName("dsid")] - public string DataSourceId { get; set; } + public string? DataSourceId { get; set; } [JsonPropertyName("dsn")] - public string DataSourceName { get; set; } + public string? DataSourceName { get; set; } [JsonPropertyName("dsv")] - public string DataSourceValue { get; set; } + public string? DataSourceValue { get; set; } /// /// 固定选项数据源 /// [JsonPropertyName("fxopds")] - public IList FiexdOptionDataSource { get; set; } + public IList? FiexdOptionDataSource { get; set; } /// /// API选项数据源 /// [JsonPropertyName("apiopds")] - public APIDataSourceSchema APIOptionDataSource { get; set; } + public APIDataSourceSchema? APIOptionDataSource { get; set; } /// /// SQL选项数据源 /// [JsonPropertyName("sqlopds")] - public SQLDataSourceSchema SQLOptionDataSource { get; set; } + public SQLDataSourceSchema? SQLOptionDataSource { get; set; } } diff --git a/src/Common/H.LowCode.MetaSchema/DataSourceSchemas/OptionDataSourceSchema.cs b/src/Common/H.LowCode.MetaSchema/DataSourceSchemas/OptionDataSourceSchema.cs index d890c91f7a8a27873096a775a05d3725e36bfe39..528022daa02b8f7ebba6c2778eacc18febf221ea 100644 --- a/src/Common/H.LowCode.MetaSchema/DataSourceSchemas/OptionDataSourceSchema.cs +++ b/src/Common/H.LowCode.MetaSchema/DataSourceSchemas/OptionDataSourceSchema.cs @@ -1,4 +1,4 @@ -using H.Util.Ids; +using H.Util.Ids; using System; using System.Collections.Generic; using System.Linq; @@ -14,8 +14,20 @@ public record OptionDataSourceSchema public string Id { get; set; } = ShortIdGenerator.Generate(); [JsonPropertyName("l")] - public string Label { get; set; } + public string? Label { get; set; } [JsonPropertyName("v")] - public string Value { get; set; } + public string? Value { get; set; } + + [JsonPropertyName("s")] + public bool IsSelected { get; set; } + + [JsonPropertyName("o")] + public int Order { get; set; } + + [JsonPropertyName("g")] + public string? Group { get; set; } + + [JsonPropertyName("d")] + public string? Description { get; set; } } diff --git a/src/Common/H.LowCode.MetaSchema/DataSourceSchemas/PageDataSourceSchema.cs b/src/Common/H.LowCode.MetaSchema/DataSourceSchemas/PageDataSourceSchema.cs index 0b65faaacee14ab8133b013d367e78ff206778b8..5f5a86f6a408f968d53a183e4221229769743b71 100644 --- a/src/Common/H.LowCode.MetaSchema/DataSourceSchemas/PageDataSourceSchema.cs +++ b/src/Common/H.LowCode.MetaSchema/DataSourceSchemas/PageDataSourceSchema.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json.Serialization; -using System.Threading.Tasks; +using System.Text.Json.Serialization; namespace H.LowCode.MetaSchema; @@ -13,11 +8,11 @@ public class PageDataSourceSchema public PageDataSourceTypeEnum DataSourceType { get; set; } [JsonPropertyName("dsid")] - public string DataSourceId { get; set; } + public string? DataSourceId { get; set; } [JsonPropertyName("dsn")] - public string DataSourceName { get; set; } + public string? DataSourceName { get; set; } [JsonPropertyName("dsv")] - public string DataSourceValue { get; set; } + public string? DataSourceValue { get; set; } } \ No newline at end of file diff --git a/src/Common/H.LowCode.MetaSchema/Enums/ActionTypeEnum.cs b/src/Common/H.LowCode.MetaSchema/Enums/ActionTypeEnum.cs deleted file mode 100644 index 376146cd34bde02561ad98c7d9c245371238f969..0000000000000000000000000000000000000000 --- a/src/Common/H.LowCode.MetaSchema/Enums/ActionTypeEnum.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json.Serialization; -using System.Threading.Tasks; - -namespace H.LowCode.MetaSchema; - -public enum ActionTypeEnum -{ - None, - Modal, - Self, - Blank -} diff --git a/src/Common/H.LowCode.MetaSchema/Enums/EventDataActionTypeEnum.cs b/src/Common/H.LowCode.MetaSchema/Enums/EventDataActionTypeEnum.cs new file mode 100644 index 0000000000000000000000000000000000000000..0feda43cda3c14fa23a0beb9abff22836fa8b254 --- /dev/null +++ b/src/Common/H.LowCode.MetaSchema/Enums/EventDataActionTypeEnum.cs @@ -0,0 +1,14 @@ +using System; + +namespace H.LowCode.MetaSchema; + +public enum EventDataActionTypeEnum +{ + None = 0, + EditRow = 10, // 编辑行 + DeleteRow = 20, // 删除行 + SaveRow = 30, // 保存行 + CancelEdit = 40, // 取消编辑 + AddRow = 50, // 添加行 + RefreshData = 60, // 刷新数据 +} \ No newline at end of file diff --git a/src/Common/H.LowCode.MetaSchema/Enums/EventTargetTypeEnum.cs b/src/Common/H.LowCode.MetaSchema/Enums/EventTargetTypeEnum.cs new file mode 100644 index 0000000000000000000000000000000000000000..d30f2b19007f20f35a5dfdfe9873974c4aae0bab --- /dev/null +++ b/src/Common/H.LowCode.MetaSchema/Enums/EventTargetTypeEnum.cs @@ -0,0 +1,29 @@ +using System; + +namespace H.LowCode.MetaSchema; + +public enum EventTargetTypeEnum +{ + None = 0, + Page = 10, //打开页面 + Component = 30, //组件 + Data = 40, //数据操作 + Custom = 99, // 自定义事件 +} + +public enum EventPageHandlerTypeEnum +{ + None = 0, + Refresh = 11, //刷新 + Modal = 12, // 弹窗 + Self = 13, // 当前页 + Blank = 14, // 空白页 +} + +public enum EventCustomLanguageEnum +{ + None = 0, + JavaScript = 1, // JavaScript + Python = 2, // Python + CSharp = 3, // C# +} \ No newline at end of file diff --git a/src/Common/H.LowCode.MetaSchema/H.LowCode.MetaSchema.csproj b/src/Common/H.LowCode.MetaSchema/H.LowCode.MetaSchema.csproj index 1312af6c00bf0f9ca91fceaefae2239ab3a26810..61f7f2b4bad7bd9cb02712469d73ee0c4e24c5bb 100644 --- a/src/Common/H.LowCode.MetaSchema/H.LowCode.MetaSchema.csproj +++ b/src/Common/H.LowCode.MetaSchema/H.LowCode.MetaSchema.csproj @@ -1,10 +1,13 @@  - + + + + + + - - diff --git a/src/Common/H.LowCode.MetaSchema/MetaSchemaBase.cs b/src/Common/H.LowCode.MetaSchema/MetaSchemaBase.cs index 7e3dada4152b3ad13c9f7a7c53bd92f583900ace..bb53e2bbdcdac7cbdc963971873bfaa7fa2e343a 100644 --- a/src/Common/H.LowCode.MetaSchema/MetaSchemaBase.cs +++ b/src/Common/H.LowCode.MetaSchema/MetaSchemaBase.cs @@ -3,17 +3,17 @@ using System.Text.Json.Serialization; namespace H.LowCode.MetaSchema; -public abstract class MetaSchemaBase +public abstract class MetaSchemaBase : StateHasChangeSchema { [JsonPropertyName("cu")] - public string CreatedUser { get; set; } + public string? CreatedUser { get; set; } [JsonPropertyName("ct")] - public DateTime CreatedTime { get; set; } + public DateTime? CreatedTime { get; set; } [JsonPropertyName("mu")] - public string ModifiedUser { get; set; } + public string? ModifiedUser { get; set; } [JsonPropertyName("mt")] - public DateTime ModifiedTime { get; set; } + public DateTime? ModifiedTime { get; set; } } diff --git a/src/Common/H.LowCode.MetaSchema/PageSchemaBase.cs b/src/Common/H.LowCode.MetaSchema/PageSchemaBase.cs index 85723b16bce7c1568f95bcf6def074efffa5ae40..5f93b3b44215d4383e77b6bfa289309d23e05d61 100644 --- a/src/Common/H.LowCode.MetaSchema/PageSchemaBase.cs +++ b/src/Common/H.LowCode.MetaSchema/PageSchemaBase.cs @@ -6,13 +6,13 @@ namespace H.LowCode.MetaSchema; public abstract class PageSchemaBase : MetaSchemaBase { [JsonPropertyName("aid")] - public string AppId { get; set; } + public string? AppId { get; set; } [JsonPropertyName("id")] public string Id { get; set; } = ShortIdGenerator.Generate(); [JsonPropertyName("n")] - public string Name { get; set; } + public string? Name { get; set; } [JsonPropertyName("order")] public int Order { get; set; } @@ -31,4 +31,10 @@ public abstract class PageSchemaBase : MetaSchemaBase [JsonPropertyName("ds")] public PageDataSourceSchema DataSource { get; set; } = new(); + + /// + /// 事件 + /// + [JsonPropertyName("evs")] + public IList? Events { get; set; } } \ No newline at end of file diff --git a/src/Common/H.LowCode.MetaSchema/PropertySchemas/ComponentAttributeDefineSchemaBase.cs b/src/Common/H.LowCode.MetaSchema/PropertySchemas/ComponentAttributeDefineSchemaBase.cs index 7d0666899ddb541414596955673a3b04e95f0143..aeebcb934a1ea2ef9d116226927c296dcdd06037 100644 --- a/src/Common/H.LowCode.MetaSchema/PropertySchemas/ComponentAttributeDefineSchemaBase.cs +++ b/src/Common/H.LowCode.MetaSchema/PropertySchemas/ComponentAttributeDefineSchemaBase.cs @@ -1,9 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json.Serialization; -using System.Threading.Tasks; +using System.Text.Json.Serialization; namespace H.LowCode.MetaSchema; @@ -14,17 +9,17 @@ public abstract class ComponentAttributeDefineSchemaBase /// /// 必须为组件中存在的属性名称, 不可随意命名 [JsonPropertyName("attrn")] - public string AttributeName { get; set; } + public string? AttributeName { get; set; } /// /// 组件属性值 clr 类型 /// [JsonPropertyName("attrt")] - public string AttributeClrType { get; set; } + public string? AttributeClrType { get; set; } /// /// 组件属性对应的值 /// [JsonPropertyName("attrv")] - public object AttributeValue { get; set; } + public object? AttributeValue { get; set; } } diff --git a/src/Common/H.LowCode.MetaSchema/PropertySchemas/ComponentEventSchema.cs b/src/Common/H.LowCode.MetaSchema/PropertySchemas/ComponentEventSchema.cs deleted file mode 100644 index 6d8fc8688e069d6325d15a5963a36ece473b0daa..0000000000000000000000000000000000000000 --- a/src/Common/H.LowCode.MetaSchema/PropertySchemas/ComponentEventSchema.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; -using System.Text.Json.Serialization; - -namespace H.LowCode.MetaSchema; - -public class ComponentEventSchema -{ - -} diff --git a/src/Common/H.LowCode.MetaSchema/PropertySchemas/ComponentFragmentSchemaBase.cs b/src/Common/H.LowCode.MetaSchema/PropertySchemas/ComponentFragmentSchemaBase.cs index 2a25a14a9980f91a1762573b901038f681ef9e7a..1d46a205e666bfd8b3ea42873acfd0649c343bb6 100644 --- a/src/Common/H.LowCode.MetaSchema/PropertySchemas/ComponentFragmentSchemaBase.cs +++ b/src/Common/H.LowCode.MetaSchema/PropertySchemas/ComponentFragmentSchemaBase.cs @@ -8,18 +8,18 @@ public abstract class ComponentFragmentSchemaBase /// 组件类型名 /// [JsonPropertyName("t")] - public virtual string TypeName { get; set; } + public virtual string? TypeName { get; set; } [JsonPropertyName("valt")] - public string ValueType { get; set; } + public string? ValueType { get; set; } [JsonPropertyName("attrs")] public ComponentAttributeFragmentSchema[] Attributes { get; set; } = []; [JsonPropertyName("content")] - public string Content { get; set; } + public string? Content { get; set; } - public object GetDefaultValue() + public object? GetDefaultValue() { if (string.IsNullOrEmpty(ValueType)) return null; @@ -32,14 +32,14 @@ public abstract class ComponentFragmentSchemaBase public record ComponentAttributeFragmentSchema { [JsonPropertyName("attrn")] - public string AttributeName { get; set; } + public string? AttributeName { get; set; } /// /// 组件属性值 clr 类型 /// [JsonPropertyName("attrt")] - public string AttributeClrType { get; set; } + public string? AttributeClrType { get; set; } [JsonPropertyName("attrv")] - public object AttributeValue { get; set; } + public object? AttributeValue { get; set; } } diff --git a/src/Common/H.LowCode.MetaSchema/PropertySchemas/ComponentStyleSchema.cs b/src/Common/H.LowCode.MetaSchema/PropertySchemas/ComponentStyleSchema.cs index 3389447d6574037b185bf4bf07a4b2f7b6dd1ee7..e4d39f1ec11055fe3fc0c1ae9a5627f3e01d89b9 100644 --- a/src/Common/H.LowCode.MetaSchema/PropertySchemas/ComponentStyleSchema.cs +++ b/src/Common/H.LowCode.MetaSchema/PropertySchemas/ComponentStyleSchema.cs @@ -29,11 +29,11 @@ public class ComponentStyleSchema /// 默认样式 /// [JsonPropertyName("dfstl")] - public string DefaultStyle { get; set; } + public string? DefaultStyle { get; set; } /// /// 自定义样式 /// [JsonPropertyName("ctstl")] - public string CustomStyle { get; set; } + public string? CustomStyle { get; set; } } diff --git a/src/Common/H.LowCode.MetaSchema/PropertySchemas/EventSchema.cs b/src/Common/H.LowCode.MetaSchema/PropertySchemas/EventSchema.cs new file mode 100644 index 0000000000000000000000000000000000000000..227da71f3f9534ae4a5053717bce2dfbd8a37967 --- /dev/null +++ b/src/Common/H.LowCode.MetaSchema/PropertySchemas/EventSchema.cs @@ -0,0 +1,67 @@ +using System; +using System.Text.Json.Serialization; + +namespace H.LowCode.MetaSchema; + +public class EventSchema +{ + [JsonPropertyName("en")] + public string EventName { get; set; } + + [JsonPropertyName("eht")] + public EventTargetTypeEnum EventHandlerType { get; set; } + + #region 标准事件 + /// + /// 事件目标id (如页面id、组件id等) + /// + [JsonPropertyName("etid")] + public string EventTargetId { get; set; } + + /// + /// 事件目标动作 + /// + [JsonPropertyName("eta")] + public string EventTargetAction { get; set; } + #endregion + + #region 自定义事件 + /// + /// 自定义脚本语言 + /// + [JsonPropertyName("ecl")] + public EventCustomLanguageEnum EventCustomLanguage { get; set; } + + /// + /// 自定义脚本内容 + /// + [JsonPropertyName("ecs")] + public string EventCustomScript { get; set; } + #endregion + + #region 数据操作事件 + /// + /// 数据操作类型 + /// + [JsonPropertyName("edat")] + public EventDataActionTypeEnum EventDataActionType { get; set; } + #endregion + + /// + /// 事件参数 + /// + public IDictionary EventArgs { get; set; } + + /// + /// 行数据参数映射 (key: URL参数名, value: 行数据字段名) + /// + [JsonPropertyName("rowparams")] + public IDictionary RowDataParams { get; set; } +} + +public class EventConsumeSchema +{ + public string EventName { get; set; } + + public string EventDisplayName { get; set; } +} \ No newline at end of file diff --git a/src/Common/H.LowCode.MetaSchema/PropertySchemas/PagePropertySchema.cs b/src/Common/H.LowCode.MetaSchema/PropertySchemas/PagePropertySchema.cs index 510ca2adbe01f0c053aea4ff58ce2b171b4610d5..d4dc539fc7507d2b1485fc581112c76014b6750a 100644 --- a/src/Common/H.LowCode.MetaSchema/PropertySchemas/PagePropertySchema.cs +++ b/src/Common/H.LowCode.MetaSchema/PropertySchemas/PagePropertySchema.cs @@ -15,23 +15,23 @@ public class PagePropertySchema /// 标题宽度 /// [JsonPropertyName("titlew")] - public string TitleWidth { get; set; } + public string? TitleWidth { get; set; } /// /// 默认样式 /// [JsonPropertyName("dsty")] - public string DefaultStyle { get; set; } + public string? DefaultStyle { get; set; } /// /// 自定义样式 /// [JsonPropertyName("csty")] - public string CustomStyle { get; set; } + public string? CustomStyle { get; set; } /// /// 页面数据源 /// [JsonPropertyName("ds")] - public PageDataSourceSchema DataSource { get; set; } = new(); + public PageDataSourceSchema? DataSource { get; set; } = new(); } diff --git a/src/Common/H.LowCode.MetaSchema/PropertySchemas/PropertyItemSchema.cs b/src/Common/H.LowCode.MetaSchema/PropertySchemas/PropertyItemSchema.cs deleted file mode 100644 index 45e8b5932a0f2018dc3396c433bdd77b33185195..0000000000000000000000000000000000000000 --- a/src/Common/H.LowCode.MetaSchema/PropertySchemas/PropertyItemSchema.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.Text.Json.Serialization; - -namespace H.LowCode.MetaSchema; - -public class PropertyItemSchema -{ - [JsonPropertyName("n")] - public string Name { get; set; } - - [JsonPropertyName("label")] - public string Label { get; set; } - - [JsonPropertyName("desc")] - public string Description { get; set; } - - public int Order { get; set; } - - [JsonPropertyName("strval")] - public string StringValue { get; set; } - - [JsonPropertyName("boolval")] - public bool? BoolValue { get; set; } - - [JsonPropertyName("intval")] - public int? IntValue { get; set; } - - public IDictionary Options { get; set; } - - ///// - ///// 设置项类型 - ///// - //[JsonPropertyName("itemtype")] - //public ComponentAttributeItemTypeEnum SettingItemType { get; set; } -} diff --git a/src/Common/H.LowCode.MetaSchema/PropertySchemas/TableSchemas/TableButtonSchema.cs b/src/Common/H.LowCode.MetaSchema/PropertySchemas/TableSchemas/TableButtonSchema.cs index 52b7cd305e50fdcd2253084d179ab29e8ea94f6f..5abb62011c5fd30eecf9564bd71250b3ffe0b0eb 100644 --- a/src/Common/H.LowCode.MetaSchema/PropertySchemas/TableSchemas/TableButtonSchema.cs +++ b/src/Common/H.LowCode.MetaSchema/PropertySchemas/TableSchemas/TableButtonSchema.cs @@ -1,25 +1,21 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Text.Json.Serialization; -using System.Threading.Tasks; namespace H.LowCode.MetaSchema; public class TableButtonSchema { [JsonPropertyName("id")] - public string Id { get; set; } + public string? Id { get; set; } [JsonPropertyName("n")] - public string Name { get; set; } + public string? Name { get; set; } [JsonPropertyName("t")] - public string Title { get; set; } + public string? Title { get; set; } - [JsonPropertyName("btnType")] - public string ButtonType { get; set; } + [JsonPropertyName("bt")] + public int ButtonType { get; set; } [JsonPropertyName("disabled")] public bool Disabled { get; set; } @@ -30,13 +26,24 @@ public class TableButtonSchema [JsonPropertyName("order")] public int Order { get; set; } - [JsonPropertyName("actType")] - public ActionTypeEnum ActionType { get; set; } = new(); + /// + /// 组件支持的事件 + /// + [JsonPropertyName("sptevs")] + public string[] SupportEvents { get; set; } = ["OnClick"]; /// - /// 目标对象Id + /// 事件 /// - /// 如打开页面时的PageId - [JsonPropertyName("tgId")] - public string TargetId { get; set; } + [JsonPropertyName("evs")] + public IList? Events { get; set; } + + public void Update(TableButtonSchema update) + { + this.Name = update.Name; + this.Title = update.Title; + this.ButtonType = update.ButtonType; + this.Disabled = update.Disabled; + this.Order = update.Order; + } } diff --git a/src/Common/H.LowCode.MetaSchema/PropertySchemas/TableSchemas/TableColumnSchema.cs b/src/Common/H.LowCode.MetaSchema/PropertySchemas/TableSchemas/TableColumnSchema.cs index 24ead29d15bd02fde7fb500de93139f8c7d46662..0e0b4d9194ea3101d0c8c4e2a88b421456b1f642 100644 --- a/src/Common/H.LowCode.MetaSchema/PropertySchemas/TableSchemas/TableColumnSchema.cs +++ b/src/Common/H.LowCode.MetaSchema/PropertySchemas/TableSchemas/TableColumnSchema.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Text.Json.Serialization; namespace H.LowCode.MetaSchema; diff --git a/src/Common/H.LowCode.MetaSchema/PropertySchemas/TableSchemas/TablePropertySchema.cs b/src/Common/H.LowCode.MetaSchema/PropertySchemas/TableSchemas/TablePropertySchema.cs index 55299083da499f67c3cea6071f9646a25d7bbf9c..88643890d335bc9241ced0f583cc88aac3882311 100644 --- a/src/Common/H.LowCode.MetaSchema/PropertySchemas/TableSchemas/TablePropertySchema.cs +++ b/src/Common/H.LowCode.MetaSchema/PropertySchemas/TableSchemas/TablePropertySchema.cs @@ -11,6 +11,15 @@ public class TablePropertySchema [JsonPropertyName("searchs")] public IList SearchItems { get; set; } = []; - [JsonPropertyName("btns")] - public IList Buttons { get; set; } = []; + /// + /// 列表上方按钮 + /// + [JsonPropertyName("tbtns")] + public IList TopButtons { get; set; } = []; + + /// + /// 表格行按钮 + /// + [JsonPropertyName("rbtns")] + public IList RowButtons { get; set; } = []; } diff --git a/src/Common/H.LowCode.MetaSchema/PropertySchemas/ValidationRuleSchema.cs b/src/Common/H.LowCode.MetaSchema/PropertySchemas/ValidationRuleSchema.cs index f6f264c4b836a2f6ba45be418ca0797259664d33..6ee2511d4e6dd99f7a17d093b9dd9d644f3849dd 100644 --- a/src/Common/H.LowCode.MetaSchema/PropertySchemas/ValidationRuleSchema.cs +++ b/src/Common/H.LowCode.MetaSchema/PropertySchemas/ValidationRuleSchema.cs @@ -2,15 +2,176 @@ using System.Collections.Generic; using System.Linq; using System.Text; +using System.Text.Json.Serialization; using System.Threading.Tasks; namespace H.LowCode.MetaSchema; public class ValidationRuleSchema { + /// + /// 校验规则ID + /// + [JsonPropertyName("id")] public string Id { get; set; } + /// + /// 关联的组件ID + /// + [JsonPropertyName("cid")] public string ComponentId { get; set; } - public string Expression { get; set; } + /// + /// 校验规则类型 + /// + [JsonPropertyName("type")] + public ValidationRuleTypeEnum RuleType { get; set; } + + /// + /// 是否必填 + /// + [JsonPropertyName("required")] + public bool IsRequired { get; set; } + + /// + /// 最小长度 + /// + [JsonPropertyName("minlen")] + public int? MinLength { get; set; } + + /// + /// 最大长度 + /// + [JsonPropertyName("maxlen")] + public int? MaxLength { get; set; } + + /// + /// 最小值 + /// + [JsonPropertyName("minval")] + public decimal? MinValue { get; set; } + + /// + /// 最大值 + /// + [JsonPropertyName("maxval")] + public decimal? MaxValue { get; set; } + + /// + /// 正则表达式 + /// + [JsonPropertyName("pattern")] + public string? Pattern { get; set; } + + /// + /// 自定义表达式 + /// + [JsonPropertyName("expr")] + public string? Expression { get; set; } + + /// + /// 错误消息 + /// + [JsonPropertyName("errmsg")] + public string? ErrorMessage { get; set; } + + /// + /// 校验触发时机 + /// + [JsonPropertyName("trigger")] + public ValidationTriggerEnum Trigger { get; set; } = ValidationTriggerEnum.Blur; + + /// + /// 是否启用 + /// + [JsonPropertyName("enabled")] + public bool IsEnabled { get; set; } = true; + + /// + /// 排序 + /// + [JsonPropertyName("order")] + public int Order { get; set; } +} + +/// +/// 校验规则类型枚举 +/// +public enum ValidationRuleTypeEnum +{ + /// + /// 必填校验 + /// + Required = 1, + + /// + /// 最小长度校验 + /// + MinLength = 2, + + /// + /// 最大长度校验 + /// + MaxLength = 3, + + /// + /// 最小值校验 + /// + MinValue = 4, + + /// + /// 最大值校验 + /// + MaxValue = 5, + + /// + /// 正则表达式校验 + /// + Pattern = 6, + + /// + /// 邮箱格式校验 + /// + Email = 7, + + /// + /// 手机号格式校验 + /// + Phone = 8, + + /// + /// URL格式校验 + /// + Url = 9, + + /// + /// 身份证号格式校验 + /// + IdCard = 10, + + /// + /// 自定义表达式校验 + /// + Custom = 99 +} + +/// +/// 校验触发时机枚举 +/// +public enum ValidationTriggerEnum +{ + /// + /// 失去焦点时校验 + /// + Blur = 1, + + /// + /// 值改变时校验 + /// + Change = 2, + + /// + /// 提交时校验 + /// + Submit = 3 } diff --git a/src/Common/H.LowCode.MetaSchema/Services/FormValidationService.cs b/src/Common/H.LowCode.MetaSchema/Services/FormValidationService.cs new file mode 100644 index 0000000000000000000000000000000000000000..5995a7cbafba262d425b979774cb8cee0c4d61e5 --- /dev/null +++ b/src/Common/H.LowCode.MetaSchema/Services/FormValidationService.cs @@ -0,0 +1,248 @@ +using System.Text.RegularExpressions; +using H.LowCode.MetaSchema; + +namespace H.LowCode.MetaSchema.Services; + +/// +/// 表单校验服务实现 +/// +public class FormValidationService : IFormValidationService +{ + public ValidationResult ValidateField(object? value, IList? validationRules) + { + if (validationRules == null || !validationRules.Any()) + return ValidationResult.Success(); + + // 按优先级排序校验规则 + var sortedRules = validationRules + .Where(r => r.IsEnabled) + .OrderBy(r => r.Order) + .ToList(); + + foreach (var rule in sortedRules) + { + var result = ValidateSingleRule(value, rule); + if (!result.IsValid) + return result; + } + + return ValidationResult.Success(); + } + + public FormValidationResult ValidateForm(Dictionary formData, IList components) + { + var result = new FormValidationResult { IsValid = true }; + + foreach (var component in components) + { + if (component.ValidationRules == null || !component.ValidationRules.Any()) + continue; + + var fieldName = component.Name ?? component.Id; + var fieldValue = formData.ContainsKey(fieldName) ? formData[fieldName] : null; + + var validationResult = ValidateField(fieldValue, component.ValidationRules); + result.AddFieldResult(fieldName, validationResult); + + if (!validationResult.IsValid) + result.IsValid = false; + } + + return result; + } + + public IList? GetValidationRules(string componentId, IList components) + { + var component = components.FirstOrDefault(c => c.Id == componentId); + return component?.ValidationRules; + } + + private ValidationResult ValidateSingleRule(object? value, ValidationRuleSchema rule) + { + try + { + switch (rule.RuleType) + { + case ValidationRuleTypeEnum.Required: + return ValidateRequired(value, rule); + + case ValidationRuleTypeEnum.MinLength: + return ValidateMinLength(value, rule); + + case ValidationRuleTypeEnum.MaxLength: + return ValidateMaxLength(value, rule); + + case ValidationRuleTypeEnum.MinValue: + return ValidateMinValue(value, rule); + + case ValidationRuleTypeEnum.MaxValue: + return ValidateMaxValue(value, rule); + + case ValidationRuleTypeEnum.Pattern: + return ValidatePattern(value, rule); + + case ValidationRuleTypeEnum.Email: + return ValidateEmail(value, rule); + + case ValidationRuleTypeEnum.Phone: + return ValidatePhone(value, rule); + + case ValidationRuleTypeEnum.Url: + return ValidateUrl(value, rule); + + case ValidationRuleTypeEnum.Custom: + return ValidateCustom(value, rule); + + default: + return ValidationResult.Success(); + } + } + catch (Exception ex) + { + return ValidationResult.Failure($"校验规则执行错误: {ex.Message}", rule.RuleType); + } + } + + private ValidationResult ValidateRequired(object? value, ValidationRuleSchema rule) + { + if (value == null || string.IsNullOrWhiteSpace(value.ToString())) + { + return ValidationResult.Failure( + rule.ErrorMessage ?? "此字段为必填项", + ValidationRuleTypeEnum.Required); + } + return ValidationResult.Success(); + } + + private ValidationResult ValidateMinLength(object? value, ValidationRuleSchema rule) + { + if (value == null) return ValidationResult.Success(); + + var stringValue = value.ToString(); + if (stringValue != null && stringValue.Length < rule.MinLength) + { + return ValidationResult.Failure( + rule.ErrorMessage ?? $"最少需要 {rule.MinLength} 个字符", + ValidationRuleTypeEnum.MinLength); + } + return ValidationResult.Success(); + } + + private ValidationResult ValidateMaxLength(object? value, ValidationRuleSchema rule) + { + if (value == null) return ValidationResult.Success(); + + var stringValue = value.ToString(); + if (stringValue != null && stringValue.Length > rule.MaxLength) + { + return ValidationResult.Failure( + rule.ErrorMessage ?? $"最多允许 {rule.MaxLength} 个字符", + ValidationRuleTypeEnum.MaxLength); + } + return ValidationResult.Success(); + } + + private ValidationResult ValidateMinValue(object? value, ValidationRuleSchema rule) + { + if (value == null) return ValidationResult.Success(); + + if (decimal.TryParse(value.ToString(), out var numericValue)) + { + if (numericValue < rule.MinValue) + { + return ValidationResult.Failure( + rule.ErrorMessage ?? $"值不能小于 {rule.MinValue}", + ValidationRuleTypeEnum.MinValue); + } + } + return ValidationResult.Success(); + } + + private ValidationResult ValidateMaxValue(object? value, ValidationRuleSchema rule) + { + if (value == null) return ValidationResult.Success(); + + if (decimal.TryParse(value.ToString(), out var numericValue)) + { + if (numericValue > rule.MaxValue) + { + return ValidationResult.Failure( + rule.ErrorMessage ?? $"值不能大于 {rule.MaxValue}", + ValidationRuleTypeEnum.MaxValue); + } + } + return ValidationResult.Success(); + } + + private ValidationResult ValidatePattern(object? value, ValidationRuleSchema rule) + { + if (value == null) return ValidationResult.Success(); + + if (!string.IsNullOrEmpty(rule.Pattern)) + { + var regex = new Regex(rule.Pattern); + if (!regex.IsMatch(value.ToString() ?? "")) + { + return ValidationResult.Failure( + rule.ErrorMessage ?? "格式不正确", + ValidationRuleTypeEnum.Pattern); + } + } + return ValidationResult.Success(); + } + + private ValidationResult ValidateEmail(object? value, ValidationRuleSchema rule) + { + if (value == null) return ValidationResult.Success(); + + var emailPattern = @"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$"; + var regex = new Regex(emailPattern); + if (!regex.IsMatch(value.ToString() ?? "")) + { + return ValidationResult.Failure( + rule.ErrorMessage ?? "请输入有效的邮箱地址", + ValidationRuleTypeEnum.Email); + } + return ValidationResult.Success(); + } + + private ValidationResult ValidatePhone(object? value, ValidationRuleSchema rule) + { + if (value == null) return ValidationResult.Success(); + + var phonePattern = @"^1[3-9]\d{9}$"; + var regex = new Regex(phonePattern); + if (!regex.IsMatch(value.ToString() ?? "")) + { + return ValidationResult.Failure( + rule.ErrorMessage ?? "请输入有效的手机号码", + ValidationRuleTypeEnum.Phone); + } + return ValidationResult.Success(); + } + + private ValidationResult ValidateUrl(object? value, ValidationRuleSchema rule) + { + if (value == null) return ValidationResult.Success(); + + if (!Uri.TryCreate(value.ToString(), UriKind.Absolute, out _)) + { + return ValidationResult.Failure( + rule.ErrorMessage ?? "请输入有效的URL地址", + ValidationRuleTypeEnum.Url); + } + return ValidationResult.Success(); + } + + private ValidationResult ValidateCustom(object? value, ValidationRuleSchema rule) + { + // 自定义校验规则可以通过Expression属性来实现 + // 这里可以扩展支持JavaScript表达式或其他自定义逻辑 + if (!string.IsNullOrEmpty(rule.Expression)) + { + // TODO: 实现自定义表达式校验 + // 可以使用JavaScript引擎或其他表达式解析器 + } + return ValidationResult.Success(); + } +} \ No newline at end of file diff --git a/src/Common/H.LowCode.MetaSchema/Services/IFormValidationService.cs b/src/Common/H.LowCode.MetaSchema/Services/IFormValidationService.cs new file mode 100644 index 0000000000000000000000000000000000000000..9815233a5432cf2700cb7ffa236369beca6b6492 --- /dev/null +++ b/src/Common/H.LowCode.MetaSchema/Services/IFormValidationService.cs @@ -0,0 +1,66 @@ +using H.LowCode.MetaSchema; + +namespace H.LowCode.MetaSchema.Services; + +/// +/// 表单校验服务接口 +/// +public interface IFormValidationService +{ + /// + /// 校验单个字段值 + /// + /// 字段值 + /// 校验规则 + /// 校验结果 + ValidationResult ValidateField(object? value, IList? validationRules); + + /// + /// 校验表单数据 + /// + /// 表单数据 + /// 组件列表 + /// 校验结果 + FormValidationResult ValidateForm(Dictionary formData, IList components); + + /// + /// 获取字段的校验规则 + /// + /// 组件ID + /// 组件列表 + /// 校验规则 + IList? GetValidationRules(string componentId, IList components); +} + +/// +/// 校验结果 +/// +public class ValidationResult +{ + public bool IsValid { get; set; } + public string? ErrorMessage { get; set; } + public ValidationRuleTypeEnum? FailedRuleType { get; set; } + + public static ValidationResult Success() => new() { IsValid = true }; + public static ValidationResult Failure(string errorMessage, ValidationRuleTypeEnum? ruleType = null) => + new() { IsValid = false, ErrorMessage = errorMessage, FailedRuleType = ruleType }; +} + +/// +/// 表单校验结果 +/// +public class FormValidationResult +{ + public bool IsValid { get; set; } + public Dictionary FieldResults { get; set; } = new(); + public List ErrorMessages { get; set; } = new(); + + public void AddFieldResult(string fieldName, ValidationResult result) + { + FieldResults[fieldName] = result; + if (!result.IsValid && !string.IsNullOrEmpty(result.ErrorMessage)) + { + ErrorMessages.Add($"{fieldName}: {result.ErrorMessage}"); + } + } +} \ No newline at end of file diff --git a/src/Common/H.LowCode.MetaSchema/StateHasChangeSchema.cs b/src/Common/H.LowCode.MetaSchema/StateHasChangeSchema.cs new file mode 100644 index 0000000000000000000000000000000000000000..6021f24968f2a11a59e3f5c9f8981a08caa00257 --- /dev/null +++ b/src/Common/H.LowCode.MetaSchema/StateHasChangeSchema.cs @@ -0,0 +1,16 @@ +using H.Util.Ids; +using System; +using System.Text.Json.Serialization; + +namespace H.LowCode.MetaSchema; + +public abstract class StateHasChangeSchema +{ + [JsonIgnore] + public string StateKey { get; internal set; } = ShortIdGenerator.Generate(); + + public void ChangeStateKey() + { + StateKey = ShortIdGenerator.Generate(); + } +} diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Abstraction/ContainerComponentBase.razor b/src/DesignEngine/H.LowCode.DesignEngine.Abstraction/ContainerComponentBase.razor deleted file mode 100644 index f3ba7c8a83935dbf97a16bc5e4f95787fa59ec99..0000000000000000000000000000000000000000 --- a/src/DesignEngine/H.LowCode.DesignEngine.Abstraction/ContainerComponentBase.razor +++ /dev/null @@ -1,47 +0,0 @@ -@* @namespace H.LowCode.DesignEngine.Abstraction *@ -@* @inherits DesignEngineLowCodeComponentBase *@ - -@* @code { *@ -@* [Parameter] *@ -@* public ComponentPartsSchema Component { get; set; } *@ - -@* protected virtual ComponentPartsSchema CreateComponent(string key, Action action = null) *@ -@* { *@ -@* var c = Component.Childrens.FirstOrDefault(t => *@ -@* { *@ -@* return false; *@ -@* }); *@ -@* if (c != null) *@ -@* return c; *@ - -@* var component = CreateContainerComponent(key); *@ - -@* if(action != null) action(component); *@ - -@* Component.Childrens.Add(component); *@ - -@* return component; *@ -@* } *@ - -@* private ComponentPartsSchema CreateContainerComponent(string name) *@ -@* { *@ -@* var component = new ComponentPartsSchema(); *@ -@* component.Id = ShortIdGenerator.Generate(); *@ -@* component.Refresh = Component.Refresh; *@ - -@* component.Fragment = new(); *@ -@* component.Style = new() { DefaultStyle = "height:100%; width:100%;" }; *@ -@* component.Event = default; *@ -@* component.DesignState.DragEffectStyle = default; *@ -@* component.DesignState.IsDropedAfter = default; *@ -@* component.DesignState.IsDroppedFromComponentPanel = default; *@ -@* component.IsHiddenLabel = true; *@ -@* component.DesignState.IsSelected = default; *@ -@* component.DesignState.Opacity = default; *@ - -@* component.IsContainer = true; *@ -@* component.ParentId = Component.Id; *@ - -@* return component; *@ -@* } *@ -@* } *@ diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Abstraction/DesignEngineLowCodePageComponentBase.cs b/src/DesignEngine/H.LowCode.DesignEngine.Abstraction/DesignEngineLowCodePageComponentBase.cs deleted file mode 100644 index fcd90a122f163d790d8c332372a7c04b056d037f..0000000000000000000000000000000000000000 --- a/src/DesignEngine/H.LowCode.DesignEngine.Abstraction/DesignEngineLowCodePageComponentBase.cs +++ /dev/null @@ -1,19 +0,0 @@ -using Microsoft.AspNetCore.Components; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace H.LowCode.DesignEngine.Abstraction; - -/// -/// 页面组件基类 -/// -public abstract class DesignEngineLowCodePageComponentBase : DesignEngineLowCodeComponentBase -{ - protected static T GetQueryValue(string name) - { - return default; - } -} diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Abstraction/DragDropComponents/DropItem.razor b/src/DesignEngine/H.LowCode.DesignEngine.Abstraction/DragDropComponents/DropItem.razor deleted file mode 100644 index 37ebb67d1034610f6defd478b2df781dcb6d2882..0000000000000000000000000000000000000000 --- a/src/DesignEngine/H.LowCode.DesignEngine.Abstraction/DragDropComponents/DropItem.razor +++ /dev/null @@ -1,191 +0,0 @@ -@namespace H.LowCode.DesignEngine.Abstraction -@inherits DesignEngineLowCodeComponentBase - -@inject DragDropStateService DragDropStateService - -
- -
- @if (Component.DesignState.IsSelected) - { -
- -
-
-
- -
-
- -
-
- } - - -
-
- -@code { - [CascadingParameter(Name = "pageCascading")] - public PageCascadingModel PageCascading { get; set; } - - [Parameter] - public ComponentPartsSchema Component { get; set; } - - /// - /// 当前组件是否在根容器内 - /// - [Parameter] - public bool IsInRootContainer { get; set; } - - [Parameter] - public Action OnItemClick { get; set; } - - [Parameter] - public Action OnItemDelete { get; set; } - - [Parameter] - public Action OnItemCopy { get; set; } - - protected ClassMapper DropItemBoxClassMapper { get; } = new ClassMapper(); - protected ClassMapper DropItemClassMapper { get; } = new ClassMapper(); - - #region Init - protected override async Task OnInitializedAsync() - { - await base.OnInitializedAsync(); - - Init(); - SetClassMap(); - } - - protected override void OnAfterRender(bool firstRender) - { - if (firstRender) - RegisterEventDispatcher(); - } - - private void Init() - { - if (Component == null) - throw new NullReferenceException(nameof(Component)); - } - - private void RegisterEventDispatcher() - { - if (IsInRootContainer) - { - //订阅 PageSetting 中的组件点击事件 - BlazorEventDispatcher.Subscribe("designengine.pagesetting.pagelayout.onchange", (value) => - { - PageCascading.PageLayout = (int)value; - StateHasChanged(); - }); - } - } - - private void SetClassMap() - { - DropItemClassMapper.Clear() - .If("dropitem-selected", () => Component.DesignState.IsSelected) - .If("dropitem-component", () => Component.IsContainer == false) - .If("dropitem-container", () => Component.IsContainer); - - DropItemBoxClassMapper.Clear() - .If("dropitem-box-layout", () => Component.IsContainer); - } - #endregion - - #region Event - private void OnClick() - { - Component.DesignState.DragEffectStyle = string.Empty; - //DragDropStateService.ResetDragStyle(); - - OnItemClick.Invoke(Component); - BlazorEventDispatcher.Publish("designengine.dropitem.onclick", Component); - } - - private void OnDragStart(DragEventArgs dragEventArgs) - { - Component.DesignState.Opacity = 0.2; - - //记录当前选中对象 - DragDropStateService.SetCurrentDragComponent(PageCascading.AppId, PageCascading.PageId, Component); - } - - private void OnDragEnter(DragEventArgs dragEventArgs) - { - DragDropStateService.SetLastDragOverComponent(PageCascading.AppId, PageCascading.PageId, Component); - } - - private void OnDragOver(DragEventArgs dragEventArgs) - { - if (ReferenceEquals(DragDropStateService.GetCurrentDragComponent(PageCascading.AppId, PageCascading.PageId), Component)) - return; - - if (DateTime.Now < DragDropStateService.GetLastDragOverTime(PageCascading.AppId, PageCascading.PageId).AddMilliseconds(100)) - return; - - //设置移动位置样式,拖拽到目标元素上半部分时,上方添加虚线边框,下半部分时下方添加虚线边框 - if (dragEventArgs.OffsetY < 30) - { - Component.DesignState.DragEffectStyle = "border-top: 2px dashed #1890ff;"; - Component.DesignState.IsDropedAfter = false; - } - else - { - Console.WriteLine($"OnDragOver: bottom"); - Component.DesignState.DragEffectStyle = "border-bottom: 2px dashed #1890ff; height: auto;"; - Component.DesignState.IsDropedAfter = true; - } - DragDropStateService.SetLastDragOverTime(PageCascading.AppId, PageCascading.PageId, DateTime.Now); - } - - private void OnDragLeave() - { - //如果当前被拖拽的组件和拖拽到上面的组件是同一个,直接返回 - if (ReferenceEquals(DragDropStateService.GetCurrentDragComponent(PageCascading.AppId, PageCascading.PageId), Component)) - return; - - Console.WriteLine("OnDragLeave"); - Component.DesignState.DragEffectStyle = string.Empty; - } - - private void OnMouseOver() - { - if (Component.DesignState.IsSelected == false) - { - Component.DesignState.DragEffectStyle = "outline: #1890ff dashed 1.5px;"; - } - } - - private void OnMouseOut() - { - if (Component.DesignState.IsSelected == false) - { - Component.DesignState.DragEffectStyle = string.Empty; - } - } - - private void OnDelete() - { - OnItemDelete.Invoke(Component); - } - - private void OnCopy() - { - OnItemCopy.Invoke(Component); - } - #endregion -} \ No newline at end of file diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Application.Contracts/AppServices/IPageAppService.cs b/src/DesignEngine/H.LowCode.DesignEngine.Application.Contracts/AppServices/IPageAppService.cs index 15a063aed91200c2633503128b6cd5adcd937435..7e30f2b034af321e6cfc4df219e420b4672445f6 100644 --- a/src/DesignEngine/H.LowCode.DesignEngine.Application.Contracts/AppServices/IPageAppService.cs +++ b/src/DesignEngine/H.LowCode.DesignEngine.Application.Contracts/AppServices/IPageAppService.cs @@ -15,4 +15,6 @@ public interface IPageAppService : IApplicationService Task SaveAsync(PagePartsSchema pageSchema); Task DeleteAsync(string appId, string pageId); + + Task GetPageComponentAsync(string appId, string pageId, string componentId); } \ No newline at end of file diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Application.Contracts/DesignEngineApplicationContractsModule.cs b/src/DesignEngine/H.LowCode.DesignEngine.Application.Contracts/DesignEngineApplicationContractsModule.cs index 9690860c2992c691feed118bd0780b21dc170f32..cb0f8d7c07ba110a2e2f1b1c335768dd0d7c00ec 100644 --- a/src/DesignEngine/H.LowCode.DesignEngine.Application.Contracts/DesignEngineApplicationContractsModule.cs +++ b/src/DesignEngine/H.LowCode.DesignEngine.Application.Contracts/DesignEngineApplicationContractsModule.cs @@ -1,16 +1,13 @@ -using Microsoft.Extensions.DependencyInjection; -using System; -using System.Collections.Generic; -using System.Linq; +using H.LowCode.Application.Contracts; using System.Reflection; -using System.Text; -using System.Threading; -using System.Threading.Tasks; using Volo.Abp.Modularity; using Volo.Abp.Validation; namespace H.LowCode.DesignEngine.Application.Contracts; +[DependsOn( + typeof(LowCodeApplicationContractsModule) + )] public class DesignEngineApplicationContractsModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Application.Contracts/H.LowCode.DesignEngine.Application.Contracts.csproj b/src/DesignEngine/H.LowCode.DesignEngine.Application.Contracts/H.LowCode.DesignEngine.Application.Contracts.csproj index a0a27e3e62929b5b3c3a756df2a29f84faf92971..de49e36fc48b3f2bd28ca2fe46a63ce98f0a7baf 100644 --- a/src/DesignEngine/H.LowCode.DesignEngine.Application.Contracts/H.LowCode.DesignEngine.Application.Contracts.csproj +++ b/src/DesignEngine/H.LowCode.DesignEngine.Application.Contracts/H.LowCode.DesignEngine.Application.Contracts.csproj @@ -1,12 +1,13 @@  - + + diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Application.Contracts/Inputs/DataSourceInput.cs b/src/DesignEngine/H.LowCode.DesignEngine.Application.Contracts/Inputs/DataSourceInput.cs index 85963afd7e1428917c1ad28404cecb8b5641d080..97fd38f21a5ef96d40e95594139d3b7363ee4596 100644 --- a/src/DesignEngine/H.LowCode.DesignEngine.Application.Contracts/Inputs/DataSourceInput.cs +++ b/src/DesignEngine/H.LowCode.DesignEngine.Application.Contracts/Inputs/DataSourceInput.cs @@ -1,8 +1,5 @@ using H.LowCode.MetaSchema; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Text.Json.Serialization; using System.Threading.Tasks; diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Application.Contracts/PartsAppServices/IComponentPartsAppService.cs b/src/DesignEngine/H.LowCode.DesignEngine.Application.Contracts/PartsAppServices/IComponentPartsAppService.cs index 4d8a91cc2c30158529fccd6f91c5f0b8d6a637fd..14bc5d5ebf1817afed6200be46cb14064c9e5d5e 100644 --- a/src/DesignEngine/H.LowCode.DesignEngine.Application.Contracts/PartsAppServices/IComponentPartsAppService.cs +++ b/src/DesignEngine/H.LowCode.DesignEngine.Application.Contracts/PartsAppServices/IComponentPartsAppService.cs @@ -1,10 +1,6 @@ using H.LowCode.DesignEngine.Model; using H.LowCode.MetaSchema.DesignEngine; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Volo.Abp.Application.Services; namespace H.LowCode.DesignEngine.Application.Contracts; diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Application/AppServices/AppApplicationService.cs b/src/DesignEngine/H.LowCode.DesignEngine.Application/AppServices/AppApplicationService.cs index 74855c4d4b8e070217d23912a8ede9fa2c97c57d..414fded123269e6a9171e9d4a30e921eaaf979c7 100644 --- a/src/DesignEngine/H.LowCode.DesignEngine.Application/AppServices/AppApplicationService.cs +++ b/src/DesignEngine/H.LowCode.DesignEngine.Application/AppServices/AppApplicationService.cs @@ -1,14 +1,12 @@ using H.LowCode.Configuration; using H.LowCode.DesignEngine.Application.Contracts; +using H.LowCode.DesignEngine.Domain.Repositories; using H.LowCode.DesignEngine.Model; -using H.LowCode.DesignEngine.Domain; +using H.LowCode.MetaSchema.DesignEngine; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; -using System.Collections.Generic; -using System.Text; using Volo.Abp; using Volo.Abp.Application.Services; -using H.LowCode.MetaSchema.DesignEngine; namespace H.LowCode.DesignEngine.Application; @@ -17,7 +15,7 @@ public class AppApplicationService : ApplicationService, IAppApplicationService { private IEnumerable _sites => LazyServiceProvider.GetRequiredService>>().Value; - private IAppDomainService _domainService => LazyServiceProvider.GetRequiredService(); + private IAppRepository _repository => LazyServiceProvider.GetRequiredService(); public async Task> GetAppsAsync() { @@ -33,12 +31,12 @@ public class AppApplicationService : ApplicationService, IAppApplicationService public async Task> GetListAsync() { - return await _domainService.GetListAsync(); + return await _repository.GetListAsync(); } public async Task GetByIdAsync(string appId) { - return await _domainService.GetAsync(appId); + return await _repository.GetAsync(appId); } public async Task SaveAsync(AppPartsSchema appSchema) @@ -46,7 +44,7 @@ public class AppApplicationService : ApplicationService, IAppApplicationService ArgumentNullException.ThrowIfNull(appSchema); ArgumentException.ThrowIfNullOrEmpty(appSchema.Id); - await _domainService.SaveAsync(appSchema); + await _repository.SaveAsync(appSchema); return true; } } diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Application/AppServices/DataSourceAppService.cs b/src/DesignEngine/H.LowCode.DesignEngine.Application/AppServices/DataSourceAppService.cs index a64ef25eb43acb162c7815f5cc630520ba61ce9d..e63439fd51c3b1e49b11ba2e00a98976dfbedbf4 100644 --- a/src/DesignEngine/H.LowCode.DesignEngine.Application/AppServices/DataSourceAppService.cs +++ b/src/DesignEngine/H.LowCode.DesignEngine.Application/AppServices/DataSourceAppService.cs @@ -1,10 +1,8 @@ using H.LowCode.DesignEngine.Application.Contracts; +using H.LowCode.DesignEngine.Domain.Repositories; using H.LowCode.DesignEngine.Model; -using H.LowCode.DesignEngine.Domain; using H.LowCode.MetaSchema; using Microsoft.Extensions.DependencyInjection; -using System.Collections.Generic; -using System.Text; using Volo.Abp; using Volo.Abp.Application.Services; @@ -13,11 +11,11 @@ namespace H.LowCode.DesignEngine.Application; [RemoteService] public class DataSourceAppService : ApplicationService, IDataSourceAppService { - private IDataSourceDomainService _domainService => LazyServiceProvider.GetRequiredService(); + private IDataSourceRepository _repository => LazyServiceProvider.GetRequiredService(); public async Task> GetListAsync(string appId, DataSourceInput input) { - var dataSources = await _domainService.GetListAsync(appId); + var dataSources = await _repository.GetListAsync(appId); List list = new List(); foreach (var dataSourceSchema in dataSources) @@ -42,7 +40,7 @@ public class DataSourceAppService : ApplicationService, IDataSourceAppService public async Task GetByIdAsync(string appId, string id) { - return await _domainService.GetAsync(appId, id); + return await _repository.GetAsync(appId, id); } public async Task SaveAsync(string appId, DataSourceSchema dataSourceSchema) @@ -50,13 +48,13 @@ public class DataSourceAppService : ApplicationService, IDataSourceAppService ArgumentNullException.ThrowIfNull(dataSourceSchema); ArgumentException.ThrowIfNullOrEmpty(dataSourceSchema.Id); - await _domainService.SaveAsync(appId, dataSourceSchema); + await _repository.SaveAsync(appId, dataSourceSchema); return true; } public async Task DeleteAsync(string appId, string id) { - await _domainService.DeleteAsync(appId, id); + await _repository.DeleteAsync(appId, id); return true; } } diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Application/AppServices/MenuAppService.cs b/src/DesignEngine/H.LowCode.DesignEngine.Application/AppServices/MenuAppService.cs index 07c2dead98456f55e4b2a1543fa616805b0d6e4b..4a4c71eeda15dbafde8885bb03cab27dbdb2c63f 100644 --- a/src/DesignEngine/H.LowCode.DesignEngine.Application/AppServices/MenuAppService.cs +++ b/src/DesignEngine/H.LowCode.DesignEngine.Application/AppServices/MenuAppService.cs @@ -1,10 +1,7 @@ -using H.Extensions.System; -using H.LowCode.DesignEngine.Application.Contracts; -using H.LowCode.DesignEngine.Domain; +using H.LowCode.DesignEngine.Application.Contracts; +using H.LowCode.DesignEngine.Domain.Repositories; using H.LowCode.MetaSchema; using Microsoft.Extensions.DependencyInjection; -using System.Collections.Generic; -using System.Text; using Volo.Abp; using Volo.Abp.Application.Services; @@ -13,16 +10,16 @@ namespace H.LowCode.DesignEngine.Application; [RemoteService] public class MenuAppService : ApplicationService, IMenuAppService { - private IMenuDomainService _domainService => LazyServiceProvider.GetRequiredService(); + private IMenuRepository _repository => LazyServiceProvider.GetRequiredService(); public async Task> GetListAsync(string appId) { - return await _domainService.GetListAsync(appId); + return await _repository.GetListAsync(appId); } public async Task GetByIdAsync(string appId, string menuId) { - return await _domainService.GetAsync(appId, menuId); + return await _repository.GetAsync(appId, menuId); } public async Task SaveAsync(MenuSchema menuSchema) @@ -30,13 +27,13 @@ public class MenuAppService : ApplicationService, IMenuAppService ArgumentNullException.ThrowIfNull(menuSchema); ArgumentException.ThrowIfNullOrEmpty(menuSchema.Id); - await _domainService.SaveAsync(menuSchema); + await _repository.SaveAsync(menuSchema); return true; } public async Task DeleteAsync(string appId, string menuId) { - await _domainService.DeleteAsync(appId, menuId); + await _repository.DeleteAsync(appId, menuId); return true; } } diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Application/AppServices/PageAppService.cs b/src/DesignEngine/H.LowCode.DesignEngine.Application/AppServices/PageAppService.cs index d1958a0c7cb0242ab53824f9c4d28b0feb942755..505f73a14ac7c1b63cd7ce2e21ff1c4a3aceef12 100644 --- a/src/DesignEngine/H.LowCode.DesignEngine.Application/AppServices/PageAppService.cs +++ b/src/DesignEngine/H.LowCode.DesignEngine.Application/AppServices/PageAppService.cs @@ -1,10 +1,8 @@ using H.LowCode.DesignEngine.Application.Contracts; -using H.LowCode.DesignEngine.Domain; +using H.LowCode.DesignEngine.Domain.Repositories; using H.LowCode.DesignEngine.Model; using H.LowCode.MetaSchema.DesignEngine; using Microsoft.Extensions.DependencyInjection; -using System.Collections.Generic; -using System.Text; using Volo.Abp; using Volo.Abp.Application.Services; @@ -13,17 +11,17 @@ namespace H.LowCode.DesignEngine.Application; [RemoteService] public class PageAppService : ApplicationService, IPageAppService { - private IPageDomainService _domainService => LazyServiceProvider.GetRequiredService(); + private IPageRepository _repository => LazyServiceProvider.GetRequiredService(); private IComponentPartsAppService _componentPartsAppService => LazyServiceProvider.GetRequiredService(); public async Task> GetListAsync(string appId) { - return await _domainService.GetListAsync(appId); + return await _repository.GetListAsync(appId); } public async Task GetByIdAsync(string appId, string pageId) { - return await _domainService.GetByIdAsync(appId, pageId); + return await _repository.GetByIdAsync(appId, pageId); } /// @@ -34,9 +32,9 @@ public class PageAppService : ApplicationService, IPageAppService /// public async Task GetByIdWithDefineAsync(string appId, string pageId) { - var pageSchema = await _domainService.GetByIdAsync(appId, pageId); + var pageSchema = await _repository.GetByIdAsync(appId, pageId); - //合并组件定义中的属性 + //合并组件定义中的属性 (支持组件升级后原有组件获取最新特性) foreach (var component in pageSchema.Components) { await MergeComponentPartsDefineRecursive(component); @@ -50,13 +48,13 @@ public class PageAppService : ApplicationService, IPageAppService ArgumentNullException.ThrowIfNull(pageSchema); ArgumentException.ThrowIfNullOrEmpty(pageSchema.Id); - await _domainService.SaveAsync(pageSchema); + await _repository.SaveAsync(pageSchema); return true; } public async Task DeleteAsync(string appId, string pageId) { - await _domainService.DeleteAsync(appId, pageId); + await _repository.DeleteAsync(appId, pageId); return true; } @@ -78,8 +76,35 @@ public class PageAppService : ApplicationService, IPageAppService { foreach (var child in component.Childrens) { + if (child.IsInnerContainer) + continue; + await MergeComponentPartsDefineRecursive(child); } } } + + public async Task GetPageComponentAsync(string appId, string pageId, string componentId) + { + var page = await GetByIdAsync(appId, pageId); + if (page == null) + { + throw new BusinessException("Page not found."); + } + + if (page.Components == null || page.Components.Count == 0) + { + throw new BusinessException("Page Component not found."); + } + + var component = page.Components.FirstOrDefault(c => c.Id == componentId); + if (component == null) + { + throw new BusinessException($"Component with ID {componentId} not found in page {pageId}."); + } + + await MergeComponentPartsDefineRecursive(component); + + return component; + } } diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Application/AppServices/TableDataAppService.cs b/src/DesignEngine/H.LowCode.DesignEngine.Application/AppServices/TableDataAppService.cs new file mode 100644 index 0000000000000000000000000000000000000000..84655978ec22fcd8b2747204ece5e67335a27f87 --- /dev/null +++ b/src/DesignEngine/H.LowCode.DesignEngine.Application/AppServices/TableDataAppService.cs @@ -0,0 +1,56 @@ +using H.LowCode.Application.Contracts; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Application.Services; + +namespace H.LowCode.ComponentBase.Services; + +/// +/// 默认表格数据提供者(提供模拟数据) +/// +public class TableDataAppService : ApplicationService, ITableDataAppService +{ + public async Task>> GetListAsync(TableDataInput request) + { + await Task.Delay(100); // 模拟异步操作 + + // 生成模拟数据 + var items = new List>(); + + // 根据页码和页大小生成数据 + for (int i = 0; i < 3; i++) + { + var rowIndex = i + 1; + var row = new Dictionary + { + ["Id"] = rowIndex, + ["CreateTime"] = DateTime.Now.AddDays(-rowIndex) + }; + items.Add(row); + } + + return new() + { + Items = items, + TotalCount = 3 + }; + } + + public async Task DeleteAsync(TableDataDeleteInput request) + { + await Task.Delay(100); // 模拟异步操作 + + // 在设计引擎中,这只是模拟删除操作 + // 实际上不会删除任何数据,只是为了演示功能 + Console.WriteLine($"模拟删除数据: AppId={request.AppId}, PageId={request.PageId}, DataSourceId={request.DataSourceId}, Id={request.Id}"); + } + + public async Task UpdateAsync(TableDataUpdateInput request) + { + await Task.Delay(100); // 模拟异步操作 + + // 在设计引擎中,这只是模拟更新操作 + // 实际上不会更新任何数据,只是为了演示功能 + Console.WriteLine($"模拟更新数据: AppId={request.AppId}, PageId={request.PageId}, DataSourceId={request.DataSourceId}, Id={request.Id}"); + Console.WriteLine($"更新字段: {string.Join(", ", request.UpdateData?.Select(kv => $"{kv.Key}={kv.Value}") ?? new string[0])}"); + } +} \ No newline at end of file diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Application/DesignEngineApplicationModule.cs b/src/DesignEngine/H.LowCode.DesignEngine.Application/DesignEngineApplicationModule.cs index 8b316ba533322e5317b583a62cb99a497f7a3841..2ce75cd90935c0c3d47d044888151654cf96d16c 100644 --- a/src/DesignEngine/H.LowCode.DesignEngine.Application/DesignEngineApplicationModule.cs +++ b/src/DesignEngine/H.LowCode.DesignEngine.Application/DesignEngineApplicationModule.cs @@ -1,4 +1,4 @@ -using H.LowCode.Configuration; +using H.LowCode.Configuration; using H.LowCode.DesignEngine.Domain; using Microsoft.Extensions.DependencyInjection; using Volo.Abp.Modularity; diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Application/H.LowCode.DesignEngine.Application.csproj b/src/DesignEngine/H.LowCode.DesignEngine.Application/H.LowCode.DesignEngine.Application.csproj index 536867b825a0ccba8b96030dedf7e52792ec7b7a..0fb068d03ae7362df4624c56c52c2a051d066332 100644 --- a/src/DesignEngine/H.LowCode.DesignEngine.Application/H.LowCode.DesignEngine.Application.csproj +++ b/src/DesignEngine/H.LowCode.DesignEngine.Application/H.LowCode.DesignEngine.Application.csproj @@ -1,6 +1,6 @@  - + @@ -8,6 +8,7 @@ + diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Application/PartsAppServices/ComponentLibraryAppService.cs b/src/DesignEngine/H.LowCode.DesignEngine.Application/PartsAppServices/ComponentLibraryAppService.cs index f7f9dfaeb5b8bf10d6eb8ceecc5997685ec3380f..4f0978af6508ad415b40a5be04bbb26163aecf9f 100644 --- a/src/DesignEngine/H.LowCode.DesignEngine.Application/PartsAppServices/ComponentLibraryAppService.cs +++ b/src/DesignEngine/H.LowCode.DesignEngine.Application/PartsAppServices/ComponentLibraryAppService.cs @@ -1,5 +1,6 @@ using H.LowCode.DesignEngine.Application.Contracts; using H.LowCode.DesignEngine.Domain; +using H.LowCode.DesignEngine.Domain.Repositories; using H.LowCode.MetaSchema.DesignEngine; using Microsoft.Extensions.DependencyInjection; using System; @@ -14,25 +15,25 @@ namespace H.LowCode.DesignEngine.Application; [RemoteService] public class ComponentLibraryAppService : ApplicationService, IComponentLibraryAppService { - private IComponentLibraryDomainService _domainService => LazyServiceProvider.GetRequiredService(); + private IComponentLibraryRepository _repository => LazyServiceProvider.GetRequiredService(); public Task> GetListAsync() { - return _domainService.GetListAsync(); + return _repository.GetListAsync(); } public async Task GetByIdAsync(string libraryId) { - return await _domainService.GetByIdAsync(libraryId); + return await _repository.GetByIdAsync(libraryId); } public async Task SaveAsync(ComponentLibrarySchema componentLibrary) { - return await _domainService.SaveAsync(componentLibrary); + return await _repository.SaveAsync(componentLibrary); } public async Task DeleteAsync(string libraryId) { - return await _domainService.DeleteAsync(libraryId); + return await _repository.DeleteAsync(libraryId); } } diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Application/PartsAppServices/ComponentPartsAppService.cs b/src/DesignEngine/H.LowCode.DesignEngine.Application/PartsAppServices/ComponentPartsAppService.cs index eabec6e90cd2c1e084992b6f02936a894aa7348b..084910fea8c9bfbf638b6a8a5ff26824d7341ef0 100644 --- a/src/DesignEngine/H.LowCode.DesignEngine.Application/PartsAppServices/ComponentPartsAppService.cs +++ b/src/DesignEngine/H.LowCode.DesignEngine.Application/PartsAppServices/ComponentPartsAppService.cs @@ -1,13 +1,8 @@ using H.LowCode.DesignEngine.Application.Contracts; +using H.LowCode.DesignEngine.Domain.Repositories; using H.LowCode.DesignEngine.Model; -using H.LowCode.DesignEngine.Domain; using H.LowCode.MetaSchema.DesignEngine; using Microsoft.Extensions.DependencyInjection; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Volo.Abp; using Volo.Abp.Application.Services; @@ -16,30 +11,30 @@ namespace H.LowCode.DesignEngine.Application; [RemoteService] public class ComponentPartsAppService : ApplicationService, IComponentPartsAppService { - private IComponentPartsDomainService _domainService => LazyServiceProvider.GetRequiredService(); + private IComponentPartsRepository _repository => LazyServiceProvider.GetRequiredService(); public async Task DeleteAsync(string libraryId, string componentId) { - return await _domainService.DeleteAsync(libraryId, componentId); + return await _repository.DeleteAsync(libraryId, componentId); } public async Task> GetAllComponentsAsync(string libraryId) { - return await _domainService.GetAllComponentsAsync(libraryId); + return await _repository.GetAllComponentsAsync(libraryId); } public async Task GetByIdAsync(string libraryId, string componentId) { - return await _domainService.GetByIdAsync(libraryId, componentId); + return await _repository.GetByIdAsync(libraryId, componentId); } public async Task> GetListAsync(string libraryId) { - return await _domainService.GetListAsync(libraryId); + return await _repository.GetListAsync(libraryId); } public async Task SaveAsync(ComponentPartsSchema componentParts) { - return await _domainService.SaveAsync(componentParts); + return await _repository.SaveAsync(componentParts); } } diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Domain/DataDomainServices/FormDataDomainService.cs b/src/DesignEngine/H.LowCode.DesignEngine.Domain/DataDomainServices/FormDataDomainService.cs deleted file mode 100644 index 951ea4c308a3ef0ba60d2e6a4dc70f60be2f1724..0000000000000000000000000000000000000000 --- a/src/DesignEngine/H.LowCode.DesignEngine.Domain/DataDomainServices/FormDataDomainService.cs +++ /dev/null @@ -1,64 +0,0 @@ -using H.LowCode.Entity; -using Microsoft.Extensions.DependencyInjection; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Volo.Abp.Domain.Entities; -using Volo.Abp.Domain.Services; - -namespace H.LowCode.DesignEngine.Domain; - -public class FormDataDomainService : DomainService, IFormDataDomainService -{ - private IFormDataRepository _formDataRepository => LazyServiceProvider.GetRequiredService(); - private IPageDomainService _pageDomainService => LazyServiceProvider.GetRequiredService(); - - public async Task GetAsync(string appId, string pageId, string id) - { - var formPageSchema = await _pageDomainService.GetByIdAsync(appId, pageId); - if (formPageSchema == null) - throw new KeyNotFoundException($"page not found: appId={appId}, pageId={pageId}"); - - string entityName = formPageSchema.DataSource.DataSourceValue; - - if (string.IsNullOrEmpty(id)) - { - var defaultEntity = new FormEntity() - { - Name = entityName, - Fields = formPageSchema.Components.Where(t => t.IsContainer == false) - .Select(t => new FormFieldEntity() - { - Name = t.Name, - TypeName = t.Fragment.ValueType, - Value = t.Fragment.GetDefaultValue() - }).ToList() - }; - return defaultEntity; - } - - var entity = await _formDataRepository.GetAsync(entityName, id); - if (entity == null) - throw new EntityNotFoundException($"Entity {entityName} Not Found: {id}"); - - return entity; - } - - public async Task SaveAsync(FormEntity entity) - { - //if (string.IsNullOrEmpty(entity.Id)) - await _formDataRepository.AddAsync(entity); - //else - // await _formDataRepository.UpdateAsync(entity); - return true; - } - - public async Task DeleteAsync(string appId, string pageId, string id) - { - var formPageSchema = await _pageDomainService.GetByIdAsync(appId, pageId); - - return await _formDataRepository.DeleteAsync(formPageSchema.DataSource.DataSourceValue, id); - } -} diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Domain/DataDomainServices/IFormDataDomainService.cs b/src/DesignEngine/H.LowCode.DesignEngine.Domain/DataDomainServices/IFormDataDomainService.cs deleted file mode 100644 index f241bd0ca1dd96b4fb95bf3f124ba8ab1d50a994..0000000000000000000000000000000000000000 --- a/src/DesignEngine/H.LowCode.DesignEngine.Domain/DataDomainServices/IFormDataDomainService.cs +++ /dev/null @@ -1,18 +0,0 @@ -using H.LowCode.Entity; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Volo.Abp.Domain.Services; - -namespace H.LowCode.DesignEngine.Domain; - -public interface IFormDataDomainService : IDomainService -{ - Task SaveAsync(FormEntity entity); - - Task GetAsync(string appId, string pageId, string id); - - Task DeleteAsync(string appId, string pageId, string id); -} diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Domain/DataDomainServices/ITableDataDomainService.cs b/src/DesignEngine/H.LowCode.DesignEngine.Domain/DataDomainServices/ITableDataDomainService.cs deleted file mode 100644 index 5c913ac0be53970204586a9abe8cee013e82638a..0000000000000000000000000000000000000000 --- a/src/DesignEngine/H.LowCode.DesignEngine.Domain/DataDomainServices/ITableDataDomainService.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Volo.Abp.Domain.Services; - -namespace H.LowCode.DesignEngine.Domain; - -public interface ITableDataDomainService : IDomainService -{ - -} diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Domain/DataDomainServices/TableDataDomainService.cs b/src/DesignEngine/H.LowCode.DesignEngine.Domain/DataDomainServices/TableDataDomainService.cs deleted file mode 100644 index f70b94b10dd28cbcc42d2c0c7cf0995b50364a8b..0000000000000000000000000000000000000000 --- a/src/DesignEngine/H.LowCode.DesignEngine.Domain/DataDomainServices/TableDataDomainService.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Volo.Abp.Domain.Services; - -namespace H.LowCode.DesignEngine.Domain; - -public class TableDataDomainService : DomainService, ITableDataDomainService -{ - public TableDataDomainService(ITableDataRepository tableDataRepository) - { - - } -} diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Domain/DesignEngineDomainModule.cs b/src/DesignEngine/H.LowCode.DesignEngine.Domain/DesignEngineDomainModule.cs index 3b4a1dc9f019afca19157a75d65bf1669b8beefc..76dec9e98359e67c962a2b939ee9e6d93440f755 100644 --- a/src/DesignEngine/H.LowCode.DesignEngine.Domain/DesignEngineDomainModule.cs +++ b/src/DesignEngine/H.LowCode.DesignEngine.Domain/DesignEngineDomainModule.cs @@ -1,5 +1,4 @@ -using Microsoft.Extensions.DependencyInjection; -using Volo.Abp.Modularity; +using Volo.Abp.Modularity; namespace H.LowCode.DesignEngine.Domain; diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Domain/H.LowCode.DesignEngine.Domain.csproj b/src/DesignEngine/H.LowCode.DesignEngine.Domain/H.LowCode.DesignEngine.Domain.csproj index ea6a366f056a7fb3ab84adc71f614ba0d8c0ed6f..596f4840f40838734c22a6fdee98241e0e83ec74 100644 --- a/src/DesignEngine/H.LowCode.DesignEngine.Domain/H.LowCode.DesignEngine.Domain.csproj +++ b/src/DesignEngine/H.LowCode.DesignEngine.Domain/H.LowCode.DesignEngine.Domain.csproj @@ -1,6 +1,6 @@  - + diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Domain/MetaDomainServices/AppDomainService.cs b/src/DesignEngine/H.LowCode.DesignEngine.Domain/MetaDomainServices/AppDomainService.cs deleted file mode 100644 index eaa6ed419ad76f448447571661b2dc78d4e5c084..0000000000000000000000000000000000000000 --- a/src/DesignEngine/H.LowCode.DesignEngine.Domain/MetaDomainServices/AppDomainService.cs +++ /dev/null @@ -1,31 +0,0 @@ -using H.LowCode.DesignEngine.Domain.Repositories; -using H.LowCode.MetaSchema; -using H.LowCode.MetaSchema.DesignEngine; -using Volo.Abp.Domain.Services; - -namespace H.LowCode.DesignEngine.Domain; - -public class AppDomainService : DomainService, IAppDomainService -{ - private readonly IAppRepository _repository; - - public AppDomainService(IAppRepository repository) - { - _repository = repository; - } - - public async Task> GetListAsync() - { - return await _repository.GetListAsync(); - } - - public async Task GetAsync(string appId) - { - return await _repository.GetAsync(appId); - } - - public async Task SaveAsync(AppPartsSchema appSchema) - { - await _repository.SaveAsync(appSchema); - } -} \ No newline at end of file diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Domain/MetaDomainServices/DataSourceDomainService.cs b/src/DesignEngine/H.LowCode.DesignEngine.Domain/MetaDomainServices/DataSourceDomainService.cs deleted file mode 100644 index ab6b9c479e7b66d4981839fada6fd3a40a776a25..0000000000000000000000000000000000000000 --- a/src/DesignEngine/H.LowCode.DesignEngine.Domain/MetaDomainServices/DataSourceDomainService.cs +++ /dev/null @@ -1,47 +0,0 @@ -using H.LowCode.DesignEngine.Domain.Repositories; -using H.LowCode.MetaSchema; -using Volo.Abp.Domain.Services; - -namespace H.LowCode.DesignEngine.Domain; - -public class DataSourceDomainService : DomainService, IDataSourceDomainService -{ - private readonly IDataSourceRepository _repository; - - public DataSourceDomainService(IDataSourceRepository repository) - { - _repository = repository; - } - - public async Task> GetListAsync(string appId) - { - return await _repository.GetListAsync(appId); - } - - public async Task> GetAllApisAsync(string appId) - { - var list = await GetListAsync(appId); - return list.Where(t => t.DataSourceType == ComponentDataSourceTypeEnum.API).ToList(); - } - - public IEnumerable GetAllEntities(string appId) - { - var list = GetListAsync(appId).Result; - return list.Where(t => t.DataSourceType == ComponentDataSourceTypeEnum.DB).ToList(); - } - - public async Task GetAsync(string appId, string id) - { - return await _repository.GetAsync(appId, id); - } - - public async Task SaveAsync(string appId, DataSourceSchema dataSourceSchema) - { - await _repository.SaveAsync(appId, dataSourceSchema); - } - - public async Task DeleteAsync(string appId, string id) - { - await _repository.DeleteAsync(appId, id); - } -} \ No newline at end of file diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Domain/MetaDomainServices/IAppDomainService.cs b/src/DesignEngine/H.LowCode.DesignEngine.Domain/MetaDomainServices/IAppDomainService.cs deleted file mode 100644 index bc05d929af9fdfbe37609f85c0783d13e4732a54..0000000000000000000000000000000000000000 --- a/src/DesignEngine/H.LowCode.DesignEngine.Domain/MetaDomainServices/IAppDomainService.cs +++ /dev/null @@ -1,13 +0,0 @@ -using H.LowCode.MetaSchema.DesignEngine; -using Volo.Abp.Domain.Services; - -namespace H.LowCode.DesignEngine.Domain; - -public interface IAppDomainService : IDomainService -{ - Task> GetListAsync(); - - Task SaveAsync(AppPartsSchema appSchema); - - Task GetAsync(string appId); -} \ No newline at end of file diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Domain/MetaDomainServices/IDataSourceDomainService.cs b/src/DesignEngine/H.LowCode.DesignEngine.Domain/MetaDomainServices/IDataSourceDomainService.cs deleted file mode 100644 index 2787ed1bd90f479a7e57fa972ec987b4991e6d31..0000000000000000000000000000000000000000 --- a/src/DesignEngine/H.LowCode.DesignEngine.Domain/MetaDomainServices/IDataSourceDomainService.cs +++ /dev/null @@ -1,20 +0,0 @@ -using H.LowCode.DesignEngine.Model; -using H.LowCode.MetaSchema; -using Volo.Abp.Domain.Services; - -namespace H.LowCode.DesignEngine.Domain; - -public interface IDataSourceDomainService : IDomainService -{ - Task> GetListAsync(string appId); - - Task> GetAllApisAsync(string appId); - - IEnumerable GetAllEntities(string appId); - - Task GetAsync(string appId, string id); - - Task SaveAsync(string appId, DataSourceSchema dataSourceSchema); - - Task DeleteAsync(string appId, string id); -} \ No newline at end of file diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Domain/MetaDomainServices/IMenuDomainService.cs b/src/DesignEngine/H.LowCode.DesignEngine.Domain/MetaDomainServices/IMenuDomainService.cs deleted file mode 100644 index e8a8dab6e6a0f7f7d94729d97fbb506e5bab7ce3..0000000000000000000000000000000000000000 --- a/src/DesignEngine/H.LowCode.DesignEngine.Domain/MetaDomainServices/IMenuDomainService.cs +++ /dev/null @@ -1,15 +0,0 @@ -using H.LowCode.MetaSchema; -using Volo.Abp.Domain.Services; - -namespace H.LowCode.DesignEngine.Domain; - -public interface IMenuDomainService : IDomainService -{ - Task GetAsync(string appId, string menuId); - - Task> GetListAsync(string appId); - - Task SaveAsync(MenuSchema menuSchema); - - Task DeleteAsync(string appId, string menuId); -} \ No newline at end of file diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Domain/MetaDomainServices/IMetaDomainService.cs b/src/DesignEngine/H.LowCode.DesignEngine.Domain/MetaDomainServices/IMetaDomainService.cs deleted file mode 100644 index f5007b9299791d1e671970b4d223c913456ab0dd..0000000000000000000000000000000000000000 --- a/src/DesignEngine/H.LowCode.DesignEngine.Domain/MetaDomainServices/IMetaDomainService.cs +++ /dev/null @@ -1,8 +0,0 @@ -using Volo.Abp.Domain.Services; - -namespace H.LowCode.DesignEngine.Domain; - -public interface IMetaDomainService : IDomainService -{ - -} diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Domain/MetaDomainServices/IPageDomainService.cs b/src/DesignEngine/H.LowCode.DesignEngine.Domain/MetaDomainServices/IPageDomainService.cs deleted file mode 100644 index d416cc628fef5c3da1bb1975f92098988903c3d9..0000000000000000000000000000000000000000 --- a/src/DesignEngine/H.LowCode.DesignEngine.Domain/MetaDomainServices/IPageDomainService.cs +++ /dev/null @@ -1,16 +0,0 @@ -using H.LowCode.DesignEngine.Model; -using H.LowCode.MetaSchema.DesignEngine; -using Volo.Abp.Domain.Services; - -namespace H.LowCode.DesignEngine.Domain; - -public interface IPageDomainService : IDomainService -{ - Task> GetListAsync(string appId); - - Task GetByIdAsync(string appId, string pageId); - - Task SaveAsync(PagePartsSchema pageSchema); - - Task DeleteAsync(string appId, string pageId); -} \ No newline at end of file diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Domain/MetaDomainServices/MenuDomainService.cs b/src/DesignEngine/H.LowCode.DesignEngine.Domain/MetaDomainServices/MenuDomainService.cs deleted file mode 100644 index 73e2d6c6b2d872d2279ec3ccb93532f1fe16f195..0000000000000000000000000000000000000000 --- a/src/DesignEngine/H.LowCode.DesignEngine.Domain/MetaDomainServices/MenuDomainService.cs +++ /dev/null @@ -1,35 +0,0 @@ -using H.LowCode.DesignEngine.Domain.Repositories; -using H.LowCode.MetaSchema; -using Volo.Abp.Domain.Services; - -namespace H.LowCode.DesignEngine.Domain; - -public class MenuDomainService : DomainService, IMenuDomainService -{ - private readonly IMenuRepository _repository; - - public MenuDomainService(IMenuRepository repository) - { - _repository = repository; - } - - public async Task> GetListAsync(string appId) - { - return await _repository.GetListAsync(appId); - } - - public async Task GetAsync(string appId, string menuId) - { - return await _repository.GetAsync(appId, menuId); - } - - public async Task SaveAsync(MenuSchema menuSchema) - { - await _repository.SaveAsync(menuSchema); - } - - public async Task DeleteAsync(string appId, string menuId) - { - await _repository.DeleteAsync(appId, menuId); - } -} \ No newline at end of file diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Domain/MetaDomainServices/MetaDomainService.cs b/src/DesignEngine/H.LowCode.DesignEngine.Domain/MetaDomainServices/MetaDomainService.cs deleted file mode 100644 index 605df0e6296efdda51f6c2dd99af62cded1d603e..0000000000000000000000000000000000000000 --- a/src/DesignEngine/H.LowCode.DesignEngine.Domain/MetaDomainServices/MetaDomainService.cs +++ /dev/null @@ -1,8 +0,0 @@ -using Volo.Abp.Domain.Services; - -namespace H.LowCode.DesignEngine.Domain; - -public class MetaDomainService : DomainService, IMetaDomainService -{ - -} diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Domain/MetaDomainServices/PageDomainService.cs b/src/DesignEngine/H.LowCode.DesignEngine.Domain/MetaDomainServices/PageDomainService.cs deleted file mode 100644 index 172405e770177e726f0cfc7077eaada42a79b14d..0000000000000000000000000000000000000000 --- a/src/DesignEngine/H.LowCode.DesignEngine.Domain/MetaDomainServices/PageDomainService.cs +++ /dev/null @@ -1,36 +0,0 @@ -using H.LowCode.DesignEngine.Model; -using H.LowCode.DesignEngine.Domain.Repositories; -using H.LowCode.MetaSchema.DesignEngine; -using Volo.Abp.Domain.Services; - -namespace H.LowCode.DesignEngine.Domain; - -public class PageDomainService : DomainService, IPageDomainService -{ - private readonly IPageRepository _repository; - - public PageDomainService(IPageRepository repository) - { - _repository = repository; - } - - public async Task> GetListAsync(string appId) - { - return await _repository.GetListAsync(appId); - } - - public async Task GetByIdAsync(string appId, string pageId) - { - return await _repository.GetByIdAsync(appId, pageId); - } - - public async Task SaveAsync(PagePartsSchema pageSchema) - { - await _repository.SaveAsync(pageSchema); - } - - public async Task DeleteAsync(string appId, string pageId) - { - await _repository.DeleteAsync(appId, pageId); - } -} \ No newline at end of file diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Domain/MetaRepositories/IDataSourceRepository.cs b/src/DesignEngine/H.LowCode.DesignEngine.Domain/MetaRepositories/IDataSourceRepository.cs index b74ee12f4c633b9ca533c8848e91405e05e44383..aef6e98a2f654eb677be3ebfac87f7c6ab589331 100644 --- a/src/DesignEngine/H.LowCode.DesignEngine.Domain/MetaRepositories/IDataSourceRepository.cs +++ b/src/DesignEngine/H.LowCode.DesignEngine.Domain/MetaRepositories/IDataSourceRepository.cs @@ -1,6 +1,4 @@ -using H.LowCode.DesignEngine.Model; -using H.LowCode.MetaSchema; -using Volo.Abp.Domain.Repositories; +using H.LowCode.MetaSchema; namespace H.LowCode.DesignEngine.Domain.Repositories; @@ -8,6 +6,8 @@ public interface IDataSourceRepository { Task> GetListAsync(string appId); + IList GetAllEntities(string appId); + Task GetAsync(string appId, string id); Task SaveAsync(string appId, DataSourceSchema dataSourceSchema); diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Domain/PartsDomainServices/ComponentLibraryDomainService.cs b/src/DesignEngine/H.LowCode.DesignEngine.Domain/PartsDomainServices/ComponentLibraryDomainService.cs deleted file mode 100644 index d56c7b5360593557c1f45b593eb4f54b6f5fde60..0000000000000000000000000000000000000000 --- a/src/DesignEngine/H.LowCode.DesignEngine.Domain/PartsDomainServices/ComponentLibraryDomainService.cs +++ /dev/null @@ -1,41 +0,0 @@ -using H.LowCode.DesignEngine.Model; -using H.LowCode.DesignEngine.Domain.Repositories; -using H.LowCode.MetaSchema.DesignEngine; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Volo.Abp.Domain.Services; - -namespace H.LowCode.DesignEngine.Domain; - -public class ComponentLibraryDomainService : DomainService, IComponentLibraryDomainService -{ - private readonly IComponentLibraryRepository _repository; - - public ComponentLibraryDomainService(IComponentLibraryRepository repository) - { - _repository = repository; - } - - public async Task> GetListAsync() - { - return await _repository.GetListAsync(); - } - - public async Task GetByIdAsync(string libraryId) - { - return await _repository.GetByIdAsync(libraryId); - } - - public async Task SaveAsync(ComponentLibrarySchema componentLibrary) - { - return await _repository.SaveAsync(componentLibrary); - } - - public async Task DeleteAsync(string libraryId) - { - return await _repository.DeleteAsync(libraryId); - } -} diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Domain/PartsDomainServices/ComponentPartsDomainService.cs b/src/DesignEngine/H.LowCode.DesignEngine.Domain/PartsDomainServices/ComponentPartsDomainService.cs deleted file mode 100644 index 53bc912e49d3de72053d6694cdaad0e25a539df8..0000000000000000000000000000000000000000 --- a/src/DesignEngine/H.LowCode.DesignEngine.Domain/PartsDomainServices/ComponentPartsDomainService.cs +++ /dev/null @@ -1,46 +0,0 @@ -using H.LowCode.DesignEngine.Model; -using H.LowCode.DesignEngine.Domain.Repositories; -using H.LowCode.MetaSchema.DesignEngine; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Volo.Abp.Domain.Services; - -namespace H.LowCode.DesignEngine.Domain; - -public class ComponentPartsDomainService : DomainService, IComponentPartsDomainService -{ - private readonly IComponentPartsRepository _repository; - - public ComponentPartsDomainService(IComponentPartsRepository repository) - { - _repository = repository; - } - - public async Task> GetListAsync(string libraryId) - { - return await _repository.GetListAsync(libraryId); - } - - public async Task> GetAllComponentsAsync(string libraryId) - { - return await _repository.GetAllComponentsAsync(libraryId); - } - - public async Task GetByIdAsync(string libraryId, string componentId) - { - return await _repository.GetByIdAsync(libraryId, componentId); - } - - public async Task SaveAsync(ComponentPartsSchema componentParts) - { - return await _repository.SaveAsync(componentParts); - } - - public async Task DeleteAsync(string libraryId, string componentId) - { - return await _repository.DeleteAsync(libraryId, componentId); - } -} diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Domain/PartsDomainServices/IComponentLibraryDomainService.cs b/src/DesignEngine/H.LowCode.DesignEngine.Domain/PartsDomainServices/IComponentLibraryDomainService.cs deleted file mode 100644 index 300ae787034d573ac74f00ccc35b03b32902eb4f..0000000000000000000000000000000000000000 --- a/src/DesignEngine/H.LowCode.DesignEngine.Domain/PartsDomainServices/IComponentLibraryDomainService.cs +++ /dev/null @@ -1,21 +0,0 @@ -using H.LowCode.DesignEngine.Model; -using H.LowCode.MetaSchema.DesignEngine; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Volo.Abp.Domain.Services; - -namespace H.LowCode.DesignEngine.Domain; - -public interface IComponentLibraryDomainService : IDomainService -{ - Task> GetListAsync(); - - Task GetByIdAsync(string libraryId); - - Task SaveAsync(ComponentLibrarySchema componentLibrary); - - Task DeleteAsync(string libraryId); -} diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Domain/PartsDomainServices/IComponentPartsDomainService.cs b/src/DesignEngine/H.LowCode.DesignEngine.Domain/PartsDomainServices/IComponentPartsDomainService.cs deleted file mode 100644 index 8beb6784ddb807ac2bcf14a573d9614526d5441a..0000000000000000000000000000000000000000 --- a/src/DesignEngine/H.LowCode.DesignEngine.Domain/PartsDomainServices/IComponentPartsDomainService.cs +++ /dev/null @@ -1,22 +0,0 @@ -using H.LowCode.DesignEngine.Model; -using H.LowCode.MetaSchema.DesignEngine; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Volo.Abp.Domain.Services; - -namespace H.LowCode.DesignEngine.Domain; - -public interface IComponentPartsDomainService : IDomainService -{ - Task> GetListAsync(string libraryId); - Task> GetAllComponentsAsync(string libraryId); - - Task GetByIdAsync(string libraryId, string componentId); - - Task SaveAsync(ComponentPartsSchema componentParts); - - Task DeleteAsync(string libraryId, string componentId); -} diff --git a/src/DesignEngine/H.LowCode.DesignEngine.EntityFrameworkCore/DataRepositories/FormDataRepository.cs b/src/DesignEngine/H.LowCode.DesignEngine.EntityFrameworkCore/DataRepositories/FormDataRepository.cs index 8c1a0cdfa242b45308f7facca0275cc95278d6ef..ceda7d25746d664ecc9aac1b0d7c763bd48edfd2 100644 --- a/src/DesignEngine/H.LowCode.DesignEngine.EntityFrameworkCore/DataRepositories/FormDataRepository.cs +++ b/src/DesignEngine/H.LowCode.DesignEngine.EntityFrameworkCore/DataRepositories/FormDataRepository.cs @@ -12,6 +12,10 @@ public class FormDataRepository : IFormDataRepository private DesignEngineDbContext _dbContext; public bool? IsChangeTrackingEnabled => true; + public string? EntityName { get; set; } + + public string ProviderName => throw new NotImplementedException(); + public FormDataRepository(DesignEngineDbContext dbContext) { _dbContext = dbContext; diff --git a/src/DesignEngine/H.LowCode.DesignEngine.EntityFrameworkCore/DataRepositories/TableDataRepository.cs b/src/DesignEngine/H.LowCode.DesignEngine.EntityFrameworkCore/DataRepositories/TableDataRepository.cs index c913db0ba6e3c9a4c9087fa109bf60c687761bea..6b4e96d9e1e5473ebbeaa56ac73497dc41eae568 100644 --- a/src/DesignEngine/H.LowCode.DesignEngine.EntityFrameworkCore/DataRepositories/TableDataRepository.cs +++ b/src/DesignEngine/H.LowCode.DesignEngine.EntityFrameworkCore/DataRepositories/TableDataRepository.cs @@ -10,6 +10,10 @@ public class TableDataRepository : ITableDataRepository { public bool? IsChangeTrackingEnabled => true; + public string? EntityName { get; set; } + + public string ProviderName => throw new NotImplementedException(); + public TableDataRepository(DesignEngineDbContext dbContext) { } diff --git a/src/DesignEngine/H.LowCode.DesignEngine.EntityFrameworkCore/EntityManager/EntityTypeManager.cs b/src/DesignEngine/H.LowCode.DesignEngine.EntityFrameworkCore/EntityManager/EntityTypeManager.cs index 31fbc6f363c56a6169a17bd3b83c5a2986b4632b..2db9f50dceae5209c8b313915c77cc77ecdb071c 100644 --- a/src/DesignEngine/H.LowCode.DesignEngine.EntityFrameworkCore/EntityManager/EntityTypeManager.cs +++ b/src/DesignEngine/H.LowCode.DesignEngine.EntityFrameworkCore/EntityManager/EntityTypeManager.cs @@ -1,13 +1,8 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection.Emit; +using System.Reflection.Emit; using System.Reflection; -using System.Text; -using System.Threading.Tasks; using System.ComponentModel.DataAnnotations; using H.LowCode.Entity; -using H.LowCode.DesignEngine.Domain; +using H.LowCode.DesignEngine.Domain.Repositories; namespace H.LowCode.DesignEngine.EntityFrameworkCore; @@ -20,11 +15,11 @@ public class EntityTypeManager private static List _dynamicEntities = []; - private IDataSourceDomainService _dataSourceDomainService; + private IDataSourceRepository _dataSourceRepository; - public EntityTypeManager(IDataSourceDomainService dataSourceDomainService) + public EntityTypeManager(IDataSourceRepository dataSourceRepository) { - _dataSourceDomainService = dataSourceDomainService; + _dataSourceRepository = dataSourceRepository; } public IReadOnlyList LoadDynamicEntities() @@ -34,7 +29,7 @@ public class EntityTypeManager if(_dynamicEntities.Count > 0) return _dynamicEntities; - var entities = _dataSourceDomainService.GetAllEntities("caseapp"); + var entities = _dataSourceRepository.GetAllEntities("caseapp"); foreach (var entity in entities) { var fields = entity.TableFields.Select(f => new DynamicEntityField() diff --git a/src/DesignEngine/H.LowCode.DesignEngine.EntityFrameworkCore/H.LowCode.DesignEngine.EntityFrameworkCore.csproj b/src/DesignEngine/H.LowCode.DesignEngine.EntityFrameworkCore/H.LowCode.DesignEngine.EntityFrameworkCore.csproj index dcfb689852b9bfda9c7ed5f5dcfd9b0534e3a4fc..e815e4fa1788daebe14ee046df6c76731b83eae0 100644 --- a/src/DesignEngine/H.LowCode.DesignEngine.EntityFrameworkCore/H.LowCode.DesignEngine.EntityFrameworkCore.csproj +++ b/src/DesignEngine/H.LowCode.DesignEngine.EntityFrameworkCore/H.LowCode.DesignEngine.EntityFrameworkCore.csproj @@ -1,6 +1,6 @@  - + diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Host.Client/DesignEngineHostClientModule.cs b/src/DesignEngine/H.LowCode.DesignEngine.Host.Client/DesignEngineHostClientModule.cs index 8302e346e8897c7eb5a253fb78eaec7b904e1fff..3799cb308bf50c739a92f9e363a661fa551e16d3 100644 --- a/src/DesignEngine/H.LowCode.DesignEngine.Host.Client/DesignEngineHostClientModule.cs +++ b/src/DesignEngine/H.LowCode.DesignEngine.Host.Client/DesignEngineHostClientModule.cs @@ -1,9 +1,10 @@ -using H.LowCode.ComponentBase; +using H.LowCode.Application.Contracts; +using H.LowCode.ComponentBase; using H.LowCode.Components.Defaults; using H.LowCode.DesignEngine.Application.Contracts; using H.LowCode.MyApp; using H.LowCode.PartsDesignEngine; -using H.LowCode.Workbench; +using H.LowCode.Portal; using Microsoft.AspNetCore.Components.WebAssembly.Hosting; using Volo.Abp.Autofac.WebAssembly; using Volo.Abp.Http.Client; @@ -18,16 +19,14 @@ namespace H.LowCode.DesignEngine.Host.Client; typeof(AbpHttpClientModule), typeof(DesignEngineApplicationContractsModule), //=====lowcode-web=====// - //Workbench - typeof(LowCodeWorkbenchModule), + //Portal + typeof(LowCodePortalModule), //DesignEngine typeof(DesignEngineModule), typeof(MyAppModule), typeof(PartsDesignEngineModule), //Components - typeof(LowCodeDefaultComponentModule), - //ComponentBase - typeof(LowCodeComponentBaseModule) + typeof(LowCodeDefaultComponentModule) )] public class DesignEngineHostClientModule : AbpModule { @@ -59,5 +58,9 @@ public class DesignEngineHostClientModule : AbpModule typeof(DesignEngineApplicationContractsModule).Assembly, RemoteServiceName ); + context.Services.AddHttpClientProxies( + typeof(LowCodeApplicationContractsModule).Assembly, + RemoteServiceName + ); } } diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Host.Client/H.LowCode.DesignEngine.Host.Client.csproj b/src/DesignEngine/H.LowCode.DesignEngine.Host.Client/H.LowCode.DesignEngine.Host.Client.csproj index da8a127d768e51ae0be5c2990bb7aef0cf00aa1f..2fd161f3ac1769bb2a070f6b98d51d8d1e7600d5 100644 --- a/src/DesignEngine/H.LowCode.DesignEngine.Host.Client/H.LowCode.DesignEngine.Host.Client.csproj +++ b/src/DesignEngine/H.LowCode.DesignEngine.Host.Client/H.LowCode.DesignEngine.Host.Client.csproj @@ -1,12 +1,11 @@  - + true Default - true - false + true @@ -23,7 +22,7 @@ - + diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Host.Client/LowCodeGlobalVariables.cs b/src/DesignEngine/H.LowCode.DesignEngine.Host.Client/LowCodeGlobalVariables.cs index 81c682dde5d1660f3074f5aba36381a6d9ef37c3..fdc0a963ae84db0128f1a2315159b93680cef3f1 100644 --- a/src/DesignEngine/H.LowCode.DesignEngine.Host.Client/LowCodeGlobalVariables.cs +++ b/src/DesignEngine/H.LowCode.DesignEngine.Host.Client/LowCodeGlobalVariables.cs @@ -4,11 +4,11 @@ namespace H.LowCode.DesignEngine.Host.Client; public static class LowCodeGlobalVariables { - public static readonly Type LowCodeDefaultLayout = typeof(Workbench.WorkbenchLayout); + public static readonly Type LowCodeDefaultLayout = typeof(DesignEngineBase.DesignEngineNavLayout); public static readonly Assembly[] AdditionalAssemblies = [ - typeof(Workbench._Imports).Assembly, + typeof(Portal._Imports).Assembly, typeof(DesignEngine._Imports).Assembly, typeof(PartsDesignEngine._Imports).Assembly, typeof(MyApp._Imports).Assembly diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Host.Client/wwwroot/appsettings.Development.json b/src/DesignEngine/H.LowCode.DesignEngine.Host.Client/wwwroot/appsettings.Development.json index b637d40ec00fb8622cf5074eda17f968b00f9f06..214f18e1ee92d9a81b597d7d9c23a8628d091ada 100644 --- a/src/DesignEngine/H.LowCode.DesignEngine.Host.Client/wwwroot/appsettings.Development.json +++ b/src/DesignEngine/H.LowCode.DesignEngine.Host.Client/wwwroot/appsettings.Development.json @@ -1,4 +1,11 @@ { + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning", + "Microsoft.AspNetCore.Components.WebAssembly": "Warning" + } + }, "RemoteServices": { "Default": { "BaseUrl": "https://localhost:5181" diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Host.Client/wwwroot/appsettings.json b/src/DesignEngine/H.LowCode.DesignEngine.Host.Client/wwwroot/appsettings.json index b637d40ec00fb8622cf5074eda17f968b00f9f06..214f18e1ee92d9a81b597d7d9c23a8628d091ada 100644 --- a/src/DesignEngine/H.LowCode.DesignEngine.Host.Client/wwwroot/appsettings.json +++ b/src/DesignEngine/H.LowCode.DesignEngine.Host.Client/wwwroot/appsettings.json @@ -1,4 +1,11 @@ { + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning", + "Microsoft.AspNetCore.Components.WebAssembly": "Warning" + } + }, "RemoteServices": { "Default": { "BaseUrl": "https://localhost:5181" diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Host/Components/App.razor b/src/DesignEngine/H.LowCode.DesignEngine.Host/Components/App.razor index f7791fc78843f5d524627c8d9f7b08772a0d1ede..a83049942390abeafb8ba6afcb7946297a697f61 100644 --- a/src/DesignEngine/H.LowCode.DesignEngine.Host/Components/App.razor +++ b/src/DesignEngine/H.LowCode.DesignEngine.Host/Components/App.razor @@ -9,6 +9,7 @@ + @@ -21,14 +22,15 @@ - + + - + diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Host/Components/_Imports.razor b/src/DesignEngine/H.LowCode.DesignEngine.Host/Components/_Imports.razor index bfd93b1c7f000c8a444b248daf52ec920531ec6e..06bf1cd375c1b2d8e4caaeb1f887fbf0d3746b37 100644 --- a/src/DesignEngine/H.LowCode.DesignEngine.Host/Components/_Imports.razor +++ b/src/DesignEngine/H.LowCode.DesignEngine.Host/Components/_Imports.razor @@ -8,4 +8,4 @@ @using Microsoft.JSInterop @using H.LowCode.DesignEngine.Host @using H.LowCode.DesignEngine.Host.Client -@using H.LowCode.DesignEngine.Host.Components +@using H.LowCode.DesignEngine.Host.Components \ No newline at end of file diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Host/DesignEngineHostModule.cs b/src/DesignEngine/H.LowCode.DesignEngine.Host/DesignEngineHostModule.cs index dd3dec457bcf0ccf20c24e2eb69ca02a075a68dc..a725eb98ff9f7347421b8cb0f9ddb262b79bd6e0 100644 --- a/src/DesignEngine/H.LowCode.DesignEngine.Host/DesignEngineHostModule.cs +++ b/src/DesignEngine/H.LowCode.DesignEngine.Host/DesignEngineHostModule.cs @@ -1,11 +1,11 @@ -using H.LowCode.ComponentBase; +using H.LowCode.ComponentBase; using H.LowCode.Components.Defaults; using H.LowCode.DesignEngine.Application; using H.LowCode.DesignEngine.EntityFrameworkCore; using H.LowCode.DesignEngine.Repository.JsonFile; using H.LowCode.MyApp; using H.LowCode.PartsDesignEngine; -using H.LowCode.Workbench; +using H.LowCode.Portal; using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.Autofac; using Volo.Abp.Modularity; @@ -21,16 +21,14 @@ namespace H.LowCode.DesignEngine.Host; typeof(DesignEngineEntityFrameworkCoreModule), typeof(DesignEngineJsonFileRepositoryModule), //=====lowcode-web=====// - //Workbench - typeof(LowCodeWorkbenchModule), + //Portal + typeof(LowCodePortalModule), //DesignEngine typeof(DesignEngineModule), typeof(MyAppModule), typeof(PartsDesignEngineModule), //Components - typeof(LowCodeDefaultComponentModule), - //ComponentBase - typeof(LowCodeComponentBaseModule) + typeof(LowCodeDefaultComponentModule) )] public class DesignEngineHostModule : AbpModule { diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Host/H.LowCode.DesignEngine.Host.csproj b/src/DesignEngine/H.LowCode.DesignEngine.Host/H.LowCode.DesignEngine.Host.csproj index 1dc8207e95faccaa30f6084519d46616a03bf1cd..62561de502ec17ee5435041344306cf4a9de8511 100644 --- a/src/DesignEngine/H.LowCode.DesignEngine.Host/H.LowCode.DesignEngine.Host.csproj +++ b/src/DesignEngine/H.LowCode.DesignEngine.Host/H.LowCode.DesignEngine.Host.csproj @@ -1,6 +1,10 @@  - + + + + true + diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Host/Program.cs b/src/DesignEngine/H.LowCode.DesignEngine.Host/Program.cs index 7d8761f9f69cf7534be6e9c351de3aa796f35118..995405fa11141d9cfdeccc9bb8308e1d96375916 100644 --- a/src/DesignEngine/H.LowCode.DesignEngine.Host/Program.cs +++ b/src/DesignEngine/H.LowCode.DesignEngine.Host/Program.cs @@ -13,12 +13,28 @@ builder.Services.AddRazorComponents() .AddInteractiveServerComponents() .AddInteractiveWebAssemblyComponents(); +// Configure SignalR and Circuit options for Blazor Server +builder.Services.AddSignalR(options => +{ + options.MaximumReceiveMessageSize = 1024 * 1024; // 1MB + options.EnableDetailedErrors = builder.Environment.IsDevelopment(); +}); + +builder.Services.Configure(options => +{ + options.DisconnectedCircuitMaxRetained = 100; + options.DisconnectedCircuitRetentionPeriod = TimeSpan.FromMinutes(3); + options.JSInteropDefaultCallTimeout = TimeSpan.FromMinutes(1); + options.MaxBufferedUnacknowledgedRenderBatches = 10; + options.DetailedErrors = builder.Environment.IsDevelopment(); +}); + builder.Services.AddControllers().AddJsonOptions(options => { options.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase; }); -// Ӧѹ +// ������Ӧѹ�� builder.Services.AddResponseCompression(options => { options.Providers.Add(); @@ -52,6 +68,9 @@ else app.UseHsts(); } +app.UseStatusCodePagesWithReExecute("/not-found", createScopeForStatusCodePages: true); +app.UseHttpsRedirection(); + app.UseResponseCompression(); app.UseStaticFiles(new StaticFileOptions { @@ -61,8 +80,6 @@ app.UseStaticFiles(new StaticFileOptions } }); -app.UseHttpsRedirection(); - app.MapStaticAssets(); app.UseRouting(); app.UseAntiforgery(); @@ -72,6 +89,7 @@ app.MapControllers(); app.MapRazorComponents() .AddInteractiveServerRenderMode() .AddInteractiveWebAssemblyRenderMode() - .AddAdditionalAssemblies(LowCodeGlobalVariables.AdditionalAssemblies); //LowCode + .AddAdditionalAssemblies(LowCodeGlobalVariables.AdditionalAssemblies) //LowCode + .AllowAnonymous(); await app.RunAsync(); \ No newline at end of file diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Host/appsettings.Development.json b/src/DesignEngine/H.LowCode.DesignEngine.Host/appsettings.Development.json index 0c208ae9181e5e5717e47ec1bd59368aebc6066e..f8063ef188a42632a2567f859434977d653bab2b 100644 --- a/src/DesignEngine/H.LowCode.DesignEngine.Host/appsettings.Development.json +++ b/src/DesignEngine/H.LowCode.DesignEngine.Host/appsettings.Development.json @@ -4,5 +4,6 @@ "Default": "Information", "Microsoft.AspNetCore": "Warning" } - } + }, + "DetailedErrors": true } diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Host/appsettings.json b/src/DesignEngine/H.LowCode.DesignEngine.Host/appsettings.json index 251a7e05410b133e356e105b31f675bbd9116074..9d21e3cdebcf0e55f540ca33cd89ed86c0f8ea6d 100644 --- a/src/DesignEngine/H.LowCode.DesignEngine.Host/appsettings.json +++ b/src/DesignEngine/H.LowCode.DesignEngine.Host/appsettings.json @@ -26,6 +26,10 @@ { "AppId": "testapp", "SiteUrl": "https://localhost:5191" + }, + { + "AppId": "timekeeping", + "SiteUrl": "https://localhost:5191" } ] } diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Model/H.LowCode.DesignEngine.Model.csproj b/src/DesignEngine/H.LowCode.DesignEngine.Model/H.LowCode.DesignEngine.Model.csproj index bf01f631036c935f0e1dcaf26a718fc59f4a61db..dd3959f6f5cb177bb3c2c563ecbbb2716f760614 100644 --- a/src/DesignEngine/H.LowCode.DesignEngine.Model/H.LowCode.DesignEngine.Model.csproj +++ b/src/DesignEngine/H.LowCode.DesignEngine.Model/H.LowCode.DesignEngine.Model.csproj @@ -1,6 +1,6 @@  - + diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Model/Models/AppListModel.cs b/src/DesignEngine/H.LowCode.DesignEngine.Model/Models/AppListModel.cs index 7374f4e6c65f7981a2e00c3aa6002f6fee37d1b7..aeeea7f1923f59a452f4ac417e229402b6e37799 100644 --- a/src/DesignEngine/H.LowCode.DesignEngine.Model/Models/AppListModel.cs +++ b/src/DesignEngine/H.LowCode.DesignEngine.Model/Models/AppListModel.cs @@ -6,21 +6,21 @@ namespace H.LowCode.DesignEngine.Model; public class AppListModel { - public string Id { get; set; } + public required string Id { get; set; } [JsonPropertyName("url")] - public string SiteUrl { get; set; } + public string? SiteUrl { get; set; } [JsonPropertyName("n")] - public string Name { get; set; } + public string? Name { get; set; } - public string Icon { get; set; } + public string? Icon { get; set; } [JsonPropertyName("pic")] - public string Picture { get; set; } + public string? Picture { get; set; } [JsonPropertyName("desc")] - public string Description { get; set; } + public string? Description { get; set; } [JsonPropertyName("pub")] public PublishStatusEnum PublishStatus { get; set; } diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Model/Models/ComponentListModel.cs b/src/DesignEngine/H.LowCode.DesignEngine.Model/Models/ComponentListModel.cs new file mode 100644 index 0000000000000000000000000000000000000000..d3680ae8b9accae3b7a926bdb7a06e05484a4fed --- /dev/null +++ b/src/DesignEngine/H.LowCode.DesignEngine.Model/Models/ComponentListModel.cs @@ -0,0 +1,16 @@ +using System; +using System.Text.Json.Serialization; + +namespace H.LowCode.DesignEngine.Model; + +public class ComponentListModel +{ + [JsonPropertyName("id")] + public string Id { get; set; } + + [JsonPropertyName("n")] + public string Name { get; set; } + + [JsonPropertyName("lb")] + public string Label { get; set; } +} diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Model/Models/DataSourceListModel.cs b/src/DesignEngine/H.LowCode.DesignEngine.Model/Models/DataSourceListModel.cs index ab96c1cac2e5c4e2daa4c60b0d34e5cf1e65f86f..3cccbcc3adcdefaeb408cd83c29a86779ae9683f 100644 --- a/src/DesignEngine/H.LowCode.DesignEngine.Model/Models/DataSourceListModel.cs +++ b/src/DesignEngine/H.LowCode.DesignEngine.Model/Models/DataSourceListModel.cs @@ -28,7 +28,7 @@ public class DataSourceListModel [JsonPropertyName("pub")] public bool PublishStatus { get; set; } - public string ModifiedUser { get; set; } + public string? ModifiedUser { get; set; } - public DateTime ModifiedTime { get; set; } + public DateTime? ModifiedTime { get; set; } } diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Model/Models/PageListModel.cs b/src/DesignEngine/H.LowCode.DesignEngine.Model/Models/PageListModel.cs index 06a6f18c9b4ff5cb479e85b430cfae0d060186b8..0439e5c8d462adac020ed27601dddd5a3449ee3b 100644 --- a/src/DesignEngine/H.LowCode.DesignEngine.Model/Models/PageListModel.cs +++ b/src/DesignEngine/H.LowCode.DesignEngine.Model/Models/PageListModel.cs @@ -17,5 +17,5 @@ public class PageListModel [JsonPropertyName("pub")] public int PublishStatus { get; set; } - public DateTime ModifiedTime { get; set; } + public DateTime? ModifiedTime { get; set; } } diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Model/PartsModels/ComponentPartsListModel.cs b/src/DesignEngine/H.LowCode.DesignEngine.Model/PartsModels/ComponentPartsListModel.cs index 727f0ea545e57c8b395fb472df31efbb7b88ca44..2b29d2380c297b0222b31e2c70f748ce24b1f8c5 100644 --- a/src/DesignEngine/H.LowCode.DesignEngine.Model/PartsModels/ComponentPartsListModel.cs +++ b/src/DesignEngine/H.LowCode.DesignEngine.Model/PartsModels/ComponentPartsListModel.cs @@ -1,9 +1,5 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Text.Json.Serialization; -using System.Threading.Tasks; namespace H.LowCode.DesignEngine.Model; diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Repository.JsonFile/Base/PartsFileRepositoryBase.cs b/src/DesignEngine/H.LowCode.DesignEngine.Repository.JsonFile/Base/PartsFileRepositoryBase.cs index 134ee70752b86a74c7ed8ef83884245eecfcb3f7..97c123bb69fca7427cc4016a16a82f99f935dd7a 100644 --- a/src/DesignEngine/H.LowCode.DesignEngine.Repository.JsonFile/Base/PartsFileRepositoryBase.cs +++ b/src/DesignEngine/H.LowCode.DesignEngine.Repository.JsonFile/Base/PartsFileRepositoryBase.cs @@ -12,7 +12,7 @@ public abstract class PartsFileRepositoryBase { public bool? IsChangeTrackingEnabled { get; set; } - protected static string _metaBaseDir; + protected static string? _metaBaseDir; public PartsFileRepositoryBase(IOptions metaOption) { @@ -20,10 +20,10 @@ public abstract class PartsFileRepositoryBase IsChangeTrackingEnabled = false; } - protected static string ReadAllText(string fileName) + protected static string? ReadAllText(string fileName) { if (!File.Exists(fileName)) - throw new FileNotFoundException(fileName); + return null; return File.ReadAllText(fileName, Encoding.UTF8); } diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Repository.JsonFile/H.LowCode.DesignEngine.Repository.JsonFile.csproj b/src/DesignEngine/H.LowCode.DesignEngine.Repository.JsonFile/H.LowCode.DesignEngine.Repository.JsonFile.csproj index 4c08f036c35a3e36a986e1a965fd0c92369797c4..d628bfded772985895383ddb26c577e234753b12 100644 --- a/src/DesignEngine/H.LowCode.DesignEngine.Repository.JsonFile/H.LowCode.DesignEngine.Repository.JsonFile.csproj +++ b/src/DesignEngine/H.LowCode.DesignEngine.Repository.JsonFile/H.LowCode.DesignEngine.Repository.JsonFile.csproj @@ -1,6 +1,6 @@  - + diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Repository.JsonFile/PartsRepositories/ComponentLibraryRepository.cs b/src/DesignEngine/H.LowCode.DesignEngine.Repository.JsonFile/PartsRepositories/ComponentLibraryRepository.cs index dd05c3c5ae26f30cd2203d2264e455c71e903a54..7a3c31b697e7e4d4ff2300134f4a5bc88c31f4e7 100644 --- a/src/DesignEngine/H.LowCode.DesignEngine.Repository.JsonFile/PartsRepositories/ComponentLibraryRepository.cs +++ b/src/DesignEngine/H.LowCode.DesignEngine.Repository.JsonFile/PartsRepositories/ComponentLibraryRepository.cs @@ -38,7 +38,7 @@ public class ComponentLibraryRepository : PartsFileRepositoryBase, IComponentLib if (!File.Exists(fileName)) continue; - var librarySchemaJson = ReadAllText(fileName); + var librarySchemaJson = ReadAllText(fileName) ?? throw new FileNotFoundException(fileName); var librarySchema = librarySchemaJson.FromJson(); list.Add(librarySchema); } @@ -49,7 +49,7 @@ public class ComponentLibraryRepository : PartsFileRepositoryBase, IComponentLib { string fileName = string.Format(componentLibraryFileName_Format, _metaBaseDir, libraryId, libraryId); - var componentLibrarySchemaJson = ReadAllText(fileName); + var componentLibrarySchemaJson = ReadAllText(fileName) ?? throw new FileNotFoundException(fileName); var componentLibrary = componentLibrarySchemaJson.FromJson(); return await Task.FromResult(componentLibrary); } diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Repository.JsonFile/PartsRepositories/ComponentPartsRepository.cs b/src/DesignEngine/H.LowCode.DesignEngine.Repository.JsonFile/PartsRepositories/ComponentPartsRepository.cs index f5030face6d415ef29d7a0007b455b8ef136cfd4..03c0cce725958468e9e8b0aba4908682ffee49f5 100644 --- a/src/DesignEngine/H.LowCode.DesignEngine.Repository.JsonFile/PartsRepositories/ComponentPartsRepository.cs +++ b/src/DesignEngine/H.LowCode.DesignEngine.Repository.JsonFile/PartsRepositories/ComponentPartsRepository.cs @@ -35,7 +35,7 @@ public class ComponentPartsRepository : PartsFileRepositoryBase, IComponentParts if (fileName.EndsWith($"{libraryId}.json")) continue; - var componentPartsSchemaJson = ReadAllText(fileName); + var componentPartsSchemaJson = ReadAllText(fileName) ?? throw new FileNotFoundException(fileName); if (string.IsNullOrWhiteSpace(componentPartsSchemaJson)) continue; @@ -80,7 +80,7 @@ public class ComponentPartsRepository : PartsFileRepositoryBase, IComponentParts if (fileName.EndsWith($"{libraryId}.json")) continue; - var componentPartsSchemaJson = ReadAllText(fileName); + var componentPartsSchemaJson = ReadAllText(fileName) ?? throw new FileNotFoundException(fileName); if (string.IsNullOrWhiteSpace(componentPartsSchemaJson)) continue; @@ -102,7 +102,7 @@ public class ComponentPartsRepository : PartsFileRepositoryBase, IComponentParts { string fileName = string.Format(componentPartsFileName_Format, _metaBaseDir, libraryId, componentId); - var componentPartsSchemaJson = ReadAllText(fileName); + var componentPartsSchemaJson = ReadAllText(fileName) ?? throw new FileNotFoundException(fileName); var componentParts = componentPartsSchemaJson.FromJson(); return await Task.FromResult(componentParts); } diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Repository.JsonFile/Repositories/DataSourceFileRepository.cs b/src/DesignEngine/H.LowCode.DesignEngine.Repository.JsonFile/Repositories/DataSourceFileRepository.cs index b1e1c420fc5714188008ac772c88f53f8635089e..73dfe46488200e763d224f7f1405b803ffda47f3 100644 --- a/src/DesignEngine/H.LowCode.DesignEngine.Repository.JsonFile/Repositories/DataSourceFileRepository.cs +++ b/src/DesignEngine/H.LowCode.DesignEngine.Repository.JsonFile/Repositories/DataSourceFileRepository.cs @@ -2,14 +2,14 @@ using H.LowCode.DesignEngine.Domain.Repositories; using H.LowCode.MetaSchema; using Microsoft.Extensions.Options; -using System.Collections.Generic; +using System.Linq; using System.Text; namespace H.LowCode.DesignEngine.Repository.JsonFile; public class DataSourceFileRepository : FileRepositoryBase, IDataSourceRepository { - private static string dataSourceName_Format = @"{0}\{1}\datasource\{2}.json"; + private static readonly string dataSourceName_Format = @"{0}\{1}\datasource\{2}.json"; public DataSourceFileRepository(IOptions metaOption) : base(metaOption) { @@ -38,6 +38,12 @@ public class DataSourceFileRepository : FileRepositoryBase, IDataSourceRepositor return list; } + public IList GetAllEntities(string appId) + { + var list = GetListAsync(appId).Result; + return [.. list.Where(t => t.DataSourceType == ComponentDataSourceTypeEnum.DB)]; + } + public async Task GetAsync(string appId, string id) { string fileName = string.Format(dataSourceName_Format, _metaBaseDir, appId, id); diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Repository.RemoteService/H.LowCode.DesignEngine.Repository.RemoteService.csproj b/src/DesignEngine/H.LowCode.DesignEngine.Repository.RemoteService/H.LowCode.DesignEngine.Repository.RemoteService.csproj index 4c08f036c35a3e36a986e1a965fd0c92369797c4..d628bfded772985895383ddb26c577e234753b12 100644 --- a/src/DesignEngine/H.LowCode.DesignEngine.Repository.RemoteService/H.LowCode.DesignEngine.Repository.RemoteService.csproj +++ b/src/DesignEngine/H.LowCode.DesignEngine.Repository.RemoteService/H.LowCode.DesignEngine.Repository.RemoteService.csproj @@ -1,6 +1,6 @@  - + diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Repository.RemoteService/Repositories/AppRemoteServiceRepository.cs b/src/DesignEngine/H.LowCode.DesignEngine.Repository.RemoteService/Repositories/AppRemoteServiceRepository.cs index a48cfc87ae3966efb954acf0c48cf9d5d99059d4..f9fba1b2279e66e2066164932fd0a72366938fba 100644 --- a/src/DesignEngine/H.LowCode.DesignEngine.Repository.RemoteService/Repositories/AppRemoteServiceRepository.cs +++ b/src/DesignEngine/H.LowCode.DesignEngine.Repository.RemoteService/Repositories/AppRemoteServiceRepository.cs @@ -2,8 +2,6 @@ using H.LowCode.DesignEngine.Domain.Repositories; using H.LowCode.MetaSchema.DesignEngine; using Microsoft.Extensions.Options; -using System.Collections.Generic; -using System.Text; namespace H.LowCode.DesignEngine.Repository.RemoteService; diff --git a/src/DesignEngine/H.LowCode.DesignEngine.Repository.RemoteService/Repositories/DataSourceRemoteServiceRepository.cs b/src/DesignEngine/H.LowCode.DesignEngine.Repository.RemoteService/Repositories/DataSourceRemoteServiceRepository.cs index a6b0d06c0d428077aa406767c866c2ab584d490d..f027b8dd5f83a7afd40dc1b900fbe285d0870ca7 100644 --- a/src/DesignEngine/H.LowCode.DesignEngine.Repository.RemoteService/Repositories/DataSourceRemoteServiceRepository.cs +++ b/src/DesignEngine/H.LowCode.DesignEngine.Repository.RemoteService/Repositories/DataSourceRemoteServiceRepository.cs @@ -1,10 +1,7 @@ using H.LowCode.Configuration; -using H.LowCode.DesignEngine.Model; using H.LowCode.DesignEngine.Domain.Repositories; using H.LowCode.MetaSchema; using Microsoft.Extensions.Options; -using System.Collections.Generic; -using System.Text; namespace H.LowCode.DesignEngine.Repository.RemoteService; @@ -15,17 +12,17 @@ public class DataSourceRemoteServiceRepository : RemoteServiceRepositoryBase, ID } - public async Task DeleteAsync(string appId, string id) + public async Task> GetListAsync(string appId) { throw new NotImplementedException(); } - public async Task GetAsync(string appId, string id) + public IList GetAllEntities(string appId) { throw new NotImplementedException(); } - public async Task> GetListAsync(string appId) + public async Task GetAsync(string appId, string id) { throw new NotImplementedException(); } @@ -34,4 +31,9 @@ public class DataSourceRemoteServiceRepository : RemoteServiceRepositoryBase, ID { throw new NotImplementedException(); } + + public async Task DeleteAsync(string appId, string id) + { + throw new NotImplementedException(); + } } diff --git a/src/DesignEngine/H.LowCode.DesignEngine/ComponentPanel/ComponentPanel.razor b/src/DesignEngine/H.LowCode.DesignEngine/ComponentPanel/ComponentPanel.razor index 1e721d8b9432f534e8079fbf1b158178254347ed..fac12c9550c44fcc2f45fb14985889a9b329af07 100644 --- a/src/DesignEngine/H.LowCode.DesignEngine/ComponentPanel/ComponentPanel.razor +++ b/src/DesignEngine/H.LowCode.DesignEngine/ComponentPanel/ComponentPanel.razor @@ -1,10 +1,8 @@ -@namespace H.LowCode.DesignEngine +@namespace H.LowCode.DesignEngine @inherits DesignEngineLowCodeComponentBase @inject IComponentLibraryAppService ComponentLibraryAppService @inject IComponentPartsAppService ComponentPartsAppService -@* @inject ComponentState> ComponentLibrariesState *@ -@inject ComponentState> ComponentPartsListState @@ -68,21 +66,14 @@ @code { - private IList _componentLibraries; - private IList _componentPartsList; + [PersistentState] + public IList? _componentPartsList { get; set; } protected override async Task OnInitializedAsync() { await base.OnInitializedAsync(); - // _componentLibraries = await ComponentLibrariesState.GetOrAddAsync(this, async () => - // { - // return await LoadComponentLibraries(); - // }); - _componentPartsList = await ComponentPartsListState.GetOrAddAsync(this, async () => - { - return await LoadComponentPartsAsync(); - }); + _componentPartsList = (await LoadComponentPartsAsync()) ?? []; } private async Task> LoadComponentLibraries() diff --git a/src/DesignEngine/H.LowCode.DesignEngine/ComponentPanel/DragItem.razor b/src/DesignEngine/H.LowCode.DesignEngine/ComponentPanel/DragItem.razor index 0a6577e59ebc650fcb051abee34ea7049a535fd3..0d7a9ceb361f6199f0ee899c39b5e004b4320d34 100644 --- a/src/DesignEngine/H.LowCode.DesignEngine/ComponentPanel/DragItem.razor +++ b/src/DesignEngine/H.LowCode.DesignEngine/ComponentPanel/DragItem.razor @@ -1,4 +1,4 @@ -@namespace H.LowCode.DesignEngine +@namespace H.LowCode.DesignEngine @inherits DesignEngineLowCodeComponentBase @inject DragDropStateService DragDropStateService diff --git a/src/DesignEngine/H.LowCode.DesignEngine/DesignEngineModule.cs b/src/DesignEngine/H.LowCode.DesignEngine/DesignEngineModule.cs index cd842b577fc88c40153d89087cf0dd0d3a08bf2b..2bc7dc55de4fb38f10a62876248bc43e69c7b040 100644 --- a/src/DesignEngine/H.LowCode.DesignEngine/DesignEngineModule.cs +++ b/src/DesignEngine/H.LowCode.DesignEngine/DesignEngineModule.cs @@ -1,4 +1,5 @@ -using H.LowCode.DesignEngine.Abstraction; +using H.LowCode.DesignEngineBase; +using H.LowCode.MetaSchema.Services; using Microsoft.Extensions.DependencyInjection; using Volo.Abp.Modularity; @@ -11,5 +12,6 @@ public class DesignEngineModule : AbpModule context.Services.AddAntDesign(); context.Services.AddSingleton(typeof(DragDropStateService)); + context.Services.AddTransient(); } } diff --git a/src/DesignEngine/H.LowCode.DesignEngine/DesignPanel/DesignPanel.razor b/src/DesignEngine/H.LowCode.DesignEngine/DesignPanel/DesignPanel.razor index 581abba5e1669793dd98b27c85a10d6d682b9301..af1f2282cf83ab90e9f4248ee0834db04ef1698c 100644 --- a/src/DesignEngine/H.LowCode.DesignEngine/DesignPanel/DesignPanel.razor +++ b/src/DesignEngine/H.LowCode.DesignEngine/DesignPanel/DesignPanel.razor @@ -7,7 +7,7 @@ @if (_rootComponent != null) {
- +
} @@ -36,7 +36,11 @@ var rootComponent = DragDropStateService.GetRootComponent(PageCascading.AppId, PageCascading.PageId); if (rootComponent == null) { - rootComponent = new ComponentPartsSchema(); + rootComponent = new ComponentPartsSchema() + { + Id = "root", + ComponentId = "root" + }; rootComponent.Name = "root"; rootComponent.Refresh = StateHasChanged; } diff --git a/src/DesignEngine/H.LowCode.DesignEngine/H.LowCode.DesignEngine.csproj b/src/DesignEngine/H.LowCode.DesignEngine/H.LowCode.DesignEngine.csproj index da3fea0b2a1aaf3258c70d3f767c9ea67bba4dca..c3898af160c352fecacdbf81c7c29108e891edf1 100644 --- a/src/DesignEngine/H.LowCode.DesignEngine/H.LowCode.DesignEngine.csproj +++ b/src/DesignEngine/H.LowCode.DesignEngine/H.LowCode.DesignEngine.csproj @@ -1,30 +1,30 @@  - + - + - - - + + + + + + + - + - - - - diff --git a/src/DesignEngine/H.LowCode.DesignEngine/Pages/DesignPage.razor b/src/DesignEngine/H.LowCode.DesignEngine/Pages/DesignPage.razor index c87689c628577ac685292ecd00d11f4b146b5e24..c07f4341f29e2835ce74d8949f3702e3dfdb228d 100644 --- a/src/DesignEngine/H.LowCode.DesignEngine/Pages/DesignPage.razor +++ b/src/DesignEngine/H.LowCode.DesignEngine/Pages/DesignPage.razor @@ -1,11 +1,10 @@ -@page "/designer/{AppId}/{PageId}" +@page "/designer/{AppId}/{PageId}" @namespace H.LowCode.DesignEngine @inherits DesignEngineLowCodePageComponentBase @layout DesignEngineLayout @inject IPageAppService PageAppService @inject DragDropStateService DragDropStateService -@inject ComponentState PagePartsSchemaState @($"{_pageCascadingModel.PageName} - 页面设计器") @@ -52,7 +51,9 @@ [Parameter] public string PageId { get; set; } - private PagePartsSchema _pageSchema; + [PersistentState] + public PagePartsSchema _pageSchema { get; set; } + private PageCascadingModel _pageCascadingModel; private bool _isNewPage; @@ -62,10 +63,8 @@ _pageCascadingModel = new() { AppId = AppId, PageId = PageId, PageName = "..." }; - _pageSchema = await PagePartsSchemaState.GetOrAddAsync(this, async () => - { - return await LoadPageSchemaAsync(); - }); + _pageSchema = await LoadPageSchemaAsync(); + SetPageCascadingModel(_pageSchema); } @@ -126,7 +125,9 @@ if (_pageSchema == null) throw new NullReferenceException(nameof(_pageSchema)); - _pageSchema.Components = DragDropStateService.GetRootComponent(_pageSchema.AppId, _pageSchema.Id).Childrens; + var pageAllComponents = DragDropStateService.GetRootComponent(_pageSchema.AppId, _pageSchema.Id).Childrens; + + _pageSchema.Components = pageAllComponents; return _pageSchema; } diff --git a/src/DesignEngine/H.LowCode.DesignEngine/SettingPanel/EventSetting.razor b/src/DesignEngine/H.LowCode.DesignEngine/SettingPanel/EventSetting.razor deleted file mode 100644 index 349d715bf9469d7650c05c7eed6b759e312a50e5..0000000000000000000000000000000000000000 --- a/src/DesignEngine/H.LowCode.DesignEngine/SettingPanel/EventSetting.razor +++ /dev/null @@ -1,70 +0,0 @@ -@namespace H.LowCode.DesignEngine -@inherits DesignEngineLowCodeComponentBase - -@if (Component != null) -{ - - - - - - - OnClick - - - OnFocus - - - OnBlur - - - 自定义事件 - - - - - - - - - -} - - - - - - - - - - - - -@code { - [Parameter] - public ComponentPartsSchema Component { get; set; } - - private bool _visible; - private string _selectedValue; - - private void AddEvent() - { - Console.WriteLine($"eventsetting-modal-visible:{_visible}"); - _visible = true; - } - - private void AddCustomEvent() - { - _visible = true; - } -} diff --git a/src/DesignEngine/H.LowCode.DesignEngine/SettingPanel/PageSetting.razor b/src/DesignEngine/H.LowCode.DesignEngine/SettingPanel/PageSetting.razor index 0e95d5b57999ad13f503a728528608096e96b36f..910ef51cb8e0243d1bb52a31c3506f4d78b47716 100644 --- a/src/DesignEngine/H.LowCode.DesignEngine/SettingPanel/PageSetting.razor +++ b/src/DesignEngine/H.LowCode.DesignEngine/SettingPanel/PageSetting.razor @@ -1,4 +1,4 @@ -@namespace H.LowCode.DesignEngine +@namespace H.LowCode.DesignEngine @inherits DesignEngineLowCodeComponentBase @if (Page != null) @@ -43,8 +43,19 @@ - - - - - - - 待发布 - 已发布 - - - -
- 组件设计面板属性: - - - - @if (context.IsContainer == false && context.IsSupportDataSource) - { - 数据源: - - - - } -
-
- - - - - - - -@code { - [Parameter] - public string LibraryId { get; set; } - - [Parameter] - public Action Refresh { get; set; } - - IEnumerable selectedRows; - - private bool _formVisible = false; - private Form _form; - private string _textComponentFragment; - private string _textDataSource; - private string _textAttributeDefineGroups; - private IList _componentPartsList; - private ComponentPartsSchema _componentPartsSchema = new ComponentPartsSchema(); - - private bool _textFormVisible = false; - private string _textFormValue; - - IDictionary _parameterEditCache = new Dictionary(); - - protected override async Task OnInitializedAsync() - { - await base.OnInitializedAsync(); - - _componentPartsList = await ComponentPartsListState.GetOrAddAsync(this, async () => - { - return await LoadComponentPartsAsync(); - }); - } - - private async Task> LoadComponentPartsAsync() - { - return await ComponentPartsAppService.GetListAsync(LibraryId); - } - - private async Task GetComponentPartsAsync(string componentPartsId) - { - var component = await ComponentPartsAppService.GetByIdAsync(LibraryId, componentPartsId); - _textComponentFragment = component.Fragment.ToJson(writeIndented: true); - _textDataSource = component.DataSource?.ToJson(writeIndented: true); - _textAttributeDefineGroups = component.AttributeDefineGroups?.ToJson(writeIndented: true); - return component; - } - - private void CreateAsync() - { - _componentPartsSchema = new ComponentPartsSchema(); - _componentPartsSchema.LibraryId = LibraryId; - _formVisible = true; - - StateHasChanged(); - } - - private async Task DesignAsync(string componentId) - { - _componentPartsSchema = await GetComponentPartsAsync(componentId); - _formVisible = true; - - StateHasChanged(); - } - - private async Task EditAsync(string componentId) - { - _componentPartsSchema = await GetComponentPartsAsync(componentId); - _formVisible = true; - - StateHasChanged(); - } - - private async Task TextEditAsync(string componentId) - { - _componentPartsSchema = await GetComponentPartsAsync(componentId); - - _textFormValue = _componentPartsSchema.ToJson(writeIndented: true); - _textFormVisible = true; - - StateHasChanged(); - } - - private async Task DeleteAsync(string componentPartsId) - { - //await ComponentPartsAppService.DeleteAsync(LibraryId, componentPartsId); - - await Message.SuccessAsync("模拟删除成功!"); - } - - private async Task OnConfirmAsync(MouseEventArgs e) - { - var validate = _form.Validate(); - if (validate) - { - _componentPartsSchema.Fragment = _textComponentFragment.FromJson(); - _componentPartsSchema.DataSource = _textDataSource.FromJson(); - _componentPartsSchema.AttributeDefineGroups = _textAttributeDefineGroups.FromJson(); - var isSuccess = await SaveComponentPartsSchemaAsync(); - if (isSuccess) - { - _formVisible = false; - _form.Submit(); - await Message.SuccessAsync("保存成功!"); - _form.Reset(); - } - else - { - _formVisible = true; - await Message.ErrorAsync("保存失败"); - } - } - else - { - _formVisible = true; - } - } - - private async Task OnFinishAsync() - { - _componentPartsList = await LoadComponentPartsAsync(); - } - - private async Task OnTextFormConfirmAsync(MouseEventArgs e) - { - _componentPartsSchema = _textFormValue.FromJson(); - var isSuccess = await SaveComponentPartsSchemaAsync(); - if (isSuccess) - { - _textFormVisible = false; - _componentPartsList = await LoadComponentPartsAsync(); - - await Message.SuccessAsync("保存成功!"); - } - else - { - _textFormVisible = true; - await Message.ErrorAsync("保存失败"); - } - } - - private async Task SaveComponentPartsSchemaAsync() - { - return await ComponentPartsAppService.SaveAsync(_componentPartsSchema); - } - - private void GoToComponentLibraryList() - { - NavigateTo("/workbench/myparts/componentlibraries"); - - if (Refresh != null) - { - Refresh(); - } - } - - #region Parameter - - private async Task CreateParameterAsync() - { - await Task.Delay(1); - - ComponentAttributeFragmentSchema newParameter = new(); - - //添加编辑缓存 - _parameterEditCache[newParameter.AttributeName] = (true, newParameter); - - _componentPartsSchema.Fragment.Attributes.Append(newParameter); - - //StateHasChanged(); - } - - private async Task SaveParameterAsync(string name) - { - await Task.Delay(1); - var index = _componentPartsSchema.Fragment.Attributes.FindIndex(item => item.AttributeName == name); - _componentPartsSchema.Fragment.Attributes[index] = _parameterEditCache[name].parameter; // apply the copy to data source - _parameterEditCache[name] = (false, _componentPartsSchema.Fragment.Attributes[index]); // don't affect rows in editing - - StateHasChanged(); - } - - private async Task DeleteParameterAsync(string name) - { - await Task.Delay(1); - - } - - private async Task ParameterStartEdit(string name) - { - await Task.Delay(1); - var data = _parameterEditCache[name]; - _parameterEditCache[name] = (true, data.parameter with { }); // add a copy in cache - - StateHasChanged(); - } - - private async Task ParameterCancelEditAsync(string name) - { - await Task.Delay(1); - var data = _componentPartsSchema.Fragment.Attributes.FirstOrDefault(item => item.AttributeName == name); - _parameterEditCache[name] = (false, data); // recovery - - StateHasChanged(); - } - #endregion -} \ No newline at end of file diff --git a/src/DesignEngine/H.LowCode.Workbench/Pages/MyParts/ComponentLibraryList.razor b/src/DesignEngine/H.LowCode.Workbench/Pages/MyParts/ComponentLibraryList.razor deleted file mode 100644 index 970746667db5924d91946a84e2a452551923cf1c..0000000000000000000000000000000000000000 --- a/src/DesignEngine/H.LowCode.Workbench/Pages/MyParts/ComponentLibraryList.razor +++ /dev/null @@ -1,110 +0,0 @@ -@namespace H.LowCode.Workbench -@inherits DesignEngineLowCodeComponentBase -@layout WorkbenchLayout - -@inject IComponentLibraryAppService ComponentLibraryAppService -@inject ComponentState> ComponentLibrariesState - -
-
- -
-
- -
-
- -@if (_componentLibraryList != null) -{ - @foreach (var componentLibrary in _componentLibraryList) - { - - - - - - - - - - - - - - - - - - - - } -} - - - - - -@code { - [Parameter] - public Action Refresh { get; set; } - - private IList _componentLibraryList; - private ComponentLibrarySchema _currentComponentLibrary; - - private bool _visible = false; - private ComponentLibraryForm _componentLibraryForm; - - RenderFragment avatarTemplate = @; - - protected override async Task OnInitializedAsync() - { - await base.OnInitializedAsync(); - - _componentLibraryList = await ComponentLibrariesState.GetOrAddAsync(this, async () => - { - return await LoadComponentLibrariesAsync(); - }); - } - - private async Task> LoadComponentLibrariesAsync() - { - return await ComponentLibraryAppService.GetListAsync(); - } - - private async Task OnConfirm(MouseEventArgs e) - { - _visible = true; - var success = await _componentLibraryForm.SubmitAsync(); - if (success) - { - _visible = false; - _componentLibraryList = await LoadComponentLibrariesAsync(); - - StateHasChanged(); - } - } - - private void CreateComponentLibrary() - { - _currentComponentLibrary = new(); - _visible = true; - StateHasChanged(); - } - - private void EditComponentLibrary(string libraryId) - { - _currentComponentLibrary = _componentLibraryList.FirstOrDefault(x => x.LibraryId == libraryId); - _visible = true; - StateHasChanged(); - } - - private void GoToComponentPartsList(string libraryId) - { - NavigateTo($"/workbench/myparts/componentlibraries?libId={libraryId}"); - - if (Refresh != null) - { - Refresh(); - } - } -} \ No newline at end of file diff --git a/src/DesignEngine/H.LowCode.Workbench/wwwroot/workbench.css b/src/DesignEngine/H.LowCode.Workbench/wwwroot/workbench.css deleted file mode 100644 index 395bcf5191a543d38af91b45c952010de23bbd51..0000000000000000000000000000000000000000 --- a/src/DesignEngine/H.LowCode.Workbench/wwwroot/workbench.css +++ /dev/null @@ -1,21 +0,0 @@ -body { -} - -.ant-layout { - background-color: #f6f6f6 !important; -} - -.myapps .ant-card-meta-avatar, .myapps .ant-card-meta-title { - cursor: pointer; -} -.myapps .ant-card-meta-detail { - color: #a2a3a5; - font-size: 12px; -} -.myapps .ant-card-meta-title { - color: #171a1d; - font-size: 16px; -} - .myapps .ant-card-meta-title:hover { - color: #40a9ff; - } \ No newline at end of file diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props index 6990374c909eaac23a911eb625477b29e176785e..5e17076a40b7c3ea735c0a431f547e205dae0eee 100644 --- a/src/Directory.Packages.props +++ b/src/Directory.Packages.props @@ -6,53 +6,50 @@ - - + + - - - - + + + + - - - - - - - + + + + + + + - - - - - - - - - - - - + + + + + + + + + + + + - + - + - - - - - - + + + diff --git a/src/H.LowCode.sln b/src/H.LowCode.sln index d13b518fe1d767df3cd42931017f0d8245286086..f7a2c2e8a1db39ad3a624bf088797fe843769c6e 100644 --- a/src/H.LowCode.sln +++ b/src/H.LowCode.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.0.31612.314 +# Visual Studio Version 18 +VisualStudioVersion = 18.0.11109.219 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "RenderEngine", "RenderEngine", "{89FE3DE3-2E58-4835-A476-CA2E309A1B3F}" EndProject @@ -13,11 +13,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "H.LowCode.DesignEngine", "D EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".config", ".config", "{8B2D37CA-78EA-401B-B598-EFB3C7FD6517}" ProjectSection(SolutionItems) = preProject + common.props = common.props Directory.Packages.props = Directory.Packages.props - global.props = global.props + global.json = global.json NuGet.config = NuGet.config - ..\README.md = ..\README.md nuget.pack.props = nuget.pack.props + ..\README.md = ..\README.md EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Protocol", "Protocol", "{4E9BFDA3-AFC6-41F3-817C-FD9E82322BDA}" @@ -28,7 +29,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "H.LowCode.DesignEngine.Appl EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "H.LowCode.DesignEngine.Application.Contracts", "DesignEngine\H.LowCode.DesignEngine.Application.Contracts\H.LowCode.DesignEngine.Application.Contracts.csproj", "{523063C9-59C7-49E4-A17F-B0A5E4247729}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "H.LowCode.DesignEngine.Abstraction", "DesignEngine\H.LowCode.DesignEngine.Abstraction\H.LowCode.DesignEngine.Abstraction.csproj", "{78087384-C445-47F5-BB2A-80CDA2132FF6}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "H.LowCode.DesignEngineBase", "DesignEngine\H.LowCode.DesignEngineBase\H.LowCode.DesignEngineBase.csproj", "{78087384-C445-47F5-BB2A-80CDA2132FF6}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Themes", "Themes", "{4B81FABE-A4D5-4602-A83C-E2875286AA53}" EndProject @@ -48,8 +49,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "H.LowCode.RenderEngine.Abst EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "H.LowCode.PartsDesignEngine", "DesignEngine\H.LowCode.PartsDesignEngine\H.LowCode.PartsDesignEngine.csproj", "{8C48BC1B-FD9B-4C39-929D-9458BD9B42E1}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "PartsDesignEngine", "PartsDesignEngine", "{30AB2F99-B015-4F98-9439-41A23A954CDE}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "H.LowCode.DesignEngine.Host.Client", "DesignEngine\H.LowCode.DesignEngine.Host.Client\H.LowCode.DesignEngine.Host.Client.csproj", "{C81282DA-2FD7-4DA4-A607-DBADD3ACD367}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "H.LowCode.DesignEngine.Host", "DesignEngine\H.LowCode.DesignEngine.Host\H.LowCode.DesignEngine.Host.csproj", "{3515BFA8-8D57-4E9E-903D-D74982DE27E0}" @@ -60,7 +59,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "H.LowCode.RenderEngine.Host EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Workbench", "Workbench", "{4D070ACB-8367-4889-806E-FA6EEA0D6A67}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "H.LowCode.Workbench", "DesignEngine\H.LowCode.Workbench\H.LowCode.Workbench.csproj", "{DE9247F1-BABC-4098-A928-960E8E4EC20E}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "H.LowCode.Portal", "DesignEngine\H.LowCode.Portal\H.LowCode.Portal.csproj", "{DE9247F1-BABC-4098-A928-960E8E4EC20E}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tools", "Tools", "{F3ABC418-7234-4DBA-8A5A-6B286A25B8AD}" EndProject @@ -70,8 +69,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "H.LowCode.ComponentBase", " EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "H.LowCode.DbMigrator", "Tools\H.LowCode.DbMigrator\H.LowCode.DbMigrator.csproj", "{F33C7AB6-CA4B-4254-9A75-D803FEDE0CB4}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DesignEngine", "DesignEngine", "{A32809CE-52C6-4E00-92D3-76903D8D9C61}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "H.LowCode.MetaSchema", "Common\H.LowCode.MetaSchema\H.LowCode.MetaSchema.csproj", "{1BF619BF-4992-46CC-B831-8E3ABA9A435A}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "H.LowCode.MetaSchema.DesignEngine", "Common\H.LowCode.MetaSchema.DesignEngine\H.LowCode.MetaSchema.DesignEngine.csproj", "{E1C86933-B2F8-4C53-BF19-AE67A206B00A}" @@ -108,6 +105,16 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Common", "Common", "{844CDB EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "H.LowCode.MetaMigrator", "Tools\H.LowCode.MetaMigrator\H.LowCode.MetaMigrator.csproj", "{193AF344-CD5E-474A-A872-CB700253967B}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "H.LowCode.Application.Contracts", "Common\H.LowCode.Application.Contracts\H.LowCode.Application.Contracts.csproj", "{677BA66C-2367-4430-82CE-59E09988DF43}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Utils", "Utils", "{AF99A147-8109-4237-86A4-2F565757AF4B}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "H.Extensions.System", "Utils\H.Extensions.System\H.Extensions.System.csproj", "{396688C7-0FCC-8361-BE69-70F54C23372D}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "H.Util.Blazor", "Utils\H.Util.Blazor\H.Util.Blazor.csproj", "{0F5D3E59-FD5A-0B41-C4F3-ACE777EE3977}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "H.Util.Ids", "Utils\H.Util.Ids\H.Util.Ids.csproj", "{E656B992-7E4C-9AC1-F011-99A4980177B5}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -250,13 +257,29 @@ Global {193AF344-CD5E-474A-A872-CB700253967B}.Debug|Any CPU.Build.0 = Debug|Any CPU {193AF344-CD5E-474A-A872-CB700253967B}.Release|Any CPU.ActiveCfg = Release|Any CPU {193AF344-CD5E-474A-A872-CB700253967B}.Release|Any CPU.Build.0 = Release|Any CPU + {677BA66C-2367-4430-82CE-59E09988DF43}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {677BA66C-2367-4430-82CE-59E09988DF43}.Debug|Any CPU.Build.0 = Debug|Any CPU + {677BA66C-2367-4430-82CE-59E09988DF43}.Release|Any CPU.ActiveCfg = Release|Any CPU + {677BA66C-2367-4430-82CE-59E09988DF43}.Release|Any CPU.Build.0 = Release|Any CPU + {396688C7-0FCC-8361-BE69-70F54C23372D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {396688C7-0FCC-8361-BE69-70F54C23372D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {396688C7-0FCC-8361-BE69-70F54C23372D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {396688C7-0FCC-8361-BE69-70F54C23372D}.Release|Any CPU.Build.0 = Release|Any CPU + {0F5D3E59-FD5A-0B41-C4F3-ACE777EE3977}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0F5D3E59-FD5A-0B41-C4F3-ACE777EE3977}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0F5D3E59-FD5A-0B41-C4F3-ACE777EE3977}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0F5D3E59-FD5A-0B41-C4F3-ACE777EE3977}.Release|Any CPU.Build.0 = Release|Any CPU + {E656B992-7E4C-9AC1-F011-99A4980177B5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E656B992-7E4C-9AC1-F011-99A4980177B5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E656B992-7E4C-9AC1-F011-99A4980177B5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E656B992-7E4C-9AC1-F011-99A4980177B5}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution {47EE6944-D5F8-46CD-A552-29A237BE87BD} = {89FE3DE3-2E58-4835-A476-CA2E309A1B3F} - {9BE2FECD-B648-4B15-B394-E354F98D1B73} = {A32809CE-52C6-4E00-92D3-76903D8D9C61} + {9BE2FECD-B648-4B15-B394-E354F98D1B73} = {4D070ACB-8367-4889-806E-FA6EEA0D6A67} {4E9BFDA3-AFC6-41F3-817C-FD9E82322BDA} = {A63C9652-517D-4BC3-B935-74D946AB0761} {B8524D2C-164A-46A1-83A3-5F47BC645B01} = {7E5B26AA-4F89-4B8C-B743-AE3F04C9DD58} {2FEAC795-B93C-4164-8A4D-92B2F26F4994} = {B8524D2C-164A-46A1-83A3-5F47BC645B01} @@ -264,14 +287,13 @@ Global {78087384-C445-47F5-BB2A-80CDA2132FF6} = {2B32F5E0-A1C9-49DA-85DD-9C3202A4AF2C} {4B81FABE-A4D5-4602-A83C-E2875286AA53} = {89FE3DE3-2E58-4835-A476-CA2E309A1B3F} {69842168-80FE-46B2-B66E-4E87B016E93D} = {4D070ACB-8367-4889-806E-FA6EEA0D6A67} - {2F7C173C-2C3C-4B8A-BBAD-852283458D87} = {7E5B26AA-4F89-4B8C-B743-AE3F04C9DD58} + {2F7C173C-2C3C-4B8A-BBAD-852283458D87} = {2B32F5E0-A1C9-49DA-85DD-9C3202A4AF2C} {240CD8ED-49F9-47E0-91B1-B170252E5437} = {89FE3DE3-2E58-4835-A476-CA2E309A1B3F} {C38DD51F-A1D3-4158-BF04-179A4C3BBEEA} = {240CD8ED-49F9-47E0-91B1-B170252E5437} {68C4F1D4-C479-4679-8074-B13EA898F4A0} = {240CD8ED-49F9-47E0-91B1-B170252E5437} {8490E431-5F81-4EF4-B765-FF0AC8A6EA10} = {A63C9652-517D-4BC3-B935-74D946AB0761} {9832C124-BE18-48FA-8C60-48857D9B4DA1} = {844CDB6A-8081-4769-8905-8A0D279D6101} - {8C48BC1B-FD9B-4C39-929D-9458BD9B42E1} = {30AB2F99-B015-4F98-9439-41A23A954CDE} - {30AB2F99-B015-4F98-9439-41A23A954CDE} = {7E5B26AA-4F89-4B8C-B743-AE3F04C9DD58} + {8C48BC1B-FD9B-4C39-929D-9458BD9B42E1} = {4D070ACB-8367-4889-806E-FA6EEA0D6A67} {C81282DA-2FD7-4DA4-A607-DBADD3ACD367} = {7E5B26AA-4F89-4B8C-B743-AE3F04C9DD58} {3515BFA8-8D57-4E9E-903D-D74982DE27E0} = {7E5B26AA-4F89-4B8C-B743-AE3F04C9DD58} {543E3996-E69A-4EE6-ABD9-9A69A8383DB8} = {89FE3DE3-2E58-4835-A476-CA2E309A1B3F} @@ -280,7 +302,6 @@ Global {DE9247F1-BABC-4098-A928-960E8E4EC20E} = {4D070ACB-8367-4889-806E-FA6EEA0D6A67} {43C23BD6-6228-4C41-BD73-FC1508178F33} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8} {F33C7AB6-CA4B-4254-9A75-D803FEDE0CB4} = {F3ABC418-7234-4DBA-8A5A-6B286A25B8AD} - {A32809CE-52C6-4E00-92D3-76903D8D9C61} = {7E5B26AA-4F89-4B8C-B743-AE3F04C9DD58} {1BF619BF-4992-46CC-B831-8E3ABA9A435A} = {4E9BFDA3-AFC6-41F3-817C-FD9E82322BDA} {E1C86933-B2F8-4C53-BF19-AE67A206B00A} = {4E9BFDA3-AFC6-41F3-817C-FD9E82322BDA} {AFC84C58-A075-45C3-BA33-609F067B471A} = {4E9BFDA3-AFC6-41F3-817C-FD9E82322BDA} @@ -299,6 +320,10 @@ Global {2B32F5E0-A1C9-49DA-85DD-9C3202A4AF2C} = {7E5B26AA-4F89-4B8C-B743-AE3F04C9DD58} {844CDB6A-8081-4769-8905-8A0D279D6101} = {89FE3DE3-2E58-4835-A476-CA2E309A1B3F} {193AF344-CD5E-474A-A872-CB700253967B} = {F3ABC418-7234-4DBA-8A5A-6B286A25B8AD} + {677BA66C-2367-4430-82CE-59E09988DF43} = {A63C9652-517D-4BC3-B935-74D946AB0761} + {396688C7-0FCC-8361-BE69-70F54C23372D} = {AF99A147-8109-4237-86A4-2F565757AF4B} + {0F5D3E59-FD5A-0B41-C4F3-ACE777EE3977} = {AF99A147-8109-4237-86A4-2F565757AF4B} + {E656B992-7E4C-9AC1-F011-99A4980177B5} = {AF99A147-8109-4237-86A4-2F565757AF4B} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {A8C26757-CDED-4779-94DE-C0D4929F64C2} diff --git a/src/RenderEngine/H.LowCode.RenderEngine.Abstraction/H.LowCode.RenderEngine.Abstraction.csproj b/src/RenderEngine/H.LowCode.RenderEngine.Abstraction/H.LowCode.RenderEngine.Abstraction.csproj index f66cf58dd949979dc3ec7a2a34a570e8aac7ec12..40fd946bf4e5c50c3d9d2e781847362aebda8d2c 100644 --- a/src/RenderEngine/H.LowCode.RenderEngine.Abstraction/H.LowCode.RenderEngine.Abstraction.csproj +++ b/src/RenderEngine/H.LowCode.RenderEngine.Abstraction/H.LowCode.RenderEngine.Abstraction.csproj @@ -1,6 +1,6 @@  - + diff --git a/src/RenderEngine/H.LowCode.RenderEngine.Application.Contracts/DataAppServices/ITableDataAppService.cs b/src/RenderEngine/H.LowCode.RenderEngine.Application.Contracts/DataAppServices/ITableDataAppService.cs deleted file mode 100644 index 9643cf982689fe03e445c978c1c1d6145847a142..0000000000000000000000000000000000000000 --- a/src/RenderEngine/H.LowCode.RenderEngine.Application.Contracts/DataAppServices/ITableDataAppService.cs +++ /dev/null @@ -1,9 +0,0 @@ -using H.LowCode.MetaSchema; -using Volo.Abp.Application.Services; - -namespace H.LowCode.RenderEngine.Application.Contracts; - -public interface ITableDataAppService : IApplicationService -{ - Task GetList(TableGetListInput input); -} \ No newline at end of file diff --git a/src/RenderEngine/H.LowCode.RenderEngine.Application.Contracts/DataDTOs/FormCreateOrUpdateDTO.cs b/src/RenderEngine/H.LowCode.RenderEngine.Application.Contracts/DataDTOs/FormCreateOrUpdateDTO.cs deleted file mode 100644 index 3c718ca9575671d005aa93bde73b2d3da78ea55a..0000000000000000000000000000000000000000 --- a/src/RenderEngine/H.LowCode.RenderEngine.Application.Contracts/DataDTOs/FormCreateOrUpdateDTO.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace H.LowCode.RenderEngine.Application.Contracts; - -public class FormCreateOrUpdateDTO -{ - -} diff --git a/src/RenderEngine/H.LowCode.RenderEngine.Application.Contracts/DataDTOs/TableGetListInput.cs b/src/RenderEngine/H.LowCode.RenderEngine.Application.Contracts/DataDTOs/TableGetListInput.cs deleted file mode 100644 index bef387bdbd0619b90abedc6e2232afde71158efc..0000000000000000000000000000000000000000 --- a/src/RenderEngine/H.LowCode.RenderEngine.Application.Contracts/DataDTOs/TableGetListInput.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace H.LowCode.RenderEngine.Application.Contracts; - -public class TableGetListInput -{ - -} diff --git a/src/RenderEngine/H.LowCode.RenderEngine.Application.Contracts/DataDTOs/TableGetListOutput.cs b/src/RenderEngine/H.LowCode.RenderEngine.Application.Contracts/DataDTOs/TableGetListOutput.cs deleted file mode 100644 index 0faa0d20f66327700a084b007b6828fec4562016..0000000000000000000000000000000000000000 --- a/src/RenderEngine/H.LowCode.RenderEngine.Application.Contracts/DataDTOs/TableGetListOutput.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace H.LowCode.RenderEngine.Application.Contracts; - -public class TableGetListOutput -{ - -} diff --git a/src/RenderEngine/H.LowCode.RenderEngine.Application.Contracts/H.LowCode.RenderEngine.Application.Contracts.csproj b/src/RenderEngine/H.LowCode.RenderEngine.Application.Contracts/H.LowCode.RenderEngine.Application.Contracts.csproj index e74e0a41d3c07e1f4bbcca3c075cbefb362e2620..f726ecf52cc2865379af585d2f9e1d9af5814e42 100644 --- a/src/RenderEngine/H.LowCode.RenderEngine.Application.Contracts/H.LowCode.RenderEngine.Application.Contracts.csproj +++ b/src/RenderEngine/H.LowCode.RenderEngine.Application.Contracts/H.LowCode.RenderEngine.Application.Contracts.csproj @@ -1,6 +1,6 @@  - + @@ -8,6 +8,7 @@ + diff --git a/src/RenderEngine/H.LowCode.RenderEngine.Application.Contracts/RenderEngineApplicationContractsModule.cs b/src/RenderEngine/H.LowCode.RenderEngine.Application.Contracts/RenderEngineApplicationContractsModule.cs index fc56a277e2b49451c813e78983ab599f51151c73..27cd7e1007ca0ff84f06886716c8f383f0e875ba 100644 --- a/src/RenderEngine/H.LowCode.RenderEngine.Application.Contracts/RenderEngineApplicationContractsModule.cs +++ b/src/RenderEngine/H.LowCode.RenderEngine.Application.Contracts/RenderEngineApplicationContractsModule.cs @@ -1,12 +1,11 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using H.LowCode.Application.Contracts; using Volo.Abp.Modularity; namespace H.LowCode.RenderEngine.Application.Contracts; +[DependsOn( + typeof(LowCodeApplicationContractsModule) + )] public class RenderEngineApplicationContractsModule : AbpModule { diff --git a/src/RenderEngine/H.LowCode.RenderEngine.Application/DataAppServices/FormDataAppService.cs b/src/RenderEngine/H.LowCode.RenderEngine.Application/DataAppServices/FormDataAppService.cs index 786d7cedb0634f6f009e4eb122ef95279fbbab49..139db1d748aeba4d649c58956214713382cd4914 100644 --- a/src/RenderEngine/H.LowCode.RenderEngine.Application/DataAppServices/FormDataAppService.cs +++ b/src/RenderEngine/H.LowCode.RenderEngine.Application/DataAppServices/FormDataAppService.cs @@ -1,37 +1,354 @@ -using H.LowCode.RenderEngine.Domain; -using H.LowCode.RenderEngine.Application.Contracts; +using H.LowCode.Application.Contracts; +using H.LowCode.Entity; +using H.LowCode.RenderEngine.Domain; +using H.LowCode.RenderEngine.Domain.Repositories; using Microsoft.Extensions.DependencyInjection; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using Microsoft.Extensions.Logging; using Volo.Abp; using Volo.Abp.Application.Services; -using H.LowCode.Entity; -using System.Text.Json; +using Volo.Abp.Domain.Entities; namespace H.LowCode.RenderEngine.Application; [RemoteService] public class FormDataAppService : ApplicationService, IFormDataAppService { - private IFormDataDomainService _formDataDomainService => LazyServiceProvider.GetRequiredService(); + private IFormDataRepository _formDataRepository => LazyServiceProvider.GetRequiredService(); + private IPageRepository _pageRepository => LazyServiceProvider.GetRequiredService(); - public async Task GetAsync(string appId, string pageId, string id) + public async Task GetAsync(string appId, string pageId, string id) { - var entity = await _formDataDomainService.GetAsync(appId, pageId, id); - var dto = ObjectMapper.Map(entity); + var formPageSchema = await _pageRepository.GetAsync(appId, pageId); + if (formPageSchema == null) + throw new KeyNotFoundException($"page not found: appId={appId}, pageId={pageId}"); + + string entityName = formPageSchema.DataSource.DataSourceValue; + + if (string.IsNullOrEmpty(id)) + { + var defaultEntity = new FormEntity() + { + Name = entityName, + Fields = formPageSchema.Components.Where(t => t.IsContainer == false) + .Select(t => new FormFieldEntity() + { + Name = t.Name, + TypeName = t.Fragment.ValueType, + Value = t.Fragment.GetDefaultValue() + }).ToList() + }; + var defaultDto = ObjectMapper.Map(defaultEntity); + return defaultDto; + } + + var entity = await _formDataRepository.GetAsync(entityName, id); + if (entity == null) + throw new EntityNotFoundException($"Entity {entityName} Not Found: {id}"); + + var dto = ObjectMapper.Map(entity); return dto; } - public async Task SaveAsync(FormDataDTO dto) + public async Task SaveAsync(FormDataDto dto) { - var entity = ObjectMapper.Map(dto); - return await _formDataDomainService.SaveAsync(entity); + if (dto == null) + throw new ArgumentNullException(nameof(dto)); + + var entity = ObjectMapper.Map(dto); + + // 设置默认表名 + entity.Name = entity.Name ?? "tb_test1"; + + // 验证字段 + if (entity.Fields == null || !entity.Fields.Any()) + throw new ArgumentException("表单字段不能为空", nameof(entity)); + + // 验证字段值类型 + foreach (var field in entity.Fields) + { + if (string.IsNullOrEmpty(field.Name)) + throw new ArgumentException("字段名称不能为空"); + + if (string.IsNullOrEmpty(field.TypeName)) + throw new ArgumentException($"字段 {field.Name} 的类型不能为空"); + } + + // 应用字段验证和默认值 + await ApplyFieldValidationAndDefaults(entity); + + try + { + // 检查是否为新增记录(通过主键字段判断) + string primaryKeyName = "f_id"; + var primaryKeyField = entity.Fields.FirstOrDefault(f => f.Name == primaryKeyName); + + bool isNewRecord = primaryKeyField == null || + string.IsNullOrEmpty(primaryKeyField.Value?.ToString()); + + if (isNewRecord) + { + // 新增记录 - 设置主键字段值 + if (primaryKeyField == null) + { + // 如果主键字段不存在,创建一个 + primaryKeyField = new FormFieldEntity + { + Name = primaryKeyName, + TypeName = typeof(string).FullName, + Value = Guid.NewGuid().ToString() + }; + entity.Fields.Add(primaryKeyField); + } + else + { + // 如果主键字段存在但值为空,设置新值 + primaryKeyField.Value = Guid.NewGuid().ToString(); + } + + await _formDataRepository.AddAsync(entity); + } + else + { + // 更新记录 + await _formDataRepository.UpdateAsync(entity); + } + return true; + } + catch (Exception ex) + { + // 记录错误日志 + string entityId = ""; + try { entityId = entity.Id; } catch { } + Logger.LogError(ex, "保存表单数据失败: EntityName={EntityName}, EntityId={EntityId}", entity.Name, entityId); + throw; + } + } + + /// + /// 应用字段验证和默认值设置 + /// + private async Task ApplyFieldValidationAndDefaults(FormEntity entity) + { + // 获取页面配置以获取字段默认值定义 + var pageConfig = await GetPageConfigForEntity(entity.Name); + + foreach (var field in entity.Fields) + { + // 跳过主键字段的验证和默认值处理 + if (field.Name == "f_id") + continue; + + // 获取字段类型 + var fieldType = Type.GetType(field.TypeName); + if (fieldType == null) + continue; + + // 检查字段是否有有效值 + bool hasValidValue = HasValidValue(field.Value, fieldType); + + if (!hasValidValue) + { + // 首先尝试从页面配置获取默认值 + var configDefaultValue = GetFieldDefaultValueFromConfig(field.Name, fieldType, pageConfig); + if (configDefaultValue != null) + { + field.Value = configDefaultValue; + Logger.LogInformation("Applied config default value for field '{FieldName}': {DefaultValue}", + field.Name, configDefaultValue); + } + else + { + // 如果没有配置默认值,使用类型默认值 + field.Value = GetTypeDefaultValue(fieldType); + Logger.LogInformation("Applied type default value for field '{FieldName}': {DefaultValue}", + field.Name, field.Value); + } + } + + // 验证字段值的有效性 + ValidateFieldValue(field, fieldType); + } + } + + /// + /// 检查字段是否有有效值 + /// + private bool HasValidValue(object value, Type fieldType) + { + if (value == null) + return false; + + // 字符串类型:空字符串视为无效值 + if (fieldType == typeof(string)) + return !string.IsNullOrWhiteSpace(value.ToString()); + + // 数值类型:0值可能是有效值,所以只检查null + if (fieldType == typeof(int) || fieldType == typeof(int?) || + fieldType == typeof(long) || fieldType == typeof(long?) || + fieldType == typeof(decimal) || fieldType == typeof(decimal?)) + return true; + + // 布尔类型:false也是有效值 + if (fieldType == typeof(bool) || fieldType == typeof(bool?)) + return true; + + // DateTime类型:检查是否为默认值 + if (fieldType == typeof(DateTime) || fieldType == typeof(DateTime?)) + { + if (value is DateTime dateValue) + return dateValue != default(DateTime); + return true; + } + + // Guid类型:检查是否为空Guid + if (fieldType == typeof(Guid) || fieldType == typeof(Guid?)) + { + if (value is Guid guidValue) + return guidValue != Guid.Empty; + return true; + } + + return true; + } + + /// + /// 获取类型的默认值 + /// + private object GetTypeDefaultValue(Type type) + { + if (type == null) + return null; + + // 处理可空类型 + if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>)) + { + return null; + } + + // 处理字符串类型 + if (type == typeof(string)) + return string.Empty; + + // 处理基本数值类型 + if (type == typeof(int)) + return 0; + if (type == typeof(long)) + return 0L; + if (type == typeof(decimal)) + return 0m; + if (type == typeof(double)) + return 0.0; + if (type == typeof(float)) + return 0.0f; + if (type == typeof(short)) + return (short)0; + if (type == typeof(byte)) + return (byte)0; + + // 处理布尔类型 + if (type == typeof(bool)) + return false; + + // 处理日期时间类型 + if (type == typeof(DateTime)) + return DateTime.Now; + if (type == typeof(DateTimeOffset)) + return DateTimeOffset.Now; + + // 处理Guid类型 + if (type == typeof(Guid)) + return Guid.NewGuid(); + + // 处理集合类型 + if (type.IsArray) + { + return Array.CreateInstance(type.GetElementType(), 0); + } + + if (type.IsGenericType) + { + var genericTypeDef = type.GetGenericTypeDefinition(); + if (genericTypeDef == typeof(List<>) || + genericTypeDef == typeof(IList<>) || + genericTypeDef == typeof(ICollection<>) || + genericTypeDef == typeof(IEnumerable<>)) + { + return Activator.CreateInstance(typeof(List<>).MakeGenericType(type.GetGenericArguments())); + } + } + + // 对于其他值类型,返回类型的默认值 + if (type.IsValueType) + return Activator.CreateInstance(type); + + // 其他引用类型返回null + return null; + } + + /// + /// 验证字段值的有效性 + /// + private void ValidateFieldValue(FormFieldEntity field, Type fieldType) + { + try + { + // 尝试转换值以验证类型兼容性 + if (field.Value != null) + { + //Convert.ChangeType(field.Value, fieldType); + } + } + catch (Exception ex) + { + throw new ArgumentException($"Field '{field.Name}' value '{field.Value}' is not compatible with type '{fieldType.Name}'", ex); + } + } + + /// + /// 获取页面配置 + /// + private async Task GetPageConfigForEntity(string entityName) + { + try + { + // 通过实体名称查找对应的页面配置 + // 这里简化处理,实际应该通过数据源配置来查找页面 + // TODO: 实现更精确的页面配置查找逻辑 + return null; + } + catch (Exception ex) + { + Logger.LogWarning(ex, "Failed to get page config for entity '{EntityName}'", entityName); + return null; + } + } + + /// + /// 从页面配置中获取字段默认值 + /// + private object GetFieldDefaultValueFromConfig(string fieldName, Type fieldType, object pageConfig) + { + if (pageConfig == null) + return null; + + try + { + // TODO: 实现从页面配置JSON中解析字段默认值的逻辑 + // 这里需要解析页面配置中的组件定义,找到对应字段的默认值 + // 由于页面配置结构复杂,暂时返回null + return null; + } + catch (Exception ex) + { + Logger.LogWarning(ex, "Failed to get default value from config for field '{FieldName}'", fieldName); + return null; + } } public async Task DeleteAsync(string appId, string pageId, string id) { - return await _formDataDomainService.DeleteAsync(appId, pageId, id); + var formPageSchema = await _pageRepository.GetAsync(appId, pageId); + + return await _formDataRepository.DeleteAsync(formPageSchema.DataSource.DataSourceValue, id); } } diff --git a/src/RenderEngine/H.LowCode.RenderEngine.Application/DataAppServices/TableDataAppService.cs b/src/RenderEngine/H.LowCode.RenderEngine.Application/DataAppServices/TableDataAppService.cs index 69f145144556948e8477d0133bd1ba76ee1c19c1..8ec7942617260220e21978e0d5a06018402a4ece 100644 --- a/src/RenderEngine/H.LowCode.RenderEngine.Application/DataAppServices/TableDataAppService.cs +++ b/src/RenderEngine/H.LowCode.RenderEngine.Application/DataAppServices/TableDataAppService.cs @@ -1,23 +1,34 @@ -using H.LowCode.RenderEngine.Domain; -using H.LowCode.RenderEngine.Application.Contracts; -using Microsoft.Extensions.DependencyInjection; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Volo.Abp; +using H.LowCode.Application.Contracts; +using H.LowCode.RenderEngine.Domain; +using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Services; namespace H.LowCode.RenderEngine.Application; -[RemoteService] +/// +/// 渲染引擎表格数据提供者 +/// public class TableDataAppService : ApplicationService, ITableDataAppService { - private ITableDataDomainService _tableDataDomainService => LazyServiceProvider.GetRequiredService(); + private readonly ITableDataRepository _tableDataRepository; - public async Task GetList(TableGetListInput input) + public TableDataAppService(ITableDataRepository tableDataRepository) { - throw new NotImplementedException(); + _tableDataRepository = tableDataRepository; } -} + + public async Task>> GetListAsync(TableDataInput input) + { + return await _tableDataRepository.GetListAsync(input); + } + + public async Task DeleteAsync(TableDataDeleteInput request) + { + await _tableDataRepository.DeleteAsync(request); + } + + public async Task UpdateAsync(TableDataUpdateInput request) + { + await _tableDataRepository.UpdateAsync(request); + } +} \ No newline at end of file diff --git a/src/RenderEngine/H.LowCode.RenderEngine.Application/H.LowCode.RenderEngine.Application.csproj b/src/RenderEngine/H.LowCode.RenderEngine.Application/H.LowCode.RenderEngine.Application.csproj index 7f2e2ee1e7ad787f30f02912cab7095ad0346d5d..d0c20901d80360e2a018073516764af1ac95541b 100644 --- a/src/RenderEngine/H.LowCode.RenderEngine.Application/H.LowCode.RenderEngine.Application.csproj +++ b/src/RenderEngine/H.LowCode.RenderEngine.Application/H.LowCode.RenderEngine.Application.csproj @@ -1,6 +1,6 @@ - + - + @@ -9,6 +9,8 @@ + + diff --git a/src/RenderEngine/H.LowCode.RenderEngine.Application/MapperProfiles/LowCodeAutoMapperProfile.cs b/src/RenderEngine/H.LowCode.RenderEngine.Application/MapperProfiles/LowCodeAutoMapperProfile.cs index 4ccfdfbcde0182271c2f43e9f30ba5ceba152a87..fc0104c94abc0253b99a02ceab4b35c85e03eb3c 100644 --- a/src/RenderEngine/H.LowCode.RenderEngine.Application/MapperProfiles/LowCodeAutoMapperProfile.cs +++ b/src/RenderEngine/H.LowCode.RenderEngine.Application/MapperProfiles/LowCodeAutoMapperProfile.cs @@ -1,11 +1,6 @@ using AutoMapper; -using H.LowCode.RenderEngine.Application.Contracts; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using H.LowCode.Entity; +using H.LowCode.Application.Contracts; namespace H.LowCode.RenderEngine.Application; @@ -13,10 +8,10 @@ public class LowCodeAutoMapperProfile : Profile { public LowCodeAutoMapperProfile() { - CreateMap(); - CreateMap(); + CreateMap(); + CreateMap(); - CreateMap(); - CreateMap(); + CreateMap(); + CreateMap(); } } \ No newline at end of file diff --git a/src/RenderEngine/H.LowCode.RenderEngine.Application/RenderAppServices/MetaAppService.cs b/src/RenderEngine/H.LowCode.RenderEngine.Application/RenderAppServices/MetaAppService.cs index 29dd6301d6606f9ad93eb7dfd0cfe7b97f9e7a32..cfd52efdced66ec16174c1367958e37e99d43ea8 100644 --- a/src/RenderEngine/H.LowCode.RenderEngine.Application/RenderAppServices/MetaAppService.cs +++ b/src/RenderEngine/H.LowCode.RenderEngine.Application/RenderAppServices/MetaAppService.cs @@ -2,6 +2,7 @@ using H.LowCode.MetaSchema.RenderEngine; using H.LowCode.RenderEngine.Application.Contracts; using H.LowCode.RenderEngine.Domain; +using H.LowCode.RenderEngine.Domain.Repositories; using Microsoft.Extensions.DependencyInjection; using System.Text; using Volo.Abp; @@ -12,17 +13,17 @@ namespace H.LowCode.RenderEngine.Application; [RemoteService] public class MetaAppService : ApplicationService, IMetaAppService { - private IMenuDomainService _menuDomainService => LazyServiceProvider.GetRequiredService(); - private IPageDomainService _pageDomainService => LazyServiceProvider.GetRequiredService(); + private IMenuRepository _menuRepository => LazyServiceProvider.GetRequiredService(); + private IPageRepository _pageRepository => LazyServiceProvider.GetRequiredService(); public async Task> GetMenusAsync(string appId) { - return await _menuDomainService.GetListAsync(appId); + return await _menuRepository.GetListAsync(appId); } public async Task GetPageAsync(string appId, string pageId) { - return await _pageDomainService.GetAsync(appId, pageId); + return await _pageRepository.GetAsync(appId, pageId); } /// @@ -33,7 +34,7 @@ public class MetaAppService : ApplicationService, IMetaAppService /// public async Task GetPageWithDefineAsync(string appId, string pageId) { - var pageSchema = await _pageDomainService.GetAsync(appId, pageId); + var pageSchema = await _pageRepository.GetAsync(appId, pageId); if (pageSchema?.Components != null) { diff --git a/src/RenderEngine/H.LowCode.RenderEngine.Application/RenderEngineApplicationModule.cs b/src/RenderEngine/H.LowCode.RenderEngine.Application/RenderEngineApplicationModule.cs index 370232e4c0afa5dae93d1f9ec3aa6c2aa89590f4..60cdc5ee45965b99537840b6a5319257f895ec5b 100644 --- a/src/RenderEngine/H.LowCode.RenderEngine.Application/RenderEngineApplicationModule.cs +++ b/src/RenderEngine/H.LowCode.RenderEngine.Application/RenderEngineApplicationModule.cs @@ -1,4 +1,4 @@ -using H.LowCode.Configuration; +using H.LowCode.Configuration; using H.LowCode.RenderEngine.Domain; using Microsoft.Extensions.DependencyInjection; using Volo.Abp.AutoMapper; diff --git a/src/RenderEngine/H.LowCode.RenderEngine.Domain/DataDomainServices/FormDataDomainService.cs b/src/RenderEngine/H.LowCode.RenderEngine.Domain/DataDomainServices/FormDataDomainService.cs deleted file mode 100644 index 1123a90fe8e2105c596225fcc2b62b82b6ca27fb..0000000000000000000000000000000000000000 --- a/src/RenderEngine/H.LowCode.RenderEngine.Domain/DataDomainServices/FormDataDomainService.cs +++ /dev/null @@ -1,69 +0,0 @@ -using H.LowCode.Entity; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Logging; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json; -using System.Threading.Tasks; -using Volo.Abp.Domain.Entities; -using Volo.Abp.Domain.Services; - -namespace H.LowCode.RenderEngine.Domain; - -public class FormDataDomainService : DomainService, IFormDataDomainService -{ - private IFormDataRepository _formDataRepository => LazyServiceProvider.GetRequiredService(); - private IPageDomainService _pageDomainService => LazyServiceProvider.GetRequiredService(); - - public async Task GetAsync(string appId, string pageId, string id) - { - var formPageSchema = await _pageDomainService.GetAsync(appId, pageId); - if (formPageSchema == null) - throw new KeyNotFoundException($"page not found: appId={appId}, pageId={pageId}"); - - string entityName = formPageSchema.DataSource.DataSourceValue; - - if (string.IsNullOrEmpty(id)) - { - var defaultEntity = new FormEntity() - { - Name = entityName, - Fields = formPageSchema.Components.Where(t => t.IsContainer == false) - .Select(t => new FormFieldEntity() - { - Name = t.Name, - TypeName = t.Fragment.ValueType, - Value = t.Fragment.GetDefaultValue() - }).ToList() - }; - return defaultEntity; - } - - var entity = await _formDataRepository.GetAsync(entityName, id); - if (entity == null) - throw new EntityNotFoundException($"Entity {entityName} Not Found: {id}"); - - return entity; - } - - public async Task SaveAsync(FormEntity entity) - { - //TODO - entity.Name = entity.Name ?? "tb_test1"; - - if (string.IsNullOrEmpty(entity.Id)) - await _formDataRepository.AddAsync(entity); - else - await _formDataRepository.UpdateAsync(entity); - return true; - } - - public async Task DeleteAsync(string appId, string pageId, string id) - { - var formPageSchema = await _pageDomainService.GetAsync(appId, pageId); - - return await _formDataRepository.DeleteAsync(formPageSchema.DataSource.DataSourceValue, id); - } -} diff --git a/src/RenderEngine/H.LowCode.RenderEngine.Domain/DataDomainServices/IFormDataDomainService.cs b/src/RenderEngine/H.LowCode.RenderEngine.Domain/DataDomainServices/IFormDataDomainService.cs deleted file mode 100644 index a2c94bbbb5458bad1fe081301bc0a73ff3eebc31..0000000000000000000000000000000000000000 --- a/src/RenderEngine/H.LowCode.RenderEngine.Domain/DataDomainServices/IFormDataDomainService.cs +++ /dev/null @@ -1,18 +0,0 @@ -using H.LowCode.Entity; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Volo.Abp.Domain.Services; - -namespace H.LowCode.RenderEngine.Domain; - -public interface IFormDataDomainService : IDomainService -{ - Task SaveAsync(FormEntity entity); - - Task GetAsync(string appId, string pageId, string id); - - Task DeleteAsync(string appId, string pageId, string id); -} diff --git a/src/RenderEngine/H.LowCode.RenderEngine.Domain/DataDomainServices/ITableDataDomainService.cs b/src/RenderEngine/H.LowCode.RenderEngine.Domain/DataDomainServices/ITableDataDomainService.cs deleted file mode 100644 index e64df35e7713b83c7e6656865e6c9669d33128dd..0000000000000000000000000000000000000000 --- a/src/RenderEngine/H.LowCode.RenderEngine.Domain/DataDomainServices/ITableDataDomainService.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Volo.Abp.Domain.Services; - -namespace H.LowCode.RenderEngine.Domain; - -public interface ITableDataDomainService : IDomainService -{ - -} diff --git a/src/RenderEngine/H.LowCode.RenderEngine.Domain/DataRepositories/ITableDataRepository.cs b/src/RenderEngine/H.LowCode.RenderEngine.Domain/DataRepositories/ITableDataRepository.cs index 91a2c31585739e1e9fd69aed19c75836b291e18f..992ff24338b46f860c916ee188de97f1c66e94a8 100644 --- a/src/RenderEngine/H.LowCode.RenderEngine.Domain/DataRepositories/ITableDataRepository.cs +++ b/src/RenderEngine/H.LowCode.RenderEngine.Domain/DataRepositories/ITableDataRepository.cs @@ -1,13 +1,12 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using H.LowCode.Application.Contracts; +using Volo.Abp.Application.Dtos; using Volo.Abp.Domain.Repositories; namespace H.LowCode.RenderEngine.Domain; public interface ITableDataRepository : IRepository { - + Task>> GetListAsync(TableDataInput input); + Task DeleteAsync(TableDataDeleteInput request); + Task UpdateAsync(TableDataUpdateInput request); } diff --git a/src/RenderEngine/H.LowCode.RenderEngine.Domain/H.LowCode.RenderEngine.Domain.csproj b/src/RenderEngine/H.LowCode.RenderEngine.Domain/H.LowCode.RenderEngine.Domain.csproj index 9b6baa7a6d7511626d97e09cf85fb54d37776910..b3a8501f6e901d32467331e755c3e37d844f8e79 100644 --- a/src/RenderEngine/H.LowCode.RenderEngine.Domain/H.LowCode.RenderEngine.Domain.csproj +++ b/src/RenderEngine/H.LowCode.RenderEngine.Domain/H.LowCode.RenderEngine.Domain.csproj @@ -1,6 +1,6 @@  - + @@ -10,6 +10,7 @@ + diff --git a/src/RenderEngine/H.LowCode.RenderEngine.Domain/MetaDomainServices/AppDomainService.cs b/src/RenderEngine/H.LowCode.RenderEngine.Domain/MetaDomainServices/AppDomainService.cs deleted file mode 100644 index 663f02599b82fe4a923f5a468698ea11c1dd121d..0000000000000000000000000000000000000000 --- a/src/RenderEngine/H.LowCode.RenderEngine.Domain/MetaDomainServices/AppDomainService.cs +++ /dev/null @@ -1,25 +0,0 @@ -using H.LowCode.RenderEngine.Domain.Repositories; -using H.LowCode.MetaSchema; -using Volo.Abp.Domain.Services; - -namespace H.LowCode.RenderEngine.Domain; - -public class AppDomainService : DomainService, IAppDomainService -{ - private readonly IAppRepository _repository; - - public AppDomainService(IAppRepository repository) - { - _repository = repository; - } - - public async Task> GetListAsync() - { - return await _repository.GetListAsync(); - } - - public async Task GetAsync(string appId) - { - return await _repository.GetAsync(appId); - } -} \ No newline at end of file diff --git a/src/RenderEngine/H.LowCode.RenderEngine.Domain/MetaDomainServices/DataSourceDomainService.cs b/src/RenderEngine/H.LowCode.RenderEngine.Domain/MetaDomainServices/DataSourceDomainService.cs deleted file mode 100644 index ad6a1ab42947deadf44dbcf18117e89684e860b3..0000000000000000000000000000000000000000 --- a/src/RenderEngine/H.LowCode.RenderEngine.Domain/MetaDomainServices/DataSourceDomainService.cs +++ /dev/null @@ -1,37 +0,0 @@ -using H.LowCode.RenderEngine.Domain.Repositories; -using H.LowCode.MetaSchema; -using Volo.Abp.Domain.Services; - -namespace H.LowCode.RenderEngine.Domain; - -public class DataSourceDomainService : DomainService, IDataSourceDomainService -{ - private readonly IDataSourceRepository _repository; - - public DataSourceDomainService(IDataSourceRepository repository) - { - _repository = repository; - } - - public async Task> GetListAsync(string appId) - { - return await _repository.GetListAsync(appId); - } - - public async Task> GetAllApisAsync(string appId) - { - var list = await GetListAsync(appId); - return list.Where(t => t.DataSourceType == ComponentDataSourceTypeEnum.API).ToList(); - } - - public IEnumerable GetAllEntities(string appId) - { - var list = GetListAsync(appId).Result; - return list.Where(t => t.DataSourceType == ComponentDataSourceTypeEnum.DB).ToList(); - } - - public async Task GetAsync(string appId, string id) - { - return await _repository.GetAsync(appId, id); - } -} \ No newline at end of file diff --git a/src/RenderEngine/H.LowCode.RenderEngine.Domain/MetaDomainServices/IAppDomainService.cs b/src/RenderEngine/H.LowCode.RenderEngine.Domain/MetaDomainServices/IAppDomainService.cs deleted file mode 100644 index 680440b9c587c59d6097f9226756eadbb82cad6c..0000000000000000000000000000000000000000 --- a/src/RenderEngine/H.LowCode.RenderEngine.Domain/MetaDomainServices/IAppDomainService.cs +++ /dev/null @@ -1,11 +0,0 @@ -using H.LowCode.MetaSchema; -using Volo.Abp.Domain.Services; - -namespace H.LowCode.RenderEngine.Domain; - -public interface IAppDomainService : IDomainService -{ - Task> GetListAsync(); - - Task GetAsync(string appId); -} \ No newline at end of file diff --git a/src/RenderEngine/H.LowCode.RenderEngine.Domain/MetaDomainServices/IDataSourceDomainService.cs b/src/RenderEngine/H.LowCode.RenderEngine.Domain/MetaDomainServices/IDataSourceDomainService.cs deleted file mode 100644 index a6d34c39e42a9ec7bc3a73833e982bfcfa072eae..0000000000000000000000000000000000000000 --- a/src/RenderEngine/H.LowCode.RenderEngine.Domain/MetaDomainServices/IDataSourceDomainService.cs +++ /dev/null @@ -1,15 +0,0 @@ -using H.LowCode.MetaSchema; -using Volo.Abp.Domain.Services; - -namespace H.LowCode.RenderEngine.Domain; - -public interface IDataSourceDomainService : IDomainService -{ - Task> GetListAsync(string appId); - - Task> GetAllApisAsync(string appId); - - IEnumerable GetAllEntities(string appId); - - Task GetAsync(string appId, string id); -} \ No newline at end of file diff --git a/src/RenderEngine/H.LowCode.RenderEngine.Domain/MetaDomainServices/IMenuDomainService.cs b/src/RenderEngine/H.LowCode.RenderEngine.Domain/MetaDomainServices/IMenuDomainService.cs deleted file mode 100644 index f7cefa5434f23579fafdfb3ae8031e53ce504b25..0000000000000000000000000000000000000000 --- a/src/RenderEngine/H.LowCode.RenderEngine.Domain/MetaDomainServices/IMenuDomainService.cs +++ /dev/null @@ -1,11 +0,0 @@ -using H.LowCode.MetaSchema; -using Volo.Abp.Domain.Services; - -namespace H.LowCode.RenderEngine.Domain; - -public interface IMenuDomainService : IDomainService -{ - Task GetAsync(string appId, string menuId); - - Task> GetListAsync(string appId); -} \ No newline at end of file diff --git a/src/RenderEngine/H.LowCode.RenderEngine.Domain/MetaDomainServices/IMetaDomainService.cs b/src/RenderEngine/H.LowCode.RenderEngine.Domain/MetaDomainServices/IMetaDomainService.cs deleted file mode 100644 index 667b9e4d8f490dbf539f3853938c4f3a2ff02709..0000000000000000000000000000000000000000 --- a/src/RenderEngine/H.LowCode.RenderEngine.Domain/MetaDomainServices/IMetaDomainService.cs +++ /dev/null @@ -1,8 +0,0 @@ -using Volo.Abp.Domain.Services; - -namespace H.LowCode.RenderEngine.Domain; - -public interface IMetaDomainService : IDomainService -{ - -} diff --git a/src/RenderEngine/H.LowCode.RenderEngine.Domain/MetaDomainServices/IPageDomainService.cs b/src/RenderEngine/H.LowCode.RenderEngine.Domain/MetaDomainServices/IPageDomainService.cs deleted file mode 100644 index e5c982f204c3b2b8c691b0f91afd7712ef8d8ec4..0000000000000000000000000000000000000000 --- a/src/RenderEngine/H.LowCode.RenderEngine.Domain/MetaDomainServices/IPageDomainService.cs +++ /dev/null @@ -1,9 +0,0 @@ -using H.LowCode.MetaSchema.RenderEngine; -using Volo.Abp.Domain.Services; - -namespace H.LowCode.RenderEngine.Domain; - -public interface IPageDomainService : IDomainService -{ - Task GetAsync(string appId, string pageId); -} \ No newline at end of file diff --git a/src/RenderEngine/H.LowCode.RenderEngine.Domain/MetaDomainServices/MenuDomainService.cs b/src/RenderEngine/H.LowCode.RenderEngine.Domain/MetaDomainServices/MenuDomainService.cs deleted file mode 100644 index eedd7e5bebcbae1033b32c2f9aacf8647933d069..0000000000000000000000000000000000000000 --- a/src/RenderEngine/H.LowCode.RenderEngine.Domain/MetaDomainServices/MenuDomainService.cs +++ /dev/null @@ -1,25 +0,0 @@ -using H.LowCode.RenderEngine.Domain.Repositories; -using H.LowCode.MetaSchema; -using Volo.Abp.Domain.Services; - -namespace H.LowCode.RenderEngine.Domain; - -public class MenuDomainService : DomainService, IMenuDomainService -{ - private readonly IMenuRepository _repository; - - public MenuDomainService(IMenuRepository repository) - { - _repository = repository; - } - - public async Task> GetListAsync(string appId) - { - return await _repository.GetListAsync(appId); - } - - public async Task GetAsync(string appId, string menuId) - { - return await _repository.GetAsync(appId, menuId); - } -} \ No newline at end of file diff --git a/src/RenderEngine/H.LowCode.RenderEngine.Domain/MetaDomainServices/MetaDomainService.cs b/src/RenderEngine/H.LowCode.RenderEngine.Domain/MetaDomainServices/MetaDomainService.cs deleted file mode 100644 index 83b721a29b13c462f3bb00304807816b439dad77..0000000000000000000000000000000000000000 --- a/src/RenderEngine/H.LowCode.RenderEngine.Domain/MetaDomainServices/MetaDomainService.cs +++ /dev/null @@ -1,8 +0,0 @@ -using Volo.Abp.Domain.Services; - -namespace H.LowCode.RenderEngine.Domain; - -public class MetaDomainService : DomainService, IMetaDomainService -{ - -} diff --git a/src/RenderEngine/H.LowCode.RenderEngine.Domain/MetaDomainServices/PageDomainService.cs b/src/RenderEngine/H.LowCode.RenderEngine.Domain/MetaDomainServices/PageDomainService.cs deleted file mode 100644 index f37aefeb8a15f269218a4f3f003e7b32f94e27b4..0000000000000000000000000000000000000000 --- a/src/RenderEngine/H.LowCode.RenderEngine.Domain/MetaDomainServices/PageDomainService.cs +++ /dev/null @@ -1,20 +0,0 @@ -using H.LowCode.RenderEngine.Domain.Repositories; -using H.LowCode.MetaSchema.RenderEngine; -using Volo.Abp.Domain.Services; - -namespace H.LowCode.RenderEngine.Domain; - -public class PageDomainService : DomainService, IPageDomainService -{ - private readonly IPageRepository _repository; - - public PageDomainService(IPageRepository repository) - { - _repository = repository; - } - - async Task IPageDomainService.GetAsync(string appId, string pageId) - { - return await _repository.GetAsync(appId, pageId); - } -} \ No newline at end of file diff --git a/src/RenderEngine/H.LowCode.RenderEngine.Domain/MetaRepositories/IDataSourceRepository.cs b/src/RenderEngine/H.LowCode.RenderEngine.Domain/MetaRepositories/IDataSourceRepository.cs index b13f2ab9b64e11c96a85954660d3143779eca2b0..9edabcf54cc47ebba9b16a35cfaae4fa90f34892 100644 --- a/src/RenderEngine/H.LowCode.RenderEngine.Domain/MetaRepositories/IDataSourceRepository.cs +++ b/src/RenderEngine/H.LowCode.RenderEngine.Domain/MetaRepositories/IDataSourceRepository.cs @@ -7,4 +7,8 @@ public interface IDataSourceRepository Task> GetListAsync(string appId); Task GetAsync(string appId, string id); + + Task> GetAllApisAsync(string appId); + + IEnumerable GetAllEntities(string appId); } \ No newline at end of file diff --git a/src/RenderEngine/H.LowCode.RenderEngine.EntityFrameworkCore/DataRepositories/FormDataRepository.cs b/src/RenderEngine/H.LowCode.RenderEngine.EntityFrameworkCore/DataRepositories/FormDataRepository.cs index 1c8a6392887c6e07a93cbb06296beafa563a3eef..d91f0ce910ce778052f6f21d7ef481539556889f 100644 --- a/src/RenderEngine/H.LowCode.RenderEngine.EntityFrameworkCore/DataRepositories/FormDataRepository.cs +++ b/src/RenderEngine/H.LowCode.RenderEngine.EntityFrameworkCore/DataRepositories/FormDataRepository.cs @@ -1,4 +1,4 @@ -using H.LowCode.Entity; +using H.LowCode.Entity; using H.LowCode.MetaSchema; using H.LowCode.RenderEngine.Domain; using Microsoft.EntityFrameworkCore; @@ -13,31 +13,39 @@ namespace H.LowCode.RenderEngine.EntityFrameworkCore; public class FormDataRepository : IFormDataRepository { - private RenderEngineDbContext _dbContext; + private readonly IDbContextFactory _dbContextFactory; public bool? IsChangeTrackingEnabled => true; - public FormDataRepository(RenderEngineDbContext dbContext) + public string? EntityName { get; set; } + + public string ProviderName => throw new NotImplementedException(); + + public FormDataRepository(IDbContextFactory dbContextFactory) { - _dbContext = dbContext; + _dbContextFactory = dbContextFactory; } public async Task AddAsync(FormEntity entity) { - return await _dbContext.AddAsync(entity); + using var dbContext = await _dbContextFactory.CreateDbContextAsync(); + return await dbContext.AddAsync(entity); } public async Task GetAsync(string tableName, string id) { - return await _dbContext.GetAsync(tableName, id); + using var dbContext = await _dbContextFactory.CreateDbContextAsync(); + return await dbContext.GetAsync(tableName, id); } public async Task UpdateAsync(FormEntity entity) { - return await _dbContext.UpdateAsync(entity); + using var dbContext = await _dbContextFactory.CreateDbContextAsync(); + return await dbContext.UpdateAsync(entity); } public async Task DeleteAsync(string entityName, string id) { - return await _dbContext.DeleteAsync(entityName, id); + using var dbContext = await _dbContextFactory.CreateDbContextAsync(); + return await dbContext.DeleteAsync(entityName, id); } } diff --git a/src/RenderEngine/H.LowCode.RenderEngine.EntityFrameworkCore/DataRepositories/TableDataRepository.cs b/src/RenderEngine/H.LowCode.RenderEngine.EntityFrameworkCore/DataRepositories/TableDataRepository.cs index ea711dc5e985f7c212b73a38aaf33b870f704922..ca571e275e18a2fadd6c5722a6890736c4efc467 100644 --- a/src/RenderEngine/H.LowCode.RenderEngine.EntityFrameworkCore/DataRepositories/TableDataRepository.cs +++ b/src/RenderEngine/H.LowCode.RenderEngine.EntityFrameworkCore/DataRepositories/TableDataRepository.cs @@ -1,17 +1,197 @@ -using H.LowCode.RenderEngine.Domain; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using H.LowCode.Application.Contracts; +using H.LowCode.RenderEngine.Domain; +using H.LowCode.RenderEngine.Domain.Repositories; +using Microsoft.EntityFrameworkCore; +using Volo.Abp.Application.Dtos; namespace H.LowCode.RenderEngine.EntityFrameworkCore; public class TableDataRepository : ITableDataRepository { + private readonly IDbContextFactory _dbContextFactory; + private readonly IDataSourceRepository _dataSourceRepository; public bool? IsChangeTrackingEnabled => true; - public TableDataRepository(RenderEngineDbContext dbContext) + public string? EntityName { get; set; } + + public string ProviderName => throw new NotImplementedException(); + + public TableDataRepository(IDbContextFactory dbContextFactory, IDataSourceRepository dataSourceRepository) + { + _dbContextFactory = dbContextFactory; + _dataSourceRepository = dataSourceRepository; + } + + /// + /// 获取表格数据列表 + /// + /// 查询参数 + /// 分页数据结果 + public async Task>> GetListAsync(TableDataInput input) + { + var dataSource = await _dataSourceRepository.GetAsync(input.AppId, input.DataSourceId); + if (dataSource == null) + { + return new(); + } + + // 使用 DbContextFactory 创建新的 DbContext 实例,确保线程安全 + using var dbContext = await _dbContextFactory.CreateDbContextAsync(); + + // 获取实体类型(使用数据源名称) + var entityType = dbContext.GetEntityType(dataSource.Name); + + // 获取DbSet + var dbSetProperty = dbContext.GetType().GetMethod("Set", Type.EmptyTypes)?.MakeGenericMethod(entityType); + var dbSet = dbSetProperty?.Invoke(dbContext, null) as IQueryable; + + if (dbSet == null) + { + return new(); + } + + // 应用筛选条件 + if (input.Filters != null && input.Filters.Any()) + { + // 这里可以根据需要实现更复杂的筛选逻辑 + // 暂时跳过筛选实现 + } + + // 应用排序 + if (!string.IsNullOrEmpty(input.Sorting)) + { + var parameter = System.Linq.Expressions.Expression.Parameter(entityType, "x"); + var property = System.Linq.Expressions.Expression.Property(parameter, input.Sorting); + var lambda = System.Linq.Expressions.Expression.Lambda(property, parameter); + + var orderByMethod = input.Sorting?.ToLower() == "desc" ? "OrderByDescending" : "OrderBy"; + var orderByExpression = System.Linq.Expressions.Expression.Call( + typeof(Queryable), + orderByMethod, + new Type[] { entityType, property.Type }, + dbSet.Expression, + System.Linq.Expressions.Expression.Quote(lambda)); + + dbSet = dbSet.Provider.CreateQuery(orderByExpression); + } + + // 获取总数 + var totalCount = await dbSet.CountAsync(); + + // 应用分页 + var pagedData = await dbSet + .Skip(input.SkipCount) + .Take(input.MaxResultCount) + .ToListAsync(); + + // 转换为字典格式 + var result = new List>(); + foreach (var item in pagedData) + { + var dict = new Dictionary(); + var properties = entityType.GetProperties(); + foreach (var prop in properties) + { + var value = prop.GetValue(item); + dict[prop.Name] = value; + } + result.Add(dict); + } + + return new() + { + Items = result, + TotalCount = totalCount + }; + } + + /// + /// 删除数据 + /// + /// 删除请求参数 + public async Task DeleteAsync(TableDataDeleteInput request) + { + var dataSource = await _dataSourceRepository.GetAsync(request.AppId, request.DataSourceId); + if (dataSource == null) + { + throw new ArgumentException($"数据源不存在: {request.DataSourceId}"); + } + + // 使用 DbContextFactory 创建新的 DbContext 实例,确保线程安全 + using var dbContext = await _dbContextFactory.CreateDbContextAsync(); + + // 获取实体类型(使用数据源名称) + var entityType = dbContext.GetEntityType(dataSource.Name); + + // 根据ID查找要删除的实体 + var entity = await dbContext.FindAsync(entityType, request.Id); + if (entity == null) + { + throw new ArgumentException($"要删除的记录不存在: {request.Id}"); + } + + // 删除实体 + dbContext.Remove(entity); + await dbContext.SaveChangesAsync(); + } + + /// + /// 更新数据 + /// + /// 更新请求参数 + public async Task UpdateAsync(TableDataUpdateInput request) { + var dataSource = await _dataSourceRepository.GetAsync(request.AppId, request.DataSourceId); + if (dataSource == null) + { + throw new ArgumentException($"数据源不存在: {request.DataSourceId}"); + } + + // 使用 DbContextFactory 创建新的 DbContext 实例,确保线程安全 + using var dbContext = await _dbContextFactory.CreateDbContextAsync(); + + // 获取实体类型(使用数据源名称) + var entityType = dbContext.GetEntityType(dataSource.Name); + + // 根据ID查找要更新的实体 + var entity = await dbContext.FindAsync(entityType, request.Id); + if (entity == null) + { + throw new ArgumentException($"要更新的记录不存在: {request.Id}"); + } + + // 更新实体属性 + if (request.UpdateData != null && request.UpdateData.Any()) + { + var properties = entityType.GetProperties(); + foreach (var updateField in request.UpdateData) + { + var property = properties.FirstOrDefault(p => + string.Equals(p.Name, updateField.Key, StringComparison.OrdinalIgnoreCase)); + + if (property != null && property.CanWrite) + { + // 类型转换 + var value = updateField.Value; + if (value != null && value.GetType() != property.PropertyType) + { + try + { + value = Convert.ChangeType(value, property.PropertyType); + } + catch + { + // 转换失败时跳过该字段 + continue; + } + } + + property.SetValue(entity, value); + } + } + } + + // 保存更改 + await dbContext.SaveChangesAsync(); } } diff --git a/src/RenderEngine/H.LowCode.RenderEngine.EntityFrameworkCore/EntityManager/EntityTypeManager.cs b/src/RenderEngine/H.LowCode.RenderEngine.EntityFrameworkCore/EntityManager/EntityTypeManager.cs index cd7aeee70784b1976077fdf3206ec00ad6b110e9..ce0cbaf5f80e3930c5aabc736b70e94446258e1d 100644 --- a/src/RenderEngine/H.LowCode.RenderEngine.EntityFrameworkCore/EntityManager/EntityTypeManager.cs +++ b/src/RenderEngine/H.LowCode.RenderEngine.EntityFrameworkCore/EntityManager/EntityTypeManager.cs @@ -8,6 +8,7 @@ using System.Threading.Tasks; using System.ComponentModel.DataAnnotations; using H.LowCode.Entity; using H.LowCode.RenderEngine.Domain; +using H.LowCode.RenderEngine.Domain.Repositories; namespace H.LowCode.RenderEngine.EntityFrameworkCore; @@ -20,11 +21,11 @@ public class EntityTypeManager private static List _dynamicEntities = []; - private IDataSourceDomainService _dataSourceDomainService; + private IDataSourceRepository _dataSourceRepository; - public EntityTypeManager(IDataSourceDomainService dataSourceDomainService) + public EntityTypeManager(IDataSourceRepository dataSourceRepository) { - _dataSourceDomainService = dataSourceDomainService; + _dataSourceRepository = dataSourceRepository; } public IReadOnlyList LoadDynamicEntities() @@ -34,7 +35,7 @@ public class EntityTypeManager if(_dynamicEntities.Count > 0) return _dynamicEntities; - var entities = _dataSourceDomainService.GetAllEntities("caseapp"); + var entities = _dataSourceRepository.GetAllEntities("caseapp"); foreach (var entity in entities) { var fields = entity.TableFields.Select(f => new DynamicEntityField() diff --git a/src/RenderEngine/H.LowCode.RenderEngine.EntityFrameworkCore/H.LowCode.RenderEngine.EntityFrameworkCore.csproj b/src/RenderEngine/H.LowCode.RenderEngine.EntityFrameworkCore/H.LowCode.RenderEngine.EntityFrameworkCore.csproj index ac31d00e324c3b9b4daf454ac224724e8b3d0757..1ebfafba6ed89328d2810d0a5af8a86e18c53ae5 100644 --- a/src/RenderEngine/H.LowCode.RenderEngine.EntityFrameworkCore/H.LowCode.RenderEngine.EntityFrameworkCore.csproj +++ b/src/RenderEngine/H.LowCode.RenderEngine.EntityFrameworkCore/H.LowCode.RenderEngine.EntityFrameworkCore.csproj @@ -1,6 +1,6 @@  - + diff --git a/src/RenderEngine/H.LowCode.RenderEngine.EntityFrameworkCore/RenderEngineEntityFrameworkCoreModule.cs b/src/RenderEngine/H.LowCode.RenderEngine.EntityFrameworkCore/RenderEngineEntityFrameworkCoreModule.cs index 09438bf09fc405d1d4525a9d2b63d1e5c7bb023c..ca33e67816301926fca8a119ef38a865ac9e84dd 100644 --- a/src/RenderEngine/H.LowCode.RenderEngine.EntityFrameworkCore/RenderEngineEntityFrameworkCoreModule.cs +++ b/src/RenderEngine/H.LowCode.RenderEngine.EntityFrameworkCore/RenderEngineEntityFrameworkCoreModule.cs @@ -1,4 +1,4 @@ -using H.LowCode.RenderEngine.Domain; +using H.LowCode.RenderEngine.Domain; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; @@ -17,6 +17,14 @@ public class RenderEngineEntityFrameworkCoreModule : AbpModule context.Services.AddScoped(typeof(EntityTypeManager)); + // 注册 DbContext 工厂,确保每次使用都创建新的实例,避免并发访问问题 + context.Services.AddDbContextFactory(options => + { + var connectionString = context.Services.GetConfiguration().GetConnectionString("Default"); + options.UseSqlServer(connectionString); + }); + + // 保持原有的 DbContext 注册方式作为备用 context.Services.AddDbContext(options => { var connectionString = context.Services.GetConfiguration().GetConnectionString("Default"); diff --git a/src/RenderEngine/H.LowCode.RenderEngine.Host.Client/H.LowCode.RenderEngine.Host.Client.csproj b/src/RenderEngine/H.LowCode.RenderEngine.Host.Client/H.LowCode.RenderEngine.Host.Client.csproj index 4358d04c3149b0dc6ef2c99b88e3b2bd2bf2bcfe..1cab00ad23b0a4ba171497ed2d93559b7bfec013 100644 --- a/src/RenderEngine/H.LowCode.RenderEngine.Host.Client/H.LowCode.RenderEngine.Host.Client.csproj +++ b/src/RenderEngine/H.LowCode.RenderEngine.Host.Client/H.LowCode.RenderEngine.Host.Client.csproj @@ -1,12 +1,11 @@  - + true Default - true - false + true diff --git a/src/RenderEngine/H.LowCode.RenderEngine.Host.Client/RenderEngineHostClientModule.cs b/src/RenderEngine/H.LowCode.RenderEngine.Host.Client/RenderEngineHostClientModule.cs index 3533cd3c4c19c77bb4a6c419bf2ded1a9c06ea65..9b007b32d517f1fa4e7f9a8999db44ab659d405d 100644 --- a/src/RenderEngine/H.LowCode.RenderEngine.Host.Client/RenderEngineHostClientModule.cs +++ b/src/RenderEngine/H.LowCode.RenderEngine.Host.Client/RenderEngineHostClientModule.cs @@ -1,8 +1,8 @@ -using H.LowCode.ComponentBase; +using H.LowCode.Application.Contracts; +using H.LowCode.ComponentBase; using H.LowCode.Components.Defaults; using H.LowCode.RenderEngine.Application.Contracts; using H.LowCode.Themes.AntBlazor; -using H.Util.Blazor; using Microsoft.AspNetCore.Components.WebAssembly.Hosting; using Volo.Abp.Autofac.WebAssembly; using Volo.Abp.Http.Client; @@ -22,9 +22,7 @@ namespace H.LowCode.RenderEngine.Host.Client; //Components typeof(LowCodeDefaultComponentModule), //Themes - typeof(AntBlazorThemeModule), - //ComponentBase - typeof(LowCodeComponentBaseModule) + typeof(AntBlazorThemeModule) )] public class RenderEngineHostClientModule : AbpModule { @@ -56,5 +54,9 @@ public class RenderEngineHostClientModule : AbpModule typeof(RenderEngineApplicationContractsModule).Assembly, RemoteServiceName ); + context.Services.AddHttpClientProxies( + typeof(LowCodeApplicationContractsModule).Assembly, + RemoteServiceName + ); } } diff --git a/src/RenderEngine/H.LowCode.RenderEngine.Host.Client/wwwroot/appsettings.Development.json b/src/RenderEngine/H.LowCode.RenderEngine.Host.Client/wwwroot/appsettings.Development.json index a576c0450c5f4d168fbb31c6a6d89623f5e06c95..f38ec4691ed11f4662d64361269298a6a3a78e93 100644 --- a/src/RenderEngine/H.LowCode.RenderEngine.Host.Client/wwwroot/appsettings.Development.json +++ b/src/RenderEngine/H.LowCode.RenderEngine.Host.Client/wwwroot/appsettings.Development.json @@ -1,4 +1,11 @@ { + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning", + "Microsoft.AspNetCore.Components.WebAssembly": "Warning" + } + }, "RemoteServices": { "Default": { "BaseUrl": "https://localhost:5191" diff --git a/src/RenderEngine/H.LowCode.RenderEngine.Host.Client/wwwroot/appsettings.json b/src/RenderEngine/H.LowCode.RenderEngine.Host.Client/wwwroot/appsettings.json index a576c0450c5f4d168fbb31c6a6d89623f5e06c95..f38ec4691ed11f4662d64361269298a6a3a78e93 100644 --- a/src/RenderEngine/H.LowCode.RenderEngine.Host.Client/wwwroot/appsettings.json +++ b/src/RenderEngine/H.LowCode.RenderEngine.Host.Client/wwwroot/appsettings.json @@ -1,4 +1,11 @@ { + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning", + "Microsoft.AspNetCore.Components.WebAssembly": "Warning" + } + }, "RemoteServices": { "Default": { "BaseUrl": "https://localhost:5191" diff --git a/src/RenderEngine/H.LowCode.RenderEngine.Host/Components/App.razor b/src/RenderEngine/H.LowCode.RenderEngine.Host/Components/App.razor index 85cab2e684dbdca4c36bda3ab39784c863681c10..97a03b47fd3f522801050dd65b3b822374058525 100644 --- a/src/RenderEngine/H.LowCode.RenderEngine.Host/Components/App.razor +++ b/src/RenderEngine/H.LowCode.RenderEngine.Host/Components/App.razor @@ -21,14 +21,16 @@ - + - + + + diff --git a/src/RenderEngine/H.LowCode.RenderEngine.Host/Components/_Imports.razor b/src/RenderEngine/H.LowCode.RenderEngine.Host/Components/_Imports.razor index b4cb54e4eb1a1c7e9592b5075814eb7d41980714..f2054eb2440cd563e2530034c2ff7184705305e3 100644 --- a/src/RenderEngine/H.LowCode.RenderEngine.Host/Components/_Imports.razor +++ b/src/RenderEngine/H.LowCode.RenderEngine.Host/Components/_Imports.razor @@ -8,4 +8,4 @@ @using Microsoft.JSInterop @using H.LowCode.RenderEngine.Host @using H.LowCode.RenderEngine.Host.Client -@using H.LowCode.RenderEngine.Host.Components +@using H.LowCode.RenderEngine.Host.Components \ No newline at end of file diff --git a/src/RenderEngine/H.LowCode.RenderEngine.Host/H.LowCode.RenderEngine.Host.csproj b/src/RenderEngine/H.LowCode.RenderEngine.Host/H.LowCode.RenderEngine.Host.csproj index 0d1962013dc95f11c21f866f32d46170728e8b2b..395f6325beb59e99e124d0edaf88840e1d31eb78 100644 --- a/src/RenderEngine/H.LowCode.RenderEngine.Host/H.LowCode.RenderEngine.Host.csproj +++ b/src/RenderEngine/H.LowCode.RenderEngine.Host/H.LowCode.RenderEngine.Host.csproj @@ -1,6 +1,10 @@  - + + + + true + diff --git a/src/RenderEngine/H.LowCode.RenderEngine.Host/Program.cs b/src/RenderEngine/H.LowCode.RenderEngine.Host/Program.cs index 856be7d6b6b51464cc0fb169dccce185c2477c69..a944b97238c3e5df688befd84f5ef79c83e0f390 100644 --- a/src/RenderEngine/H.LowCode.RenderEngine.Host/Program.cs +++ b/src/RenderEngine/H.LowCode.RenderEngine.Host/Program.cs @@ -52,6 +52,9 @@ else app.UseHsts(); } +app.UseStatusCodePagesWithReExecute("/not-found", createScopeForStatusCodePages: true); +app.UseHttpsRedirection(); + app.UseResponseCompression(); app.UseStaticFiles(new StaticFileOptions { @@ -61,8 +64,6 @@ app.UseStaticFiles(new StaticFileOptions } }); -app.UseHttpsRedirection(); - app.MapStaticAssets(); app.UseRouting(); app.UseAntiforgery(); diff --git a/src/RenderEngine/H.LowCode.RenderEngine.Host/RenderEngineHostModule.cs b/src/RenderEngine/H.LowCode.RenderEngine.Host/RenderEngineHostModule.cs index aa068e6d9f23b8f7b2ed2d38098949ed16313ec1..c8074f443ef69437fd9b3c795bd4656600ca4ec8 100644 --- a/src/RenderEngine/H.LowCode.RenderEngine.Host/RenderEngineHostModule.cs +++ b/src/RenderEngine/H.LowCode.RenderEngine.Host/RenderEngineHostModule.cs @@ -1,4 +1,4 @@ -using H.LowCode.ComponentBase; +using H.LowCode.ComponentBase; using H.LowCode.Components.Defaults; using H.LowCode.RenderEngine.Application; using H.LowCode.RenderEngine.EntityFrameworkCore; @@ -25,9 +25,7 @@ namespace H.LowCode.RenderEngine.Host; //Components typeof(LowCodeDefaultComponentModule), //Themes - typeof(AntBlazorThemeModule), - //ComponentBase - typeof(LowCodeComponentBaseModule) + typeof(AntBlazorThemeModule) )] public class RenderEngineHostModule : AbpModule { diff --git a/src/RenderEngine/H.LowCode.RenderEngine.Repository.JsonFile/H.LowCode.RenderEngine.Repository.JsonFile.csproj b/src/RenderEngine/H.LowCode.RenderEngine.Repository.JsonFile/H.LowCode.RenderEngine.Repository.JsonFile.csproj index 15163eee4932fd351a12035b6e1ac968ffc20988..ef8b4f31d7be60d89f7f215ae17836a7cf72e76e 100644 --- a/src/RenderEngine/H.LowCode.RenderEngine.Repository.JsonFile/H.LowCode.RenderEngine.Repository.JsonFile.csproj +++ b/src/RenderEngine/H.LowCode.RenderEngine.Repository.JsonFile/H.LowCode.RenderEngine.Repository.JsonFile.csproj @@ -1,6 +1,6 @@  - + diff --git a/src/RenderEngine/H.LowCode.RenderEngine.Repository.JsonFile/Repositories/DataSourceFileRepository.cs b/src/RenderEngine/H.LowCode.RenderEngine.Repository.JsonFile/Repositories/DataSourceFileRepository.cs index 22bea1c37e053a00887675226a72010f548fc3a1..1980b82715abd228777f33f8373f42346b54fb0a 100644 --- a/src/RenderEngine/H.LowCode.RenderEngine.Repository.JsonFile/Repositories/DataSourceFileRepository.cs +++ b/src/RenderEngine/H.LowCode.RenderEngine.Repository.JsonFile/Repositories/DataSourceFileRepository.cs @@ -46,4 +46,16 @@ public class DataSourceFileRepository : FileRepositoryBase, IDataSourceRepositor var dataSource = dataSourceSchemaJson.FromJson(); return await Task.FromResult(dataSource); } + + public async Task> GetAllApisAsync(string appId) + { + var list = await GetListAsync(appId); + return list.Where(t => t.DataSourceType == ComponentDataSourceTypeEnum.API).ToList(); + } + + public IEnumerable GetAllEntities(string appId) + { + var list = GetListAsync(appId).Result; + return list.Where(t => t.DataSourceType == ComponentDataSourceTypeEnum.DB).ToList(); + } } diff --git a/src/RenderEngine/H.LowCode.RenderEngine.Repository.RemoteService/H.LowCode.RenderEngine.Repository.RemoteService.csproj b/src/RenderEngine/H.LowCode.RenderEngine.Repository.RemoteService/H.LowCode.RenderEngine.Repository.RemoteService.csproj index b2c56a6d87e26809ad357b02270b33fa2fcbc097..4a1ed43382c10958280c5610a406f31aad669be0 100644 --- a/src/RenderEngine/H.LowCode.RenderEngine.Repository.RemoteService/H.LowCode.RenderEngine.Repository.RemoteService.csproj +++ b/src/RenderEngine/H.LowCode.RenderEngine.Repository.RemoteService/H.LowCode.RenderEngine.Repository.RemoteService.csproj @@ -1,6 +1,6 @@  - + diff --git a/src/RenderEngine/H.LowCode.RenderEngine.Repository.RemoteService/Repositories/DataSourceRemoteServiceRepository.cs b/src/RenderEngine/H.LowCode.RenderEngine.Repository.RemoteService/Repositories/DataSourceRemoteServiceRepository.cs index b328381df48556c5912753646dc86219f79c1b9e..36a4098d68740f7a27e4f975276abee79313cbda 100644 --- a/src/RenderEngine/H.LowCode.RenderEngine.Repository.RemoteService/Repositories/DataSourceRemoteServiceRepository.cs +++ b/src/RenderEngine/H.LowCode.RenderEngine.Repository.RemoteService/Repositories/DataSourceRemoteServiceRepository.cs @@ -23,4 +23,14 @@ public class DataSourceRemoteServiceRepository : RemoteServiceRepositoryBase, ID { throw new NotImplementedException(); } + + public Task> GetAllApisAsync(string appId) + { + throw new NotImplementedException(); + } + + public IEnumerable GetAllEntities(string appId) + { + throw new NotImplementedException(); + } } diff --git a/src/RenderEngine/H.LowCode.RenderEngine/H.LowCode.RenderEngine.csproj b/src/RenderEngine/H.LowCode.RenderEngine/H.LowCode.RenderEngine.csproj index 8fe5b14ccdfd88ecfb1f9cc3e52fe273105e3fda..abaf0e841c6c9d9dccaea993e66cfb7d1db2d812 100644 --- a/src/RenderEngine/H.LowCode.RenderEngine/H.LowCode.RenderEngine.csproj +++ b/src/RenderEngine/H.LowCode.RenderEngine/H.LowCode.RenderEngine.csproj @@ -1,6 +1,6 @@  - + @@ -15,13 +15,13 @@ - - - + - + + + diff --git a/src/RenderEngine/H.LowCode.RenderEngine/RenderEngineModule.cs b/src/RenderEngine/H.LowCode.RenderEngine/RenderEngineModule.cs index 5fcf88c4ccb974540aa40f34c9d5891354c771a7..8ff4e031a29c0eb5c05c6fcd1d832fba9800e19f 100644 --- a/src/RenderEngine/H.LowCode.RenderEngine/RenderEngineModule.cs +++ b/src/RenderEngine/H.LowCode.RenderEngine/RenderEngineModule.cs @@ -1,8 +1,10 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using H.LowCode.MetaSchema.Services; +using Microsoft.Extensions.DependencyInjection; using Volo.Abp.Modularity; namespace H.LowCode.RenderEngine; @@ -11,6 +13,6 @@ public class RenderEngineModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) { - + context.Services.AddTransient(); } } diff --git a/src/RenderEngine/H.LowCode.Themes.AntBlazor/ComponentRender/FormComponentRender.razor b/src/RenderEngine/H.LowCode.Themes.AntBlazor/ComponentRender/FormComponentRender.razor index 5a1e6b0efbb8b77ff50e74a72a48ae97181e8b8f..79bbcd24d3090c6f09d72057d88848895170955d 100644 --- a/src/RenderEngine/H.LowCode.Themes.AntBlazor/ComponentRender/FormComponentRender.razor +++ b/src/RenderEngine/H.LowCode.Themes.AntBlazor/ComponentRender/FormComponentRender.razor @@ -1,5 +1,7 @@ -@namespace H.LowCode.Themes.AntBlazor +@namespace H.LowCode.Themes.AntBlazor @inherits RenderEngineDynamicComponentBase +@using H.LowCode.MetaSchema.Services +@inject IFormValidationService ValidationService @if (Component.IsContainer) { @@ -14,7 +16,10 @@ else + Style="width:100%" + Rules="@_validationRules" + ValidateStatus="@_validateStatus" + Help="@_helpMessage">
@_renderFragment
@@ -36,6 +41,9 @@ else public bool IsInRootContainer { get; set; } private RenderFragment _renderFragment; + private FormValidationRule[] _validationRules = Array.Empty(); + private FormValidateStatus _validateStatus = FormValidateStatus.Default; + private string? _helpMessage; protected override async Task OnInitializedAsync() { @@ -50,5 +58,92 @@ else throw new NullReferenceException(nameof(Component)); _renderFragment = RenderComponent(Component); + InitializeValidationRules(); + } + + private void InitializeValidationRules() + { + if (Component.ValidationRules == null || !Component.ValidationRules.Any()) + { + _validationRules = Array.Empty(); + return; + } + + var rules = new List(); + + foreach (var rule in Component.ValidationRules.Where(r => r.IsEnabled)) + { + var formRule = new FormValidationRule + { + Required = rule.RuleType == ValidationRuleTypeEnum.Required, + Message = rule.ErrorMessage ?? GetDefaultErrorMessage(rule.RuleType) + }; + + // 设置长度校验 + if (rule.RuleType == ValidationRuleTypeEnum.MinLength && rule.MinLength.HasValue) + { + formRule.Min = rule.MinLength.Value; + } + if (rule.RuleType == ValidationRuleTypeEnum.MaxLength && rule.MaxLength.HasValue) + { + formRule.Max = rule.MaxLength.Value; + } + + // 设置数值校验 + if (rule.RuleType == ValidationRuleTypeEnum.MinValue && rule.MinValue.HasValue) + { + formRule.Min = (int)rule.MinValue.Value; + } + if (rule.RuleType == ValidationRuleTypeEnum.MaxValue && rule.MaxValue.HasValue) + { + formRule.Max = (int)rule.MaxValue.Value; + } + + // 设置正则表达式校验 + if (rule.RuleType == ValidationRuleTypeEnum.Pattern && !string.IsNullOrEmpty(rule.Pattern)) + { + formRule.Pattern = rule.Pattern; + } + + // 设置邮箱校验 + if (rule.RuleType == ValidationRuleTypeEnum.Email) + { + formRule.Type = FormFieldType.Email; + } + + // 设置URL校验 + if (rule.RuleType == ValidationRuleTypeEnum.Url) + { + formRule.Type = FormFieldType.Url; + } + + rules.Add(formRule); + } + + _validationRules = rules.ToArray(); + } + + private string GetDefaultErrorMessage(ValidationRuleTypeEnum ruleType) + { + return ruleType switch + { + ValidationRuleTypeEnum.Required => "此字段为必填项", + ValidationRuleTypeEnum.MinLength => "输入长度不足", + ValidationRuleTypeEnum.MaxLength => "输入长度超限", + ValidationRuleTypeEnum.MinValue => "输入值过小", + ValidationRuleTypeEnum.MaxValue => "输入值过大", + ValidationRuleTypeEnum.Pattern => "格式不正确", + ValidationRuleTypeEnum.Email => "请输入有效的邮箱地址", + ValidationRuleTypeEnum.Phone => "请输入有效的手机号码", + ValidationRuleTypeEnum.Url => "请输入有效的URL地址", + _ => "输入不符合要求" + }; + } + + public void UpdateValidationStatus(FormValidateStatus status, string? message = null) + { + _validateStatus = status; + _helpMessage = message; + StateHasChanged(); } } \ No newline at end of file diff --git a/src/RenderEngine/H.LowCode.Themes.AntBlazor/H.LowCode.Themes.AntBlazor.csproj b/src/RenderEngine/H.LowCode.Themes.AntBlazor/H.LowCode.Themes.AntBlazor.csproj index cc03d5012fc2ef1e980a056cfb93ad0ec9a9a82f..330e85d3c411f7002231367ce50f60a9c4f45744 100644 --- a/src/RenderEngine/H.LowCode.Themes.AntBlazor/H.LowCode.Themes.AntBlazor.csproj +++ b/src/RenderEngine/H.LowCode.Themes.AntBlazor/H.LowCode.Themes.AntBlazor.csproj @@ -1,6 +1,6 @@  - + @@ -17,17 +17,17 @@ - + + + + + + - - - - - - + diff --git a/src/RenderEngine/H.LowCode.Themes.AntBlazor/Layout/AntBlazorThemeLayout.razor b/src/RenderEngine/H.LowCode.Themes.AntBlazor/Layout/AntBlazorThemeLayout.razor index 9823e54efbf3845899f556533d8bb3ebe1e4e572..2bbdfc451ce310aa080566ecf79489ca9bfdf6e1 100644 --- a/src/RenderEngine/H.LowCode.Themes.AntBlazor/Layout/AntBlazorThemeLayout.razor +++ b/src/RenderEngine/H.LowCode.Themes.AntBlazor/Layout/AntBlazorThemeLayout.razor @@ -1,8 +1,6 @@ @namespace H.LowCode.Themes.AntBlazor @inherits ThemePartLayoutBase -@inject ComponentState MenuDataState -