Skip to content

Commit 494abb2

Browse files
committed
feat(curd): enhance StdDetail, support edit mode
1 parent edf9eca commit 494abb2

12 files changed

Lines changed: 904 additions & 37 deletions

File tree

.changeset/social-sides-invent.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@uozi-admin/curd": minor
3+
---
4+
5+
feat(curd): enhance StdDetail, support edit mode

docs/zh/curd/basic-concepts.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,12 @@ StdCurd (顶层容器)
9696
├── StdSearch (搜索表单)
9797
├── StdTable (数据表格)
9898
├── StdForm (编辑表单)
99-
└── StdDetail (数据详情)
99+
└── StdDetail (数据详情/可编辑详情)
100100
```
101101

102+
每个组件既可以在 StdCurd 中使用,也可以单独使用:
103+
- **StdDetail**: 支持查看和编辑两种模式,可用于构建独立的详情页面
104+
102105
## 数据流
103106

104107
CURD 组件的数据流向:

docs/zh/curd/components/std-curd.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,56 @@ const api = {
6767
| showSearchBtn | 显示搜索按钮 | boolean | false |
6868
| searchFormExtraRender | 搜索表单额外渲染函数 | (searchFormData: any, searchColumns: StdTableColumn[], stdTableConfig: Record<any, any>) => VNode \| JSX.Element | - |
6969

70+
## 详情页编辑
71+
72+
StdCurd 组件内置的详情页是只读的。如果需要在详情页进行编辑,建议单独使用 [StdDetail](./std-detail.md) 组件:
73+
74+
```vue
75+
<script setup lang="ts">
76+
import { StdDetail } from '@uozi-admin/curd'
77+
import { ref } from 'vue'
78+
79+
const userDetail = ref({
80+
id: 1,
81+
username: 'admin',
82+
email: 'admin@example.com'
83+
})
84+
85+
const columns = [
86+
{
87+
title: '用户名',
88+
dataIndex: 'username',
89+
edit: {
90+
type: 'input',
91+
formItem: { rules: [{ required: true }] }
92+
}
93+
},
94+
{
95+
title: '邮箱',
96+
dataIndex: 'email',
97+
edit: {
98+
type: 'input',
99+
formItem: { rules: [{ type: 'email' }] }
100+
}
101+
}
102+
]
103+
104+
function handleSave(data) {
105+
// 保存逻辑
106+
userDetail.value = { ...data }
107+
}
108+
</script>
109+
110+
<template>
111+
<StdDetail
112+
:record="userDetail"
113+
:columns="columns"
114+
:editable="true"
115+
@save="handleSave"
116+
/>
117+
</template>
118+
```
119+
70120
## 事件
71121

72122
| 事件名 | 说明 | 回调参数 |

0 commit comments

Comments
 (0)