@a2simcode/ui 0.0.55 → 0.0.56
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/.cursor/skills/ui-component-helper/README.md +43 -43
- package/.cursor/skills/ui-component-helper/SKILL.md +81 -81
- package/LICENSE +53 -53
- package/README.md +156 -156
- package/dist/components/index.d.ts +2 -1
- package/dist/components/input-cards/index.d.ts +189 -0
- package/dist/components/input-cards/src/input-cards.vue.d.ts +142 -0
- package/dist/components/input-cards/src/interface.d.ts +29 -0
- package/dist/components/table/src/interface.d.ts +4 -0
- package/dist/simcode-ui.es.js +3523 -3304
- package/dist/simcode-ui.umd.js +2 -2
- package/dist/stats.html +1 -1
- package/dist/ui.css +1 -1
- package/docs/components/autocomplete.md +89 -89
- package/docs/components/barcode.md +101 -101
- package/docs/components/button-select.md +24 -24
- package/docs/components/button.md +117 -117
- package/docs/components/buttons.md +119 -119
- package/docs/components/cascader-select.md +114 -114
- package/docs/components/checkbox.md +114 -114
- package/docs/components/code-mirror.md +85 -85
- package/docs/components/collapse.md +26 -26
- package/docs/components/comp.md +71 -71
- package/docs/components/count-up.md +24 -24
- package/docs/components/count.md +24 -24
- package/docs/components/data-panel.md +24 -24
- package/docs/components/dialog-full.md +112 -112
- package/docs/components/dialog.md +127 -127
- package/docs/components/divider.md +24 -24
- package/docs/components/drawer.md +127 -127
- package/docs/components/dynamic-layer.md +118 -118
- package/docs/components/echarts.md +72 -72
- package/docs/components/editor.md +24 -24
- package/docs/components/form.md +27 -27
- package/docs/components/guid.md +39 -39
- package/docs/components/hpanel.md +24 -24
- package/docs/components/icon.md +56 -56
- package/docs/components/input-button.md +24 -24
- package/docs/components/input-cards.md +27 -0
- package/docs/components/input-code.md +24 -24
- package/docs/components/input-color.md +114 -114
- package/docs/components/input-layer.md +26 -26
- package/docs/components/input-rows.md +370 -370
- package/docs/components/input-tag.md +50 -50
- package/docs/components/input.md +129 -129
- package/docs/components/layer-form.md +61 -61
- package/docs/components/layer.md +127 -127
- package/docs/components/layout.md +132 -132
- package/docs/components/map.md +24 -24
- package/docs/components/menu.md +121 -121
- package/docs/components/meta/buttons.ts +56 -56
- package/docs/components/meta/comp.ts +224 -224
- package/docs/components/meta/dynamic-layer.ts +99 -99
- package/docs/components/meta/echarts.ts +64 -64
- package/docs/components/meta/form-item.ts +50 -50
- package/docs/components/meta/form.ts +160 -160
- package/docs/components/meta/guid.ts +42 -42
- package/docs/components/meta/input-cards.ts +112 -0
- package/docs/components/meta/input-color.ts +243 -243
- package/docs/components/meta/input-rows.ts +113 -113
- package/docs/components/meta/layer-form.ts +56 -56
- package/docs/components/meta/map.ts +68 -68
- package/docs/components/meta/number.ts +296 -296
- package/docs/components/meta/page.ts +67 -67
- package/docs/components/meta/panel.ts +83 -83
- package/docs/components/meta/radio.ts +55 -55
- package/docs/components/meta/slider.ts +270 -270
- package/docs/components/meta/table-panel.ts +154 -154
- package/docs/components/meta/table.ts +328 -328
- package/docs/components/meta/tabs.ts +136 -136
- package/docs/components/meta/workflow-viewer.ts +55 -55
- package/docs/components/meta/workflow.ts +113 -113
- package/docs/components/number.md +124 -124
- package/docs/components/page.md +42 -42
- package/docs/components/panel.md +37 -37
- package/docs/components/radio.md +87 -87
- package/docs/components/rate.md +71 -71
- package/docs/components/select.md +133 -133
- package/docs/components/slider-captcha.md +41 -41
- package/docs/components/slider.md +101 -101
- package/docs/components/switch.md +90 -90
- package/docs/components/table-panel.md +199 -199
- package/docs/components/table.md +202 -202
- package/docs/components/tabs.md +26 -26
- package/docs/components/title.md +24 -24
- package/docs/components/tree.md +207 -207
- package/docs/components/upload.md +117 -117
- package/docs/components/workflow-viewer.md +21 -21
- package/docs/components/workflow.md +21 -21
- package/docs/examples/autocomplete/advanced.vue +35 -35
- package/docs/examples/autocomplete/basic.vue +32 -32
- package/docs/examples/autocomplete/clearable.vue +33 -33
- package/docs/examples/autocomplete/custom-template.vue +49 -49
- package/docs/examples/autocomplete/disabled.vue +33 -33
- package/docs/examples/autocomplete/icon.vue +37 -37
- package/docs/examples/barcode/all-types.vue +380 -380
- package/docs/examples/barcode/basic.vue +14 -14
- package/docs/examples/barcode/props-appearance.vue +243 -243
- package/docs/examples/barcode/props-geometry.vue +143 -143
- package/docs/examples/barcode/props-logic.vue +216 -216
- package/docs/examples/barcode/props-symbology.vue +199 -199
- package/docs/examples/barcode/props-text.vue +268 -268
- package/docs/examples/button/basic.vue +7 -7
- package/docs/examples/button/danger-ghost.vue +17 -17
- package/docs/examples/button/disabled.vue +10 -10
- package/docs/examples/button/loading.vue +6 -6
- package/docs/examples/button/shape.vue +7 -7
- package/docs/examples/button/size.vue +14 -14
- package/docs/examples/button/type.vue +9 -9
- package/docs/examples/button-select/basic.vue +19 -19
- package/docs/examples/buttons/basic.vue +45 -45
- package/docs/examples/buttons/disabled.vue +36 -36
- package/docs/examples/buttons/dropdown.vue +63 -63
- package/docs/examples/buttons/group.vue +52 -52
- package/docs/examples/buttons/link.vue +47 -47
- package/docs/examples/buttons/popup.vue +39 -39
- package/docs/examples/buttons/size.vue +45 -45
- package/docs/examples/cascader-select/basic.vue +28 -28
- package/docs/examples/cascader-select/clearable.vue +34 -34
- package/docs/examples/cascader-select/disabled.vue +43 -43
- package/docs/examples/cascader-select/filterable.vue +37 -37
- package/docs/examples/cascader-select/methods.vue +84 -84
- package/docs/examples/cascader-select/multiple.vue +38 -38
- package/docs/examples/cascader-select/slot.vue +45 -45
- package/docs/examples/checkbox/basic.vue +18 -18
- package/docs/examples/checkbox/button.vue +19 -19
- package/docs/examples/checkbox/color.vue +25 -25
- package/docs/examples/checkbox/disabled.vue +17 -17
- package/docs/examples/checkbox/min-max.vue +20 -20
- package/docs/examples/checkbox/mixed.vue +56 -56
- package/docs/examples/checkbox/size.vue +28 -28
- package/docs/examples/code-mirror/basic.vue +11 -11
- package/docs/examples/code-mirror/events.vue +42 -42
- package/docs/examples/code-mirror/height.vue +25 -25
- package/docs/examples/code-mirror/mode.vue +33 -33
- package/docs/examples/code-mirror/readonly.vue +14 -14
- package/docs/examples/collapse/basic.vue +82 -82
- package/docs/examples/comp/basic.vue +7 -7
- package/docs/examples/comp/collapse.vue +38 -38
- package/docs/examples/comp/tabs.vue +38 -38
- package/docs/examples/count/basic.vue +54 -54
- package/docs/examples/count-up/basic.vue +89 -89
- package/docs/examples/data-panel/basic.vue +110 -110
- package/docs/examples/dialog/basic.vue +36 -36
- package/docs/examples/dialog/custom-buttons.vue +44 -44
- package/docs/examples/dialog/fullscreen.vue +23 -23
- package/docs/examples/dialog/no-mask.vue +17 -17
- package/docs/examples/dialog/size.vue +44 -44
- package/docs/examples/dialog/steps.vue +57 -57
- package/docs/examples/dialog-full/basic.vue +29 -29
- package/docs/examples/dialog-full/custom-buttons.vue +45 -45
- package/docs/examples/dialog-full/no-buttons.vue +18 -18
- package/docs/examples/dialog-full/no-header.vue +27 -27
- package/docs/examples/dialog-full/steps.vue +71 -71
- package/docs/examples/divider/basic.vue +52 -52
- package/docs/examples/drawer/basic.vue +35 -35
- package/docs/examples/drawer/custom-buttons.vue +34 -34
- package/docs/examples/drawer/direction.vue +47 -47
- package/docs/examples/drawer/mask.vue +36 -36
- package/docs/examples/drawer/no-buttons.vue +20 -20
- package/docs/examples/drawer/size.vue +28 -28
- package/docs/examples/dynamic-layer/basic.vue +33 -33
- package/docs/examples/dynamic-layer/custom-buttons.vue +43 -43
- package/docs/examples/dynamic-layer/form.vue +73 -73
- package/docs/examples/dynamic-layer/steps.vue +52 -52
- package/docs/examples/dynamic-layer/types.vue +40 -40
- package/docs/examples/echarts/basic.vue +31 -31
- package/docs/examples/echarts/dynamic.vue +43 -43
- package/docs/examples/echarts/line.vue +46 -46
- package/docs/examples/echarts/pie.vue +44 -44
- package/docs/examples/editor/basic.vue +15 -15
- package/docs/examples/form/basic.vue +242 -242
- package/docs/examples/guid/basic.vue +10 -10
- package/docs/examples/guid/size.vue +13 -13
- package/docs/examples/hpanel/basic.vue +79 -79
- package/docs/examples/icon/basic.vue +9 -9
- package/docs/examples/icon/rotate-flip.vue +9 -9
- package/docs/examples/icon/size.vue +7 -7
- package/docs/examples/input/basic.vue +10 -10
- package/docs/examples/input/clearable.vue +12 -12
- package/docs/examples/input/disabled.vue +6 -6
- package/docs/examples/input/icon.vue +23 -23
- package/docs/examples/input/password.vue +18 -18
- package/docs/examples/input/size.vue +13 -13
- package/docs/examples/input/textarea.vue +25 -25
- package/docs/examples/input/word-limit.vue +28 -28
- package/docs/examples/input-button/basic.vue +33 -33
- package/docs/examples/input-cards/basic.vue +82 -0
- package/docs/examples/input-code/basic.vue +29 -29
- package/docs/examples/input-color/basic.vue +10 -10
- package/docs/examples/input-color/disabled.vue +13 -13
- package/docs/examples/input-color/format.vue +17 -17
- package/docs/examples/input-color/no-alpha.vue +13 -13
- package/docs/examples/input-color/only-button.vue +15 -15
- package/docs/examples/input-color/predefine.vue +31 -31
- package/docs/examples/input-color/size.vue +15 -15
- package/docs/examples/input-layer/basic.vue +69 -69
- package/docs/examples/input-rows/basic.vue +73 -73
- package/docs/examples/input-rows/drag.vue +48 -48
- package/docs/examples/input-rows/layer-form.vue +85 -85
- package/docs/examples/input-rows/nested.vue +91 -91
- package/docs/examples/input-tag/basic.vue +27 -27
- package/docs/examples/input-tag/colors.vue +23 -23
- package/docs/examples/input-tag/readonly.vue +17 -17
- package/docs/examples/layer/basic.vue +43 -43
- package/docs/examples/layer/custom-buttons.vue +61 -61
- package/docs/examples/layer/drawer.vue +37 -37
- package/docs/examples/layer/full.vue +38 -38
- package/docs/examples/layer/modal.vue +34 -34
- package/docs/examples/layer/steps.vue +46 -46
- package/docs/examples/layer-form/basic.vue +76 -76
- package/docs/examples/layer-form/config.vue +82 -82
- package/docs/examples/layer-form/size.vue +72 -72
- package/docs/examples/layout/basic.vue +36 -36
- package/docs/examples/layout/custom-size.vue +50 -50
- package/docs/examples/layout/disable-move.vue +37 -37
- package/docs/examples/layout/hide-mid-when-narrow.vue +96 -96
- package/docs/examples/layout/min-size.vue +73 -73
- package/docs/examples/layout/percent-size.vue +80 -80
- package/docs/examples/layout/simple.vue +22 -22
- package/docs/examples/layout/top-side.vue +34 -34
- package/docs/examples/map/basic.vue +22 -22
- package/docs/examples/menu/basic.vue +58 -58
- package/docs/examples/menu/collapsed.vue +49 -49
- package/docs/examples/menu/horizontal.vue +44 -44
- package/docs/examples/menu/selection-test.vue +104 -104
- package/docs/examples/menu/theme.vue +46 -46
- package/docs/examples/menu/vertical.vue +46 -46
- package/docs/examples/number/advanced.vue +143 -143
- package/docs/examples/number/basic.vue +63 -63
- package/docs/examples/number/disabled.vue +49 -49
- package/docs/examples/number/size.vue +42 -42
- package/docs/examples/number/slots.vue +123 -123
- package/docs/examples/number/step-strictly.vue +41 -41
- package/docs/examples/number/step.vue +47 -47
- package/docs/examples/page/basic.vue +41 -41
- package/docs/examples/page/init.vue +87 -87
- package/docs/examples/panel/tool-buttons.vue +18 -18
- package/docs/examples/radio/basic.vue +17 -17
- package/docs/examples/radio/button.vue +17 -17
- package/docs/examples/radio/color.vue +18 -18
- package/docs/examples/radio/disabled.vue +17 -17
- package/docs/examples/radio/size.vue +29 -29
- package/docs/examples/rate/basic.vue +24 -24
- package/docs/examples/rate/half.vue +24 -24
- package/docs/examples/rate/readonly.vue +11 -11
- package/docs/examples/rate/text.vue +32 -32
- package/docs/examples/select/basic.vue +16 -16
- package/docs/examples/select/clearable.vue +22 -22
- package/docs/examples/select/disabled.vue +31 -31
- package/docs/examples/select/filterable.vue +24 -24
- package/docs/examples/select/group.vue +23 -23
- package/docs/examples/select/icon.vue +16 -16
- package/docs/examples/select/multiple.vue +18 -18
- package/docs/examples/select/size.vue +39 -39
- package/docs/examples/slider/basic.vue +42 -42
- package/docs/examples/slider/disabled.vue +17 -17
- package/docs/examples/slider/marks.vue +30 -30
- package/docs/examples/slider/size.vue +37 -37
- package/docs/examples/slider/tooltip.vue +36 -36
- package/docs/examples/slider/vertical.vue +26 -26
- package/docs/examples/slider-captcha/basic.vue +44 -44
- package/docs/examples/slider-captcha/custom.vue +48 -48
- package/docs/examples/switch/basic.vue +16 -16
- package/docs/examples/switch/disabled.vue +13 -13
- package/docs/examples/switch/loading.vue +13 -13
- package/docs/examples/switch/size.vue +15 -15
- package/docs/examples/switch/text.vue +13 -13
- package/docs/examples/table/actions.vue +116 -116
- package/docs/examples/table/add-row.vue +103 -103
- package/docs/examples/table/basic.vue +168 -168
- package/docs/examples/table/editable.vue +261 -261
- package/docs/examples/table/field-selection.vue +87 -87
- package/docs/examples/table/frozen-column.vue +140 -140
- package/docs/examples/table/height-mode.vue +99 -99
- package/docs/examples/table/multiple.vue +178 -178
- package/docs/examples/table/pagination.vue +151 -151
- package/docs/examples/table/single-selection.vue +64 -64
- package/docs/examples/table/tree-column.vue +119 -119
- package/docs/examples/table/tree-data.vue +141 -141
- package/docs/examples/table-panel/basic.vue +228 -228
- package/docs/examples/table-panel/batch-operations.vue +285 -285
- package/docs/examples/table-panel/filter.vue +209 -209
- package/docs/examples/table-panel/multiple-selection.vue +243 -243
- package/docs/examples/table-panel/pagination.vue +133 -133
- package/docs/examples/tabs/basic.vue +98 -98
- package/docs/examples/title/basic.vue +80 -80
- package/docs/examples/tree/accordion.vue +46 -46
- package/docs/examples/tree/basic.vue +50 -50
- package/docs/examples/tree/buttons.vue +53 -53
- package/docs/examples/tree/checkable.vue +52 -52
- package/docs/examples/tree/custom-keys.vue +39 -39
- package/docs/examples/tree/default-expanded.vue +52 -52
- package/docs/examples/tree/draggable.vue +29 -29
- package/docs/examples/tree/expand-on-click.vue +39 -39
- package/docs/examples/tree/flat-data.vue +20 -20
- package/docs/examples/tree/icon.vue +40 -40
- package/docs/examples/tree/load-data.vue +37 -37
- package/docs/examples/tree/methods.vue +74 -74
- package/docs/examples/tree/theme.vue +33 -33
- package/docs/examples/upload/accept.vue +31 -31
- package/docs/examples/upload/basic.vue +12 -12
- package/docs/examples/upload/drag.vue +11 -11
- package/docs/examples/upload/image.vue +17 -17
- package/docs/examples/upload/limit.vue +20 -20
- package/docs/examples/upload/multiple.vue +17 -17
- package/docs/examples/upload/readonly.vue +17 -17
- package/docs/examples/utils/cipher.vue +160 -160
- package/docs/examples/utils/common.vue +153 -153
- package/docs/examples/utils/date.vue +56 -56
- package/docs/examples/utils/dom.vue +52 -52
- package/docs/examples/utils/is.vue +70 -70
- package/docs/examples/workflow/basic.vue +265 -265
- package/docs/examples/workflow-viewer/basic.vue +248 -248
- package/package.json +23 -23
|
@@ -1,370 +1,370 @@
|
|
|
1
|
-
# InputRows 行输入
|
|
2
|
-
|
|
3
|
-
`j-input-rows` 用于维护“多行对象数组”类型的数据:每一行通过 `columns` 渲染若干输入控件,支持新增行、删除行,以及(可选)拖拽排序。
|
|
4
|
-
|
|
5
|
-
## 基础用法
|
|
6
|
-
|
|
7
|
-
通过 `columns` 属性定义列配置,`v-model` 绑定数据。
|
|
8
|
-
|
|
9
|
-
<Demo :source-code="basicCode">
|
|
10
|
-
<template #source>
|
|
11
|
-
<basic />
|
|
12
|
-
</template>
|
|
13
|
-
<template #description>
|
|
14
|
-
使用 `j-input-rows` 创建一个可编辑的数据表格。每行包含多个字段,支持添加、删除行操作。
|
|
15
|
-
</template>
|
|
16
|
-
</Demo>
|
|
17
|
-
|
|
18
|
-
## 拖拽排序
|
|
19
|
-
|
|
20
|
-
通过 `editConfig.drag` 属性启用拖拽排序功能。
|
|
21
|
-
|
|
22
|
-
<Demo :source-code="dragCode">
|
|
23
|
-
<template #source>
|
|
24
|
-
<drag />
|
|
25
|
-
</template>
|
|
26
|
-
<template #description>
|
|
27
|
-
设置 `editConfig.drag` 为 `true` 启用拖拽排序功能,可以通过拖拽图标调整行的顺序。
|
|
28
|
-
</template>
|
|
29
|
-
</Demo>
|
|
30
|
-
|
|
31
|
-
## 嵌套表单
|
|
32
|
-
|
|
33
|
-
支持在行内嵌套 `j-input-rows` 组件,实现多层级的数据录入。
|
|
34
|
-
|
|
35
|
-
<Demo :source-code="nestedCode">
|
|
36
|
-
<template #source>
|
|
37
|
-
<nested />
|
|
38
|
-
</template>
|
|
39
|
-
<template #description>
|
|
40
|
-
示例展示在列配置中使用嵌套能力来录入多层级数据结构。
|
|
41
|
-
</template>
|
|
42
|
-
</Demo>
|
|
43
|
-
|
|
44
|
-
## API(表格)
|
|
45
|
-
|
|
46
|
-
<ApiTable :data="inputRowsApi" componentName="input-rows" />
|
|
47
|
-
|
|
48
|
-
## 1. 组件概述
|
|
49
|
-
|
|
50
|
-
### 主要功能和用途
|
|
51
|
-
|
|
52
|
-
- 行级数据维护:`modelValue` 为对象数组,每个对象代表一行。
|
|
53
|
-
- 行内字段渲染:通过 `columns` 逐列渲染行内输入控件(内部使用 `j-comp` 动态渲染)。
|
|
54
|
-
- 编辑能力:添加、删除、拖拽排序(由 `editConfig` 控制)。
|
|
55
|
-
- 辅助展示:支持显示行序号(1,2,3...)或字母序号(A-Z 循环)。
|
|
56
|
-
|
|
57
|
-
### 适用的业务场景和使用限制
|
|
58
|
-
|
|
59
|
-
适用场景:
|
|
60
|
-
|
|
61
|
-
- 表单里需要录入可变数量条目:如“联系人列表”“参数列表”“阈值配置”“规则列表”等。
|
|
62
|
-
- 需要一个轻量的列表型编辑器,但又不想引入完整表格组件。
|
|
63
|
-
|
|
64
|
-
限制/注意事项:
|
|
65
|
-
|
|
66
|
-
- 组件会对数组进行就地修改(`push/splice`),并可能对每行对象补充唯一标识字段 `i`(UUID)。请避免把业务字段命名为 `i`。
|
|
67
|
-
- 当 `modelValue` 为空数组时,组件会在初始化时触发一次 `update:modelValue([])`;后续新增/删除/排序主要依赖就地修改与 `change` 事件。
|
|
68
|
-
- `change` 事件中的 `formData` 来自表单注入;不在 `j-form` 环境使用时,`formData` 可能为 `undefined`。
|
|
69
|
-
|
|
70
|
-
## 2. 属性说明(Props)
|
|
71
|
-
|
|
72
|
-
> 下文“类型/默认值”以组件源码为准。
|
|
73
|
-
|
|
74
|
-
### 2.1 组件属性
|
|
75
|
-
|
|
76
|
-
#### modelValue
|
|
77
|
-
|
|
78
|
-
- 名称:`modelValue`
|
|
79
|
-
- 类型:`Record<string, any>[]`
|
|
80
|
-
- 默认值:`[]`
|
|
81
|
-
- 是否必填:否(通常与 `v-model` 搭配)
|
|
82
|
-
- 详细描述:行数据数组。每项是一个对象,字段写入到行对象上的 key 通常来自 `columns[*].id`,也可通过 `columns[*].config.valueRowKey` 指定。
|
|
83
|
-
- 使用示例:
|
|
84
|
-
|
|
85
|
-
```vue
|
|
86
|
-
<template>
|
|
87
|
-
<j-input-rows v-model="rows" :columns="columns" />
|
|
88
|
-
</template>
|
|
89
|
-
|
|
90
|
-
<script setup lang="ts">
|
|
91
|
-
import { ref } from 'vue'
|
|
92
|
-
|
|
93
|
-
const rows = ref<Record<string, any>[]>([
|
|
94
|
-
{ i: '1', name: '张三', age: 18 },
|
|
95
|
-
{ i: '2', name: '李四', age: 20 },
|
|
96
|
-
])
|
|
97
|
-
</script>
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
#### columns
|
|
101
|
-
|
|
102
|
-
- 名称:`columns`
|
|
103
|
-
- 类型:`SchemaConfig[]`
|
|
104
|
-
- 默认值:`[]`
|
|
105
|
-
- 是否必填:是
|
|
106
|
-
- 详细描述:列配置数组。每个列配置会被透传给 `j-comp` 渲染为具体输入控件。
|
|
107
|
-
- 使用示例:
|
|
108
|
-
|
|
109
|
-
```ts
|
|
110
|
-
const columns = [
|
|
111
|
-
{
|
|
112
|
-
id: 'name',
|
|
113
|
-
type: 'j-input',
|
|
114
|
-
config: { label: '姓名', placeholder: '请输入姓名', defaultValue: '' },
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
id: 'age',
|
|
118
|
-
type: 'j-number',
|
|
119
|
-
config: { label: '年龄', placeholder: '请输入年龄', defaultValue: 0, min: 0, max: 150 },
|
|
120
|
-
},
|
|
121
|
-
]
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
#### editConfig
|
|
125
|
-
|
|
126
|
-
- 名称:`editConfig`
|
|
127
|
-
- 类型:`EditConfigType`
|
|
128
|
-
- 默认值:`{}`
|
|
129
|
-
- 是否必填:否
|
|
130
|
-
- 详细描述:编辑配置,控制添加/删除/只读/拖拽等行为。
|
|
131
|
-
- 使用示例:
|
|
132
|
-
|
|
133
|
-
```ts
|
|
134
|
-
const editConfig = {
|
|
135
|
-
isAddBtn: true,
|
|
136
|
-
isRemoveBtn: true,
|
|
137
|
-
addBtnText: '添加一行',
|
|
138
|
-
buttonsAlign: 'left',
|
|
139
|
-
readonly: false,
|
|
140
|
-
drag: true,
|
|
141
|
-
isNullValue: true,
|
|
142
|
-
}
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
#### isCompact
|
|
146
|
-
|
|
147
|
-
- 名称:`isCompact`
|
|
148
|
-
- 类型:`Boolean`
|
|
149
|
-
- 默认值:`false`
|
|
150
|
-
- 是否必填:否
|
|
151
|
-
- 详细描述:是否紧凑模式(行高与 padding 更小)。
|
|
152
|
-
- 使用示例:`<j-input-rows v-model="rows" :columns="columns" is-compact />`
|
|
153
|
-
|
|
154
|
-
#### showNum
|
|
155
|
-
|
|
156
|
-
- 名称:`showNum`
|
|
157
|
-
- 类型:`Boolean`
|
|
158
|
-
- 默认值:`false`
|
|
159
|
-
- 是否必填:否
|
|
160
|
-
- 详细描述:是否显示行序号(1,2,3...)。
|
|
161
|
-
- 使用示例:`<j-input-rows v-model="rows" :columns="columns" show-num />`
|
|
162
|
-
|
|
163
|
-
#### showChar
|
|
164
|
-
|
|
165
|
-
- 名称:`showChar`
|
|
166
|
-
- 类型:`Boolean`
|
|
167
|
-
- 默认值:`false`
|
|
168
|
-
- 是否必填:否
|
|
169
|
-
- 详细描述:是否显示字母序号(A-Z 循环)。
|
|
170
|
-
- 使用示例:`<j-input-rows v-model="rows" :columns="columns" show-char />`
|
|
171
|
-
|
|
172
|
-
#### isWrap
|
|
173
|
-
|
|
174
|
-
- 名称:`isWrap`
|
|
175
|
-
- 类型:`Boolean`
|
|
176
|
-
- 默认值:`false`
|
|
177
|
-
- 是否必填:否
|
|
178
|
-
- 详细描述:是否允许行内字段换行(`flex-wrap: wrap`)。
|
|
179
|
-
- 使用示例:`<j-input-rows v-model="rows" :columns="columns" is-wrap />`
|
|
180
|
-
|
|
181
|
-
#### id
|
|
182
|
-
|
|
183
|
-
- 名称:`id`
|
|
184
|
-
- 类型:`String`
|
|
185
|
-
- 默认值:`''`
|
|
186
|
-
- 是否必填:否
|
|
187
|
-
- 详细描述:字段/组件 id。该值会原样透传到 `change` 事件的回调参数 `payload.id` 中,用于区分来源。
|
|
188
|
-
- 使用示例:`<j-input-rows id="user-list" v-model="rows" :columns="columns" />`
|
|
189
|
-
|
|
190
|
-
### 2.2 EditConfigType 说明
|
|
191
|
-
|
|
192
|
-
#### isAddBtn
|
|
193
|
-
|
|
194
|
-
- 名称:`isAddBtn`
|
|
195
|
-
- 类型:`Boolean`
|
|
196
|
-
- 默认值:`true`(逻辑为 `!== false` 即显示)
|
|
197
|
-
- 是否必填:否
|
|
198
|
-
- 详细描述:是否显示添加按钮。
|
|
199
|
-
- 使用示例:`editConfig: { isAddBtn: false }`
|
|
200
|
-
|
|
201
|
-
#### addBtnText
|
|
202
|
-
|
|
203
|
-
- 名称:`addBtnText`
|
|
204
|
-
- 类型:`String`
|
|
205
|
-
- 默认值:`'添加'`
|
|
206
|
-
- 是否必填:否
|
|
207
|
-
- 详细描述:添加按钮文本。
|
|
208
|
-
- 使用示例:`editConfig: { addBtnText: '新增条目' }`
|
|
209
|
-
|
|
210
|
-
#### buttonsAlign
|
|
211
|
-
|
|
212
|
-
- 名称:`buttonsAlign`
|
|
213
|
-
- 类型:`'left' | 'center' | 'right'`
|
|
214
|
-
- 默认值:`'left'`
|
|
215
|
-
- 是否必填:否
|
|
216
|
-
- 详细描述:底部操作区(添加按钮区域)对齐方式。
|
|
217
|
-
- 使用示例:`editConfig: { buttonsAlign: 'right' }`
|
|
218
|
-
|
|
219
|
-
#### isRemoveBtn
|
|
220
|
-
|
|
221
|
-
- 名称:`isRemoveBtn`
|
|
222
|
-
- 类型:`Boolean`
|
|
223
|
-
- 默认值:`true`(逻辑为 `!== false` 即显示)
|
|
224
|
-
- 是否必填:否
|
|
225
|
-
- 详细描述:是否显示删除按钮。
|
|
226
|
-
- 使用示例:`editConfig: { isRemoveBtn: false }`
|
|
227
|
-
|
|
228
|
-
#### readonly
|
|
229
|
-
|
|
230
|
-
- 名称:`readonly`
|
|
231
|
-
- 类型:`Boolean`
|
|
232
|
-
- 默认值:`false`
|
|
233
|
-
- 是否必填:否
|
|
234
|
-
- 详细描述:是否只读。为 `true` 时隐藏添加/删除操作区;行内输入控件是否只读取决于列配置本身。
|
|
235
|
-
- 使用示例:`editConfig: { readonly: true }`
|
|
236
|
-
|
|
237
|
-
#### drag
|
|
238
|
-
|
|
239
|
-
- 名称:`drag`
|
|
240
|
-
- 类型:`Boolean`
|
|
241
|
-
- 默认值:`false`
|
|
242
|
-
- 是否必填:否
|
|
243
|
-
- 详细描述:是否支持拖拽排序。开启后每行会显示拖拽手柄图标。
|
|
244
|
-
- 使用示例:`editConfig: { drag: true }`
|
|
245
|
-
|
|
246
|
-
#### isNullValue
|
|
247
|
-
|
|
248
|
-
- 名称:`isNullValue`
|
|
249
|
-
- 类型:`Boolean`
|
|
250
|
-
- 默认值:`true`(逻辑为 `!== false` 即允许“可删到空”)
|
|
251
|
-
- 是否必填:否
|
|
252
|
-
- 详细描述:是否允许删除到空。当 `isNullValue === false` 时,仅当 `list.length > 1` 才显示删除按钮(禁止删除最后一行)。
|
|
253
|
-
- 使用示例:`editConfig: { isNullValue: false }`
|
|
254
|
-
|
|
255
|
-
## 3. 事件说明(Events)
|
|
256
|
-
|
|
257
|
-
### update:modelValue
|
|
258
|
-
|
|
259
|
-
- 事件名称:`update:modelValue`
|
|
260
|
-
- 触发条件:初始化时 `modelValue` 为空数组会触发一次;其他场景通常依赖数组就地修改,不保证每次新增/删除/排序都触发该事件。
|
|
261
|
-
- 回调参数:`value: Record<string, any>[]`
|
|
262
|
-
|
|
263
|
-
### change
|
|
264
|
-
|
|
265
|
-
- 事件名称:`change`
|
|
266
|
-
- 触发条件:新增行、删除行、拖拽排序后触发。
|
|
267
|
-
- 回调参数说明:
|
|
268
|
-
|
|
269
|
-
```ts
|
|
270
|
-
type InputRowsChangePayload = {
|
|
271
|
-
id: string
|
|
272
|
-
value: any
|
|
273
|
-
data: any
|
|
274
|
-
formData: Record<string, any> | undefined
|
|
275
|
-
tableData: Record<string, any>[]
|
|
276
|
-
type: 'add' | 'delete' | 'update' | 'sort'
|
|
277
|
-
}
|
|
278
|
-
```
|
|
279
|
-
|
|
280
|
-
### rowChange
|
|
281
|
-
|
|
282
|
-
- 事件名称:`rowChange`
|
|
283
|
-
- 触发条件:行内字段变化时触发(由内部注入的 `rowChange` 回调触发)。
|
|
284
|
-
- 回调参数说明:`data: Record<string, any>`(透传自内部 `j-comp` 的变更数据)
|
|
285
|
-
|
|
286
|
-
## 4. 方法说明(Methods)
|
|
287
|
-
|
|
288
|
-
- 当前版本未通过 `defineExpose` 暴露任何公共方法。
|
|
289
|
-
|
|
290
|
-
## 5. 插槽说明(Slots)
|
|
291
|
-
|
|
292
|
-
- 当前版本不支持插槽。
|
|
293
|
-
|
|
294
|
-
## 6. 使用示例(进阶)
|
|
295
|
-
|
|
296
|
-
### 6.1 新增行默认值(defaultValue)与字段落点(valueRowKey)
|
|
297
|
-
|
|
298
|
-
```ts
|
|
299
|
-
const columns = [
|
|
300
|
-
{ id: 'name', type: 'j-input', config: { label: '名称', defaultValue: '未命名' } },
|
|
301
|
-
{
|
|
302
|
-
id: 'amount',
|
|
303
|
-
type: 'j-number',
|
|
304
|
-
config: { label: '金额', defaultValue: 0, valueRowKey: 'price' },
|
|
305
|
-
},
|
|
306
|
-
]
|
|
307
|
-
```
|
|
308
|
-
|
|
309
|
-
点击“添加”后,新行会写入到行对象的 `price` 字段(而不是 `amount`),形如:`{ i: 'uuid', name: '未命名', price: 0 }`。
|
|
310
|
-
|
|
311
|
-
### 6.2 不允许删到空(isNullValue: false)
|
|
312
|
-
|
|
313
|
-
```vue
|
|
314
|
-
<template>
|
|
315
|
-
<j-input-rows
|
|
316
|
-
v-model="rows"
|
|
317
|
-
:columns="columns"
|
|
318
|
-
:edit-config="{ isNullValue: false, isRemoveBtn: true }"
|
|
319
|
-
/>
|
|
320
|
-
</template>
|
|
321
|
-
```
|
|
322
|
-
|
|
323
|
-
当 `rows.length === 1` 时不显示删除按钮。
|
|
324
|
-
|
|
325
|
-
## 7. 样式定制
|
|
326
|
-
|
|
327
|
-
### 7.1 可自定义的 CSS 变量
|
|
328
|
-
|
|
329
|
-
组件样式使用到以下 CSS 变量(来自主题系统):
|
|
330
|
-
|
|
331
|
-
- `--j-color-hover`
|
|
332
|
-
- `--j-color-text-secondary`
|
|
333
|
-
- `--j-color-text`
|
|
334
|
-
- `--j-color-primary`
|
|
335
|
-
- `--j-color-danger`
|
|
336
|
-
|
|
337
|
-
### 7.2 样式覆盖指南
|
|
338
|
-
|
|
339
|
-
组件关键类名:
|
|
340
|
-
|
|
341
|
-
- 根容器:`.j-input-rows`
|
|
342
|
-
- 单行容器:`.j-space` / `.j-space-compact`,并可叠加 `.j-space-wrap`
|
|
343
|
-
- 序号/字母:`.j-input-rows-num` / `.j-input-rows-char`
|
|
344
|
-
- 拖拽图标:`.j-input-rows-drag`
|
|
345
|
-
- 删除图标:`.j-input-rows-delete`
|
|
346
|
-
- 操作区:`.j-input-rows-actions`
|
|
347
|
-
|
|
348
|
-
覆盖示例:
|
|
349
|
-
|
|
350
|
-
```css
|
|
351
|
-
.j-input-rows .j-space:hover,
|
|
352
|
-
.j-input-rows .j-space-compact:hover {
|
|
353
|
-
background-color: rgba(0, 0, 0, 0.04);
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
.j-input-rows-actions {
|
|
357
|
-
margin-top: 12px;
|
|
358
|
-
}
|
|
359
|
-
```
|
|
360
|
-
|
|
361
|
-
<script setup>
|
|
362
|
-
import Basic from '../examples/input-rows/basic.vue'
|
|
363
|
-
import Drag from '../examples/input-rows/drag.vue'
|
|
364
|
-
import Nested from '../examples/input-rows/nested.vue'
|
|
365
|
-
import inputRowsApi from './meta/input-rows'
|
|
366
|
-
|
|
367
|
-
import basicCode from '../examples/input-rows/basic.vue?raw'
|
|
368
|
-
import dragCode from '../examples/input-rows/drag.vue?raw'
|
|
369
|
-
import nestedCode from '../examples/input-rows/nested.vue?raw'
|
|
370
|
-
</script>
|
|
1
|
+
# InputRows 行输入
|
|
2
|
+
|
|
3
|
+
`j-input-rows` 用于维护“多行对象数组”类型的数据:每一行通过 `columns` 渲染若干输入控件,支持新增行、删除行,以及(可选)拖拽排序。
|
|
4
|
+
|
|
5
|
+
## 基础用法
|
|
6
|
+
|
|
7
|
+
通过 `columns` 属性定义列配置,`v-model` 绑定数据。
|
|
8
|
+
|
|
9
|
+
<Demo :source-code="basicCode">
|
|
10
|
+
<template #source>
|
|
11
|
+
<basic />
|
|
12
|
+
</template>
|
|
13
|
+
<template #description>
|
|
14
|
+
使用 `j-input-rows` 创建一个可编辑的数据表格。每行包含多个字段,支持添加、删除行操作。
|
|
15
|
+
</template>
|
|
16
|
+
</Demo>
|
|
17
|
+
|
|
18
|
+
## 拖拽排序
|
|
19
|
+
|
|
20
|
+
通过 `editConfig.drag` 属性启用拖拽排序功能。
|
|
21
|
+
|
|
22
|
+
<Demo :source-code="dragCode">
|
|
23
|
+
<template #source>
|
|
24
|
+
<drag />
|
|
25
|
+
</template>
|
|
26
|
+
<template #description>
|
|
27
|
+
设置 `editConfig.drag` 为 `true` 启用拖拽排序功能,可以通过拖拽图标调整行的顺序。
|
|
28
|
+
</template>
|
|
29
|
+
</Demo>
|
|
30
|
+
|
|
31
|
+
## 嵌套表单
|
|
32
|
+
|
|
33
|
+
支持在行内嵌套 `j-input-rows` 组件,实现多层级的数据录入。
|
|
34
|
+
|
|
35
|
+
<Demo :source-code="nestedCode">
|
|
36
|
+
<template #source>
|
|
37
|
+
<nested />
|
|
38
|
+
</template>
|
|
39
|
+
<template #description>
|
|
40
|
+
示例展示在列配置中使用嵌套能力来录入多层级数据结构。
|
|
41
|
+
</template>
|
|
42
|
+
</Demo>
|
|
43
|
+
|
|
44
|
+
## API(表格)
|
|
45
|
+
|
|
46
|
+
<ApiTable :data="inputRowsApi" componentName="input-rows" />
|
|
47
|
+
|
|
48
|
+
## 1. 组件概述
|
|
49
|
+
|
|
50
|
+
### 主要功能和用途
|
|
51
|
+
|
|
52
|
+
- 行级数据维护:`modelValue` 为对象数组,每个对象代表一行。
|
|
53
|
+
- 行内字段渲染:通过 `columns` 逐列渲染行内输入控件(内部使用 `j-comp` 动态渲染)。
|
|
54
|
+
- 编辑能力:添加、删除、拖拽排序(由 `editConfig` 控制)。
|
|
55
|
+
- 辅助展示:支持显示行序号(1,2,3...)或字母序号(A-Z 循环)。
|
|
56
|
+
|
|
57
|
+
### 适用的业务场景和使用限制
|
|
58
|
+
|
|
59
|
+
适用场景:
|
|
60
|
+
|
|
61
|
+
- 表单里需要录入可变数量条目:如“联系人列表”“参数列表”“阈值配置”“规则列表”等。
|
|
62
|
+
- 需要一个轻量的列表型编辑器,但又不想引入完整表格组件。
|
|
63
|
+
|
|
64
|
+
限制/注意事项:
|
|
65
|
+
|
|
66
|
+
- 组件会对数组进行就地修改(`push/splice`),并可能对每行对象补充唯一标识字段 `i`(UUID)。请避免把业务字段命名为 `i`。
|
|
67
|
+
- 当 `modelValue` 为空数组时,组件会在初始化时触发一次 `update:modelValue([])`;后续新增/删除/排序主要依赖就地修改与 `change` 事件。
|
|
68
|
+
- `change` 事件中的 `formData` 来自表单注入;不在 `j-form` 环境使用时,`formData` 可能为 `undefined`。
|
|
69
|
+
|
|
70
|
+
## 2. 属性说明(Props)
|
|
71
|
+
|
|
72
|
+
> 下文“类型/默认值”以组件源码为准。
|
|
73
|
+
|
|
74
|
+
### 2.1 组件属性
|
|
75
|
+
|
|
76
|
+
#### modelValue
|
|
77
|
+
|
|
78
|
+
- 名称:`modelValue`
|
|
79
|
+
- 类型:`Record<string, any>[]`
|
|
80
|
+
- 默认值:`[]`
|
|
81
|
+
- 是否必填:否(通常与 `v-model` 搭配)
|
|
82
|
+
- 详细描述:行数据数组。每项是一个对象,字段写入到行对象上的 key 通常来自 `columns[*].id`,也可通过 `columns[*].config.valueRowKey` 指定。
|
|
83
|
+
- 使用示例:
|
|
84
|
+
|
|
85
|
+
```vue
|
|
86
|
+
<template>
|
|
87
|
+
<j-input-rows v-model="rows" :columns="columns" />
|
|
88
|
+
</template>
|
|
89
|
+
|
|
90
|
+
<script setup lang="ts">
|
|
91
|
+
import { ref } from 'vue'
|
|
92
|
+
|
|
93
|
+
const rows = ref<Record<string, any>[]>([
|
|
94
|
+
{ i: '1', name: '张三', age: 18 },
|
|
95
|
+
{ i: '2', name: '李四', age: 20 },
|
|
96
|
+
])
|
|
97
|
+
</script>
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
#### columns
|
|
101
|
+
|
|
102
|
+
- 名称:`columns`
|
|
103
|
+
- 类型:`SchemaConfig[]`
|
|
104
|
+
- 默认值:`[]`
|
|
105
|
+
- 是否必填:是
|
|
106
|
+
- 详细描述:列配置数组。每个列配置会被透传给 `j-comp` 渲染为具体输入控件。
|
|
107
|
+
- 使用示例:
|
|
108
|
+
|
|
109
|
+
```ts
|
|
110
|
+
const columns = [
|
|
111
|
+
{
|
|
112
|
+
id: 'name',
|
|
113
|
+
type: 'j-input',
|
|
114
|
+
config: { label: '姓名', placeholder: '请输入姓名', defaultValue: '' },
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
id: 'age',
|
|
118
|
+
type: 'j-number',
|
|
119
|
+
config: { label: '年龄', placeholder: '请输入年龄', defaultValue: 0, min: 0, max: 150 },
|
|
120
|
+
},
|
|
121
|
+
]
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
#### editConfig
|
|
125
|
+
|
|
126
|
+
- 名称:`editConfig`
|
|
127
|
+
- 类型:`EditConfigType`
|
|
128
|
+
- 默认值:`{}`
|
|
129
|
+
- 是否必填:否
|
|
130
|
+
- 详细描述:编辑配置,控制添加/删除/只读/拖拽等行为。
|
|
131
|
+
- 使用示例:
|
|
132
|
+
|
|
133
|
+
```ts
|
|
134
|
+
const editConfig = {
|
|
135
|
+
isAddBtn: true,
|
|
136
|
+
isRemoveBtn: true,
|
|
137
|
+
addBtnText: '添加一行',
|
|
138
|
+
buttonsAlign: 'left',
|
|
139
|
+
readonly: false,
|
|
140
|
+
drag: true,
|
|
141
|
+
isNullValue: true,
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
#### isCompact
|
|
146
|
+
|
|
147
|
+
- 名称:`isCompact`
|
|
148
|
+
- 类型:`Boolean`
|
|
149
|
+
- 默认值:`false`
|
|
150
|
+
- 是否必填:否
|
|
151
|
+
- 详细描述:是否紧凑模式(行高与 padding 更小)。
|
|
152
|
+
- 使用示例:`<j-input-rows v-model="rows" :columns="columns" is-compact />`
|
|
153
|
+
|
|
154
|
+
#### showNum
|
|
155
|
+
|
|
156
|
+
- 名称:`showNum`
|
|
157
|
+
- 类型:`Boolean`
|
|
158
|
+
- 默认值:`false`
|
|
159
|
+
- 是否必填:否
|
|
160
|
+
- 详细描述:是否显示行序号(1,2,3...)。
|
|
161
|
+
- 使用示例:`<j-input-rows v-model="rows" :columns="columns" show-num />`
|
|
162
|
+
|
|
163
|
+
#### showChar
|
|
164
|
+
|
|
165
|
+
- 名称:`showChar`
|
|
166
|
+
- 类型:`Boolean`
|
|
167
|
+
- 默认值:`false`
|
|
168
|
+
- 是否必填:否
|
|
169
|
+
- 详细描述:是否显示字母序号(A-Z 循环)。
|
|
170
|
+
- 使用示例:`<j-input-rows v-model="rows" :columns="columns" show-char />`
|
|
171
|
+
|
|
172
|
+
#### isWrap
|
|
173
|
+
|
|
174
|
+
- 名称:`isWrap`
|
|
175
|
+
- 类型:`Boolean`
|
|
176
|
+
- 默认值:`false`
|
|
177
|
+
- 是否必填:否
|
|
178
|
+
- 详细描述:是否允许行内字段换行(`flex-wrap: wrap`)。
|
|
179
|
+
- 使用示例:`<j-input-rows v-model="rows" :columns="columns" is-wrap />`
|
|
180
|
+
|
|
181
|
+
#### id
|
|
182
|
+
|
|
183
|
+
- 名称:`id`
|
|
184
|
+
- 类型:`String`
|
|
185
|
+
- 默认值:`''`
|
|
186
|
+
- 是否必填:否
|
|
187
|
+
- 详细描述:字段/组件 id。该值会原样透传到 `change` 事件的回调参数 `payload.id` 中,用于区分来源。
|
|
188
|
+
- 使用示例:`<j-input-rows id="user-list" v-model="rows" :columns="columns" />`
|
|
189
|
+
|
|
190
|
+
### 2.2 EditConfigType 说明
|
|
191
|
+
|
|
192
|
+
#### isAddBtn
|
|
193
|
+
|
|
194
|
+
- 名称:`isAddBtn`
|
|
195
|
+
- 类型:`Boolean`
|
|
196
|
+
- 默认值:`true`(逻辑为 `!== false` 即显示)
|
|
197
|
+
- 是否必填:否
|
|
198
|
+
- 详细描述:是否显示添加按钮。
|
|
199
|
+
- 使用示例:`editConfig: { isAddBtn: false }`
|
|
200
|
+
|
|
201
|
+
#### addBtnText
|
|
202
|
+
|
|
203
|
+
- 名称:`addBtnText`
|
|
204
|
+
- 类型:`String`
|
|
205
|
+
- 默认值:`'添加'`
|
|
206
|
+
- 是否必填:否
|
|
207
|
+
- 详细描述:添加按钮文本。
|
|
208
|
+
- 使用示例:`editConfig: { addBtnText: '新增条目' }`
|
|
209
|
+
|
|
210
|
+
#### buttonsAlign
|
|
211
|
+
|
|
212
|
+
- 名称:`buttonsAlign`
|
|
213
|
+
- 类型:`'left' | 'center' | 'right'`
|
|
214
|
+
- 默认值:`'left'`
|
|
215
|
+
- 是否必填:否
|
|
216
|
+
- 详细描述:底部操作区(添加按钮区域)对齐方式。
|
|
217
|
+
- 使用示例:`editConfig: { buttonsAlign: 'right' }`
|
|
218
|
+
|
|
219
|
+
#### isRemoveBtn
|
|
220
|
+
|
|
221
|
+
- 名称:`isRemoveBtn`
|
|
222
|
+
- 类型:`Boolean`
|
|
223
|
+
- 默认值:`true`(逻辑为 `!== false` 即显示)
|
|
224
|
+
- 是否必填:否
|
|
225
|
+
- 详细描述:是否显示删除按钮。
|
|
226
|
+
- 使用示例:`editConfig: { isRemoveBtn: false }`
|
|
227
|
+
|
|
228
|
+
#### readonly
|
|
229
|
+
|
|
230
|
+
- 名称:`readonly`
|
|
231
|
+
- 类型:`Boolean`
|
|
232
|
+
- 默认值:`false`
|
|
233
|
+
- 是否必填:否
|
|
234
|
+
- 详细描述:是否只读。为 `true` 时隐藏添加/删除操作区;行内输入控件是否只读取决于列配置本身。
|
|
235
|
+
- 使用示例:`editConfig: { readonly: true }`
|
|
236
|
+
|
|
237
|
+
#### drag
|
|
238
|
+
|
|
239
|
+
- 名称:`drag`
|
|
240
|
+
- 类型:`Boolean`
|
|
241
|
+
- 默认值:`false`
|
|
242
|
+
- 是否必填:否
|
|
243
|
+
- 详细描述:是否支持拖拽排序。开启后每行会显示拖拽手柄图标。
|
|
244
|
+
- 使用示例:`editConfig: { drag: true }`
|
|
245
|
+
|
|
246
|
+
#### isNullValue
|
|
247
|
+
|
|
248
|
+
- 名称:`isNullValue`
|
|
249
|
+
- 类型:`Boolean`
|
|
250
|
+
- 默认值:`true`(逻辑为 `!== false` 即允许“可删到空”)
|
|
251
|
+
- 是否必填:否
|
|
252
|
+
- 详细描述:是否允许删除到空。当 `isNullValue === false` 时,仅当 `list.length > 1` 才显示删除按钮(禁止删除最后一行)。
|
|
253
|
+
- 使用示例:`editConfig: { isNullValue: false }`
|
|
254
|
+
|
|
255
|
+
## 3. 事件说明(Events)
|
|
256
|
+
|
|
257
|
+
### update:modelValue
|
|
258
|
+
|
|
259
|
+
- 事件名称:`update:modelValue`
|
|
260
|
+
- 触发条件:初始化时 `modelValue` 为空数组会触发一次;其他场景通常依赖数组就地修改,不保证每次新增/删除/排序都触发该事件。
|
|
261
|
+
- 回调参数:`value: Record<string, any>[]`
|
|
262
|
+
|
|
263
|
+
### change
|
|
264
|
+
|
|
265
|
+
- 事件名称:`change`
|
|
266
|
+
- 触发条件:新增行、删除行、拖拽排序后触发。
|
|
267
|
+
- 回调参数说明:
|
|
268
|
+
|
|
269
|
+
```ts
|
|
270
|
+
type InputRowsChangePayload = {
|
|
271
|
+
id: string
|
|
272
|
+
value: any
|
|
273
|
+
data: any
|
|
274
|
+
formData: Record<string, any> | undefined
|
|
275
|
+
tableData: Record<string, any>[]
|
|
276
|
+
type: 'add' | 'delete' | 'update' | 'sort'
|
|
277
|
+
}
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
### rowChange
|
|
281
|
+
|
|
282
|
+
- 事件名称:`rowChange`
|
|
283
|
+
- 触发条件:行内字段变化时触发(由内部注入的 `rowChange` 回调触发)。
|
|
284
|
+
- 回调参数说明:`data: Record<string, any>`(透传自内部 `j-comp` 的变更数据)
|
|
285
|
+
|
|
286
|
+
## 4. 方法说明(Methods)
|
|
287
|
+
|
|
288
|
+
- 当前版本未通过 `defineExpose` 暴露任何公共方法。
|
|
289
|
+
|
|
290
|
+
## 5. 插槽说明(Slots)
|
|
291
|
+
|
|
292
|
+
- 当前版本不支持插槽。
|
|
293
|
+
|
|
294
|
+
## 6. 使用示例(进阶)
|
|
295
|
+
|
|
296
|
+
### 6.1 新增行默认值(defaultValue)与字段落点(valueRowKey)
|
|
297
|
+
|
|
298
|
+
```ts
|
|
299
|
+
const columns = [
|
|
300
|
+
{ id: 'name', type: 'j-input', config: { label: '名称', defaultValue: '未命名' } },
|
|
301
|
+
{
|
|
302
|
+
id: 'amount',
|
|
303
|
+
type: 'j-number',
|
|
304
|
+
config: { label: '金额', defaultValue: 0, valueRowKey: 'price' },
|
|
305
|
+
},
|
|
306
|
+
]
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
点击“添加”后,新行会写入到行对象的 `price` 字段(而不是 `amount`),形如:`{ i: 'uuid', name: '未命名', price: 0 }`。
|
|
310
|
+
|
|
311
|
+
### 6.2 不允许删到空(isNullValue: false)
|
|
312
|
+
|
|
313
|
+
```vue
|
|
314
|
+
<template>
|
|
315
|
+
<j-input-rows
|
|
316
|
+
v-model="rows"
|
|
317
|
+
:columns="columns"
|
|
318
|
+
:edit-config="{ isNullValue: false, isRemoveBtn: true }"
|
|
319
|
+
/>
|
|
320
|
+
</template>
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
当 `rows.length === 1` 时不显示删除按钮。
|
|
324
|
+
|
|
325
|
+
## 7. 样式定制
|
|
326
|
+
|
|
327
|
+
### 7.1 可自定义的 CSS 变量
|
|
328
|
+
|
|
329
|
+
组件样式使用到以下 CSS 变量(来自主题系统):
|
|
330
|
+
|
|
331
|
+
- `--j-color-hover`
|
|
332
|
+
- `--j-color-text-secondary`
|
|
333
|
+
- `--j-color-text`
|
|
334
|
+
- `--j-color-primary`
|
|
335
|
+
- `--j-color-danger`
|
|
336
|
+
|
|
337
|
+
### 7.2 样式覆盖指南
|
|
338
|
+
|
|
339
|
+
组件关键类名:
|
|
340
|
+
|
|
341
|
+
- 根容器:`.j-input-rows`
|
|
342
|
+
- 单行容器:`.j-space` / `.j-space-compact`,并可叠加 `.j-space-wrap`
|
|
343
|
+
- 序号/字母:`.j-input-rows-num` / `.j-input-rows-char`
|
|
344
|
+
- 拖拽图标:`.j-input-rows-drag`
|
|
345
|
+
- 删除图标:`.j-input-rows-delete`
|
|
346
|
+
- 操作区:`.j-input-rows-actions`
|
|
347
|
+
|
|
348
|
+
覆盖示例:
|
|
349
|
+
|
|
350
|
+
```css
|
|
351
|
+
.j-input-rows .j-space:hover,
|
|
352
|
+
.j-input-rows .j-space-compact:hover {
|
|
353
|
+
background-color: rgba(0, 0, 0, 0.04);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
.j-input-rows-actions {
|
|
357
|
+
margin-top: 12px;
|
|
358
|
+
}
|
|
359
|
+
```
|
|
360
|
+
|
|
361
|
+
<script setup>
|
|
362
|
+
import Basic from '../examples/input-rows/basic.vue'
|
|
363
|
+
import Drag from '../examples/input-rows/drag.vue'
|
|
364
|
+
import Nested from '../examples/input-rows/nested.vue'
|
|
365
|
+
import inputRowsApi from './meta/input-rows'
|
|
366
|
+
|
|
367
|
+
import basicCode from '../examples/input-rows/basic.vue?raw'
|
|
368
|
+
import dragCode from '../examples/input-rows/drag.vue?raw'
|
|
369
|
+
import nestedCode from '../examples/input-rows/nested.vue?raw'
|
|
370
|
+
</script>
|