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,178 @@
|
|
|
1
|
+
# EpForm 表单容器
|
|
2
|
+
|
|
3
|
+
基于 el-form 封装,支持通过配置生成表单。
|
|
4
|
+
|
|
5
|
+
## 基本用法
|
|
6
|
+
|
|
7
|
+
```vue
|
|
8
|
+
<template>
|
|
9
|
+
<EpForm
|
|
10
|
+
ref="epForm"
|
|
11
|
+
v-model="formData"
|
|
12
|
+
:formItemList="formItemList"
|
|
13
|
+
/>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<script setup lang="tsx">
|
|
17
|
+
import { reactive, ref, useTemplateRef } from 'vue'
|
|
18
|
+
import type { FormProps } from 'el-plus'
|
|
19
|
+
|
|
20
|
+
const epForm = useTemplateRef('epForm')
|
|
21
|
+
const formData = reactive({
|
|
22
|
+
name: '',
|
|
23
|
+
type: '',
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
const formItemList = ref<FormProps['formItemList']>([
|
|
27
|
+
{
|
|
28
|
+
prop: 'name',
|
|
29
|
+
label: '名称',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
prop: 'type',
|
|
33
|
+
label: '类型',
|
|
34
|
+
type: 'EpSelect',
|
|
35
|
+
props: {
|
|
36
|
+
options: [
|
|
37
|
+
{ label: '类型1', value: '1' },
|
|
38
|
+
{ label: '类型2', value: '2' },
|
|
39
|
+
],
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
])
|
|
43
|
+
</script>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Props
|
|
47
|
+
|
|
48
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
49
|
+
|------|------|------|--------|
|
|
50
|
+
| v-model | 表单数据 | `Record<string, any>` | `{}` |
|
|
51
|
+
| formItemList | 表单项配置 | [`FormItemProps[]`](#formitemprops-配置) | `[]` |
|
|
52
|
+
| col | 每行列数 | `number` | `4` |
|
|
53
|
+
| isShowFold | 是否显示折叠 | `boolean` | `false` |
|
|
54
|
+
| showFieldCount | 折叠时显示数量 | `number` | `8` |
|
|
55
|
+
| labelWidth | 标签宽度 ^el^ | `string \| number` | `100` |
|
|
56
|
+
| labelPosition | 标签位置 ^el^ | `'left' \| 'right' \| 'top'` | - |
|
|
57
|
+
| size | 表单尺寸 ^el^ | `'large' \| 'default' \| 'small'` | `'small'` |
|
|
58
|
+
| scrollIntoViewOptions | 滚动到错误项配置 ^el^ | `object` | `{ inline: 'center' }` |
|
|
59
|
+
|
|
60
|
+
> ^el^ 表示继承自 [el-form](https://element-plus.org/zh-CN/component/form.html) 的属性
|
|
61
|
+
|
|
62
|
+
## FormItemProps 配置
|
|
63
|
+
|
|
64
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
65
|
+
|------|------|------|--------|
|
|
66
|
+
| type | 组件类型 | `string` | `'EpInput'` |
|
|
67
|
+
| prop | 字段名 | `string` | - |
|
|
68
|
+
| label | 标签文本 | `string` | - |
|
|
69
|
+
| col | 占用列数 | `number` | - |
|
|
70
|
+
| disabled | 是否禁用 | `boolean` | `false` |
|
|
71
|
+
| visible | 是否显示 | `boolean` | `true` |
|
|
72
|
+
| required | 是否必填 | `boolean` | `false` |
|
|
73
|
+
| rules | 校验规则 | `FormItemRule[]` | - |
|
|
74
|
+
| props | 传递给组件的属性 | `object` | - |
|
|
75
|
+
| render | 自定义渲染 | `() => VNode` | - |
|
|
76
|
+
| labelRender | 自定义标签渲染 | `({ label }) => VNode` | - |
|
|
77
|
+
| isShowLabel | 是否显示标签 | `boolean` | `true` |
|
|
78
|
+
| class | 样式类名 | `string` | - |
|
|
79
|
+
| style | 行内样式 | `string \| CSSProperties` | - |
|
|
80
|
+
| onChange | 值变化事件 | `(val, item?) => void` | - |
|
|
81
|
+
|
|
82
|
+
## Expose 方法
|
|
83
|
+
|
|
84
|
+
| 方法 | 说明 | 类型 |
|
|
85
|
+
|------|------|------|
|
|
86
|
+
| validate | 表单验证 | `() => Promise<boolean>` |
|
|
87
|
+
| resetFields | 重置表单 | `() => void` |
|
|
88
|
+
| clearValidate | 清除验证 | `(props?: string[]) => void` |
|
|
89
|
+
| getFormItemRenderRef | 获取表单项组件 ref | `(ref: string) => any` |
|
|
90
|
+
|
|
91
|
+
## 组件自由组合示例
|
|
92
|
+
|
|
93
|
+
在 formItemList 中可自由组合其他组件:
|
|
94
|
+
- type:组件名字,优先使用 Ep 前缀的组件,如 EpInput、EpSelect 等,其次使用 Element Plus 的组件,如 ElInput、ElSelect 等。
|
|
95
|
+
- 外层: EpFormItem的属性
|
|
96
|
+
- props:传递给组件的属性
|
|
97
|
+
- 事件:组件的事件,以 `on` 开头,如 onClick、onChange 等
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
```tsx
|
|
101
|
+
const formItemList = computed<FormProps['formItemList']>(() => [
|
|
102
|
+
// 标题分组
|
|
103
|
+
{
|
|
104
|
+
col: 24,
|
|
105
|
+
type: 'EpTitle',
|
|
106
|
+
props: {
|
|
107
|
+
title: '基本信息',
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
// 输入框
|
|
111
|
+
{
|
|
112
|
+
prop: 'name',
|
|
113
|
+
label: '名称',
|
|
114
|
+
},
|
|
115
|
+
// 下拉选择
|
|
116
|
+
{
|
|
117
|
+
prop: 'type',
|
|
118
|
+
label: '类型',
|
|
119
|
+
type: 'EpSelect',
|
|
120
|
+
props: {
|
|
121
|
+
options: [],
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
// 日期范围
|
|
125
|
+
{
|
|
126
|
+
prop: 'orderDate',
|
|
127
|
+
label: '日期范围',
|
|
128
|
+
type: 'EpDatePickerRange',
|
|
129
|
+
props: {
|
|
130
|
+
start: formData.orderDateStart,
|
|
131
|
+
end: formData.orderDateEnd,
|
|
132
|
+
},
|
|
133
|
+
'onUpdate:start': (val) => {
|
|
134
|
+
formData.orderDateStart = val
|
|
135
|
+
},
|
|
136
|
+
'onUpdate:end': (val) => {
|
|
137
|
+
formData.orderDateEnd = val
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
// 表格嵌套
|
|
141
|
+
{
|
|
142
|
+
col: 24,
|
|
143
|
+
type: 'EpTable',
|
|
144
|
+
props: {
|
|
145
|
+
ref: 'detailTable',
|
|
146
|
+
data: formData.detailList,
|
|
147
|
+
columns: [],
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
// 附件
|
|
151
|
+
{
|
|
152
|
+
col: 24,
|
|
153
|
+
type: 'EpAttachment',
|
|
154
|
+
props: {
|
|
155
|
+
modelValue: formData.fileList,
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
])
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## 验证示例
|
|
162
|
+
|
|
163
|
+
```ts
|
|
164
|
+
const handleSave = async () => {
|
|
165
|
+
const valid = await epForm.value?.validate()
|
|
166
|
+
if (valid) {
|
|
167
|
+
// 验证通过,提交数据
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## 获取嵌套组件 ref
|
|
173
|
+
|
|
174
|
+
```ts
|
|
175
|
+
// 获取 formItemList 中 props.ref='detailTable' 的组件
|
|
176
|
+
const table = epForm.value?.getFormItemRenderRef('detailTable')
|
|
177
|
+
const rows = table?.getSelectionRows()
|
|
178
|
+
```
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# EpHeader 顶部操作栏
|
|
2
|
+
|
|
3
|
+
详情页顶部操作栏组件,支持返回、按钮组、附件等功能。
|
|
4
|
+
|
|
5
|
+
## 基本用法
|
|
6
|
+
|
|
7
|
+
```vue
|
|
8
|
+
<template>
|
|
9
|
+
<EpHeader
|
|
10
|
+
:buttons="headerButtons"
|
|
11
|
+
/>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script setup lang="tsx">
|
|
15
|
+
import { computed } from 'vue'
|
|
16
|
+
import type { HeaderProps } from 'el-plus'
|
|
17
|
+
|
|
18
|
+
const headerButtons:HeaderProps['buttons']= [
|
|
19
|
+
{
|
|
20
|
+
name: '提交',
|
|
21
|
+
prop: 'submit',
|
|
22
|
+
type: 'primary',
|
|
23
|
+
onClick: () => {},
|
|
24
|
+
},
|
|
25
|
+
]
|
|
26
|
+
</script>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Props
|
|
30
|
+
|
|
31
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
32
|
+
|------|------|------|--------|
|
|
33
|
+
| buttons | 自定义按钮列表 | [`ButtonProps[]`](./buttons.md#buttonprops-配置) | `[]` |
|
|
34
|
+
| defaultButtons | 显示的默认按钮 | `('edit' \| 'save' \| 'cancel' \| 'refresh' \| 'auditLog')[]` | - |
|
|
35
|
+
| mode | 页面模式 | `'add' \| 'edit' \| 'browse'` | - |
|
|
36
|
+
| allowBack | 是否允许返回 | `boolean` | `true` |
|
|
37
|
+
| name | 权限前缀 | `string` | - |
|
|
38
|
+
| workflowId | 工作流ID | `string` | - |
|
|
39
|
+
| isShowAttachmentButton | 显示附件按钮 | `boolean` | `false` |
|
|
40
|
+
| fileList | 附件列表 | `Record<string, any>[]` | `[]` |
|
|
41
|
+
| attachmentProps | 附件组件属性 | [`AttachmentProps`](./attachment.md#props) | `{}` |
|
|
42
|
+
|
|
43
|
+
## 默认按钮说明
|
|
44
|
+
|
|
45
|
+
| 按钮 | 说明 |
|
|
46
|
+
|------|------|
|
|
47
|
+
| edit | 编辑按钮 |
|
|
48
|
+
| save | 保存按钮 |
|
|
49
|
+
| cancel | 取消按钮 |
|
|
50
|
+
| refresh | 刷新按钮 |
|
|
51
|
+
| auditLog | 审批日志按钮 |
|
|
52
|
+
|
|
53
|
+
## 带附件按钮
|
|
54
|
+
|
|
55
|
+
```vue
|
|
56
|
+
<template>
|
|
57
|
+
<EpHeader
|
|
58
|
+
:buttons="headerButtons"
|
|
59
|
+
is-show-attachment-button
|
|
60
|
+
:file-list="formData.fileList"
|
|
61
|
+
:attachment-props="attachmentProps"
|
|
62
|
+
/>
|
|
63
|
+
</template>
|
|
64
|
+
|
|
65
|
+
<script setup>
|
|
66
|
+
const attachmentProps = {
|
|
67
|
+
formatColumns: [
|
|
68
|
+
{
|
|
69
|
+
prop: 'type',
|
|
70
|
+
props: {
|
|
71
|
+
options: [
|
|
72
|
+
{ label: '图片', value: 0 },
|
|
73
|
+
{ label: '附件', value: 2 },
|
|
74
|
+
],
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
}
|
|
79
|
+
</script>
|
|
80
|
+
```
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# 组件文档索引
|
|
2
|
+
|
|
3
|
+
所有组件可自由组合到 Form 中,配置时请参考各组件文档:
|
|
4
|
+
|
|
5
|
+
| 组件 | 文档 | 说明 |
|
|
6
|
+
|------|------|------|
|
|
7
|
+
| EpSearchListPage | [search-list-page.md](./search-list-page.md) | 搜索列表页容器 |
|
|
8
|
+
| EpForm | [form.md](./form.md) | 表单容器 |
|
|
9
|
+
| EpHeader | [header.md](./header.md) | 顶部操作栏 |
|
|
10
|
+
| EpTitle | [title.md](./title.md) | 标题分组 |
|
|
11
|
+
| EpDialog | [dialog.md](./dialog.md) | 对话框 |
|
|
12
|
+
| useFormDialog | [use-form-dialog.md](./use-form-dialog.md) | 表单对话框 Hook |
|
|
13
|
+
| useConfirmDialog | [use-confirm-dialog.md](./use-confirm-dialog.md) | 确认对话框 Hook |
|
|
14
|
+
| useChooseDialog | [use-choose-dialog.md](./use-choose-dialog.md) | 选择对话框 Hook |
|
|
15
|
+
| EpInput | [input.md](./input.md) | 输入框 |
|
|
16
|
+
| EpSelect | [select.md](./select.md) | 下拉选择 |
|
|
17
|
+
| EpDatePickerRange | [date-picker-range.md](./date-picker-range.md) | 日期范围选择 |
|
|
18
|
+
| EpTable | [table.md](./table.md) | 数据表格 |
|
|
19
|
+
| EpCustomColumn | [custom-column.md](./custom-column.md) | 自定义列配置 |
|
|
20
|
+
| EpLink | [link.md](./link.md) | 链接 |
|
|
21
|
+
| EpButtons | [buttons.md](./buttons.md) | 按钮组 |
|
|
22
|
+
| EpAttachment | [attachment.md](./attachment.md) | 附件管理 |
|
|
23
|
+
| EpFooterInfo | [footer-info.md](./footer-info.md) | 底部信息 |
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# EpInput 输入框
|
|
2
|
+
|
|
3
|
+
基于 el-input 封装,增加数字格式化等功能。
|
|
4
|
+
|
|
5
|
+
## 基本用法
|
|
6
|
+
|
|
7
|
+
```vue
|
|
8
|
+
<template>
|
|
9
|
+
<EpInput v-model="value" />
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script setup>
|
|
13
|
+
import { ref } from 'vue'
|
|
14
|
+
|
|
15
|
+
const value = ref('')
|
|
16
|
+
</script>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Props
|
|
20
|
+
|
|
21
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
22
|
+
|------|------|------|--------|
|
|
23
|
+
| v-model | 绑定值 ^el^ | `string \| number` | - |
|
|
24
|
+
| placeholder | 占位文本 ^el^ | `string` | '请输入' |
|
|
25
|
+
| clearable | 是否可清空 ^el^ | `boolean` | `true` |
|
|
26
|
+
| max | 最大值(数字模式) | `number` | - |
|
|
27
|
+
| min | 最小值(数字模式) | `number` | - |
|
|
28
|
+
| radix | 小数位数 | `number` | - |
|
|
29
|
+
| nonzero | 不允许为零 | `boolean` | `false` |
|
|
30
|
+
| thousand | 千分位格式化 | `boolean` | `true` |
|
|
31
|
+
|
|
32
|
+
> ^el^ 表示继承自 [el-input](https://element-plus.org/zh-CN/component/input.html) 的属性
|
|
33
|
+
|
|
34
|
+
## 在 Form 中使用
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
const formItemList = [
|
|
38
|
+
{
|
|
39
|
+
prop: 'name',
|
|
40
|
+
label: '名称',
|
|
41
|
+
// type 默认为 EpInput
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
prop: 'remark',
|
|
45
|
+
label: '备注',
|
|
46
|
+
col: 24,
|
|
47
|
+
props: {
|
|
48
|
+
type: 'textarea',
|
|
49
|
+
rows: 4,
|
|
50
|
+
maxlength: 200,
|
|
51
|
+
showWordLimit: true,
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
]
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## 数字输入
|
|
58
|
+
|
|
59
|
+
```tsx
|
|
60
|
+
const formItemList = [
|
|
61
|
+
{
|
|
62
|
+
prop: 'amount',
|
|
63
|
+
label: '金额',
|
|
64
|
+
props: {
|
|
65
|
+
max: 999999,
|
|
66
|
+
min: 0,
|
|
67
|
+
radix: 2, // 保留2位小数
|
|
68
|
+
thousand: true, // 千分位
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
]
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## 格式化显示
|
|
75
|
+
|
|
76
|
+
通过 `formatter` 属性自定义显示格式:
|
|
77
|
+
|
|
78
|
+
```tsx
|
|
79
|
+
{
|
|
80
|
+
prop: 'value',
|
|
81
|
+
label: '值',
|
|
82
|
+
disabled: true,
|
|
83
|
+
props: {
|
|
84
|
+
formatter: (value) => `${value} 元`,
|
|
85
|
+
},
|
|
86
|
+
}
|
|
87
|
+
```
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# EpLink 链接
|
|
2
|
+
|
|
3
|
+
基于 el-link 封装的链接组件。
|
|
4
|
+
|
|
5
|
+
## 基本用法
|
|
6
|
+
|
|
7
|
+
```vue
|
|
8
|
+
<template>
|
|
9
|
+
<EpLink content="查看详情" @click="handleClick" />
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script setup>
|
|
13
|
+
const handleClick = () => {
|
|
14
|
+
console.log('点击')
|
|
15
|
+
}
|
|
16
|
+
</script>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Props
|
|
20
|
+
|
|
21
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
22
|
+
|------|------|------|--------|
|
|
23
|
+
| content | 链接文本 | `string` | - |
|
|
24
|
+
| type | 类型 ^el^ | `'primary' \| 'success' \| 'warning' \| 'danger' \| 'info'` | `'primary'` |
|
|
25
|
+
| underline | 下划线 ^el^ | `'always' \| 'hover' \| 'never'` | `'never'` |
|
|
26
|
+
| disabled | 是否禁用 ^el^ | `boolean` | `false` |
|
|
27
|
+
| href | 链接地址 ^el^ | `string` | - |
|
|
28
|
+
|
|
29
|
+
> ^el^ 表示继承自 [el-link](https://element-plus.org/zh-CN/component/link.html) 的属性
|
|
30
|
+
|
|
31
|
+
## 在表格中使用
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
const columns = [
|
|
35
|
+
{
|
|
36
|
+
prop: 'orderNo',
|
|
37
|
+
label: '订单号',
|
|
38
|
+
type: 'EpLink',
|
|
39
|
+
props: {
|
|
40
|
+
onClick: (row) => {
|
|
41
|
+
// 跳转详情
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
]
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## 在 Form 中使用
|
|
49
|
+
|
|
50
|
+
```tsx
|
|
51
|
+
const formItemList = [
|
|
52
|
+
{
|
|
53
|
+
prop: 'relatedNo',
|
|
54
|
+
label: '关联单号',
|
|
55
|
+
type: 'EpLink',
|
|
56
|
+
props: {
|
|
57
|
+
onClick: () => {
|
|
58
|
+
// 跳转关联单据
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
]
|
|
63
|
+
```
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# EpSearchListPage 搜索列表页
|
|
2
|
+
|
|
3
|
+
集成搜索表单和数据表格的列表页容器组件。
|
|
4
|
+
|
|
5
|
+
## 基本用法
|
|
6
|
+
|
|
7
|
+
```vue
|
|
8
|
+
<template>
|
|
9
|
+
<EpSearchListPage
|
|
10
|
+
:form-item-list="formItemList"
|
|
11
|
+
:form-data="formData"
|
|
12
|
+
:columns="columns"
|
|
13
|
+
:left-buttons="leftButtons"
|
|
14
|
+
api="/api/list/page"
|
|
15
|
+
:add="handleAdd"
|
|
16
|
+
show-selection-col
|
|
17
|
+
:action-buttons="actionButtons"
|
|
18
|
+
/>
|
|
19
|
+
</template>
|
|
20
|
+
|
|
21
|
+
<script setup lang="tsx">
|
|
22
|
+
import { ref, reactive } from 'vue'
|
|
23
|
+
import type { SearchListPageProps } from 'el-plus'
|
|
24
|
+
|
|
25
|
+
const formData = reactive({
|
|
26
|
+
name: '',
|
|
27
|
+
status: '',
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
const formItemList = ref<SearchListPageProps['formItemList']>([
|
|
31
|
+
{ prop: 'name', label: '名称' },
|
|
32
|
+
{ prop: 'status', label: '状态', type: 'EpSelect', props: { options: [] } },
|
|
33
|
+
])
|
|
34
|
+
|
|
35
|
+
const columns = [
|
|
36
|
+
{ prop: 'name', label: '名称' },
|
|
37
|
+
{ prop: 'status', label: '状态' },
|
|
38
|
+
]
|
|
39
|
+
|
|
40
|
+
const leftButtons = ref<SearchListPageProps['leftButtons']>([
|
|
41
|
+
{ name: '删除', prop: 'delete', type: 'danger' },
|
|
42
|
+
])
|
|
43
|
+
|
|
44
|
+
const actionButtons = ref<SearchListPageProps['actionButtons']>([
|
|
45
|
+
{ name: '编辑', prop: 'edit', onClick: (row) => {} },
|
|
46
|
+
{ name: '删除', prop: 'delete', onClick: (row) => {} },
|
|
47
|
+
])
|
|
48
|
+
|
|
49
|
+
const handleAdd = () => {}
|
|
50
|
+
</script>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Props
|
|
54
|
+
|
|
55
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
56
|
+
|------|------|------|--------|
|
|
57
|
+
| api | 列表接口地址 | `string \| (reqData) => Promise` | - |
|
|
58
|
+
| method | 请求方法 | `string` | `'post'` |
|
|
59
|
+
| reqData | 请求体数据 | `object` | `{}` |
|
|
60
|
+
| reqParams | URL 参数 | `object` | `{}` |
|
|
61
|
+
| reqBefore | 请求前处理 | `(reqData) => reqData` | - |
|
|
62
|
+
| reqAfter | 响应后处理 | `(res) => data` | - |
|
|
63
|
+
| formData | 表单数据 | `object` | `{}` |
|
|
64
|
+
| formItemList | 搜索表单配置 | [`FormItemProps[]`](./form.md#formitemprops-配置) | `[]` |
|
|
65
|
+
| columns | 表格列配置 | [`TableColumn[]`](./table.md#tablecolumn-配置) | `[]` |
|
|
66
|
+
| leftButtons | 左侧按钮 | [`ButtonProps[]`](./buttons.md#buttonprops-配置) | `[]` |
|
|
67
|
+
| actionButtons | 操作列按钮 | [`ButtonProps[]`](./buttons.md#buttonprops-配置) | `[]` |
|
|
68
|
+
| add | 新增按钮回调 | `Function` | - |
|
|
69
|
+
| showSelectionCol | 显示多选列 | `boolean` | `false` |
|
|
70
|
+
| showSingleSelectionCol | 显示单选列 | `boolean` | `false` |
|
|
71
|
+
| showIndexCol | 显示序号列 | `boolean` | `true` |
|
|
72
|
+
| showOperationColumn | 显示操作列 | `boolean` | - |
|
|
73
|
+
| minWidth | 列最小宽度 | `number \| string` | - |
|
|
74
|
+
| actionColWidth | 操作列宽度 | `number \| string` | `200` |
|
|
75
|
+
| formatColumns | 格式化列配置 | [`TableColumn[]`](./table.md#tablecolumn-配置) | `[]` |
|
|
76
|
+
| offsetTop | 表格额外距离 | `number` | `0` |
|
|
77
|
+
| isInitSearch | 是否初始化加载 | `boolean` | `true` |
|
|
78
|
+
| tableProps | 表格额外属性 | `object` | - |
|
|
79
|
+
| formProps | 表单额外属性 | `object` | - |
|
|
80
|
+
| buttonsProps | 按钮组额外属性 | `object` | - |
|
|
81
|
+
| name | 权限前缀 | `string` | - |
|
|
82
|
+
| customColumnModule | 自定义列模块 | `string \| number` | - |
|
|
83
|
+
| customColumnApi | 自定义列接口 | `string` | - |
|
|
84
|
+
| customColumnSaveApi | 自定义列保存接口 | `string` | - |
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# EpSelect 下拉选择
|
|
2
|
+
|
|
3
|
+
基于 el-select 封装,支持接口获取选项、自定义 label 等功能。
|
|
4
|
+
|
|
5
|
+
## 基本用法
|
|
6
|
+
|
|
7
|
+
```vue
|
|
8
|
+
<template>
|
|
9
|
+
<EpSelect v-model="value" :options="options" />
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script setup>
|
|
13
|
+
import { ref } from 'vue'
|
|
14
|
+
|
|
15
|
+
const value = ref('')
|
|
16
|
+
const options = [
|
|
17
|
+
{ label: '选项1', value: '1' },
|
|
18
|
+
{ label: '选项2', value: '2' },
|
|
19
|
+
]
|
|
20
|
+
</script>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Props
|
|
24
|
+
|
|
25
|
+
| 属性 | 说明 | 类型 | 默认值 |
|
|
26
|
+
|------|------|------|--------|
|
|
27
|
+
| v-model | 绑定值 ^el^ | `string \| number \| array` | - |
|
|
28
|
+
| options | 选项列表 ^el^ | `array` | `[]` |
|
|
29
|
+
| api | 选项接口地址 | `string \| (reqData) => Promise` | - |
|
|
30
|
+
| method | 请求方法 | `string` | `'post'` |
|
|
31
|
+
| reqData | 请求体数据 | `object` | `{}` |
|
|
32
|
+
| reqParams | URL 参数 | `object` | `{}` |
|
|
33
|
+
| reqBefore | 请求前处理 | `(reqData) => reqData` | - |
|
|
34
|
+
| reqAfter | 响应后处理 | `(res) => options` | - |
|
|
35
|
+
| labelKey | label 字段名 | `string` | `'label'` |
|
|
36
|
+
| valueKey | value 字段名 | `string` | `'value'` |
|
|
37
|
+
| formatLabel | 自定义 label 格式化 | `(item) => string` | - |
|
|
38
|
+
| disabledOption | 禁用选项判断 | `(item) => boolean` | - |
|
|
39
|
+
| lazy | 延迟加载(api模式) | `boolean` | `false` |
|
|
40
|
+
| codeInLabel | 下拉label 中显示 code ,当为boolean默认是valueKey| `boolean \| string` | - |
|
|
41
|
+
| clearable | 是否可清空 ^el^ | `boolean` | `true` |
|
|
42
|
+
|
|
43
|
+
> ^el^ 表示继承自 [el-select](https://element-plus.org/zh-CN/component/select.html#select-attributes) 的属性
|
|
44
|
+
|
|
45
|
+
## 在 Form 中使用
|
|
46
|
+
|
|
47
|
+
```tsx
|
|
48
|
+
const formItemList = [
|
|
49
|
+
{
|
|
50
|
+
prop: 'status',
|
|
51
|
+
label: '状态',
|
|
52
|
+
type: 'EpSelect',
|
|
53
|
+
props: {
|
|
54
|
+
options: [
|
|
55
|
+
{ label: '启用', value: 1 },
|
|
56
|
+
{ label: '禁用', value: 0 },
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
]
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## 接口获取选项
|
|
64
|
+
|
|
65
|
+
```tsx
|
|
66
|
+
{
|
|
67
|
+
prop: 'companyCode',
|
|
68
|
+
label: '公司',
|
|
69
|
+
type: 'EpSelect',
|
|
70
|
+
props: {
|
|
71
|
+
api: '/api/company/list',
|
|
72
|
+
valueKey: 'code',
|
|
73
|
+
labelKey: 'name',
|
|
74
|
+
},
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## 远程搜索
|
|
79
|
+
```tsx
|
|
80
|
+
{
|
|
81
|
+
prop: 'companyCode',
|
|
82
|
+
label: '公司',
|
|
83
|
+
type: 'EpSelect',
|
|
84
|
+
props: {
|
|
85
|
+
api: '/api/company/list',
|
|
86
|
+
valueKey: 'code',
|
|
87
|
+
labelKey: 'name',
|
|
88
|
+
remote: true,
|
|
89
|
+
filterable: true,
|
|
90
|
+
},
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## 带描述
|
|
96
|
+
- 适用于有code,但配置为remote/lazy,导致没有name的情况
|
|
97
|
+
```tsx
|
|
98
|
+
{
|
|
99
|
+
prop: 'companyCode',
|
|
100
|
+
label: '公司',
|
|
101
|
+
type: 'EpSelect',
|
|
102
|
+
props: {
|
|
103
|
+
api: '/api/company/list',
|
|
104
|
+
valueKey: 'code',
|
|
105
|
+
labelKey: 'name',
|
|
106
|
+
lazy: true,
|
|
107
|
+
desc: '描述信息'
|
|
108
|
+
},
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## 自定义 label 格式
|
|
113
|
+
|
|
114
|
+
```tsx
|
|
115
|
+
{
|
|
116
|
+
prop: 'companyCode',
|
|
117
|
+
label: '公司',
|
|
118
|
+
type: 'EpSelect',
|
|
119
|
+
props: {
|
|
120
|
+
api: '/api/company/list',
|
|
121
|
+
valueKey: 'code',
|
|
122
|
+
labelKey: 'name',
|
|
123
|
+
formatLabel: (item) => `${item.name} (${item.code})`,
|
|
124
|
+
},
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## 监听变化
|
|
129
|
+
|
|
130
|
+
```tsx
|
|
131
|
+
{
|
|
132
|
+
prop: 'companyCode',
|
|
133
|
+
label: '公司',
|
|
134
|
+
type: 'EpSelect',
|
|
135
|
+
props: {
|
|
136
|
+
options: [],
|
|
137
|
+
},
|
|
138
|
+
onChange: (value, item) => {
|
|
139
|
+
// value: 选中的值
|
|
140
|
+
// item: 选中的选项对象
|
|
141
|
+
formData.companyName = item?.name
|
|
142
|
+
},
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## codeInLabel 模式
|
|
147
|
+
|
|
148
|
+
下拉同时显示 code 和 label:
|
|
149
|
+
|
|
150
|
+
```tsx
|
|
151
|
+
{
|
|
152
|
+
prop: 'itemCode',
|
|
153
|
+
label: '商品',
|
|
154
|
+
type: 'EpSelect',
|
|
155
|
+
props: {
|
|
156
|
+
api: '/api/item/list',
|
|
157
|
+
valueKey: 'code',
|
|
158
|
+
labelKey: 'name',
|
|
159
|
+
codeInLabel: true, // 显示为 "name code"
|
|
160
|
+
// codeInLabel: 'itemCode', // 显示为 "name itemCode字段值"
|
|
161
|
+
},
|
|
162
|
+
}
|
|
163
|
+
```
|