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.
Files changed (92) hide show
  1. package/README.md +1 -0
  2. package/dist/components/AiDatePicker/index.vue.mjs +62 -9
  3. package/dist/components/AiDatePicker/types.ts +9 -12
  4. package/dist/components/AiDateRangePicker/index.mjs +7 -0
  5. package/dist/components/AiDateRangePicker/index.vue.mjs +33 -0
  6. package/dist/components/AiDateRangePicker/types.ts +33 -0
  7. package/dist/components/AiForm/README.md +35 -0
  8. package/dist/components/AiForm/index.mjs +4 -1
  9. package/dist/components/AiForm/index.vue.mjs +145 -36
  10. package/dist/components/AiForm/types.ts +402 -22
  11. package/dist/components/AiInput/index.vue.mjs +46 -11
  12. package/dist/components/AiInput/types.ts +7 -6
  13. package/dist/components/AiSelect/index.vue.mjs +98 -17
  14. package/dist/components/AiSelect/types.ts +10 -17
  15. package/dist/components/AiTable/index.mjs +5 -2
  16. package/dist/components/AiTable/index.vue.mjs +213 -22
  17. package/dist/components/AiTable/types.ts +196 -16
  18. package/dist/components/AiTag/types.ts +6 -7
  19. package/dist/components/README.md +1 -26
  20. package/dist/components/_virtual/_plugin-vue_export-helper.mjs +9 -0
  21. package/dist/components/install.mjs +15 -0
  22. package/dist/index.mjs +17 -52
  23. package/dist/layouts/README.md +17 -14
  24. package/dist/layouts/default.md +238 -0
  25. package/dist/styles/README.md +18 -139
  26. package/dist/styles/index.scss +5 -0
  27. package/dist/styles/light.scss +102 -0
  28. package/package.json +2 -1
  29. package/dist/components/AiAside/index.mjs +0 -4
  30. package/dist/components/AiAside/index.vue.mjs +0 -20
  31. package/dist/components/AiAside/types.ts +0 -6
  32. package/dist/components/AiBadge/index.mjs +0 -4
  33. package/dist/components/AiBadge/index.vue.mjs +0 -20
  34. package/dist/components/AiBadge/types.ts +0 -10
  35. package/dist/components/AiBreadcrumb/index.mjs +0 -4
  36. package/dist/components/AiBreadcrumb/index.vue.mjs +0 -20
  37. package/dist/components/AiBreadcrumb/types.ts +0 -7
  38. package/dist/components/AiCheckbox/index.mjs +0 -4
  39. package/dist/components/AiCheckbox/index.vue.mjs +0 -20
  40. package/dist/components/AiCheckbox/types.ts +0 -14
  41. package/dist/components/AiContainer/index.mjs +0 -4
  42. package/dist/components/AiContainer/index.vue.mjs +0 -20
  43. package/dist/components/AiContainer/types.ts +0 -6
  44. package/dist/components/AiDialog/index.mjs +0 -4
  45. package/dist/components/AiDialog/index.vue.mjs +0 -20
  46. package/dist/components/AiDialog/types.ts +0 -11
  47. package/dist/components/AiFooter/index.mjs +0 -4
  48. package/dist/components/AiFooter/index.vue.mjs +0 -20
  49. package/dist/components/AiFooter/types.ts +0 -6
  50. package/dist/components/AiHeader/index.mjs +0 -4
  51. package/dist/components/AiHeader/index.vue.mjs +0 -20
  52. package/dist/components/AiHeader/types.ts +0 -6
  53. package/dist/components/AiLoading/index.mjs +0 -5
  54. package/dist/components/AiLoading/types.ts +0 -7
  55. package/dist/components/AiMain/index.mjs +0 -4
  56. package/dist/components/AiMain/index.vue.mjs +0 -20
  57. package/dist/components/AiMain/types.ts +0 -4
  58. package/dist/components/AiMenu/index.mjs +0 -4
  59. package/dist/components/AiMenu/index.vue.mjs +0 -20
  60. package/dist/components/AiMenu/types.ts +0 -9
  61. package/dist/components/AiMessage/index.mjs +0 -5
  62. package/dist/components/AiMessage/types.ts +0 -9
  63. package/dist/components/AiNotification/index.mjs +0 -5
  64. package/dist/components/AiNotification/types.ts +0 -10
  65. package/dist/components/AiPagination/index.mjs +0 -4
  66. package/dist/components/AiPagination/index.vue.mjs +0 -15
  67. package/dist/components/AiPagination/types.ts +0 -9
  68. package/dist/components/AiProgress/index.mjs +0 -4
  69. package/dist/components/AiProgress/index.vue.mjs +0 -15
  70. package/dist/components/AiProgress/types.ts +0 -10
  71. package/dist/components/AiRadio/index.mjs +0 -4
  72. package/dist/components/AiRadio/index.vue.mjs +0 -20
  73. package/dist/components/AiRadio/types.ts +0 -8
  74. package/dist/components/AiSwitch/index.mjs +0 -4
  75. package/dist/components/AiSwitch/index.vue.mjs +0 -15
  76. package/dist/components/AiSwitch/types.ts +0 -9
  77. package/dist/components/AiTabs/index.mjs +0 -4
  78. package/dist/components/AiTabs/index.vue.mjs +0 -20
  79. package/dist/components/AiTabs/types.ts +0 -9
  80. package/dist/components/AiTimePicker/index.mjs +0 -4
  81. package/dist/components/AiTimePicker/index.vue.mjs +0 -15
  82. package/dist/components/AiTimePicker/types.ts +0 -16
  83. package/dist/components/AiUpload/index.mjs +0 -4
  84. package/dist/components/AiUpload/index.vue.mjs +0 -20
  85. package/dist/components/AiUpload/types.ts +0 -11
  86. package/dist/layouts/government.md +0 -223
  87. package/dist/layouts/union.md +0 -229
  88. package/dist/styles/blue.scss +0 -71
  89. package/dist/styles/dark.scss +0 -71
  90. package/dist/styles/element-plus-theme.css +0 -52
  91. package/dist/styles/index.css +0 -77
  92. 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 v-model="formData" :config="formConfig" @submit="handleSubmit" />
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
- * { prop: 'name', label: '姓名', type: 'input', required: true },
10
- * { prop: 'age', label: '年龄', type: 'input' },
11
- * { prop: 'gender', label: '性别', type: 'select', options: [
12
- * { label: '', value: 'male' },
13
- * { label: '女', value: 'female' }
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
- export interface IFormItem {
19
- prop: string // 字段名
20
- label: string // 标签文本
21
- type: 'input' | 'select' | 'textarea' // 表单项类型
22
- placeholder?: string // 占位符
23
- required?: boolean // 是否必填
24
- options?: Array<{ label: string; value: any }> // select选项
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
- export interface IAiFormProps {
28
- config: IFormItem[] // 表单配置数组
29
- modelValue: Record<string, any> // 表单数据对象
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
- (e: 'update:modelValue', value: Record<string, any>): void // 数据更新
34
- (e: 'submit', value: Record<string, any>): void // 表单提交
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 n, openBlock as u, createElementBlock as d } from "vue";
2
- const r = ["value", "placeholder"], c = /* @__PURE__ */ n({
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
- clearable: { type: Boolean, default: !0 }
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(e, { emit: t }) {
11
- const o = t;
12
- return (p, l) => (u(), d("input", {
13
- value: e.modelValue,
14
- placeholder: e.placeholder,
15
- onInput: l[0] || (l[0] = (a) => o("update:modelValue", a.target.value))
16
- }, null, 40, r));
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
- c as default
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
- export interface IAiInputProps {
9
- modelValue: string // 输入值
10
- placeholder?: string // 占位符
11
- clearable?: boolean // 是否可清空(默认true)
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 r, openBlock as l, createElementBlock as o, createElementVNode as i, Fragment as d, renderList as m, toDisplayString as s } from "vue";
2
- const p = ["value"], v = ["value"], V = /* @__PURE__ */ r({
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
- clearable: { type: Boolean, default: !0 },
8
- filterable: { type: Boolean, default: !0 }
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(a, { emit: n }) {
12
- const u = n;
13
- return (f, t) => (l(), o("select", {
14
- value: a.modelValue,
15
- onChange: t[0] || (t[0] = (e) => u("update:modelValue", e.target.value))
16
- }, [
17
- t[1] || (t[1] = i("option", { value: "" }, "请选择", -1)),
18
- (l(!0), o(d, null, m(a.options, (e) => (l(), o("option", {
19
- key: e.value,
20
- value: e.value
21
- }, s(e.label), 9, v))), 128))
22
- ], 40, p));
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
- V as default
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: any // 选中值
21
- options: ISelectOption[] // 选项数组
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
  }