xt-element-ui 2.1.4 → 2.1.5

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.
@@ -0,0 +1,272 @@
1
+ ## XtTransferTree 树形穿梭框组件
2
+
3
+ 树形穿梭框组件,支持树形结构数据的穿梭,提供多种穿梭模式满足不同业务场景。
4
+
5
+ ## 基本用法
6
+
7
+ ::: demo 基本用法
8
+ ```vue
9
+ <template>
10
+ <XtTransferTree
11
+ :data="treeData"
12
+ v-model="selectedIds"
13
+ :height="400"
14
+ />
15
+ </template>
16
+
17
+ <script>
18
+ export default {
19
+ data() {
20
+ return {
21
+ selectedIds: [],
22
+ treeData: [
23
+ {
24
+ id: '1',
25
+ label: '一级菜单',
26
+ children: [
27
+ {
28
+ id: '1-1',
29
+ label: '二级菜单1'
30
+ },
31
+ {
32
+ id: '1-2',
33
+ label: '二级菜单2'
34
+ }
35
+ ]
36
+ },
37
+ {
38
+ id: '2',
39
+ label: '一级菜单2',
40
+ children: [
41
+ {
42
+ id: '2-1',
43
+ label: '二级菜单3'
44
+ }
45
+ ]
46
+ }
47
+ ]
48
+ }
49
+ }
50
+ }
51
+ </script>
52
+ ```
53
+ :::
54
+
55
+ ## 属性说明
56
+
57
+ | 属性 | 类型 | 默认值 | 可选值 | 说明 |
58
+ |------|------|--------|--------|------|
59
+ | `value` / `v-model` | Array | `[]` | - | 已选择的节点 ID 数组 |
60
+ | `data` | Array | `[]` | - | 树形数据源 |
61
+ | `leftTitle` | String | `待选择` | - | 左侧面板标题 |
62
+ | `rightTitle` | String | `已选择` | - | 右侧面板标题 |
63
+ | `treeProps` | Object | `{ label, children, value }` | - | 树节点属性配置 |
64
+ | `defaultExpandAll` | Boolean | `true` | - | 是否默认展开所有节点 |
65
+ | `filterable` | Boolean | `false` | - | 是否支持搜索过滤 |
66
+ | `showCheckbox` | Boolean | `true` | - | 是否显示复选框 |
67
+ | `cascade` | Boolean | `true` | - | 是否级联选择 |
68
+ | `transferMode` | String | `single` | `single`, `multiple`, `parent-child` | 穿梭模式 |
69
+ | `buttonSize` | String | `small` | - | 按钮尺寸 |
70
+
71
+ ## 穿梭模式说明
72
+
73
+ | 模式 | 说明 |
74
+ |------|------|
75
+ | `single` | 单选模式,点击节点或勾选后只穿梭当前节点 |
76
+ | `multiple` | 多选模式,勾选多个节点后一次性穿梭 |
77
+ | `parent-child` | 父子模式,穿梭父节点时自动包含所有子节点 |
78
+
79
+ ## 事件
80
+
81
+ | 事件名 | 说明 | 参数 |
82
+ |--------|------|------|
83
+ | `change` | 数据变化时触发 | `{ value, addedKeys, removedKeys }` |
84
+
85
+ ## 示例
86
+
87
+ ### 父子级联穿梭
88
+
89
+ ::: demo 父子级联穿梭
90
+ ```vue
91
+ <template>
92
+ <XtTransferTree
93
+ :data="treeData"
94
+ v-model="selectedIds"
95
+ :height="400"
96
+ transfer-mode="parent-child"
97
+ @change="handleChange"
98
+ />
99
+ </template>
100
+
101
+ <script>
102
+ export default {
103
+ data() {
104
+ return {
105
+ selectedIds: [],
106
+ treeData: [
107
+ {
108
+ id: '1',
109
+ label: '部门A',
110
+ children: [
111
+ { id: '1-1', label: '员工1' },
112
+ { id: '1-2', label: '员工2' }
113
+ ]
114
+ },
115
+ {
116
+ id: '2',
117
+ label: '部门B',
118
+ children: [
119
+ { id: '2-1', label: '员工3' }
120
+ ]
121
+ }
122
+ ]
123
+ }
124
+ },
125
+ methods: {
126
+ handleChange({ value, addedKeys, removedKeys }) {
127
+ console.log('已选择:', value)
128
+ console.log('新增:', addedKeys)
129
+ console.log('移除:', removedKeys)
130
+ }
131
+ }
132
+ }
133
+ </script>
134
+ ```
135
+ :::
136
+
137
+ ### 支持搜索过滤
138
+
139
+ ::: demo 支持搜索过滤
140
+ ```vue
141
+ <template>
142
+ <XtTransferTree
143
+ :data="treeData"
144
+ v-model="selectedIds"
145
+ :height="400"
146
+ :filterable="true"
147
+ />
148
+ </template>
149
+
150
+ <script>
151
+ export default {
152
+ data() {
153
+ return {
154
+ selectedIds: [],
155
+ treeData: [
156
+ {
157
+ id: '1',
158
+ label: '水果',
159
+ children: [
160
+ { id: '1-1', label: '苹果' },
161
+ { id: '1-2', label: '香蕉' },
162
+ { id: '1-3', label: '橙子' }
163
+ ]
164
+ },
165
+ {
166
+ id: '2',
167
+ label: '蔬菜',
168
+ children: [
169
+ { id: '2-1', label: '西红柿' },
170
+ { id: '2-2', label: '黄瓜' }
171
+ ]
172
+ }
173
+ ]
174
+ }
175
+ }
176
+ }
177
+ </script>
178
+ ```
179
+ :::
180
+
181
+ ### 不级联选择
182
+
183
+ ::: demo 不级联选择
184
+ ```vue
185
+ <template>
186
+ <XtTransferTree
187
+ :data="treeData"
188
+ v-model="selectedIds"
189
+ :height="400"
190
+ :cascade="false"
191
+ />
192
+ </template>
193
+
194
+ <script>
195
+ export default {
196
+ data() {
197
+ return {
198
+ selectedIds: [],
199
+ treeData: [
200
+ {
201
+ id: '1',
202
+ label: '分类1',
203
+ children: [
204
+ { id: '1-1', label: '项目1' },
205
+ { id: '1-2', label: '项目2' }
206
+ ]
207
+ }
208
+ ]
209
+ }
210
+ }
211
+ }
212
+ </script>
213
+ ```
214
+ :::
215
+
216
+ ### 点击穿梭(无复选框)
217
+
218
+ ::: demo 点击穿梭
219
+ ```vue
220
+ <template>
221
+ <XtTransferTree
222
+ :data="treeData"
223
+ v-model="selectedIds"
224
+ :height="400"
225
+ :show-checkbox="false"
226
+ />
227
+ </template>
228
+
229
+ <script>
230
+ export default {
231
+ data() {
232
+ return {
233
+ selectedIds: [],
234
+ treeData: [
235
+ {
236
+ id: '1',
237
+ label: '选项1'
238
+ },
239
+ {
240
+ id: '2',
241
+ label: '选项2'
242
+ }
243
+ ]
244
+ }
245
+ }
246
+ }
247
+ </script>
248
+ ```
249
+ :::
250
+
251
+ ## 方法
252
+
253
+ | 方法名 | 说明 | 参数 |
254
+ |--------|------|------|
255
+ | `clearSelection` | 清空选择 | - |
256
+
257
+ ## 数据格式
258
+
259
+ ```javascript
260
+ [
261
+ {
262
+ id: 'node-id',
263
+ label: '节点名称',
264
+ children: [
265
+ {
266
+ id: 'child-id',
267
+ label: '子节点名称'
268
+ }
269
+ ]
270
+ }
271
+ ]
272
+ ```