@aspire-ui/element-component-pro 1.0.24 → 1.0.26

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.
@@ -285,3 +285,238 @@ export interface DescriptionActionType {
285
285
  setData: (data: Record<string, unknown>) => Promise<void>
286
286
  getData: () => Record<string, unknown>
287
287
  }
288
+
289
+ // ---------------------------------------------------------------------------
290
+ // ProTableForm
291
+ // ---------------------------------------------------------------------------
292
+
293
+ /** el-form 实例 */
294
+ export interface FormInstance {
295
+ validate?(cb?: (valid: boolean) => void): Promise<unknown> | void
296
+ clearValidate?(props?: string | string[]): void
297
+ resetFields?(): void
298
+ scrollToField?(name: string): void
299
+ }
300
+
301
+ /** 指标列单元格渲染方式 */
302
+ export type ProTableFormBuiltInComponent =
303
+ | 'input'
304
+ | 'input-number'
305
+ | 'formatted-number'
306
+ | 'select'
307
+ | 'api-select'
308
+ | 'tree-select'
309
+ | 'date-picker'
310
+ | 'date-range'
311
+ | 'switch'
312
+ | 'cascader'
313
+ | 'checkbox'
314
+ | 'radio'
315
+ | 'slot'
316
+
317
+ /** 自定义渲染函数,返回文本或 VNode;参数为 { row, value, column } */
318
+ export type ProTableFormColumnRender = (params: {
319
+ row: Record<string, unknown>
320
+ value: unknown
321
+ column: ProTableFormColumn | ProTableFormColumnChild
322
+ }) => string | VNode
323
+
324
+ /** 指标列(或含友商名称等任意 key) */
325
+ export interface ProTableFormColumn {
326
+ /** 对应 model 中对象字段名 */
327
+ key: string
328
+ title: string
329
+ required?: boolean
330
+ /** 单元格渲染方式:input / formatted-number / slot */
331
+ component?: ProTableFormBuiltInComponent
332
+ /** component 为 slot 时必填,对应插槽名为 `cell-{slotName}` */
333
+ slotName?: string
334
+ /**
335
+ * 自定义渲染,返回 string(文本)或 VNode(组件)。
336
+ * 若返回 string 且不为纯数字,单元格自动包裹 `el-form-item` 做校验;
337
+ * 若返回 VNode 则直接渲染,不包裹 form-item(适合纯展示列)。
338
+ */
339
+ render?: ProTableFormColumnRender
340
+ placeholder?: string
341
+ /** 列宽(优先级低于 minWidth) */
342
+ width?: number
343
+ /** 列最小宽度 */
344
+ minWidth?: number
345
+ /**
346
+ * 透传给单元格组件。`component === 'formatted-number'` 时在此传入
347
+ * `integerDigits`、`decimalPlaces`、`rounding`、`inputLimit` 等(与 FormattedNumberInput 一致)。
348
+ * 支持函数形式,参数为 { row, value, column },返回要合并到组件上的属性。
349
+ */
350
+ componentProps?: Record<string, unknown> | ((params: {
351
+ row: Record<string, unknown>
352
+ value: unknown
353
+ column: ProTableFormColumn
354
+ }) => Record<string, unknown>)
355
+ /** 动态校验规则 */
356
+ dynamicRules?: unknown[] | ((params: {
357
+ row: Record<string, unknown>
358
+ value: unknown
359
+ column: ProTableFormColumn
360
+ }) => unknown[])
361
+ /** 列级校验规则(会与 dynamicRules/required 合并) */
362
+ rules?: unknown[]
363
+ /**
364
+ * 多级表头子列。
365
+ * 配置后本列作为分组标题行,不渲染数据单元格,子列渲染数据。
366
+ */
367
+ children?: ProTableFormColumnChild[]
368
+ /**
369
+ * 本列是否渲染单元格(默认 true)。children 存在时自动为 false。
370
+ */
371
+ hideInTable?: boolean
372
+ /** 单元格对齐方式 */
373
+ align?: 'left' | 'center' | 'right'
374
+ /** 表头对齐方式 */
375
+ headerAlign?: 'left' | 'center' | 'right'
376
+ /** 是否固定列 */
377
+ fixed?: boolean | 'left' | 'right'
378
+ /** 单元格样式 */
379
+ cellStyle?: Record<string, string | number>
380
+ /** 表头单元格样式 */
381
+ headerCellStyle?: Record<string, string | number>
382
+ /** 单元格 className */
383
+ cellClassName?: string
384
+ /** 表头单元格 className */
385
+ headerCellClassName?: string
386
+ /** 是否可排序 */
387
+ sortable?: boolean
388
+ /** 是否可拖拽调整宽度 */
389
+ resizable?: boolean
390
+ }
391
+
392
+ /** 多级表头子列 */
393
+ export interface ProTableFormColumnChild {
394
+ key: string
395
+ title: string
396
+ required?: boolean
397
+ component?: ProTableFormBuiltInComponent
398
+ slotName?: string
399
+ /** 自定义渲染,返回 string(文本)或 VNode(组件) */
400
+ render?: ProTableFormColumnRender
401
+ placeholder?: string
402
+ /** 列宽(优先级低于 minWidth) */
403
+ width?: number
404
+ /** 列最小宽度 */
405
+ minWidth?: number
406
+ /**
407
+ * 透传给单元格组件。`component === 'formatted-number'` 时在此传入
408
+ * `integerDigits`、`decimalPlaces`、`rounding`、`inputLimit` 等。
409
+ * 支持函数形式,参数为 { row, value, column },返回要合并到组件上的属性。
410
+ */
411
+ componentProps?: Record<string, unknown> | ((params: {
412
+ row: Record<string, unknown>
413
+ value: unknown
414
+ column: ProTableFormColumnChild
415
+ }) => Record<string, unknown>)
416
+ rules?: unknown[]
417
+ /** 动态校验规则 */
418
+ dynamicRules?: unknown[] | ((params: {
419
+ row: Record<string, unknown>
420
+ value: unknown
421
+ column: ProTableFormColumnChild
422
+ }) => unknown[])
423
+ hideInTable?: boolean
424
+ /** 单元格对齐方式 */
425
+ align?: 'left' | 'center' | 'right'
426
+ /** 表头对齐方式 */
427
+ headerAlign?: 'left' | 'center' | 'right'
428
+ /** 是否固定列 */
429
+ fixed?: boolean | 'left' | 'right'
430
+ /** 单元格样式 */
431
+ cellStyle?: Record<string, string | number>
432
+ /** 表头单元格样式 */
433
+ headerCellStyle?: Record<string, string | number>
434
+ /** 单元格 className */
435
+ cellClassName?: string
436
+ /** 表头单元格 className */
437
+ headerCellClassName?: string
438
+ /** 是否可排序 */
439
+ sortable?: boolean
440
+ /** 是否可拖拽调整宽度 */
441
+ resizable?: boolean
442
+ }
443
+
444
+ /** ProTableForm Props */
445
+ export interface ProTableFormProps {
446
+ modelValue?: Record<string, unknown>[]
447
+ columns: ProTableFormColumn[]
448
+ metricPlaceholder?: string
449
+ minRows?: number
450
+ rules?: Record<string, unknown>
451
+ labelWidth?: string
452
+ bordered?: boolean
453
+ /**
454
+ * 表格合并单元格函数,参数同 Element UI el-table span-method。
455
+ * column.property 格式:叶子列 `{colKey}` 或 `{colKey}.{childKey}`;分组列 `{colKey}`。
456
+ */
457
+ spanMethod?: (params: {
458
+ row: Record<string, unknown>
459
+ column: { property: string; label: string }
460
+ rowIndex: number
461
+ columnIndex: number
462
+ }) => [number, number] | { rowspan: number; colspan: number } | void
463
+ // ─── el-form 原生配置 ───────────────────────────────────────────────────────
464
+ /** 表单尺寸 */
465
+ formSize?: 'medium' | 'small' | 'large'
466
+ /** 标签位置 */
467
+ labelPosition?: 'left' | 'right' | 'top'
468
+ /** 表单禁用态 */
469
+ disabled?: boolean
470
+ // ─── el-table 原生配置 ───────────────────────────────────────────────────────
471
+ /** 斑马纹 */
472
+ stripe?: boolean
473
+ /** 表格尺寸 */
474
+ size?: 'medium' | 'small' | 'large'
475
+ /** 表格最大高度 */
476
+ maxHeight?: number | string
477
+ /** 表格固定高度 */
478
+ height?: number | string
479
+ /** 行 ClassName */
480
+ rowClassName?: string | ((params: { row: Record<string, unknown>; rowIndex: number }) => string)
481
+ /** 展开行 Keys(树形数据) */
482
+ expandRowKeys?: (string | number)[]
483
+ /** 默认展开所有行 */
484
+ defaultExpandAll?: boolean
485
+ /** 行点击事件 */
486
+ onRowClick?: (row: Record<string, unknown>, event: Event) => void
487
+ /** 行双击事件 */
488
+ onRowDblclick?: (row: Record<string, unknown>, event: Event) => void
489
+ /** 排序变化事件 */
490
+ onSortChange?: (sortInfo: { prop: string; order: string }) => void
491
+ /** 展开变化事件 */
492
+ onExpandChange?: (row: Record<string, unknown>, expanded: boolean) => void
493
+ /** 透传给 el-table 的额外属性(所有上面未覆盖的 el-table 属性均可通过此传入) */
494
+ tableProps?: Record<string, unknown>
495
+ /** 透传给 el-form 的额外属性 */
496
+ formProps?: Record<string, unknown>
497
+ }
498
+
499
+ /** ProTableForm 操作实例类型 */
500
+ export interface ProTableFormActionType {
501
+ /** 表单校验 */
502
+ validate: () => Promise<boolean>
503
+ /** 清除校验 */
504
+ clearValidate: (props?: string | string[]) => void
505
+ /** 新增行 */
506
+ addRow: () => void
507
+ /** 删除行 */
508
+ removeRow: (index: number) => void
509
+ /** 获取行列表 */
510
+ getRows: () => Record<string, unknown>[]
511
+ /** 获取 el-table 实例 */
512
+ getTable: () => { clearSelection: () => void } | null
513
+ /** 获取当前行数 */
514
+ getRowCount: () => number
515
+ /** 获取整个 modelValue */
516
+ getModelValue: () => Record<string, unknown>[]
517
+ /** 设置整个 modelValue(触发 update:modelValue) */
518
+ setModelValue: (val: Record<string, unknown>[]) => void
519
+ /** 获取 el-form 实例(可用于滚动、聚焦等高级操作) */
520
+ getFormRef: () => FormInstance | null
521
+ }
522
+
@@ -16,8 +16,9 @@ function deepMerge(target: Record<string, unknown>, source?: Record<string, unkn
16
16
  if (Object.prototype.hasOwnProperty.call(source, key)) {
17
17
  const targetValue = target[key]
18
18
  const sourceValue = source[key]
19
-
20
- if (isPlainObject(sourceValue) || key !== 'components') {
19
+ if (key === 'components') {
20
+ target[key] = { ...(targetValue as Record<string, unknown>), ...(sourceValue as Record<string, unknown>) }
21
+ } else if (isPlainObject(sourceValue)) {
21
22
  if (!isPlainObject(targetValue)) {
22
23
  target[key] = { ...(sourceValue as Record<string, unknown>) }
23
24
  } else {