@qin-ui/element-plus-pro 1.0.7 → 1.1.0
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/AI-CONTEXT.md +227 -23
- package/LICENSE +9 -0
- package/api.json +44 -27
- package/bin/init-ai.mjs +214 -52
- package/es/component-provider/{index-Bmx9Q9Q-.js → index-BGGIWSkO.js} +2 -1
- package/es/component-provider/index-BGGIWSkO.js.map +1 -0
- package/es/component-provider/index.js +2 -1
- package/es/component-provider/index.js.map +1 -0
- package/es/components/component-provider/components/index.vue.d.ts +27 -0
- package/es/components/component-provider/components/index.vue.d.ts.map +1 -0
- package/es/components/component-provider/constants/index.d.ts +16 -0
- package/es/components/component-provider/constants/index.d.ts.map +1 -0
- package/es/components/component-provider/index.d.ts +4 -0
- package/es/components/component-provider/index.d.ts.map +1 -0
- package/es/components/component-provider/types/index.d.ts +35 -0
- package/es/components/component-provider/types/index.d.ts.map +1 -0
- package/es/components/form/components/BaseField/index.vue.d.ts +13 -0
- package/es/components/form/components/BaseField/index.vue.d.ts.map +1 -0
- package/es/components/form/components/BaseField/utils/index.d.ts +3 -0
- package/es/components/form/components/BaseField/utils/index.d.ts.map +1 -0
- package/es/components/form/components/BaseFormItem/index.vue.d.ts +9 -0
- package/es/components/form/components/BaseFormItem/index.vue.d.ts.map +1 -0
- package/es/components/form/components/ContainerFragment/index.vue.d.ts +23 -0
- package/es/components/form/components/ContainerFragment/index.vue.d.ts.map +1 -0
- package/es/components/form/components/GroupedFieldAttrs/index.vue.d.ts +31 -0
- package/es/components/form/components/GroupedFieldAttrs/index.vue.d.ts.map +1 -0
- package/es/components/form/components/PathProvider/index.vue.d.ts +24 -0
- package/es/components/form/components/PathProvider/index.vue.d.ts.map +1 -0
- package/es/components/form/components/ProForm/index.vue.d.ts +36 -0
- package/es/components/form/components/ProForm/index.vue.d.ts.map +1 -0
- package/es/components/form/components/SlotComponent/index.vue.d.ts +7 -0
- package/es/components/form/components/SlotComponent/index.vue.d.ts.map +1 -0
- package/es/components/form/components/index.d.ts +12 -0
- package/es/components/form/components/index.d.ts.map +1 -0
- package/es/components/form/constants/index.d.ts +67 -0
- package/es/components/form/constants/index.d.ts.map +1 -0
- package/es/components/form/hooks/index.d.ts +5 -0
- package/es/components/form/hooks/index.d.ts.map +1 -0
- package/es/components/form/hooks/useFields.d.ts +57 -0
- package/es/components/form/hooks/useFields.d.ts.map +1 -0
- package/es/components/form/hooks/useForm.d.ts +93 -0
- package/es/components/form/hooks/useForm.d.ts.map +1 -0
- package/es/components/form/hooks/useFormRef.d.ts +30 -0
- package/es/components/form/hooks/useFormRef.d.ts.map +1 -0
- package/es/components/form/index.d.ts +7 -0
- package/es/components/form/index.d.ts.map +1 -0
- package/es/components/form/types/index.d.ts +234 -0
- package/es/components/form/types/index.d.ts.map +1 -0
- package/es/components/table/components/ColumnControl.vue.d.ts +9 -0
- package/es/components/table/components/ColumnControl.vue.d.ts.map +1 -0
- package/es/components/table/components/DefaultSearchFormContainer.vue.d.ts +18 -0
- package/es/components/table/components/DefaultSearchFormContainer.vue.d.ts.map +1 -0
- package/es/components/table/components/DefaultTableContainer.vue.d.ts +18 -0
- package/es/components/table/components/DefaultTableContainer.vue.d.ts.map +1 -0
- package/es/components/table/components/ProTable.vue.d.ts +47 -0
- package/es/components/table/components/ProTable.vue.d.ts.map +1 -0
- package/es/components/table/components/SearchForm.vue.d.ts +48 -0
- package/es/components/table/components/SearchForm.vue.d.ts.map +1 -0
- package/es/components/table/components/SizeControl.vue.d.ts +12 -0
- package/es/components/table/components/SizeControl.vue.d.ts.map +1 -0
- package/es/components/table/components/TableColumnRenderer.vue.d.ts +17 -0
- package/es/components/table/components/TableColumnRenderer.vue.d.ts.map +1 -0
- package/es/components/table/components/icons/ColumnHeightOutlined.vue.d.ts +3 -0
- package/es/components/table/components/icons/ColumnHeightOutlined.vue.d.ts.map +1 -0
- package/es/components/table/components/icons/DownOutlined.vue.d.ts +3 -0
- package/es/components/table/components/icons/DownOutlined.vue.d.ts.map +1 -0
- package/es/components/table/components/icons/FilterOutlined.vue.d.ts +3 -0
- package/es/components/table/components/icons/FilterOutlined.vue.d.ts.map +1 -0
- package/es/components/table/components/index.d.ts +5 -0
- package/es/components/table/components/index.d.ts.map +1 -0
- package/es/components/table/index.d.ts +33 -0
- package/es/components/table/index.d.ts.map +1 -0
- package/es/components/table/types/index.d.ts +67 -0
- package/es/components/table/types/index.d.ts.map +1 -0
- package/es/components/table/useTable.d.ts +111 -0
- package/es/components/table/useTable.d.ts.map +1 -0
- package/es/element-plus-pro.css +10 -10
- package/es/form/{index-D8btGgqa.js → index-oI6LGSpA.js} +13 -7
- package/es/form/index-oI6LGSpA.js.map +1 -0
- package/es/form/index.js +4 -3
- package/es/form/index.js.map +1 -0
- package/es/index.d.ts +76 -1472
- package/es/index.d.ts.map +1 -0
- package/es/index.js +14 -23
- package/es/index.js.map +1 -0
- package/es/shared/core/index.d.ts +6 -0
- package/es/shared/core/index.d.ts.map +1 -0
- package/es/shared/ui/index.d.ts +12 -0
- package/es/shared/ui/index.d.ts.map +1 -0
- package/es/table/index.js +10 -10
- package/es/table/index.js.map +1 -0
- package/package.json +10 -11
- package/src/components/component-provider/components/index.vue +67 -0
- package/src/components/component-provider/constants/index.ts +209 -0
- package/src/components/component-provider/index.ts +6 -0
- package/src/components/component-provider/types/index.ts +64 -0
- package/src/components/form/components/BaseField/index.vue +181 -0
- package/src/components/form/components/BaseField/utils/index.ts +15 -0
- package/src/components/form/components/BaseFormItem/index.vue +170 -0
- package/src/components/form/components/ContainerFragment/index.vue +24 -0
- package/src/components/form/components/GroupedFieldAttrs/index.vue +115 -0
- package/src/components/form/components/PathProvider/index.vue +19 -0
- package/src/components/form/components/ProForm/index.vue +106 -0
- package/src/components/form/components/SlotComponent/index.vue +26 -0
- package/src/components/form/components/index.ts +15 -0
- package/src/components/form/constants/index.ts +116 -0
- package/src/components/form/hooks/index.ts +5 -0
- package/src/components/form/hooks/useFields.ts +67 -0
- package/src/components/form/hooks/useForm.ts +110 -0
- package/src/components/form/hooks/useFormRef.ts +35 -0
- package/src/components/form/index.ts +29 -0
- package/src/components/form/types/index.ts +300 -0
- package/src/components/table/components/ColumnControl.vue +136 -0
- package/src/components/table/components/DefaultSearchFormContainer.vue +14 -0
- package/src/components/table/components/DefaultTableContainer.vue +14 -0
- package/src/components/table/components/ProTable.vue +420 -0
- package/src/components/table/components/SearchForm.vue +302 -0
- package/src/components/table/components/SizeControl.vue +55 -0
- package/src/components/table/components/TableColumnRenderer.vue +71 -0
- package/src/components/table/components/icons/ColumnHeightOutlined.vue +4 -0
- package/src/components/table/components/icons/DownOutlined.vue +4 -0
- package/src/components/table/components/icons/FilterOutlined.vue +4 -0
- package/src/components/table/components/index.ts +4 -0
- package/src/components/table/index.ts +38 -0
- package/src/components/table/types/index.ts +77 -0
- package/src/components/table/useTable.ts +144 -0
- package/src/index.ts +81 -0
- package/src/shared/core/index.ts +38 -0
- package/src/shared/ui/index.ts +106 -0
- package/es/core/index-C0Pbv44C.js +0 -360
- package/es/vendor/utils/lodash-es-p6jau26B.js +0 -1120
package/AI-CONTEXT.md
CHANGED
|
@@ -1,37 +1,241 @@
|
|
|
1
|
-
# @qin-ui/element-plus-pro
|
|
1
|
+
# @qin-ui/element-plus-pro — AI 上下文
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
基于 **element-plus**(Vue 3,el- 前缀)的 Schema 驱动高级组件库。用 JS 对象描述 UI,而非模板堆砌组件标签。
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
---
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
## 1. 架构概览
|
|
8
|
+
|
|
9
|
+
### 1.1 三层架构
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
┌─────────────────────────────────────────────────┐
|
|
13
|
+
│ Field[] 配置层(用户编写的 JS 对象) │
|
|
14
|
+
│ { path:'name', component:'input', span:8, ... } │
|
|
15
|
+
├─────────────────────────────────────────────────┤
|
|
16
|
+
│ @qin-ui/element-plus-pro(Schema 解析 + 组件解析)│
|
|
17
|
+
│ 属性分层剥离 → Grid→el-col, FormItem→el-form-item, 剩余→输入控件 │
|
|
18
|
+
├─────────────────────────────────────────────────┤
|
|
19
|
+
│ element-plus(Vue 3 组件库,el- 前缀) │
|
|
20
|
+
│ el-input / el-select / el-date-picker / el-table ...│
|
|
21
|
+
└─────────────────────────────────────────────────┘
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
ProForm/ProTable 是**渲染引擎**,不是组件库。Field 属性被逐层剥离,分发到不同层级的 el-\* 组件。
|
|
25
|
+
|
|
26
|
+
### 1.2 内置组件映射表
|
|
27
|
+
|
|
28
|
+
| Field `component` | 渲染的 el 组件 | 子类型(`type`) | 常用透传 Props(示例) |
|
|
29
|
+
| :----------------- | :---------------- | :--------------------------------------------------------------------------------- | :---------------------------------------------------------------------------------------- |
|
|
30
|
+
| `'input'` | el-input | textarea, password | placeholder, maxlength, clearable, showWordLimit, showPassword, autosize |
|
|
31
|
+
| `'input-number'` | el-input-number | — | min, max, step, precision, controls, placeholder |
|
|
32
|
+
| `'autocomplete'` | el-autocomplete | — | placeholder, clearable, fetchSuggestions, triggerOnFocus |
|
|
33
|
+
| `'select'` | el-select | — | **options**, multiple, filterable, clearable, allowCreate, loading, remote, remoteMethod |
|
|
34
|
+
| `'cascader'` | el-cascader | — | **options**, props, filterable, clearable, showAllLevels |
|
|
35
|
+
| `'date-picker'` | el-date-picker | date, daterange, datetime, datetimerange, week, month, monthrange, year, yearrange | format, valueFormat, disabledDate, clearable, startPlaceholder, endPlaceholder, shortcuts |
|
|
36
|
+
| `'time-picker'` | el-time-picker | — | format, clearable, isRange, startPlaceholder, endPlaceholder |
|
|
37
|
+
| `'time-select'` | el-time-select | — | start, end, step, clearable, minTime, maxTime |
|
|
38
|
+
| `'checkbox-group'` | el-checkbox-group | — | **options**, min, max, disabled |
|
|
39
|
+
| `'radio-group'` | el-radio-group | — | **options**, disabled, size |
|
|
40
|
+
| `'switch'` | el-switch | — | activeText, inactiveText, activeValue, inactiveValue, loading, size |
|
|
41
|
+
| `'slider'` | el-slider | — | min, max, step, showStops, range, marks |
|
|
42
|
+
| `'tree-select'` | el-tree-select | — | **data**, filterable, clearable, checkStrictly, props, multiple, showCheckbox |
|
|
43
|
+
| `'transfer'` | el-transfer | — | **data**, **titles**, filterable, filterMethod, props |
|
|
44
|
+
| `'custom'` | 自定义 | — | component 直接传入 Vue 组件或 h() 渲染函数 |
|
|
45
|
+
|
|
46
|
+
> **编写任何控件属性前,必须查阅 [element-plus 官方文档](https://element-plus.org/) 确认属性名和类型。**
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## 2. 属性分层传递(核心规则)
|
|
51
|
+
|
|
52
|
+
Field 属性按渲染目标逐层剥离:
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
<el-col :span="8"> <!-- Grid 层 -->
|
|
56
|
+
<el-form-item label="城市"> <!-- FormItem 层 -->
|
|
57
|
+
<el-select v-model="..." placeholder="选择" /> <!-- 输入控件层 -->
|
|
58
|
+
</el-form-item>
|
|
59
|
+
</el-col>
|
|
9
60
|
```
|
|
10
61
|
|
|
11
|
-
|
|
62
|
+
**Grid 层 → `<el-col>`**(仅 grid 启用时):`span`, `offset`, `push`, `pull`, `xs`, `sm`, `md`, `lg`, `xl`
|
|
63
|
+
|
|
64
|
+
**FormItem 层 → `<el-form-item>`**:`label`, `rules`, `error`, `required`, `size`, `showMessage`, `inlineMessage`, `labelWidth`;`formItemClass`/`formItemStyle`→`class`/`style`;`formItemDataAttrs`→`data-*`
|
|
12
65
|
|
|
13
|
-
|
|
66
|
+
**输入控件层 → 输入组件**:其余所有属性(`disabled`, `placeholder`, `clearable`, `options`, `filterable`, `maxlength`, `multiple` 等);`componentClass`/`componentStyle`→`class`/`style`;`componentDataAttrs`→`data-*`
|
|
14
67
|
|
|
15
|
-
|
|
16
|
-
- `ProTable` - 配置驱动表格组件
|
|
17
|
-
- `ProComponentProvider` - 全局配置提供者
|
|
68
|
+
**渲染逻辑消费(不绑定 DOM)**:`component`, `fields`, `hidden`, `slots`, `modelProp`, `valueFormatter`, `componentContainer`, `extraProps`
|
|
18
69
|
|
|
19
|
-
###
|
|
70
|
+
### 2.1 modelProp
|
|
20
71
|
|
|
21
|
-
|
|
22
|
-
- `useFields<D>()` - 字段配置管理
|
|
23
|
-
- `useFormRef()` - 表单组件引用
|
|
24
|
-
- `useTable<D, T>()` - 创建表格实例
|
|
72
|
+
决定 `v-model:xxx` 的绑定变量名:
|
|
25
73
|
|
|
26
|
-
|
|
74
|
+
- 默认 `modelProp: 'modelValue'` → `v-model`(element-plus 惯例)
|
|
75
|
+
- **ProComponentProvider 已为 `switch` 预设 `modelProp: 'modelValue'`**,通常无需手动指定
|
|
76
|
+
- 自定义场景:`modelProp: 'visible'` → `v-model:visible`
|
|
77
|
+
|
|
78
|
+
### 2.2 element-plus 命名约定
|
|
79
|
+
|
|
80
|
+
- 使用 `clearable`(不是 `allowClear`)
|
|
81
|
+
- el-form-item 插槽为 `label` 和 `error`;其他 slot key 透传到底层输入组件(如 el-input 的 `prefix`/`suffix`/`append`/`prepend`)
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## 3. 渐进式用法
|
|
86
|
+
|
|
87
|
+
### 第一阶段:基础渲染
|
|
88
|
+
|
|
89
|
+
完全依赖 Field 配置,**禁止手写 `<el-form-item>` 或 `<el-input>`**。
|
|
90
|
+
|
|
91
|
+
```ts
|
|
92
|
+
const form = useForm({ username: '', password: '' }, [
|
|
93
|
+
{
|
|
94
|
+
path: 'username',
|
|
95
|
+
component: 'input',
|
|
96
|
+
label: '用户名',
|
|
97
|
+
placeholder: '请输入',
|
|
98
|
+
rules: [{ required: true, message: '请输入用户名', trigger: 'blur' }],
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
path: 'password',
|
|
102
|
+
component: 'input',
|
|
103
|
+
type: 'password',
|
|
104
|
+
label: '密码',
|
|
105
|
+
rules: [{ required: true, message: '请输入密码', trigger: 'blur' }],
|
|
106
|
+
},
|
|
107
|
+
]);
|
|
108
|
+
// 模板:<ProForm :form="form" />
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
### 第二阶段:字段联动
|
|
112
|
+
|
|
113
|
+
`disabled`, `hidden`, `rules` 等控制属性支持三种方式:
|
|
114
|
+
|
|
115
|
+
```ts
|
|
116
|
+
// computed() — 声明式,初始化联动首选
|
|
117
|
+
disabled: computed(() => !form.formData.hasLimit),
|
|
118
|
+
|
|
119
|
+
// ref() — 外部共享状态
|
|
120
|
+
const isDisabled = ref(false);
|
|
121
|
+
|
|
122
|
+
// setField() — 运行时命令式
|
|
123
|
+
form.setField('limitCount', { disabled: true });
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
**选择:初始化联动→`computed()`;事件触发→`setField()`;共享状态→`ref()`。**
|
|
127
|
+
|
|
128
|
+
### 第三阶段:自定义组件
|
|
129
|
+
|
|
130
|
+
```ts
|
|
131
|
+
// h() 挂载自定义组件
|
|
132
|
+
{ path: 'key', component: (p, ctx) => h(CustomInput, { ...p, ...ctx.attrs }) }
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
```html
|
|
136
|
+
<!-- 同名插槽接管渲染,scoped 内置所有绑定参数 -->
|
|
137
|
+
<ProForm :form="form">
|
|
138
|
+
<template #agreement="scoped">
|
|
139
|
+
<el-checkbox v-bind="scoped">阅读并同意协议</el-checkbox>
|
|
140
|
+
</template>
|
|
141
|
+
</ProForm>
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## 4. 反模式
|
|
147
|
+
|
|
148
|
+
```html
|
|
149
|
+
<!-- ❌ 禁止在 ProForm 内手写 el-form-item -->
|
|
150
|
+
<ProForm :form="form">
|
|
151
|
+
<el-form-item label="姓名"
|
|
152
|
+
><el-input v-model="form.formData.name"
|
|
153
|
+
/></el-form-item>
|
|
154
|
+
</ProForm>
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
```ts
|
|
158
|
+
// ❌ 不查文档盲目猜测 — element-plus 用 filterable,不是 searchable
|
|
159
|
+
{ path: 'city', component: 'select', searchable: true }
|
|
160
|
+
// ✅ 查 element-plus 文档确认后
|
|
161
|
+
{ path: 'city', component: 'select', filterable: true }
|
|
162
|
+
|
|
163
|
+
// span→Grid 层(el-col);placeholder→控件层(el-input)
|
|
164
|
+
{ path: 'name', component: 'input', span: 12, placeholder: '请输入' }
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## 5. ProComponentProvider:全局默认配置
|
|
170
|
+
|
|
171
|
+
统一配置子组件默认属性,避免逐字段重复。
|
|
172
|
+
|
|
173
|
+
### INJECT_CONFIG 预设默认值
|
|
174
|
+
|
|
175
|
+
| 组件 | 预设默认值 |
|
|
176
|
+
| :---------------------------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
177
|
+
| `switch` | `{ modelProp: 'modelValue' }` |
|
|
178
|
+
| `input` | `{ maxlength: 100, clearable: true, placeholder: '请输入' }` |
|
|
179
|
+
| `input.textarea` | `{ maxlength: 200, autosize: {minRows:3,maxRows:6}, showWordLimit: true, clearable: true, placeholder: '请输入' }` |
|
|
180
|
+
| `input.password` | `{ maxlength: 100, clearable: true, showPassword: true, placeholder: '请输入' }` |
|
|
181
|
+
| `select` / `cascader` | `{ clearable: true, placeholder: '请选择' }` |
|
|
182
|
+
| `input-number` | `{ max: 10^15-1, min: -(10^15+1), controls: false, placeholder: '请输入', style: {width:'100%'} }` |
|
|
183
|
+
| `date-picker` 系列 | `{ style: {width:'100%'} }` + 各子类型专用占位符 |
|
|
184
|
+
| `time-picker` / `time-select` | `{ style: {width:'100%'}, placeholder: '请选择' }` |
|
|
185
|
+
| `tree-select` | `{ clearable: true, placeholder: '请选择' }` |
|
|
186
|
+
| `pro-table` | `{ pagination: {layout:'total,sizes,prev,pager,next,jumper',pageSizes:[10,20,30,40,50,100],background:true}, searchFormConfig: {layout:'grid',expand:{minExpandRows:2,expandStatus:false}}, control: true, addIndexColumn: true }` |
|
|
187
|
+
| `pro-form` | `{ grid: { gutter: 24 } }` |
|
|
188
|
+
| `pro-form-item` | `{ span: 8 }` |
|
|
189
|
+
|
|
190
|
+
### 优先级(高→低)
|
|
191
|
+
|
|
192
|
+
1. Field 级别配置
|
|
193
|
+
2. `ProComponentProvider` 的 `componentVars` 参数
|
|
194
|
+
3. `INJECT_CONFIG` 内置预设
|
|
195
|
+
|
|
196
|
+
### 覆盖示例
|
|
197
|
+
|
|
198
|
+
```vue
|
|
199
|
+
<template>
|
|
200
|
+
<ProComponentProvider :component-vars="config">
|
|
201
|
+
<ProForm :form="form" />
|
|
202
|
+
</ProComponentProvider>
|
|
203
|
+
</template>
|
|
204
|
+
<script setup lang="ts">
|
|
205
|
+
const config = {
|
|
206
|
+
'pro-form-item': { span: 6 },
|
|
207
|
+
input: { maxlength: 200 },
|
|
208
|
+
select: { filterable: true },
|
|
209
|
+
};
|
|
210
|
+
</script>
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
## 6. ProTable 速览
|
|
216
|
+
|
|
217
|
+
```ts
|
|
218
|
+
const table = useTable<any, Row>({
|
|
219
|
+
columns: [
|
|
220
|
+
{ prop: 'id', label: 'ID', width: 80 },
|
|
221
|
+
{ prop: 'name', label: '姓名', width: 120 },
|
|
222
|
+
],
|
|
223
|
+
// searchFields 与 ProForm fields 格式一致,支持相同分层剥离
|
|
224
|
+
searchFields: [
|
|
225
|
+
{ path: 'name', component: 'input', placeholder: '搜索' },
|
|
226
|
+
{ path: 'status', component: 'select', options: [...] },
|
|
227
|
+
],
|
|
228
|
+
data: [],
|
|
229
|
+
});
|
|
230
|
+
// 模板:<ProTable :table="table" :search="() => fetchData()" immediateSearch />
|
|
231
|
+
```
|
|
27
232
|
|
|
28
|
-
|
|
233
|
+
> element-plus Table Column 用 `prop`(非 `dataIndex`),数据源用 `data`(非 `dataSource`)。
|
|
29
234
|
|
|
30
|
-
|
|
235
|
+
---
|
|
31
236
|
|
|
32
|
-
##
|
|
237
|
+
## 7. 关键参考
|
|
33
238
|
|
|
34
|
-
-
|
|
35
|
-
|
|
36
|
-
-
|
|
37
|
-
- 所有 Element Plus TableColumn 属性
|
|
239
|
+
1. **`node_modules/@qin-ui/element-plus-pro/api.json`** — 结构化 API 元数据
|
|
240
|
+
2. **`node_modules/@qin-ui/element-plus-pro/README.md`** — 完整文档和示例
|
|
241
|
+
3. **[https://element-plus.org/](https://element-plus.org/)** — 确认控件属性时必查
|
package/LICENSE
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023-present pro-components
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/api.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"generatedAt": "2026-
|
|
2
|
+
"generatedAt": "2026-07-09T04:30:17.104Z",
|
|
3
3
|
"name": "@qin-ui/element-plus-pro",
|
|
4
4
|
"api": [
|
|
5
5
|
{
|
|
@@ -12,25 +12,25 @@
|
|
|
12
12
|
"```vue\n<ProComponentProvider\n:componentVars=\"{ 'input': { placeholder: '请输入' } }\"\n>\n<ProForm :form=\"form\" :fields=\"fields\" />\n</ProComponentProvider>\n```"
|
|
13
13
|
]
|
|
14
14
|
},
|
|
15
|
+
{
|
|
16
|
+
"name": "ContainerFragment",
|
|
17
|
+
"type": "component",
|
|
18
|
+
"package": "@qin-ui/element-plus-pro",
|
|
19
|
+
"signature": "<ContainerFragment>",
|
|
20
|
+
"description": "容器分片渲染组件。用于动态渲染表单行或表单项的外部包裹容器(例如 Grid 行、Col 列等布局容器)。"
|
|
21
|
+
},
|
|
15
22
|
{
|
|
16
23
|
"name": "ProForm",
|
|
17
24
|
"type": "component",
|
|
18
25
|
"package": "@qin-ui/element-plus-pro",
|
|
19
26
|
"signature": "<ProForm>",
|
|
20
|
-
"description": "@qin-ui/element-plus-pro 配置驱动表单组件\n通过配置驱动的方式快速构建表单,支持:\n- 字段联动、嵌套字段、自定义组件、网格布局",
|
|
27
|
+
"description": "@qin-ui/element-plus-pro 配置驱动表单组件\n架构设计说明 (Architecture Overview)\n[ 数据层 (Core) ] => [ 绑定层 (ProForm) ] => [ 渲染层 (BaseFormItem / BaseField) ]\n1. 数据隔离:ProForm 本身不负责存储和管理表单状态,所有核心状态(formData, fields, 校验规则)\n均交由底层的 `useForm`(@qin-ui/pro-components-core)驱动。\n2. 上下文透传:通过 `provide` 将核心状态下发给子组件,避免了深层嵌套的 Props 传递。\n3. 递归渲染:网格布局和具体字段的解析交由 `<BaseFormItem>` 递归完成,实现了 UI 布局与表单逻辑的解耦。\n通过配置驱动的方式快速构建表单,支持:\n- 字段联动、嵌套字段、自定义组件、网格布局",
|
|
21
28
|
"typeParams": [
|
|
22
29
|
{
|
|
23
30
|
"name": "F"
|
|
24
31
|
}
|
|
25
32
|
]
|
|
26
33
|
},
|
|
27
|
-
{
|
|
28
|
-
"name": "ContainerFragment",
|
|
29
|
-
"type": "component",
|
|
30
|
-
"package": "@qin-ui/element-plus-pro",
|
|
31
|
-
"signature": "<ContainerFragment>",
|
|
32
|
-
"description": "容器分片渲染组件。用于动态渲染表单行或表单项的外部包裹容器(例如 Grid 行、Col 列等布局容器)。"
|
|
33
|
-
},
|
|
34
34
|
{
|
|
35
35
|
"name": "SlotComponent",
|
|
36
36
|
"type": "component",
|
|
@@ -59,9 +59,9 @@
|
|
|
59
59
|
"name": "useFormData",
|
|
60
60
|
"type": "function",
|
|
61
61
|
"package": "@qin-ui/element-plus-pro",
|
|
62
|
-
"signature": "export const useFormData = <D extends Data = Data>(\n initFormData?: ExtendWithAny<DeepPartial<D>>\n) =>",
|
|
62
|
+
"signature": "export const useFormData = <D extends Data = Data>(\n initFormData?: ExtendWithAny<DeepPartial<D>>\n): UseFormDataReturn<D> =>",
|
|
63
63
|
"description": "表单数据处理 Hook\n提供响应式表单数据的管理能力,支持:\n- 响应式数据存储(基于 Vue reactive)\n- 深层路径读写(支持点号分隔,如 'address.city')\n- 类型安全的路径提示(传入泛型 D 后,path 参数可获得类型推导)\n- 父子表单自动注入(非根表单会从注入中获取数据)",
|
|
64
|
-
"returns": "{
|
|
64
|
+
"returns": "{UseFormDataReturn<D>} 表单数据操作对象",
|
|
65
65
|
"typeParams": [
|
|
66
66
|
{
|
|
67
67
|
"name": "D"
|
|
@@ -75,15 +75,16 @@
|
|
|
75
75
|
"name": "useFields",
|
|
76
76
|
"type": "function",
|
|
77
77
|
"package": "@qin-ui/element-plus-pro",
|
|
78
|
-
"signature": "export
|
|
79
|
-
"description": "
|
|
78
|
+
"signature": "export function useFields<D extends Data = Data>(\n initFields?: Fields<D>\n): UseFieldsReturn<D, Field<ComponentName, D>, FormItemInstance>;",
|
|
79
|
+
"description": "字段配置管理 Hook\n基于 `@qin-ui/pro-components-core` 的 `useFields`,将泛型参数绑定为 Element Plus 的本地类型:\n- 字段类型 F -> `Field<ComponentName, D>`(支持 Element Plus 组件类型推导)\n- FormItem 实例 -> Element Plus 的 `FormItemInstance`\n提供对字段配置数组的增删改查操作,支持:\n- 通过路径字符串或查找函数定位字段\n- 深层嵌套字段的遍历和匹配\n- 字段配置的合并/覆盖更新\n- 字段的添加、插入、删除\n- 父级字段查找\n- `fields` - 字段配置数组(响应式 Ref\\<F[]\\>)\n- `getField(path)` - 获取字段配置,支持路径字符串或查找函数\n- `setField(path, field, options?)` - 更新字段配置,默认合并模式\n- `deleteField(path, options?)` - 删除字段配置\n- `appendField(path, field, options?)` - 在指定字段后追加\n- `prependField(path, field, options?)` - 在指定字段前插入\n- `getParentField(path, options?)` - 获取父级字段配置",
|
|
80
|
+
"returns": "字段操作对象,包含以下属性:",
|
|
80
81
|
"typeParams": [
|
|
81
82
|
{
|
|
82
83
|
"name": "D"
|
|
83
84
|
}
|
|
84
85
|
],
|
|
85
86
|
"examples": [
|
|
86
|
-
"```ts\ninterface User { name: string; age: number }\n\nconst { fields, getField, setField } = useFields<User>([\n{ path: 'name', label: '姓名', component: 'input' },\n{ path: 'age', label: '年龄', component: 'input-number' },\n])\n```"
|
|
87
|
+
"```ts\ninterface User { name: string; age: number }\n\nconst { fields, getField, setField } = useFields<User>([\n{ path: 'name', label: '姓名', component: 'input' },\n{ path: 'age', label: '年龄', component: 'input-number' },\n])\n\n// 通过路径获取\ngetField('name')\n// 通过查找函数获取\ngetField(f => f.label === '姓名')\n// 更新字段(合并模式)\nsetField('name', { label: '用户名', disabled: true })\n```"
|
|
87
88
|
]
|
|
88
89
|
},
|
|
89
90
|
{
|
|
@@ -91,14 +92,14 @@
|
|
|
91
92
|
"type": "type",
|
|
92
93
|
"package": "@qin-ui/element-plus-pro",
|
|
93
94
|
"signature": "export type UseFields<D extends Data = Data> = ReturnType<typeof useFields<D>>;",
|
|
94
|
-
"description": "useFields
|
|
95
|
+
"description": "useFields 返回值类型"
|
|
95
96
|
},
|
|
96
97
|
{
|
|
97
98
|
"name": "Form",
|
|
98
99
|
"type": "type",
|
|
99
100
|
"package": "@qin-ui/element-plus-pro",
|
|
100
101
|
"signature": "export type Form<\n D extends Data = Data,\n F extends Field<ComponentName, D> = Field<ComponentName, D>,\n> = _Form<D, F, FormInstance>;",
|
|
101
|
-
"description": "在 core Form
|
|
102
|
+
"description": "表单实例类型\n在 core Form 类型的基础上,将字段类型 F 绑定为本地 Field<ComponentName, D>,\n将底层表单实例 I 绑定为 Element Plus 的 FormInstance,使 formRef 获得完整的类型提示。\n1. `setFormData(path, value)` - 设置指定路径的值<br>\n2. `setFormData(path, prev => newVal)` - 函数式更新<br>\n3. `setFormData({ ... })` - 批量覆盖整个表单",
|
|
102
103
|
"typeParams": [
|
|
103
104
|
{
|
|
104
105
|
"name": "D"
|
|
@@ -106,32 +107,36 @@
|
|
|
106
107
|
{
|
|
107
108
|
"name": "F"
|
|
108
109
|
}
|
|
110
|
+
],
|
|
111
|
+
"examples": [
|
|
112
|
+
"```ts\ninterface User { name: string; age: number }\nconst form: Form<User> = useForm({ name: '张三', age: 25 })\n\nform.formData.name // 直接读写响应式数据\nform.getFormData('name') // 通过路径读取\nform.setFormData('name', '李四') // 更新数据\nform.formRef.value?.validate() // 访问底层 Form 实例\n```"
|
|
109
113
|
]
|
|
110
114
|
},
|
|
111
115
|
{
|
|
112
116
|
"name": "useForm",
|
|
113
117
|
"type": "function",
|
|
114
118
|
"package": "@qin-ui/element-plus-pro",
|
|
115
|
-
"signature": "export
|
|
116
|
-
"description": "
|
|
119
|
+
"signature": "export function useForm<D extends Data = Data>(\n initFormData?: ExtendWithAny<DeepPartial<D>>,\n initFields?: Field<ComponentName, D>[],\n root?: boolean\n): Form<D, Field<ComponentName, D>>;",
|
|
120
|
+
"description": "创建表单实例的 Hook\n基于 `@qin-ui/pro-components-core` 的 `useForm`,将泛型参数绑定为 Element Plus 的本地类型:\n- 字段类型 F -> `Field<ComponentName, D>`(支持 Element Plus 所有内置组件类型推导)\n- 表单实例 -> Element Plus 的 `FormInstance`(使 formRef 获得完整的类型提示)\n表单实例组合了三个子模块的能力:\n- **useFormData**:表单数据管理(响应式数据、读写、批量更新)\n- **useFields**:字段配置管理(增删改查字段配置,支持嵌套)\n- **useFormRef**:底层 Form 组件实例引用",
|
|
121
|
+
"returns": "{Form<D>} 表单实例,包含数据操作、字段操作和 ref 操作",
|
|
117
122
|
"typeParams": [
|
|
118
123
|
{
|
|
119
124
|
"name": "D"
|
|
120
125
|
}
|
|
121
126
|
],
|
|
122
127
|
"examples": [
|
|
123
|
-
"```ts\ninterface User { name: string; age: number }\n\nconst form = useForm<User>(\n{ name: '张三', age: 25 },\n[\n{ path: 'name', label: '姓名', component: 'input' },\n{ path: 'age', label: '年龄', component: 'input-number' },\n]\n)\n```"
|
|
128
|
+
"```ts\ninterface User { name: string; age: number }\n\n// 方式一:同时传入初始数据和字段\nconst form = useForm<User>(\n{ name: '张三', age: 25 },\n[\n{ path: 'name', label: '姓名', component: 'input' },\n{ path: 'age', label: '年龄', component: 'input-number' },\n],\ntrue\n)\n\n// 方式二:仅设置 root 标识\nconst form = useForm<User>(true)\n\n// 使用\nconst { formData, formRef, fields, setFormData, getField } = form\nsetFormData('name', '李四')\nawait formRef.value?.validate()\n```"
|
|
124
129
|
]
|
|
125
130
|
},
|
|
126
131
|
{
|
|
127
132
|
"name": "useFormRef",
|
|
128
133
|
"type": "function",
|
|
129
134
|
"package": "@qin-ui/element-plus-pro",
|
|
130
|
-
"signature": "export
|
|
131
|
-
"description": "
|
|
132
|
-
"returns": "
|
|
135
|
+
"signature": "export function useFormRef(): UseFormRefReturn<FormInstance>",
|
|
136
|
+
"description": "表单组件实例引用 Hook\n基于 `@qin-ui/pro-components-core` 的 `useFormRef`,将泛型参数绑定为 Element Plus 的 `FormInstance`,\n使 formRef 获取到完整的 Element Plus Form 组件 API 类型提示(如 `validate()`、`resetFields()` 等)。\n`formRef` 由 ProForm 组件内部自动通过 `setFormRef` 绑定,无需手动调用。\n- `formRef` — Element Plus Form 组件实例的响应式引用(`Ref<FormInstance | undefined>`)\n- `setFormRef(inst)` — 设置 Form 组件实例,由 ProForm 内部自动调用",
|
|
137
|
+
"returns": "表单组件实例引用管理对象:",
|
|
133
138
|
"examples": [
|
|
134
|
-
"```ts\nconst { formRef, setFormRef } = useFormRef()\nawait formRef.value?.validate()\nformRef.value?.resetFields()\n```"
|
|
139
|
+
"```ts\nconst { formRef, setFormRef } = useFormRef()\n\n// formRef 由 ProForm 自动绑定,可直接使用\nawait formRef.value?.validate()\nformRef.value?.resetFields()\nformRef.value?.scrollToField('username')\n```"
|
|
135
140
|
]
|
|
136
141
|
},
|
|
137
142
|
{
|
|
@@ -190,7 +195,7 @@
|
|
|
190
195
|
"type": "type",
|
|
191
196
|
"package": "@qin-ui/element-plus-pro",
|
|
192
197
|
"signature": "export type Table<\n D extends Data = Data,\n T extends Data = ExtendWithAny<D>,\n> = Omit<_Table<D, T, Column<T>>, 'dataSource'> &",
|
|
193
|
-
"description": "在 core Table
|
|
198
|
+
"description": "表格实例类型\n在 core Table 类型的基础上,将列类型 C 绑定为本地 Column<T>,\n并将 dataSource 重命名为 data(Element Plus 使用 data 而非 dataSource),\n使 columns 操作获得 Element Plus 表格列的完整属性类型提示。",
|
|
194
199
|
"typeParams": [
|
|
195
200
|
{
|
|
196
201
|
"name": "D"
|
|
@@ -198,14 +203,26 @@
|
|
|
198
203
|
{
|
|
199
204
|
"name": "T"
|
|
200
205
|
}
|
|
206
|
+
],
|
|
207
|
+
"examples": [
|
|
208
|
+
"```ts\ninterface SearchParams { keyword: string }\ninterface User { name: string; age: number }\n\nconst table: Table<SearchParams, User> = useTable({\ncolumns: [{ prop: 'name', title: '姓名' }],\n})\n\ntable.columns.value // 访问列配置\ntable.setColumn('name', { width: 150 }) // 更新列\ntable.setPageParam({ current: 2 }) // 切换页码\ntable.searchForm.setFormData('keyword', '搜索词') // 操作搜索表单\n```"
|
|
201
209
|
]
|
|
202
210
|
},
|
|
203
211
|
{
|
|
204
212
|
"name": "useTable",
|
|
205
213
|
"type": "function",
|
|
206
214
|
"package": "@qin-ui/element-plus-pro",
|
|
207
|
-
"signature": "export
|
|
208
|
-
"description": "
|
|
215
|
+
"signature": "export function useTable<\n D extends Data = Data,\n T extends Data = ExtendWithAny<D>,\n>(params: UseTableParams<D, T> = {}): Table<D, T>",
|
|
216
|
+
"description": "创建表格实例的 Hook\n基于 `@qin-ui/pro-components-core` 的 `useTable` 封装,适配 Element Plus 的 API 风格:\n- 数据源使用 `data` 而非 `dataSource`\n是 ProTable 组件的核心 Hook,提供了:\n- 列配置管理(增删改查)\n- 数据源管理\n- 分页管理\n- 搜索表单集成(内部使用 useForm)\n- 查询参数重置",
|
|
217
|
+
"params": [
|
|
218
|
+
{
|
|
219
|
+
"name": "params",
|
|
220
|
+
"type": "object",
|
|
221
|
+
"optional": false,
|
|
222
|
+
"description": "表格配置参数"
|
|
223
|
+
}
|
|
224
|
+
],
|
|
225
|
+
"returns": "{Table<D, T>} 表格实例",
|
|
209
226
|
"typeParams": [
|
|
210
227
|
{
|
|
211
228
|
"name": "D"
|
|
@@ -215,7 +232,7 @@
|
|
|
215
232
|
}
|
|
216
233
|
],
|
|
217
234
|
"examples": [
|
|
218
|
-
"```ts\ninterface User { name: string; age: number }\n\nconst table = useTable<User>({\ncolumns: [\n{ prop: 'name', title: '姓名', width: 120 },\n{ prop: 'age', title: '年龄', width: 80 },\n],\ndata: [],\npageParam: { current: 1, pageSize: 20, total: 0 },\n})\n```"
|
|
235
|
+
"```ts\ninterface SearchParams { keyword: string }\ninterface User { name: string; age: number; email: string }\n\nconst table = useTable<SearchParams, User>({\ncolumns: [\n{ prop: 'name', title: '姓名', width: 120 },\n{ prop: 'age', title: '年龄', width: 80 },\n],\ndata: [],\npageParam: { current: 1, pageSize: 20, total: 0 },\nsearchParam: { keyword: '' },\nsearchFields: [\n{ path: 'keyword', label: '关键词', component: 'input' },\n],\n})\n```"
|
|
219
236
|
]
|
|
220
237
|
}
|
|
221
238
|
]
|