mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-07-08 11:02:48 +08:00
feat: 实现基本的详情生成
This commit is contained in:
134
.trae/documents/添加CURD详情页面生成功能.md
Normal file
134
.trae/documents/添加CURD详情页面生成功能.md
Normal file
@@ -0,0 +1,134 @@
|
||||
# CURD详情页面生成功能实现计划
|
||||
|
||||
## 1. 需求分析
|
||||
|
||||
* 当前CURD生成功能不包含详情页面
|
||||
|
||||
* 详情页面需要合理布局:顶部是标题+ID,左侧8/12是主体,右侧4/12是基础字段
|
||||
|
||||
* 详情页面需要包含编辑、删除、返回等基础按钮操作
|
||||
|
||||
* 支持后续扩展更多字段
|
||||
|
||||
* 使用Layui栅格系统
|
||||
|
||||
## 2. 实现步骤
|
||||
|
||||
### 2.1 添加详情方法到CURD Trait
|
||||
|
||||
* 在 `CurdTraitBase.php` 中添加 `read` 方法
|
||||
|
||||
* 实现详情数据获取和页面渲染逻辑
|
||||
|
||||
### 2.2 创建详情页面模板
|
||||
|
||||
* 创建 `view/read.code` 主模板
|
||||
|
||||
* 设计Layui风格布局:
|
||||
* 顶部区域:标题、ID和操作按钮(编辑、删除、返回)
|
||||
* 内容区域:使用 `layui-row` 和 `layui-col-md-*` 实现8/4分栏
|
||||
* 左侧:主体字段(8列)
|
||||
* 右侧:基础字段(4列,包含创建时间、更新时间等)
|
||||
|
||||
### 2.3 修改BuildCurdServiceBase
|
||||
|
||||
* 在 `renderView` 方法中添加详情页面生成逻辑
|
||||
|
||||
* 实现字段分类:
|
||||
* 主体字段:除ID、创建时间、更新时间外的大部分字段
|
||||
* 基础字段:ID、创建时间、更新时间、状态等系统字段
|
||||
|
||||
* 添加详情页面到文件列表
|
||||
|
||||
### 2.4 更新JS文件生成
|
||||
|
||||
* 修改 `js/index.code` 模板
|
||||
|
||||
* 在操作列添加详情按钮
|
||||
|
||||
* 实现详情跳转逻辑
|
||||
|
||||
### 2.5 更新控制器模板
|
||||
|
||||
* 确保控制器支持详情页面路由
|
||||
|
||||
## 3. 布局设计(Layui风格)
|
||||
|
||||
```html
|
||||
<!-- 顶部区域 -->
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-header detail-header">
|
||||
<div class="layui-row">
|
||||
<div class="layui-col-md9">
|
||||
<h2 class="detail-title">{{title}}</h2>
|
||||
<div class="detail-id">ID: {{id}}</div>
|
||||
</div>
|
||||
<div class="layui-col-md3 text-right">
|
||||
<button class="layui-btn layui-btn-primary" onclick="window.history.back()">返回</button>
|
||||
<button class="layui-btn" onclick="location.href='{{editUrl}}'">编辑</button>
|
||||
<button class="layui-btn layui-btn-danger" onclick="deleteData({{id}})">删除</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 内容区域 -->
|
||||
<div class="layui-card-body">
|
||||
<div class="layui-row detail-content">
|
||||
<!-- 左侧主体内容(8/12) -->
|
||||
<div class="layui-col-md-8 detail-main">
|
||||
<div class="layui-form">
|
||||
<!-- 主体字段展示 -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 右侧基础信息(4/12) -->
|
||||
<div class="layui-col-md-4 detail-side">
|
||||
<div class="layui-form">
|
||||
<!-- 基础字段展示:创建时间、更新时间等 -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
```
|
||||
|
||||
## 4. 字段分类规则
|
||||
|
||||
* **主体字段**:所有非系统字段,如名称、描述、内容等
|
||||
|
||||
* **基础字段**:
|
||||
* id
|
||||
* create_time
|
||||
* update_time
|
||||
* status
|
||||
* 其他系统相关字段
|
||||
|
||||
## 5. 实现要点
|
||||
|
||||
* 保持与Layui框架风格一致
|
||||
|
||||
* 遵循现有代码生成模式
|
||||
|
||||
* 支持后续字段扩展
|
||||
|
||||
* 确保详情页面与现有功能无缝集成
|
||||
|
||||
* 添加必要的JavaScript交互逻辑
|
||||
|
||||
## 6. 文件修改清单
|
||||
|
||||
1. `extend/base/admin/traits/CurdTraitBase.php` - 添加read方法
|
||||
2. `extend/base/admin/service/curd/templates/view/read.code` - 详情页面模板
|
||||
3. `extend/base/admin/service/curd/BuildCurdServiceBase.php` - 添加详情页面生成逻辑
|
||||
4. `extend/base/admin/service/curd/templates/js/index.code` - 添加详情按钮
|
||||
5. `extend/base/admin/service/curd/templates/js/read.code` - 详情页面JS逻辑
|
||||
|
||||
## 7. 详情页面按钮功能
|
||||
|
||||
* **返回**:返回上一页
|
||||
|
||||
* **编辑**:跳转到编辑页面
|
||||
|
||||
* **删除**:调用删除接口,删除当前数据
|
||||
|
||||
* 所有按钮使用Layui样式,保持一致的视觉效果
|
||||
Reference in New Issue
Block a user