el-plus 0.0.84 → 0.0.85
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/index.full.js +7 -3
- package/dist/index.full.min.js +2 -2
- package/dist/index.full.min.js.map +1 -1
- package/dist/index.full.min.mjs +2 -2
- package/dist/index.full.min.mjs.map +1 -1
- package/dist/index.full.mjs +7 -3
- package/docs/api-examples.md +49 -0
- package/docs/components/attachment.md +111 -0
- package/docs/components/buttons.md +108 -0
- package/docs/components/custom-column.md +70 -0
- package/docs/components/date-picker-range.md +61 -0
- package/docs/components/dialog.md +104 -0
- package/docs/components/footer-info.md +101 -0
- package/docs/components/form.md +178 -0
- package/docs/components/header.md +80 -0
- package/docs/components/index.md +23 -0
- package/docs/components/input.md +87 -0
- package/docs/components/link.md +63 -0
- package/docs/components/search-list-page.md +84 -0
- package/docs/components/select.md +163 -0
- package/docs/components/table.md +133 -0
- package/docs/components/title.md +70 -0
- package/docs/components/use-choose-dialog.md +115 -0
- package/docs/components/use-confirm-dialog.md +87 -0
- package/docs/components/use-form-dialog.md +87 -0
- package/docs/guide/markdown-examples.md +85 -0
- package/docs/index.md +25 -0
- package/docs/pages/detail.md +84 -0
- package/docs/pages/list.md +75 -0
- package/es/cli/src/commands/gen-docs.d.ts +2 -0
- package/es/cli/src/commands/install.d.ts +13 -0
- package/es/cli/src/commands/parse.d.ts +2 -0
- package/es/cli/src/index.d.ts +2 -0
- package/es/cli/src/parser/modao.d.ts +33 -0
- package/es/components/buttons/index.d.ts +45 -45
- package/es/components/buttons/src/buttons-vue.d.ts +16 -16
- package/es/components/buttons/src/buttons.d.ts +1 -1
- package/es/components/date-picker-range/index.d.ts +3 -3
- package/es/components/date-picker-range/src/date-picker-range.vue.d.ts +1 -1
- package/es/components/footer-info/index.d.ts +3 -3
- package/es/components/footer-info/src/footer-info.vue.d.ts +1 -1
- package/es/components/form/src/form-item-vue.mjs +6 -2
- package/es/components/form/src/form-item-vue.mjs.map +1 -1
- package/es/components/header/src/header.d.ts +1 -1
- package/es/components/header/src/header.mjs.map +1 -1
- package/es/components/input/index.d.ts +3 -3
- package/es/components/input/src/input.vue.d.ts +1 -1
- package/es/components/link/index.d.ts +6 -6
- package/es/components/link/src/link.d.ts +1 -1
- package/es/components/link/src/link.vue.d.ts +3 -3
- package/es/components/search-list-page/index.d.ts +12 -12
- package/es/components/search-list-page/src/search-list-page.vue.d.ts +4 -4
- package/es/components/search-list-page/src/use-search-list-page.d.ts +4 -4
- package/es/package.json.mjs +1 -1
- package/lib/cli/src/commands/gen-docs.d.ts +2 -0
- package/lib/cli/src/commands/install.d.ts +13 -0
- package/lib/cli/src/commands/parse.d.ts +2 -0
- package/lib/cli/src/index.d.ts +2 -0
- package/lib/cli/src/parser/modao.d.ts +33 -0
- package/lib/components/buttons/index.d.ts +45 -45
- package/lib/components/buttons/src/buttons-vue.d.ts +16 -16
- package/lib/components/buttons/src/buttons.d.ts +1 -1
- package/lib/components/date-picker-range/index.d.ts +3 -3
- package/lib/components/date-picker-range/src/date-picker-range.vue.d.ts +1 -1
- package/lib/components/footer-info/index.d.ts +3 -3
- package/lib/components/footer-info/src/footer-info.vue.d.ts +1 -1
- package/lib/components/form/src/form-item-vue.js +5 -1
- package/lib/components/form/src/form-item-vue.js.map +1 -1
- package/lib/components/header/src/header.d.ts +1 -1
- package/lib/components/header/src/header.js.map +1 -1
- package/lib/components/input/index.d.ts +3 -3
- package/lib/components/input/src/input.vue.d.ts +1 -1
- package/lib/components/link/index.d.ts +6 -6
- package/lib/components/link/src/link.d.ts +1 -1
- package/lib/components/link/src/link.vue.d.ts +3 -3
- package/lib/components/search-list-page/index.d.ts +12 -12
- package/lib/components/search-list-page/src/search-list-page.vue.d.ts +4 -4
- package/lib/components/search-list-page/src/use-search-list-page.d.ts +4 -4
- package/lib/package.json.js +1 -1
- package/package.json +2 -1
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# EpTable 数据表格
|
|
2
|
+
|
|
3
|
+
基于 el-table 封装,支持配置化列、分页、操作列等功能。
|
|
4
|
+
|
|
5
|
+
## 基本用法
|
|
6
|
+
|
|
7
|
+
```vue
|
|
8
|
+
<template>
|
|
9
|
+
<EpTable
|
|
10
|
+
:data="tableData"
|
|
11
|
+
:columns="columns"
|
|
12
|
+
:action-buttons="actionButtons"
|
|
13
|
+
/>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<script setup lang="tsx">
|
|
17
|
+
import { ref } from 'vue'
|
|
18
|
+
|
|
19
|
+
const tableData = ref([])
|
|
20
|
+
|
|
21
|
+
const columns = [
|
|
22
|
+
{ prop: 'name', label: '名称' },
|
|
23
|
+
{ prop: 'status', label: '状态' },
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
const actionButtons = [
|
|
27
|
+
{ name: '编辑', onClick: (row) => {} },
|
|
28
|
+
{ name: '删除', onClick: (row) => {} },
|
|
29
|
+
]
|
|
30
|
+
</script>
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Props
|
|
34
|
+
|
|
35
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
36
|
+
|------|------|------|--------|
|
|
37
|
+
| data | 表格数据 ^el^ | `array` | `[]` |
|
|
38
|
+
| columns | 列配置 | [`TableColumn[]`](#tablecolumn-配置) | `[]` |
|
|
39
|
+
| api | 数据接口 | `string \| (reqData) => Promise` | - |
|
|
40
|
+
| method | 请求方法 | `string` | `'post'` |
|
|
41
|
+
| reqData | 请求体数据 | `object` | `{}` |
|
|
42
|
+
| reqParams | URL 参数 | `object` | `{}` |
|
|
43
|
+
| reqBefore | 请求前处理 | `(reqData) => reqData` | - |
|
|
44
|
+
| reqAfter | 响应后处理 | `(res) => data` | - |
|
|
45
|
+
| size | 表格尺寸 ^el^ | `'large' \| 'default' \| 'small'` | `'default'` |
|
|
46
|
+
| border | 是否带边框 ^el^ | `boolean` | `true` |
|
|
47
|
+
| headerCellStyle | 表头样式 ^el^ | `object` | `{ background: '#EEEFF3', fontSize: '14px', color: '#505050' }` |
|
|
48
|
+
| showSelectionCol | 显示多选列 | `boolean` | `false` |
|
|
49
|
+
| showSingleSelectionCol | 显示单选列 | `boolean` | `false` |
|
|
50
|
+
| showIndexCol | 显示序号列 | `boolean` | `true` |
|
|
51
|
+
| align | 对齐方式 | `'left' \| 'center' \| 'right'` | `'center'` |
|
|
52
|
+
| minWidth | 列最小宽度 | `number \| string` | - |
|
|
53
|
+
| actionColWidth | 操作列宽度 | `number \| string` | `200` |
|
|
54
|
+
| actionButtons | 操作列按钮 | [`ButtonProps[]`](./buttons.md#buttonprops-配置) | `[]` |
|
|
55
|
+
| formatColumns | 格式化列配置 | [`TableColumn[]`](#tablecolumn-配置) | `[]` |
|
|
56
|
+
| showPagination | 显示分页 | `boolean` | `false` |
|
|
57
|
+
| paginationProps | 分页属性 | `object` | `{}` |
|
|
58
|
+
| isFrontPage | 前端分页 | `boolean` | `false` |
|
|
59
|
+
| isInitSearch | 初始化加载 | `boolean` | `true` |
|
|
60
|
+
| disabled | 是否禁用 | `boolean` | `false` |
|
|
61
|
+
| reserveSelection | 保留选择 | `boolean` | `false` |
|
|
62
|
+
| selectable | 可选择函数 | `(row, index) => boolean` | - |
|
|
63
|
+
| indexFormatter | 序号列格式化 | `number \| Function` | - |
|
|
64
|
+
|
|
65
|
+
> ^el^ 表示继承自 [el-table](https://element-plus.org/zh-CN/component/table.html) 的属性
|
|
66
|
+
|
|
67
|
+
## TableColumn 配置
|
|
68
|
+
|
|
69
|
+
| 属性 | 说明 | 类型 |
|
|
70
|
+
|------|------|------|
|
|
71
|
+
| prop | 字段名 | `string` |
|
|
72
|
+
| label | 列标题 | `string` |
|
|
73
|
+
| width | 列宽度 | `number \| string` |
|
|
74
|
+
| minWidth | 最小宽度 | `number \| string` |
|
|
75
|
+
| type | 组件类型 | `string` |
|
|
76
|
+
| props | 组件属性 | `object` |
|
|
77
|
+
| render | 自定义渲染 | `({ row, $index }) => VNode` |
|
|
78
|
+
| headerRender | 自定义表头渲染 | `() => VNode` |
|
|
79
|
+
| required | 是否必填 | `boolean \| () => boolean` |
|
|
80
|
+
| disabled | 是否禁用 | `boolean \| (scope) => boolean` |
|
|
81
|
+
| visible | 是否显示 | `boolean \| () => boolean` |
|
|
82
|
+
| filter | 显示筛选 | `boolean` |
|
|
83
|
+
| editable | 可批量编辑 | `boolean` |
|
|
84
|
+
|
|
85
|
+
## 在 Form 中使用
|
|
86
|
+
|
|
87
|
+
```tsx
|
|
88
|
+
const formItemList = [
|
|
89
|
+
{
|
|
90
|
+
col: 24,
|
|
91
|
+
type: 'EpTable',
|
|
92
|
+
props: {
|
|
93
|
+
ref: 'detailTable',
|
|
94
|
+
data: formData.detailList,
|
|
95
|
+
showSelectionCol: true,
|
|
96
|
+
columns: [
|
|
97
|
+
{ prop: 'itemCode', label: '编号', width: 150 },
|
|
98
|
+
{ prop: 'itemName', label: '名称' },
|
|
99
|
+
{
|
|
100
|
+
prop: 'quantity',
|
|
101
|
+
label: '数量',
|
|
102
|
+
type: 'EpInput',
|
|
103
|
+
props: { radix: 0 },
|
|
104
|
+
},
|
|
105
|
+
],
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
]
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## 自定义渲染
|
|
112
|
+
|
|
113
|
+
```tsx
|
|
114
|
+
const columns = [
|
|
115
|
+
{
|
|
116
|
+
prop: 'status',
|
|
117
|
+
label: '状态',
|
|
118
|
+
render: ({ row }) => (
|
|
119
|
+
<el-tag type={row.status === 1 ? 'success' : 'danger'}>
|
|
120
|
+
{row.status === 1 ? '启用' : '禁用'}
|
|
121
|
+
</el-tag>
|
|
122
|
+
),
|
|
123
|
+
},
|
|
124
|
+
]
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Expose 方法
|
|
128
|
+
|
|
129
|
+
| 方法 | 说明 |
|
|
130
|
+
|------|------|
|
|
131
|
+
| getSelectionRows | 获取选中行 |
|
|
132
|
+
| clearSelection | 清空选择 |
|
|
133
|
+
| search | 重新加载数据 |
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# EpTitle 标题分组
|
|
2
|
+
|
|
3
|
+
用于表单分组的标题组件,支持右侧按钮和展开折叠。
|
|
4
|
+
|
|
5
|
+
## 基本用法
|
|
6
|
+
|
|
7
|
+
```vue
|
|
8
|
+
<template>
|
|
9
|
+
<EpTitle title="基本信息" />
|
|
10
|
+
</template>
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Props
|
|
14
|
+
|
|
15
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
16
|
+
|------|------|------|--------|
|
|
17
|
+
| title | 标题文本 | `string` | - |
|
|
18
|
+
| buttons | 右侧按钮列表 | [`ButtonProps[]`](./buttons.md#buttonprops-配置) | `[]` |
|
|
19
|
+
| showDownUp | 显示展开折叠 | `boolean` | `false` |
|
|
20
|
+
|
|
21
|
+
## Events
|
|
22
|
+
|
|
23
|
+
| 事件名 | 说明 | 回调参数 |
|
|
24
|
+
|--------|------|----------|
|
|
25
|
+
| toggle | 折叠状态切换 | `(expanded: boolean)` |
|
|
26
|
+
|
|
27
|
+
## 带按钮
|
|
28
|
+
|
|
29
|
+
```vue
|
|
30
|
+
<template>
|
|
31
|
+
<EpTitle title="商品明细" :buttons="buttons" />
|
|
32
|
+
</template>
|
|
33
|
+
|
|
34
|
+
<script setup>
|
|
35
|
+
const buttons = [
|
|
36
|
+
{
|
|
37
|
+
name: '新增',
|
|
38
|
+
type: 'primary',
|
|
39
|
+
onClick: () => {},
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
name: '删除',
|
|
43
|
+
type: 'danger',
|
|
44
|
+
plain: true,
|
|
45
|
+
onClick: () => {},
|
|
46
|
+
},
|
|
47
|
+
]
|
|
48
|
+
</script>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## 在 Form 中使用
|
|
52
|
+
|
|
53
|
+
```tsx
|
|
54
|
+
const formItemList = [
|
|
55
|
+
{
|
|
56
|
+
col: 24,
|
|
57
|
+
type: 'EpTitle',
|
|
58
|
+
props: {
|
|
59
|
+
title: '基本信息',
|
|
60
|
+
buttons: [
|
|
61
|
+
{
|
|
62
|
+
name: '操作',
|
|
63
|
+
onClick: () => {},
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
// 其他表单项...
|
|
69
|
+
]
|
|
70
|
+
```
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# useChooseDialog 选择对话框
|
|
2
|
+
|
|
3
|
+
基于 useDialog 实现的选择对话框,集成 EpSearchListPage 组件,支持单选和多选。
|
|
4
|
+
|
|
5
|
+
## 基本用法
|
|
6
|
+
|
|
7
|
+
```vue
|
|
8
|
+
<template>
|
|
9
|
+
<el-button @click="handleChoose">选择用户</el-button>
|
|
10
|
+
<ChooseDialog />
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<script setup lang="tsx">
|
|
14
|
+
import { useChooseDialog } from 'el-plus'
|
|
15
|
+
|
|
16
|
+
const ChooseDialog = useChooseDialog({
|
|
17
|
+
title: '选择用户',
|
|
18
|
+
multiple: false, // 单选模式
|
|
19
|
+
dialogProps: {
|
|
20
|
+
destroyOnClose: true, // 关闭时销毁对话框内容
|
|
21
|
+
},
|
|
22
|
+
formItemList: [
|
|
23
|
+
{ prop: 'name', label: '姓名' },
|
|
24
|
+
],
|
|
25
|
+
columns: [
|
|
26
|
+
{ prop: 'name', label: '姓名' },
|
|
27
|
+
{ prop: 'dept', label: '部门' },
|
|
28
|
+
],
|
|
29
|
+
api: getUserList, // 列表接口
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
const handleChoose = async () => {
|
|
33
|
+
try {
|
|
34
|
+
const selection = await ChooseDialog.start()
|
|
35
|
+
console.log('选中', selection)
|
|
36
|
+
} catch (e) {
|
|
37
|
+
console.log('取消')
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
</script>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Options
|
|
44
|
+
|
|
45
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
46
|
+
|------|------|------|--------|
|
|
47
|
+
| title | 对话框标题 | `string` | - |
|
|
48
|
+
| dialogProps | 对话框属性,继承自 useDialog | `DialogOptions` | - |
|
|
49
|
+
| multiple | 是否多选 | `boolean` | `false` |
|
|
50
|
+
| formItemList | 搜索表单项配置,参考 [EpForm](./form.md) | `FormItemProps[]` | - |
|
|
51
|
+
| columns | 表格列配置,参考 [EpTable](./table.md) | `TableColumn[]` | - |
|
|
52
|
+
| api | 列表数据接口 | `(params) => Promise` | - |
|
|
53
|
+
| formData | 搜索表单数据 | `object` | - |
|
|
54
|
+
| formProps | 表单属性,参考 [EpForm](./form.md) | `FormProps` | `{ col: 3 }` |
|
|
55
|
+
| tableProps | 表格属性,参考 [EpTable](./table.md) | `TableProps` | `{ height: 300 }` |
|
|
56
|
+
|
|
57
|
+
## 多选模式
|
|
58
|
+
|
|
59
|
+
```tsx
|
|
60
|
+
const ChooseDialog = useChooseDialog({
|
|
61
|
+
title: '选择用户',
|
|
62
|
+
multiple: true, // 多选模式
|
|
63
|
+
formItemList: [
|
|
64
|
+
{ prop: 'name', label: '姓名' },
|
|
65
|
+
],
|
|
66
|
+
columns: [
|
|
67
|
+
{ prop: 'name', label: '姓名' },
|
|
68
|
+
{ prop: 'dept', label: '部门' },
|
|
69
|
+
],
|
|
70
|
+
api: getUserList,
|
|
71
|
+
})
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
多选模式下,底部会显示已选数量,确认后返回选中的行数据数组。
|
|
75
|
+
|
|
76
|
+
## 单选模式
|
|
77
|
+
|
|
78
|
+
```tsx
|
|
79
|
+
const ChooseDialog = useChooseDialog({
|
|
80
|
+
title: '选择用户',
|
|
81
|
+
multiple: false, // 单选模式(默认)
|
|
82
|
+
columns: [
|
|
83
|
+
{ prop: 'name', label: '姓名' },
|
|
84
|
+
],
|
|
85
|
+
api: getUserList,
|
|
86
|
+
})
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
单选模式下,点击行即可选中并关闭对话框,返回选中的行数据对象。
|
|
90
|
+
|
|
91
|
+
## 自定义表格高度
|
|
92
|
+
|
|
93
|
+
```tsx
|
|
94
|
+
const ChooseDialog = useChooseDialog({
|
|
95
|
+
title: '选择用户',
|
|
96
|
+
tableProps: {
|
|
97
|
+
height: 500, // 自定义表格高度
|
|
98
|
+
},
|
|
99
|
+
columns: [...],
|
|
100
|
+
api: getUserList,
|
|
101
|
+
})
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## 返回值
|
|
105
|
+
|
|
106
|
+
- **单选模式**: 返回选中的行数据对象
|
|
107
|
+
- **多选模式**: 返回选中的行数据数组
|
|
108
|
+
|
|
109
|
+
## 方法
|
|
110
|
+
|
|
111
|
+
| 方法 | 说明 | 类型 |
|
|
112
|
+
|------|------|------|
|
|
113
|
+
| start | 打开对话框并返回 Promise | `() => Promise<Selection>` |
|
|
114
|
+
| open | 打开对话框 | `() => void` |
|
|
115
|
+
| close | 关闭对话框 | `() => void` |
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# useConfirmDialog 确认对话框
|
|
2
|
+
|
|
3
|
+
基于 useFormDialog 实现的确认对话框,内置 textarea 输入框,适用于审批意见、备注填写等场景。
|
|
4
|
+
|
|
5
|
+
## 基本用法
|
|
6
|
+
|
|
7
|
+
```vue
|
|
8
|
+
<template>
|
|
9
|
+
<el-button @click="handleConfirm">审批</el-button>
|
|
10
|
+
<ConfirmDialog />
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<script setup lang="tsx">
|
|
14
|
+
import { useConfirmDialog } from 'el-plus'
|
|
15
|
+
|
|
16
|
+
const ConfirmDialog = useConfirmDialog({
|
|
17
|
+
title: '审批确认',
|
|
18
|
+
placeholder: '请输入审批意见',
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
const handleConfirm = async () => {
|
|
22
|
+
try {
|
|
23
|
+
const result = await ConfirmDialog.start()
|
|
24
|
+
console.log '确认,意见:', result.value)
|
|
25
|
+
} catch (e) {
|
|
26
|
+
console.log('取消')
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
</script>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Options
|
|
33
|
+
|
|
34
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
35
|
+
|------|------|------|--------|
|
|
36
|
+
| title | 对话框标题 | `string` | - |
|
|
37
|
+
| width | 对话框宽度 | `string` | `'50%'` |
|
|
38
|
+
| dialogProps | 对话框属性,继承自 useDialog | `DialogOptions` | - |
|
|
39
|
+
| rows | textarea 行数 | `number` | `5` |
|
|
40
|
+
| maxlength | 最大输入长度 | `number` | `500` |
|
|
41
|
+
| minlength | 最小输入长度 | `number` | - |
|
|
42
|
+
| showWordLimit | 显示字数统计 | `boolean` | `true` |
|
|
43
|
+
| placeholder | 输入框占位符 | `string` | - |
|
|
44
|
+
| rules | 表单验证规则 | `FormItemProps['rules']` | - |
|
|
45
|
+
| required | 是否必填 | `boolean` | `true` |
|
|
46
|
+
|
|
47
|
+
## 自定义验证
|
|
48
|
+
|
|
49
|
+
```tsx
|
|
50
|
+
const ConfirmDialog = useConfirmDialog({
|
|
51
|
+
title: '驳回原因',
|
|
52
|
+
required: true,
|
|
53
|
+
rules: [
|
|
54
|
+
{ required: true, message: '请输入驳回原因', trigger: 'blur' },
|
|
55
|
+
{ min: 10, message: '驳回原因不能少于10个字', trigger: 'blur' },
|
|
56
|
+
],
|
|
57
|
+
placeholder: '请输入驳回原因(不少于10个字)',
|
|
58
|
+
})
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## 非必填确认
|
|
62
|
+
|
|
63
|
+
```tsx
|
|
64
|
+
const ConfirmDialog = useConfirmDialog({
|
|
65
|
+
title: '备注',
|
|
66
|
+
required: false, // 非必填
|
|
67
|
+
placeholder: '请输入备注(选填)',
|
|
68
|
+
})
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## 返回值
|
|
72
|
+
|
|
73
|
+
确认时返回表单数据对象:
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
{
|
|
77
|
+
value: string // textarea 输入的内容
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## 方法
|
|
82
|
+
|
|
83
|
+
| 方法 | 说明 | 类型 |
|
|
84
|
+
|------|------|------|
|
|
85
|
+
| start | 打开对话框并返回 Promise | `() => Promise<{ value: string }>` |
|
|
86
|
+
| open | 打开对话框 | `() => void` |
|
|
87
|
+
| close | 关闭对话框 | `() => void` |
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# useFormDialog 表单对话框
|
|
2
|
+
|
|
3
|
+
基于 useDialog 实现的表单对话框,集成 EpForm 组件,支持表单验证。
|
|
4
|
+
|
|
5
|
+
## 基本用法
|
|
6
|
+
|
|
7
|
+
```vue
|
|
8
|
+
<template>
|
|
9
|
+
<el-button @click="openDialog">打开表单对话框</el-button>
|
|
10
|
+
<FormDialog />
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<script setup lang="tsx">
|
|
14
|
+
import { useFormDialog } from 'el-plus'
|
|
15
|
+
|
|
16
|
+
const formItemList = [
|
|
17
|
+
{ prop: 'name', label: '姓名', required: true },
|
|
18
|
+
{ prop: 'age', label: '年龄' },
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
const FormDialog = useFormDialog({
|
|
22
|
+
title: '用户信息',
|
|
23
|
+
formItemList,
|
|
24
|
+
dialogProps: {
|
|
25
|
+
destroyOnClose: true, // 关闭时销毁对话框内容
|
|
26
|
+
},
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
const openDialog = async () => {
|
|
30
|
+
try {
|
|
31
|
+
const formData = await FormDialog.start()
|
|
32
|
+
console.log('表单数据', formData)
|
|
33
|
+
} catch (e) {
|
|
34
|
+
console.log('取消')
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
</script>
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Options
|
|
41
|
+
|
|
42
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
43
|
+
|------|------|------|--------|
|
|
44
|
+
| title | 对话框标题 | `string` | - |
|
|
45
|
+
| width | 对话框宽度 | `string` | `'80%'` |
|
|
46
|
+
| dialogProps | 对话框属性,继承自 useDialog | `DialogOptions` | - |
|
|
47
|
+
| formData | 表单数据对象 | `object` | - |
|
|
48
|
+
| formItemList | 表单项配置,参考 [EpForm](./form.md) | `FormItemProps[]` | - |
|
|
49
|
+
| onBeforeConfirm | 确认前回调,可用于额外处理 | `(formData, resolve) => Promise<void>` | - |
|
|
50
|
+
| onBeforeCancel | 取消前回调 | `(formData, resolve) => Promise<void>` | - |
|
|
51
|
+
|
|
52
|
+
## 自定义表单数据
|
|
53
|
+
|
|
54
|
+
```tsx
|
|
55
|
+
const formData = reactive({
|
|
56
|
+
name: '',
|
|
57
|
+
age: '',
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
const FormDialog = useFormDialog({
|
|
61
|
+
title: '编辑用户',
|
|
62
|
+
formData, // 传入外部表单数据
|
|
63
|
+
formItemList,
|
|
64
|
+
})
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## 确认前处理
|
|
68
|
+
|
|
69
|
+
```tsx
|
|
70
|
+
const FormDialog = useFormDialog({
|
|
71
|
+
title: '提交表单',
|
|
72
|
+
formItemList,
|
|
73
|
+
onBeforeConfirm: async (formData, resolve) => {
|
|
74
|
+
// 可以在此处进行额外的异步操作
|
|
75
|
+
await api.submit(formData)
|
|
76
|
+
resolve(formData)
|
|
77
|
+
},
|
|
78
|
+
})
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## 方法
|
|
82
|
+
|
|
83
|
+
| 方法 | 说明 | 类型 |
|
|
84
|
+
|------|------|------|
|
|
85
|
+
| start | 打开对话框并返回 Promise | `() => Promise<FormData>` |
|
|
86
|
+
| open | 打开对话框 | `() => void` |
|
|
87
|
+
| close | 关闭对话框 | `() => void` |
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# Markdown Extension Examples
|
|
2
|
+
|
|
3
|
+
This page demonstrates some of the built-in markdown extensions provided by VitePress.
|
|
4
|
+
|
|
5
|
+
## Syntax Highlighting
|
|
6
|
+
|
|
7
|
+
VitePress provides Syntax Highlighting powered by [Shiki](https://github.com/shikijs/shiki), with additional features like line-highlighting:
|
|
8
|
+
|
|
9
|
+
**Input**
|
|
10
|
+
|
|
11
|
+
````md
|
|
12
|
+
```js{4}
|
|
13
|
+
export default {
|
|
14
|
+
data () {
|
|
15
|
+
return {
|
|
16
|
+
msg: 'Highlighted!'
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
```
|
|
21
|
+
````
|
|
22
|
+
|
|
23
|
+
**Output**
|
|
24
|
+
|
|
25
|
+
```js{4}
|
|
26
|
+
export default {
|
|
27
|
+
data () {
|
|
28
|
+
return {
|
|
29
|
+
msg: 'Highlighted!'
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Custom Containers
|
|
36
|
+
|
|
37
|
+
**Input**
|
|
38
|
+
|
|
39
|
+
```md
|
|
40
|
+
::: info
|
|
41
|
+
This is an info box.
|
|
42
|
+
:::
|
|
43
|
+
|
|
44
|
+
::: tip
|
|
45
|
+
This is a tip.
|
|
46
|
+
:::
|
|
47
|
+
|
|
48
|
+
::: warning
|
|
49
|
+
This is a warning.
|
|
50
|
+
:::
|
|
51
|
+
|
|
52
|
+
::: danger
|
|
53
|
+
This is a dangerous warning.
|
|
54
|
+
:::
|
|
55
|
+
|
|
56
|
+
::: details
|
|
57
|
+
This is a details block.
|
|
58
|
+
:::
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
**Output**
|
|
62
|
+
|
|
63
|
+
::: info
|
|
64
|
+
This is an info box.
|
|
65
|
+
:::
|
|
66
|
+
|
|
67
|
+
::: tip
|
|
68
|
+
This is a tip.
|
|
69
|
+
:::
|
|
70
|
+
|
|
71
|
+
::: warning
|
|
72
|
+
This is a warning.
|
|
73
|
+
:::
|
|
74
|
+
|
|
75
|
+
::: danger
|
|
76
|
+
This is a dangerous warning.
|
|
77
|
+
:::
|
|
78
|
+
|
|
79
|
+
::: details
|
|
80
|
+
This is a details block.
|
|
81
|
+
:::
|
|
82
|
+
|
|
83
|
+
## More
|
|
84
|
+
|
|
85
|
+
Check out the documentation for the [full list of markdown extensions](https://vitepress.dev/guide/markdown).
|
package/docs/index.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
# https://vitepress.dev/reference/default-theme-home-page
|
|
3
|
+
layout: home
|
|
4
|
+
|
|
5
|
+
hero:
|
|
6
|
+
name: "el-plus-docs"
|
|
7
|
+
text: "宏信组件文档"
|
|
8
|
+
tagline: My great project tagline
|
|
9
|
+
actions:
|
|
10
|
+
- theme: brand
|
|
11
|
+
text: Markdown Examples
|
|
12
|
+
link: /markdown-examples
|
|
13
|
+
- theme: alt
|
|
14
|
+
text: API Examples
|
|
15
|
+
link: /api-examples
|
|
16
|
+
|
|
17
|
+
features:
|
|
18
|
+
- title: Feature A
|
|
19
|
+
details: Lorem ipsum dolor sit amet, consectetur adipiscing elit
|
|
20
|
+
- title: Feature B
|
|
21
|
+
details: Lorem ipsum dolor sit amet, consectetur adipiscing elit
|
|
22
|
+
- title: Feature C
|
|
23
|
+
details: Lorem ipsum dolor sit amet, consectetur adipiscing elit
|
|
24
|
+
---
|
|
25
|
+
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# 详情页面
|
|
2
|
+
|
|
3
|
+
详情页面用于展示和编辑单条数据,组件自由组合。
|
|
4
|
+
|
|
5
|
+
## 页面结构
|
|
6
|
+
|
|
7
|
+
详情页无固定结构,根据业务需求自由组合以下组件:
|
|
8
|
+
|
|
9
|
+
- **EpHeader**: 顶部操作栏(可选)
|
|
10
|
+
- **EpForm**: 表单容器(可选)
|
|
11
|
+
- **EpTitle**: 标题分组(可选)
|
|
12
|
+
- **EpTable**: 明细表格(可选)
|
|
13
|
+
- **EpAttachment**: 附件管理(可选)
|
|
14
|
+
|
|
15
|
+
## 完整示例
|
|
16
|
+
|
|
17
|
+
> 完整示例参考:[play/src/views/demo/detail.vue](../../play/src/views/demo/detail.vue)
|
|
18
|
+
|
|
19
|
+
```vue
|
|
20
|
+
<template>
|
|
21
|
+
<div>
|
|
22
|
+
<!-- 组件自由组合,以下仅为示例 -->
|
|
23
|
+
<EpHeader
|
|
24
|
+
:buttons="headerButtons"
|
|
25
|
+
></EpHeader>
|
|
26
|
+
|
|
27
|
+
<EpForm
|
|
28
|
+
ref="epForm"
|
|
29
|
+
:formItemList="formItemList"
|
|
30
|
+
v-model="formData"
|
|
31
|
+
labelPosition="left"
|
|
32
|
+
></EpForm>
|
|
33
|
+
</div>
|
|
34
|
+
</template>
|
|
35
|
+
|
|
36
|
+
<script setup lang="tsx">
|
|
37
|
+
import type { FormProps, HeaderProps } from 'el-plus'
|
|
38
|
+
import {useNavigation} from 'el-plus'
|
|
39
|
+
import { reactive, computed, useTemplateRef } from 'vue'
|
|
40
|
+
import { useRoute, useRouter } from 'vue-router'
|
|
41
|
+
|
|
42
|
+
defineOptions({
|
|
43
|
+
name: 'DemoDetail'
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
const route = useRoute()
|
|
47
|
+
const router = useRouter()
|
|
48
|
+
const epForm = useTemplateRef('epForm')
|
|
49
|
+
const { isEdit } = useNavigation()
|
|
50
|
+
const id = route.query.id
|
|
51
|
+
|
|
52
|
+
// 顶部按钮 - 参考 EpHeader 文档
|
|
53
|
+
const headerButtons: HeaderProps['buttons'] = [
|
|
54
|
+
// 按钮配置
|
|
55
|
+
]
|
|
56
|
+
|
|
57
|
+
// 表单数据
|
|
58
|
+
const formData = reactive({
|
|
59
|
+
// 字段定义
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
// 表单配置 - 组件自由组合,参考各组件文档
|
|
63
|
+
const formItemList = ref<FormProps['formItemList']>([
|
|
64
|
+
// 组件自由组合
|
|
65
|
+
])
|
|
66
|
+
|
|
67
|
+
// 保存
|
|
68
|
+
const handleSave = async () => {
|
|
69
|
+
const valid = await epForm.value?.validate()
|
|
70
|
+
if (valid) {
|
|
71
|
+
// TODO: 调用保存接口
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// 加载数据
|
|
76
|
+
if (isEdit.value === 'edit' && id) {
|
|
77
|
+
// TODO: 调用接口获取详情
|
|
78
|
+
}
|
|
79
|
+
</script>
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## 组件文档
|
|
83
|
+
|
|
84
|
+
> 查看所有可用组件:[组件文档索引](../components/index.md)
|