ai-front-base 0.2.3 → 0.2.7
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/README.md +1 -0
- package/dist/components/AiDatePicker/index.vue.mjs +62 -9
- package/dist/components/AiDatePicker/types.ts +9 -12
- package/dist/components/AiDateRangePicker/index.mjs +7 -0
- package/dist/components/AiDateRangePicker/index.vue.mjs +33 -0
- package/dist/components/AiDateRangePicker/types.ts +33 -0
- package/dist/components/AiForm/README.md +35 -0
- package/dist/components/AiForm/index.mjs +4 -1
- package/dist/components/AiForm/index.vue.mjs +145 -36
- package/dist/components/AiForm/types.ts +402 -22
- package/dist/components/AiInput/index.vue.mjs +46 -11
- package/dist/components/AiInput/types.ts +7 -6
- package/dist/components/AiSelect/index.vue.mjs +98 -17
- package/dist/components/AiSelect/types.ts +10 -17
- package/dist/components/AiTable/index.mjs +5 -2
- package/dist/components/AiTable/index.vue.mjs +213 -22
- package/dist/components/AiTable/types.ts +196 -16
- package/dist/components/AiTag/types.ts +6 -7
- package/dist/components/README.md +1 -26
- package/dist/components/_virtual/_plugin-vue_export-helper.mjs +9 -0
- package/dist/components/install.mjs +15 -0
- package/dist/index.mjs +17 -52
- package/dist/layouts/README.md +17 -14
- package/dist/layouts/default.md +238 -0
- package/dist/styles/README.md +18 -139
- package/dist/styles/index.scss +5 -0
- package/dist/styles/light.scss +102 -0
- package/package.json +2 -1
- package/dist/components/AiAside/index.mjs +0 -4
- package/dist/components/AiAside/index.vue.mjs +0 -20
- package/dist/components/AiAside/types.ts +0 -6
- package/dist/components/AiBadge/index.mjs +0 -4
- package/dist/components/AiBadge/index.vue.mjs +0 -20
- package/dist/components/AiBadge/types.ts +0 -10
- package/dist/components/AiBreadcrumb/index.mjs +0 -4
- package/dist/components/AiBreadcrumb/index.vue.mjs +0 -20
- package/dist/components/AiBreadcrumb/types.ts +0 -7
- package/dist/components/AiCheckbox/index.mjs +0 -4
- package/dist/components/AiCheckbox/index.vue.mjs +0 -20
- package/dist/components/AiCheckbox/types.ts +0 -14
- package/dist/components/AiContainer/index.mjs +0 -4
- package/dist/components/AiContainer/index.vue.mjs +0 -20
- package/dist/components/AiContainer/types.ts +0 -6
- package/dist/components/AiDialog/index.mjs +0 -4
- package/dist/components/AiDialog/index.vue.mjs +0 -20
- package/dist/components/AiDialog/types.ts +0 -11
- package/dist/components/AiFooter/index.mjs +0 -4
- package/dist/components/AiFooter/index.vue.mjs +0 -20
- package/dist/components/AiFooter/types.ts +0 -6
- package/dist/components/AiHeader/index.mjs +0 -4
- package/dist/components/AiHeader/index.vue.mjs +0 -20
- package/dist/components/AiHeader/types.ts +0 -6
- package/dist/components/AiLoading/index.mjs +0 -5
- package/dist/components/AiLoading/types.ts +0 -7
- package/dist/components/AiMain/index.mjs +0 -4
- package/dist/components/AiMain/index.vue.mjs +0 -20
- package/dist/components/AiMain/types.ts +0 -4
- package/dist/components/AiMenu/index.mjs +0 -4
- package/dist/components/AiMenu/index.vue.mjs +0 -20
- package/dist/components/AiMenu/types.ts +0 -9
- package/dist/components/AiMessage/index.mjs +0 -5
- package/dist/components/AiMessage/types.ts +0 -9
- package/dist/components/AiNotification/index.mjs +0 -5
- package/dist/components/AiNotification/types.ts +0 -10
- package/dist/components/AiPagination/index.mjs +0 -4
- package/dist/components/AiPagination/index.vue.mjs +0 -15
- package/dist/components/AiPagination/types.ts +0 -9
- package/dist/components/AiProgress/index.mjs +0 -4
- package/dist/components/AiProgress/index.vue.mjs +0 -15
- package/dist/components/AiProgress/types.ts +0 -10
- package/dist/components/AiRadio/index.mjs +0 -4
- package/dist/components/AiRadio/index.vue.mjs +0 -20
- package/dist/components/AiRadio/types.ts +0 -8
- package/dist/components/AiSwitch/index.mjs +0 -4
- package/dist/components/AiSwitch/index.vue.mjs +0 -15
- package/dist/components/AiSwitch/types.ts +0 -9
- package/dist/components/AiTabs/index.mjs +0 -4
- package/dist/components/AiTabs/index.vue.mjs +0 -20
- package/dist/components/AiTabs/types.ts +0 -9
- package/dist/components/AiTimePicker/index.mjs +0 -4
- package/dist/components/AiTimePicker/index.vue.mjs +0 -15
- package/dist/components/AiTimePicker/types.ts +0 -16
- package/dist/components/AiUpload/index.mjs +0 -4
- package/dist/components/AiUpload/index.vue.mjs +0 -20
- package/dist/components/AiUpload/types.ts +0 -11
- package/dist/layouts/government.md +0 -223
- package/dist/layouts/union.md +0 -229
- package/dist/styles/blue.scss +0 -71
- package/dist/styles/dark.scss +0 -71
- package/dist/styles/element-plus-theme.css +0 -52
- package/dist/styles/index.css +0 -77
- package/dist/styles/light-blue.scss +0 -71
|
@@ -1,35 +1,415 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* AiForm -
|
|
2
|
+
* AiForm - 动态表单组件
|
|
3
|
+
* 基于Element Plus el-form封装,支持JSON配置驱动
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
-
* <AiForm
|
|
5
|
+
* ==================== 基础用法 ====================
|
|
6
|
+
* <AiForm
|
|
7
|
+
* v-model="formData"
|
|
8
|
+
* :config="formConfig"
|
|
9
|
+
* :rules="rules"
|
|
10
|
+
* label-width="100px"
|
|
11
|
+
* @change="handleChange"
|
|
12
|
+
* />
|
|
13
|
+
*
|
|
14
|
+
* ==================== 配置示例 ====================
|
|
15
|
+
* const formData = ref({
|
|
16
|
+
* name: '',
|
|
17
|
+
* age: '',
|
|
18
|
+
* gender: '',
|
|
19
|
+
* birthday: '',
|
|
20
|
+
* address: ''
|
|
21
|
+
* })
|
|
22
|
+
*
|
|
23
|
+
* const formConfig: IFormItem[] = [
|
|
24
|
+
* // 1. 基础输入框
|
|
25
|
+
* {
|
|
26
|
+
* prop: 'name',
|
|
27
|
+
* label: '姓名',
|
|
28
|
+
* type: 'AiInput', // 使用组件库的AiInput
|
|
29
|
+
* required: true, // 必填
|
|
30
|
+
* col: 8, // 占8格
|
|
31
|
+
* placeholder: '请输入姓名'
|
|
32
|
+
* },
|
|
33
|
+
*
|
|
34
|
+
* // 2. 数字输入框(通过attrs透传属性)
|
|
35
|
+
* {
|
|
36
|
+
* prop: 'age',
|
|
37
|
+
* label: '年龄',
|
|
38
|
+
* type: 'AiInput',
|
|
39
|
+
* col: 8,
|
|
40
|
+
* attrs: {
|
|
41
|
+
* type: 'number', // 透传给AiInput的type属性
|
|
42
|
+
* min: 0,
|
|
43
|
+
* max: 150
|
|
44
|
+
* }
|
|
45
|
+
* },
|
|
46
|
+
*
|
|
47
|
+
* // 3. 下拉选择器(静态数据)
|
|
48
|
+
* {
|
|
49
|
+
* prop: 'gender',
|
|
50
|
+
* label: '性别',
|
|
51
|
+
* type: 'AiSelect',
|
|
52
|
+
* col: 8,
|
|
53
|
+
* attrs: {
|
|
54
|
+
* options: [ // 透传给AiSelect的options
|
|
55
|
+
* { label: '男', value: 1 },
|
|
56
|
+
* { label: '女', value: 2 }
|
|
57
|
+
* ]
|
|
58
|
+
* }
|
|
59
|
+
* },
|
|
60
|
+
*
|
|
61
|
+
* // 4. 下拉选择器(异步数据源 - 响应式)
|
|
62
|
+
* {
|
|
63
|
+
* prop: 'category',
|
|
64
|
+
* label: '分类',
|
|
65
|
+
* type: 'AiSelect',
|
|
66
|
+
* col: 8,
|
|
67
|
+
* attrs: {
|
|
68
|
+
* options: categoryOptions.value // 响应式数据源,变化时自动更新
|
|
69
|
+
* }
|
|
70
|
+
* },
|
|
71
|
+
*
|
|
72
|
+
* // 5. 日期选择器
|
|
73
|
+
* {
|
|
74
|
+
* prop: 'birthday',
|
|
75
|
+
* label: '生日',
|
|
76
|
+
* type: 'AiDatePicker',
|
|
77
|
+
* col: 8,
|
|
78
|
+
* attrs: {
|
|
79
|
+
* format: 'YYYY-MM-DD'
|
|
80
|
+
* }
|
|
81
|
+
* },
|
|
82
|
+
*
|
|
83
|
+
* // 5. 空占位符(用于布局)
|
|
84
|
+
* {
|
|
85
|
+
* type: 'empty', // 特殊类型:空占位
|
|
86
|
+
* col: 8, // 占8格,用于对齐
|
|
87
|
+
* prop: 'empty1' // 必须提供唯一prop作为key
|
|
88
|
+
* },
|
|
89
|
+
*
|
|
90
|
+
* // 6. 使用ElementPlus原生组件
|
|
91
|
+
* {
|
|
92
|
+
* prop: 'remark',
|
|
93
|
+
* label: '备注',
|
|
94
|
+
* type: 'el-input', // 直接使用el-input
|
|
95
|
+
* col: 16,
|
|
96
|
+
* attrs: {
|
|
97
|
+
* type: 'textarea',
|
|
98
|
+
* rows: 3
|
|
99
|
+
* }
|
|
100
|
+
* },
|
|
101
|
+
*
|
|
102
|
+
* // 7. 插槽模式 - 自定义表单项内容
|
|
103
|
+
* {
|
|
104
|
+
* prop: 'custom',
|
|
105
|
+
* label: '自定义内容',
|
|
106
|
+
* type: 'slot', // 特殊类型:插槽
|
|
107
|
+
* col: 12
|
|
108
|
+
* },
|
|
109
|
+
*
|
|
110
|
+
* // 8. 插槽模式 - 自定义label
|
|
111
|
+
* {
|
|
112
|
+
* prop: 'address',
|
|
113
|
+
* type: 'slotLabel', // 特殊类型:label插槽
|
|
114
|
+
* col: 12
|
|
115
|
+
* },
|
|
116
|
+
*
|
|
117
|
+
* // 9. 插槽模式 - 同时自定义label和内容
|
|
118
|
+
* {
|
|
119
|
+
* prop: 'complex',
|
|
120
|
+
* type: 'slotBoth', // 特殊类型:label和内容都用插槽
|
|
121
|
+
* col: 24
|
|
122
|
+
* },
|
|
123
|
+
*
|
|
124
|
+
* // 10. 动态显隐
|
|
125
|
+
* {
|
|
126
|
+
* prop: 'email',
|
|
127
|
+
* label: '邮箱',
|
|
128
|
+
* type: 'AiInput',
|
|
129
|
+
* visible: computed(() => formData.value.gender === 1), // 响应式控制显隐
|
|
130
|
+
* col: 12
|
|
131
|
+
* }
|
|
132
|
+
* ]
|
|
133
|
+
*
|
|
134
|
+
* ==================== 插槽用法详解 ====================
|
|
135
|
+
*
|
|
136
|
+
* 1. type="slot" - 自定义表单项内容
|
|
137
|
+
* 插槽名称:prop的值
|
|
138
|
+
* <AiForm v-model="formData" :config="config">
|
|
139
|
+
* <template #custom>
|
|
140
|
+
* <el-input v-model="formData.custom" />
|
|
141
|
+
* </template>
|
|
142
|
+
* </AiForm>
|
|
143
|
+
*
|
|
144
|
+
* 2. type="slotLabel" - 自定义label
|
|
145
|
+
* 插槽名称:prop的值
|
|
146
|
+
* <AiForm v-model="formData" :config="config">
|
|
147
|
+
* <template #address>
|
|
148
|
+
* <span style="color: red">地址 *</span>
|
|
149
|
+
* </template>
|
|
150
|
+
* </AiForm>
|
|
151
|
+
*
|
|
152
|
+
* 3. type="slotBoth" - 同时自定义label和内容
|
|
153
|
+
* 插槽名称:prop的值
|
|
154
|
+
* 插槽内容:必须包含两个div,第一个是label,第二个是内容
|
|
155
|
+
* 组件内部自动转换为:${prop}Label 和 ${prop}Default
|
|
156
|
+
*
|
|
157
|
+
* <AiForm v-model="formData" :config="config">
|
|
158
|
+
* <template #complex>
|
|
159
|
+
* <div>
|
|
160
|
+
* <span style="color: red">复杂字段 *</span>
|
|
161
|
+
* </div>
|
|
162
|
+
* <div>
|
|
163
|
+
* <el-input v-model="formData.complex" />
|
|
164
|
+
* <el-button>操作</el-button>
|
|
165
|
+
* </div>
|
|
166
|
+
* </template>
|
|
167
|
+
* </AiForm>
|
|
168
|
+
*
|
|
169
|
+
* ==================== 校验规则 ====================
|
|
170
|
+
* const rules = {
|
|
171
|
+
* name: [
|
|
172
|
+
* { required: true, message: '请输入姓名', trigger: 'blur' }
|
|
173
|
+
* ],
|
|
174
|
+
* age: [
|
|
175
|
+
* { required: true, message: '请输入年龄', trigger: 'blur' },
|
|
176
|
+
* { type: 'number', message: '年龄必须为数字', trigger: 'blur' }
|
|
177
|
+
* ]
|
|
178
|
+
* }
|
|
179
|
+
*
|
|
180
|
+
* ==================== 事件监听 ====================
|
|
181
|
+
* const handleChange = (prop: string, value: any, formValues: Record<string, any>) => {
|
|
182
|
+
* console.log('变化的字段:', prop)
|
|
183
|
+
* console.log('变化的值:', value)
|
|
184
|
+
* console.log('完整表单数据:', formValues)
|
|
185
|
+
*
|
|
186
|
+
* // 示例:根据某个字段变化触发查询
|
|
187
|
+
* if (prop === 'category') {
|
|
188
|
+
* fetchTableData()
|
|
189
|
+
* }
|
|
190
|
+
* }
|
|
191
|
+
*
|
|
192
|
+
* ==================== 异步数据源支持 ====================
|
|
193
|
+
* // 场景:下拉选择器的选项需要异步获取
|
|
194
|
+
*
|
|
195
|
+
* const categoryOptions = ref([])
|
|
196
|
+
* const cityOptions = ref([])
|
|
197
|
+
*
|
|
198
|
+
* // 组件挂载时获取数据
|
|
199
|
+
* onMounted(async () => {
|
|
200
|
+
* categoryOptions.value = await fetchCategories()
|
|
201
|
+
* })
|
|
202
|
+
*
|
|
203
|
+
* // 根据其他字段联动获取数据
|
|
204
|
+
* const handleChange = async (prop: string, value: any) => {
|
|
205
|
+
* if (prop === 'province') {
|
|
206
|
+
* cityOptions.value = await fetchCities(value)
|
|
207
|
+
* }
|
|
208
|
+
* }
|
|
6
209
|
*
|
|
7
|
-
* 配置示例:
|
|
8
210
|
* const formConfig = [
|
|
9
|
-
* {
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
211
|
+
* {
|
|
212
|
+
* prop: 'category',
|
|
213
|
+
* label: '分类',
|
|
214
|
+
* type: 'AiSelect',
|
|
215
|
+
* attrs: {
|
|
216
|
+
* options: categoryOptions // 响应式ref,数据变化自动更新
|
|
217
|
+
* }
|
|
218
|
+
* },
|
|
219
|
+
* {
|
|
220
|
+
* prop: 'province',
|
|
221
|
+
* label: '省份',
|
|
222
|
+
* type: 'AiSelect',
|
|
223
|
+
* attrs: {
|
|
224
|
+
* options: provinceOptions
|
|
225
|
+
* }
|
|
226
|
+
* },
|
|
227
|
+
* {
|
|
228
|
+
* prop: 'city',
|
|
229
|
+
* label: '城市',
|
|
230
|
+
* type: 'AiSelect',
|
|
231
|
+
* attrs: {
|
|
232
|
+
* options: cityOptions // 根据省份联动变化
|
|
233
|
+
* }
|
|
234
|
+
* }
|
|
235
|
+
* ]
|
|
236
|
+
*
|
|
237
|
+
* ==================== 表单方法 ====================
|
|
238
|
+
* const formRef = ref()
|
|
239
|
+
*
|
|
240
|
+
* // 校验表单
|
|
241
|
+
* await formRef.value.validate()
|
|
242
|
+
*
|
|
243
|
+
* // 重置表单
|
|
244
|
+
* formRef.value.resetFields()
|
|
245
|
+
*
|
|
246
|
+
* // 清除校验
|
|
247
|
+
* formRef.value.clearValidate()
|
|
248
|
+
*
|
|
249
|
+
* ==================== 控件匹配优先级 ====================
|
|
250
|
+
* 1. 优先匹配组件库组件:AiInput → 使用本组件库的AiInput
|
|
251
|
+
* 2. 其次匹配ElementPlus组件:el-input → 使用ElementPlus的el-input
|
|
252
|
+
* 3. 都不存在:显示错误提示组件
|
|
253
|
+
*
|
|
254
|
+
* ==================== 栅格布局说明 ====================
|
|
255
|
+
* - 采用ElementPlus的24栅格系统
|
|
256
|
+
* - 默认每个表单项 col: 6(占6格,一行4个)
|
|
257
|
+
* - 可通过col属性自定义:1-24
|
|
258
|
+
* - 使用empty类型配合col实现灵活布局
|
|
259
|
+
*
|
|
260
|
+
* 示例:实现"两个字段 + 空白 + 一个字段"的布局
|
|
261
|
+
* [
|
|
262
|
+
* { prop: 'field1', label: '字段1', type: 'AiInput', col: 6 },
|
|
263
|
+
* { prop: 'field2', label: '字段2', type: 'AiInput', col: 6 },
|
|
264
|
+
* { type: 'empty', col: 6, prop: 'empty1' },
|
|
265
|
+
* { prop: 'field3', label: '字段3', type: 'AiInput', col: 6 }
|
|
15
266
|
* ]
|
|
16
267
|
*/
|
|
17
268
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
269
|
+
import type { FormProps, FormItemProps } from 'element-plus'
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* 表单项配置接口
|
|
273
|
+
*/
|
|
274
|
+
export interface IFormItem extends Partial<FormItemProps> {
|
|
275
|
+
/**
|
|
276
|
+
* 字段名
|
|
277
|
+
* - 作为表单数据的key
|
|
278
|
+
* - 作为插槽名称
|
|
279
|
+
* - 作为el-form-item的prop
|
|
280
|
+
* - type为'empty'时可不传
|
|
281
|
+
*/
|
|
282
|
+
prop?: string
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* 标签文本
|
|
286
|
+
* - type为slotLabel或slotBoth时可不传
|
|
287
|
+
*/
|
|
288
|
+
label?: string
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* 控件类型(必填)
|
|
292
|
+
*
|
|
293
|
+
* 普通控件:
|
|
294
|
+
* - 'AiInput' - 使用组件库的输入框
|
|
295
|
+
* - 'AiSelect' - 使用组件库的选择器
|
|
296
|
+
* - 'AiDatePicker' - 使用组件库的日期选择器
|
|
297
|
+
* - 'el-input' - 使用ElementPlus的输入框
|
|
298
|
+
* - 'el-select' - 使用ElementPlus的选择器
|
|
299
|
+
* - ... 其他组件库或ElementPlus组件
|
|
300
|
+
*
|
|
301
|
+
* 特殊类型:
|
|
302
|
+
* - 'slot' - 插槽模式,插槽名=prop,替换表单项内容
|
|
303
|
+
* - 'slotLabel' - 插槽模式,插槽名=prop,仅替换label
|
|
304
|
+
* - 'slotBoth' - 插槽模式,插槽名=prop,内容包含两个div(label+内容)
|
|
305
|
+
* - 'empty' - 空占位符,配合col实现布局
|
|
306
|
+
*/
|
|
307
|
+
type: string
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* 占位符文本
|
|
311
|
+
* - 会透传给控件的placeholder属性
|
|
312
|
+
*/
|
|
313
|
+
placeholder?: string
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* 是否必填
|
|
317
|
+
* - 默认false
|
|
318
|
+
* - 仅用于标识,实际校验需配置rules
|
|
319
|
+
*/
|
|
320
|
+
required?: boolean
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* 栅格占位(1-24)
|
|
324
|
+
* - 默认6(一行4个)
|
|
325
|
+
* - 24表示独占一行
|
|
326
|
+
* - 配合empty实现灵活布局
|
|
327
|
+
*/
|
|
328
|
+
col?: number
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* 是否显示
|
|
332
|
+
* - 默认true
|
|
333
|
+
* - 支持响应式:visible: computed(() => condition)
|
|
334
|
+
* - 使用v-if实现,隐藏时不渲染DOM
|
|
335
|
+
*/
|
|
336
|
+
visible?: boolean
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* 透传给控件的属性
|
|
340
|
+
* - 会通过v-bind传递给动态组件
|
|
341
|
+
*
|
|
342
|
+
* 示例:
|
|
343
|
+
* attrs: {
|
|
344
|
+
* type: 'number', // 输入框类型
|
|
345
|
+
* min: 0, // 最小值
|
|
346
|
+
* max: 100, // 最大值
|
|
347
|
+
* options: [...], // 选择器选项
|
|
348
|
+
* format: 'YYYY-MM-DD' // 日期格式
|
|
349
|
+
* }
|
|
350
|
+
*/
|
|
351
|
+
attrs?: Record<string, any>
|
|
352
|
+
|
|
353
|
+
// 继承el-form-item的其他属性
|
|
354
|
+
// 如:labelWidth, rules, error, showMessage等
|
|
25
355
|
}
|
|
26
356
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
357
|
+
/**
|
|
358
|
+
* 表单组件Props接口
|
|
359
|
+
*/
|
|
360
|
+
export interface IAiFormProps extends Partial<FormProps> {
|
|
361
|
+
/**
|
|
362
|
+
* 表单配置数组(必填)
|
|
363
|
+
* - 定义表单项的结构和行为
|
|
364
|
+
*/
|
|
365
|
+
config: IFormItem[]
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* 表单数据对象(必填)
|
|
369
|
+
* - 使用v-model双向绑定
|
|
370
|
+
* - key为表单项的prop
|
|
371
|
+
*/
|
|
372
|
+
modelValue: Record<string, any>
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* 校验规则
|
|
376
|
+
* - 配置方式同el-form的rules
|
|
377
|
+
* - 不传则不校验
|
|
378
|
+
*
|
|
379
|
+
* 示例:
|
|
380
|
+
* rules: {
|
|
381
|
+
* name: [{ required: true, message: '请输入', trigger: 'blur' }],
|
|
382
|
+
* age: [{ type: 'number', message: '必须为数字' }]
|
|
383
|
+
* }
|
|
384
|
+
*/
|
|
385
|
+
rules?: Record<string, any>
|
|
386
|
+
|
|
387
|
+
// 继承el-form的其他属性
|
|
388
|
+
// 如:labelWidth, labelPosition, inline, disabled等
|
|
30
389
|
}
|
|
31
390
|
|
|
391
|
+
/**
|
|
392
|
+
* 表单组件事件接口
|
|
393
|
+
*/
|
|
32
394
|
export interface IAiFormEmits {
|
|
33
|
-
|
|
34
|
-
|
|
395
|
+
/**
|
|
396
|
+
* 表单数据更新事件
|
|
397
|
+
* - v-model触发
|
|
398
|
+
*/
|
|
399
|
+
(e: 'update:modelValue', value: Record<string, any>): void
|
|
400
|
+
|
|
401
|
+
/**
|
|
402
|
+
* 表单项值变化事件
|
|
403
|
+
* - 任意表单项值变化时触发
|
|
404
|
+
*
|
|
405
|
+
* @param prop - 变化的字段名
|
|
406
|
+
* @param value - 变化后的值
|
|
407
|
+
* @param formValues - 完整的表单数据
|
|
408
|
+
*
|
|
409
|
+
* 使用场景:
|
|
410
|
+
* - 联动查询:某字段变化时触发表格查询
|
|
411
|
+
* - 联动显隐:根据某字段值控制其他字段显隐
|
|
412
|
+
* - 联动赋值:某字段变化时自动填充其他字段
|
|
413
|
+
*/
|
|
414
|
+
(e: 'change', prop: string, value: any, formValues: Record<string, any>): void
|
|
35
415
|
}
|
|
@@ -1,21 +1,56 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
const
|
|
1
|
+
import { defineComponent as u, computed as m, resolveComponent as s, openBlock as d, createBlock as c, mergeProps as y } from "vue";
|
|
2
|
+
const B = /* @__PURE__ */ u({
|
|
3
3
|
__name: "index",
|
|
4
4
|
props: {
|
|
5
5
|
modelValue: {},
|
|
6
|
+
id: {},
|
|
7
|
+
size: {},
|
|
8
|
+
disabled: { type: Boolean },
|
|
9
|
+
modelModifiers: {},
|
|
10
|
+
maxlength: {},
|
|
11
|
+
minlength: {},
|
|
12
|
+
type: {},
|
|
13
|
+
resize: {},
|
|
14
|
+
autosize: { type: [Object, Boolean] },
|
|
15
|
+
autocomplete: {},
|
|
16
|
+
formatter: { type: Function },
|
|
17
|
+
parser: { type: Function },
|
|
6
18
|
placeholder: {},
|
|
7
|
-
|
|
19
|
+
form: {},
|
|
20
|
+
readonly: { type: Boolean },
|
|
21
|
+
clearable: { type: Boolean },
|
|
22
|
+
clearIcon: {},
|
|
23
|
+
showPassword: { type: Boolean },
|
|
24
|
+
showWordLimit: { type: Boolean },
|
|
25
|
+
wordLimitPosition: {},
|
|
26
|
+
suffixIcon: {},
|
|
27
|
+
prefixIcon: {},
|
|
28
|
+
containerRole: {},
|
|
29
|
+
tabindex: {},
|
|
30
|
+
validateEvent: { type: Boolean },
|
|
31
|
+
inputStyle: { type: [Boolean, null, String, Object, Array] },
|
|
32
|
+
autofocus: { type: Boolean },
|
|
33
|
+
rows: {},
|
|
34
|
+
ariaLabel: {},
|
|
35
|
+
inputmode: {},
|
|
36
|
+
name: {}
|
|
8
37
|
},
|
|
9
38
|
emits: ["update:modelValue"],
|
|
10
|
-
setup(
|
|
11
|
-
const o =
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
39
|
+
setup(l, { emit: n }) {
|
|
40
|
+
const a = l, p = n, o = m({
|
|
41
|
+
get: () => a.modelValue,
|
|
42
|
+
set: (e) => p("update:modelValue", e)
|
|
43
|
+
});
|
|
44
|
+
return (e, t) => {
|
|
45
|
+
const r = s("el-input");
|
|
46
|
+
return d(), c(r, y({
|
|
47
|
+
modelValue: o.value,
|
|
48
|
+
"onUpdate:modelValue": t[0] || (t[0] = (i) => o.value = i),
|
|
49
|
+
clearable: ""
|
|
50
|
+
}, e.$attrs), null, 16, ["modelValue"]);
|
|
51
|
+
};
|
|
17
52
|
}
|
|
18
53
|
});
|
|
19
54
|
export {
|
|
20
|
-
|
|
55
|
+
B as default
|
|
21
56
|
};
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* AiInput - 输入框组件
|
|
3
|
+
* 基于Element Plus el-input封装,默认可清空
|
|
3
4
|
*
|
|
4
|
-
*
|
|
5
|
+
* 用法:
|
|
5
6
|
* <AiInput v-model="value" placeholder="请输入" />
|
|
6
7
|
*/
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
import type { InputProps } from 'element-plus'
|
|
10
|
+
|
|
11
|
+
export interface IAiInputProps extends Partial<InputProps> {
|
|
12
|
+
modelValue?: string | number
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
export interface IAiInputEmits {
|
|
15
|
-
(e: 'update:modelValue', value: string): void
|
|
16
|
+
(e: 'update:modelValue', value: string | number): void
|
|
16
17
|
}
|
|
@@ -1,27 +1,108 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
const
|
|
1
|
+
import { defineComponent as v, computed as s, resolveComponent as c, openBlock as u, createBlock as i, mergeProps as V, withCtx as b, createCommentVNode as g, createElementBlock as x, Fragment as T, renderList as h } from "vue";
|
|
2
|
+
const C = /* @__PURE__ */ v({
|
|
3
3
|
__name: "index",
|
|
4
4
|
props: {
|
|
5
5
|
modelValue: {},
|
|
6
6
|
options: {},
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
ariaLabel: {},
|
|
8
|
+
emptyValues: {},
|
|
9
|
+
valueOnClear: {},
|
|
10
|
+
name: {},
|
|
11
|
+
id: {},
|
|
12
|
+
autocomplete: {},
|
|
13
|
+
automaticDropdown: { type: Boolean },
|
|
14
|
+
size: {},
|
|
15
|
+
effect: {},
|
|
16
|
+
disabled: { type: Boolean },
|
|
17
|
+
clearable: { type: Boolean },
|
|
18
|
+
filterable: { type: Boolean },
|
|
19
|
+
allowCreate: { type: Boolean },
|
|
20
|
+
loading: { type: Boolean },
|
|
21
|
+
popperClass: {},
|
|
22
|
+
popperStyle: {},
|
|
23
|
+
popperOptions: {},
|
|
24
|
+
remote: { type: Boolean },
|
|
25
|
+
debounce: {},
|
|
26
|
+
loadingText: {},
|
|
27
|
+
noMatchText: {},
|
|
28
|
+
noDataText: {},
|
|
29
|
+
remoteMethod: {},
|
|
30
|
+
filterMethod: {},
|
|
31
|
+
multiple: { type: Boolean },
|
|
32
|
+
multipleLimit: {},
|
|
33
|
+
placeholder: {},
|
|
34
|
+
defaultFirstOption: { type: Boolean },
|
|
35
|
+
reserveKeyword: { type: Boolean },
|
|
36
|
+
valueKey: {},
|
|
37
|
+
collapseTags: { type: Boolean },
|
|
38
|
+
collapseTagsTooltip: { type: Boolean },
|
|
39
|
+
tagTooltip: {},
|
|
40
|
+
maxCollapseTags: {},
|
|
41
|
+
teleported: { type: Boolean },
|
|
42
|
+
persistent: { type: Boolean },
|
|
43
|
+
clearIcon: {},
|
|
44
|
+
fitInputWidth: { type: Boolean },
|
|
45
|
+
suffixIcon: {},
|
|
46
|
+
tagType: {},
|
|
47
|
+
tagEffect: {},
|
|
48
|
+
validateEvent: { type: Boolean },
|
|
49
|
+
remoteShowSuffix: { type: Boolean },
|
|
50
|
+
showArrow: { type: Boolean },
|
|
51
|
+
offset: {},
|
|
52
|
+
placement: {},
|
|
53
|
+
fallbackPlacements: {},
|
|
54
|
+
tabindex: {},
|
|
55
|
+
appendTo: {},
|
|
56
|
+
props: {}
|
|
9
57
|
},
|
|
10
58
|
emits: ["update:modelValue"],
|
|
11
|
-
setup(
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
59
|
+
setup(m, { emit: y }) {
|
|
60
|
+
const l = m, n = y, r = s(() => l.multiple), f = s(() => {
|
|
61
|
+
const { modelValue: o, options: e, ...t } = l;
|
|
62
|
+
return t;
|
|
63
|
+
}), d = s({
|
|
64
|
+
get: () => {
|
|
65
|
+
var o;
|
|
66
|
+
return r.value && Array.isArray(l.modelValue) && l.modelValue.includes("") ? ((o = l.options) == null ? void 0 : o.map((e) => e.value)) || [] : l.modelValue;
|
|
67
|
+
},
|
|
68
|
+
set: (o) => {
|
|
69
|
+
var t, p;
|
|
70
|
+
if (!r.value) {
|
|
71
|
+
n("update:modelValue", o);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const e = o;
|
|
75
|
+
if (e.includes("")) {
|
|
76
|
+
const a = ((t = l.options) == null ? void 0 : t.map((B) => B.value)) || [];
|
|
77
|
+
n("update:modelValue", a);
|
|
78
|
+
} else e.length === ((p = l.options) == null ? void 0 : p.length) ? n("update:modelValue", [...e, ""]) : n("update:modelValue", e);
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
return (o, e) => {
|
|
82
|
+
const t = c("el-option"), p = c("el-select");
|
|
83
|
+
return u(), i(p, V({
|
|
84
|
+
modelValue: d.value,
|
|
85
|
+
"onUpdate:modelValue": e[0] || (e[0] = (a) => d.value = a),
|
|
86
|
+
clearable: "",
|
|
87
|
+
filterable: ""
|
|
88
|
+
}, f.value), {
|
|
89
|
+
default: b(() => [
|
|
90
|
+
r.value ? (u(), i(t, {
|
|
91
|
+
key: 0,
|
|
92
|
+
label: "全部",
|
|
93
|
+
value: ""
|
|
94
|
+
})) : g("", !0),
|
|
95
|
+
(u(!0), x(T, null, h(m.options, (a) => (u(), i(t, {
|
|
96
|
+
key: a.value,
|
|
97
|
+
label: a.label,
|
|
98
|
+
value: a.value
|
|
99
|
+
}, null, 8, ["label", "value"]))), 128))
|
|
100
|
+
]),
|
|
101
|
+
_: 1
|
|
102
|
+
}, 16, ["modelValue"]);
|
|
103
|
+
};
|
|
23
104
|
}
|
|
24
105
|
});
|
|
25
106
|
export {
|
|
26
|
-
|
|
107
|
+
C as default
|
|
27
108
|
};
|
|
@@ -1,28 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* AiSelect - 选择器组件
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* <AiSelect v-model="value" :options="options" />
|
|
6
|
-
*
|
|
7
|
-
* 配置示例:
|
|
8
|
-
* const options = [
|
|
9
|
-
* { label: '选项1', value: 1 },
|
|
10
|
-
* { label: '选项2', value: 2 }
|
|
11
|
-
* ]
|
|
3
|
+
* 基于Element Plus el-select封装
|
|
4
|
+
* 默认可清空、可过滤,多选时自动添加"全部"选项
|
|
12
5
|
*/
|
|
13
6
|
|
|
7
|
+
import type { SelectProps } from 'element-plus'
|
|
8
|
+
|
|
14
9
|
export interface ISelectOption {
|
|
15
|
-
label: string
|
|
16
|
-
value: any
|
|
10
|
+
label: string
|
|
11
|
+
value: any
|
|
17
12
|
}
|
|
18
13
|
|
|
19
|
-
export interface IAiSelectProps {
|
|
20
|
-
modelValue
|
|
21
|
-
options
|
|
22
|
-
clearable?: boolean // 是否可清空(默认true)
|
|
23
|
-
filterable?: boolean // 是否可过滤(默认true)
|
|
14
|
+
export interface IAiSelectProps extends Partial<SelectProps> {
|
|
15
|
+
modelValue?: any
|
|
16
|
+
options?: ISelectOption[]
|
|
24
17
|
}
|
|
25
18
|
|
|
26
19
|
export interface IAiSelectEmits {
|
|
27
|
-
(e: 'update:modelValue', value: any): void
|
|
20
|
+
(e: 'update:modelValue', value: any): void
|
|
28
21
|
}
|