pit-docs-mcp 1.0.2
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 +180 -0
- package/dist/codegen.d.ts +5 -0
- package/dist/codegen.d.ts.map +1 -0
- package/dist/codegen.js +112 -0
- package/dist/constants.d.ts +6 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +10 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +115 -0
- package/dist/resources.d.ts +3 -0
- package/dist/resources.d.ts.map +1 -0
- package/dist/resources.js +80 -0
- package/dist/tools.d.ts +3 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +258 -0
- package/dist/utils.d.ts +26 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +198 -0
- package/docs/codegen/pit-simplify-web.md +686 -0
- package/docs/pitBusinessUi/README.md +102 -0
- package/docs/pitBusinessUi/add-date-picker.md +57 -0
- package/docs/pitBusinessUi/add-operation.md +64 -0
- package/docs/pitBusinessUi/batch-download.md +44 -0
- package/docs/pitBusinessUi/bill-tree-dialog.md +82 -0
- package/docs/pitBusinessUi/collapse.md +88 -0
- package/docs/pitBusinessUi/date-time-picker.md +74 -0
- package/docs/pitBusinessUi/design-report-explain.md +47 -0
- package/docs/pitBusinessUi/dialog.md +89 -0
- package/docs/pitBusinessUi/dic-radio.md +67 -0
- package/docs/pitBusinessUi/dic.md +78 -0
- package/docs/pitBusinessUi/document-preview.md +54 -0
- package/docs/pitBusinessUi/drawer.md +67 -0
- package/docs/pitBusinessUi/editor.md +63 -0
- package/docs/pitBusinessUi/expand-search-form.md +65 -0
- package/docs/pitBusinessUi/file-preview.md +56 -0
- package/docs/pitBusinessUi/flow-table-status.md +47 -0
- package/docs/pitBusinessUi/icon-box.md +74 -0
- package/docs/pitBusinessUi/image-preview.md +55 -0
- package/docs/pitBusinessUi/image.md +53 -0
- package/docs/pitBusinessUi/input-formatter.md +100 -0
- package/docs/pitBusinessUi/input-number.md +47 -0
- package/docs/pitBusinessUi/input-select.md +68 -0
- package/docs/pitBusinessUi/input.md +56 -0
- package/docs/pitBusinessUi/jm-preview.md +47 -0
- package/docs/pitBusinessUi/json-editor.md +71 -0
- package/docs/pitBusinessUi/loading-btn.md +64 -0
- package/docs/pitBusinessUi/monaco.md +82 -0
- package/docs/pitBusinessUi/money-input.md +59 -0
- package/docs/pitBusinessUi/pagination.md +70 -0
- package/docs/pitBusinessUi/password-strength.md +59 -0
- package/docs/pitBusinessUi/positive-number.md +63 -0
- package/docs/pitBusinessUi/preview-image.md +62 -0
- package/docs/pitBusinessUi/preview-office.md +50 -0
- package/docs/pitBusinessUi/preview.md +57 -0
- package/docs/pitBusinessUi/quill.md +52 -0
- package/docs/pitBusinessUi/runflow-btn.md +52 -0
- package/docs/pitBusinessUi/search-date-picker.md +60 -0
- package/docs/pitBusinessUi/select-bid-list.md +66 -0
- package/docs/pitBusinessUi/select-color.md +38 -0
- package/docs/pitBusinessUi/select-contract-tree.md +41 -0
- package/docs/pitBusinessUi/select-dept.md +38 -0
- package/docs/pitBusinessUi/select-project-unit.md +48 -0
- package/docs/pitBusinessUi/select-section-tree.md +45 -0
- package/docs/pitBusinessUi/select-section.md +66 -0
- package/docs/pitBusinessUi/select-string.md +60 -0
- package/docs/pitBusinessUi/select-system-unit.md +41 -0
- package/docs/pitBusinessUi/select-user-by-role.md +51 -0
- package/docs/pitBusinessUi/switch.md +43 -0
- package/docs/pitBusinessUi/table-contract.md +66 -0
- package/docs/pitBusinessUi/table-operation.md +81 -0
- package/docs/pitBusinessUi/table.md +75 -0
- package/docs/pitBusinessUi/tag.md +86 -0
- package/docs/pitBusinessUi/textarea.md +65 -0
- package/docs/pitBusinessUi/transfer-direct.md +57 -0
- package/docs/pitBusinessUi/transfer-user-project.md +78 -0
- package/docs/pitBusinessUi/transfer.md +68 -0
- package/docs/pitBusinessUi/tree-lazy.md +72 -0
- package/docs/pitBusinessUi/tree-select-name.md +59 -0
- package/docs/pitBusinessUi/tree-select-plus.md +106 -0
- package/docs/pitBusinessUi/tree-select.md +86 -0
- package/docs/pitBusinessUi/upload-avatar.md +60 -0
- package/docs/pitBusinessUi/upload-file-dialog.md +86 -0
- package/docs/pitBusinessUi/upload-file.md +77 -0
- package/docs/pitBusinessUi/upload-list-card.md +62 -0
- package/docs/pitBusinessUi/upload-table.md +77 -0
- package/docs/pitBusinessUi/user-transform.md +72 -0
- package/docs/pitBusinessUi/utils.md +272 -0
- package/docs/pitBusinessUtils/README.md +144 -0
- package/docs/pitBusinessUtils/auth.md +170 -0
- package/docs/pitBusinessUtils/clipboard.md +72 -0
- package/docs/pitBusinessUtils/filePreview.md +60 -0
- package/docs/pitBusinessUtils/formValidate.md +75 -0
- package/docs/pitBusinessUtils/generateTitle.md +49 -0
- package/docs/pitBusinessUtils/get-page-title.md +65 -0
- package/docs/pitBusinessUtils/i18n.md +130 -0
- package/docs/pitBusinessUtils/jwks.md +82 -0
- package/docs/pitBusinessUtils/oss.md +391 -0
- package/docs/pitBusinessUtils/passwordValidate.md +120 -0
- package/docs/pitBusinessUtils/pit.md +496 -0
- package/docs/pitBusinessUtils/print.md +126 -0
- package/docs/pitBusinessUtils/request.md +137 -0
- package/docs/pitBusinessUtils/scroll-to.md +68 -0
- package/docs/pitBusinessUtils/utils.md +762 -0
- package/docs/pitBusinessUtils/validate.md +224 -0
- package/docs/pitElementUi/alert.md +238 -0
- package/docs/pitElementUi/avatar.md +147 -0
- package/docs/pitElementUi/backtop.md +60 -0
- package/docs/pitElementUi/badge.md +120 -0
- package/docs/pitElementUi/base-tabs.md +73 -0
- package/docs/pitElementUi/border.md +135 -0
- package/docs/pitElementUi/breadcrumb.md +44 -0
- package/docs/pitElementUi/button.md +301 -0
- package/docs/pitElementUi/calendar.md +66 -0
- package/docs/pitElementUi/card.md +170 -0
- package/docs/pitElementUi/carousel.md +212 -0
- package/docs/pitElementUi/cascader.md +1966 -0
- package/docs/pitElementUi/checkbox.md +283 -0
- package/docs/pitElementUi/collapse.md +131 -0
- package/docs/pitElementUi/color-picker.md +123 -0
- package/docs/pitElementUi/color.md +244 -0
- package/docs/pitElementUi/container.md +240 -0
- package/docs/pitElementUi/custom-theme.md +131 -0
- package/docs/pitElementUi/date-picker.md +448 -0
- package/docs/pitElementUi/datetime-picker.md +254 -0
- package/docs/pitElementUi/descriptions.md +191 -0
- package/docs/pitElementUi/dialog-header.md +53 -0
- package/docs/pitElementUi/dialog.md +239 -0
- package/docs/pitElementUi/divider.md +61 -0
- package/docs/pitElementUi/drawer.md +307 -0
- package/docs/pitElementUi/dropdown.md +308 -0
- package/docs/pitElementUi/empty.md +61 -0
- package/docs/pitElementUi/font-family.md +90 -0
- package/docs/pitElementUi/form-base.md +1239 -0
- package/docs/pitElementUi/form-item-checkbox-group.md +48 -0
- package/docs/pitElementUi/form-item-date.md +60 -0
- package/docs/pitElementUi/form-item-dic.md +18 -0
- package/docs/pitElementUi/form-item-editor.md +16 -0
- package/docs/pitElementUi/form-item-input-money.md +19 -0
- package/docs/pitElementUi/form-item-input-number.md +20 -0
- package/docs/pitElementUi/form-item-input.md +18 -0
- package/docs/pitElementUi/form-item-radio-group.md +21 -0
- package/docs/pitElementUi/form-item-select.md +21 -0
- package/docs/pitElementUi/form-item-switch.md +15 -0
- package/docs/pitElementUi/form-item-textarea.md +20 -0
- package/docs/pitElementUi/form-item-tree-select.md +27 -0
- package/docs/pitElementUi/form-item-upload-card.md +18 -0
- package/docs/pitElementUi/form-item-upload.md +1 -0
- package/docs/pitElementUi/form-two.md +102 -0
- package/docs/pitElementUi/form.md +952 -0
- package/docs/pitElementUi/i18n.md +228 -0
- package/docs/pitElementUi/icon-custom.md +99 -0
- package/docs/pitElementUi/icon-line-custom.md +12 -0
- package/docs/pitElementUi/icon.md +28 -0
- package/docs/pitElementUi/image.md +178 -0
- package/docs/pitElementUi/infiniteScroll.md +87 -0
- package/docs/pitElementUi/input-number.md +197 -0
- package/docs/pitElementUi/input-select.md +1 -0
- package/docs/pitElementUi/input.md +800 -0
- package/docs/pitElementUi/installation.md +9 -0
- package/docs/pitElementUi/layout-column.md +376 -0
- package/docs/pitElementUi/layout-tree.md +715 -0
- package/docs/pitElementUi/layout.md +354 -0
- package/docs/pitElementUi/link.md +66 -0
- package/docs/pitElementUi/loading.md +208 -0
- package/docs/pitElementUi/menu.md +403 -0
- package/docs/pitElementUi/message-box.md +326 -0
- package/docs/pitElementUi/message.md +219 -0
- package/docs/pitElementUi/notification.md +311 -0
- package/docs/pitElementUi/page-header.md +40 -0
- package/docs/pitElementUi/pagination.md +200 -0
- package/docs/pitElementUi/popconfirm.md +60 -0
- package/docs/pitElementUi/popover.md +167 -0
- package/docs/pitElementUi/progress.md +178 -0
- package/docs/pitElementUi/quickstart.md +290 -0
- package/docs/pitElementUi/radio.md +211 -0
- package/docs/pitElementUi/rate.md +135 -0
- package/docs/pitElementUi/result.md +76 -0
- package/docs/pitElementUi/select-tree.md +661 -0
- package/docs/pitElementUi/select.md +586 -0
- package/docs/pitElementUi/skeleton.md +316 -0
- package/docs/pitElementUi/slider.md +237 -0
- package/docs/pitElementUi/steps.md +154 -0
- package/docs/pitElementUi/switch.md +142 -0
- package/docs/pitElementUi/table.md +4023 -0
- package/docs/pitElementUi/tabs.md +303 -0
- package/docs/pitElementUi/tag.md +203 -0
- package/docs/pitElementUi/time-picker.md +199 -0
- package/docs/pitElementUi/timeline.md +154 -0
- package/docs/pitElementUi/tooltip.md +177 -0
- package/docs/pitElementUi/transfer.md +249 -0
- package/docs/pitElementUi/transition.md +155 -0
- package/docs/pitElementUi/tree.md +1157 -0
- package/docs/pitElementUi/typography.md +151 -0
- package/docs/pitElementUi/upload-table.md +39 -0
- package/docs/pitElementUi/upload.md +392 -0
- package/docs/pitElementUi/virtual-list.md +154 -0
- package/docs/pitElementUi/virtual-select-tree.md +243 -0
- package/docs/pitElementUi/virtual-select.md +451 -0
- package/docs/pitElementUi/virtual-table-column.md +1 -0
- package/docs/pitElementUi/virtual-table.md +490 -0
- package/docs/pitElementUi/virtual-tree.md +119 -0
- package/package.json +33 -0
|
@@ -0,0 +1,661 @@
|
|
|
1
|
+
## 树型选择器
|
|
2
|
+
|
|
3
|
+
### 基础用法
|
|
4
|
+
|
|
5
|
+
在select的基础上添加树形选择功能,并提供丰富的操作模式。
|
|
6
|
+
|
|
7
|
+
:::demo 通过options进行赋值,默认为单选模式。允许在data上设置`isDisabled`为true,禁用选项。通过设置`clearable`为true(默认),开启清空功能。defaultExpandLevel加载时应自动扩展多少级分支节点。设置 Infinity 为默认使所有分支节点扩展。
|
|
8
|
+
|
|
9
|
+
```html
|
|
10
|
+
|
|
11
|
+
<template>
|
|
12
|
+
<div>
|
|
13
|
+
<div style="
|
|
14
|
+
margin-bottom: 1rem;
|
|
15
|
+
background-color: #F5F7FA;
|
|
16
|
+
padding: 10px;
|
|
17
|
+
border-radius: 5px">
|
|
18
|
+
value: {{ value }}
|
|
19
|
+
</div>
|
|
20
|
+
<el-select-tree
|
|
21
|
+
:options="options"
|
|
22
|
+
v-model="value"
|
|
23
|
+
:limit="1"
|
|
24
|
+
multiple
|
|
25
|
+
:limitText="limitText"
|
|
26
|
+
valueConsistsOf="ALL"
|
|
27
|
+
noOptionsText="暂无数据"
|
|
28
|
+
noChildrenText="没有数据了"
|
|
29
|
+
noResultsText="暂无数据"
|
|
30
|
+
placeholder="请选择"
|
|
31
|
+
/>
|
|
32
|
+
</div>
|
|
33
|
+
</template>
|
|
34
|
+
|
|
35
|
+
<script>
|
|
36
|
+
function dig(path = '0', level = 3) {
|
|
37
|
+
const list = [];
|
|
38
|
+
for (let i = 0; i < 10; i += 1) {
|
|
39
|
+
const key = `${path}-${i}`;
|
|
40
|
+
const treeNode = {
|
|
41
|
+
label: key,
|
|
42
|
+
key,
|
|
43
|
+
id: key
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
if (level > 0) {
|
|
47
|
+
treeNode.children = dig(key, level - 1);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
list.push(treeNode);
|
|
51
|
+
}
|
|
52
|
+
return list;
|
|
53
|
+
}
|
|
54
|
+
const OPTIONS = dig()
|
|
55
|
+
|
|
56
|
+
export default {
|
|
57
|
+
data() {
|
|
58
|
+
return {
|
|
59
|
+
value: '',
|
|
60
|
+
checked: null,
|
|
61
|
+
size: 'mini', // medium small mini
|
|
62
|
+
limitText: (count) => `还有 ${count} 个`,
|
|
63
|
+
options: OPTIONS
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
computed: {
|
|
68
|
+
showMultiple() {
|
|
69
|
+
return ['FLAT', 'LIMIT TWO', 'CLEAR_ON_SELECT'].includes(this.checked)
|
|
70
|
+
},
|
|
71
|
+
|
|
72
|
+
checkedOptionsKeys() {
|
|
73
|
+
return Object.keys(this.checkedOptions)
|
|
74
|
+
},
|
|
75
|
+
|
|
76
|
+
checkedOptionsValues() {
|
|
77
|
+
return Object.values(this.checkedOptions)
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
checkedOptionsLen() {
|
|
81
|
+
const len = Math.floor(this.checkedOptionsKeys.length / 3)
|
|
82
|
+
const isMode = this.checkedOptionsKeys.length % 3 === 0
|
|
83
|
+
return !isMode ? len + 1 : len
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
|
|
87
|
+
watch: {
|
|
88
|
+
checked: {
|
|
89
|
+
handler(val) {
|
|
90
|
+
if (val === 'NO_OPTIONS') this.options = []
|
|
91
|
+
else this.options = OPTIONS
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
}
|
|
96
|
+
</script>
|
|
97
|
+
```
|
|
98
|
+
:::
|
|
99
|
+
|
|
100
|
+
:::demo 通过options进行赋值,默认为单选模式。允许在data上设置`isDisabled`为true,禁用选项。通过设置`clearable`为true(默认),开启清空功能。defaultExpandLevel加载时应自动扩展多少级分支节点。设置 Infinity 为默认使所有分支节点扩展。
|
|
101
|
+
|
|
102
|
+
```html
|
|
103
|
+
|
|
104
|
+
<template>
|
|
105
|
+
<div>
|
|
106
|
+
<div style="
|
|
107
|
+
margin-bottom: 1rem;
|
|
108
|
+
background-color: #F5F7FA;
|
|
109
|
+
padding: 10px;
|
|
110
|
+
border-radius: 5px">
|
|
111
|
+
value: {{ value }}
|
|
112
|
+
</div>
|
|
113
|
+
<el-radio-group
|
|
114
|
+
v-model="checked"
|
|
115
|
+
style="padding: 1rem 0"
|
|
116
|
+
v-for="index in checkedOptionsLen"
|
|
117
|
+
:key="index"
|
|
118
|
+
>
|
|
119
|
+
<template v-for="jndex in 3">
|
|
120
|
+
<el-radio
|
|
121
|
+
v-if="checkedOptionsKeys[(index - 1) * 3 + (jndex - 1)]"
|
|
122
|
+
:key="checkedOptionsKeys[(index - 1) * 3 + (jndex -1)]"
|
|
123
|
+
:label="checkedOptionsKeys[(index - 1) * 3 + (jndex -1)]">
|
|
124
|
+
{{ checkedOptionsValues[(index - 1) * 3 + (jndex -1)] }}
|
|
125
|
+
</el-radio>
|
|
126
|
+
</template>
|
|
127
|
+
</el-radio-group>
|
|
128
|
+
<el-select-tree
|
|
129
|
+
:options="options"
|
|
130
|
+
v-model="value"
|
|
131
|
+
:size="size"
|
|
132
|
+
:multiple="showMultiple"
|
|
133
|
+
:flat="checked === 'FLAT'"
|
|
134
|
+
:always-open="checked === 'ALWAYS_OPEN'"
|
|
135
|
+
:disabled="checked === 'DISABLED'"
|
|
136
|
+
:disable-branch-nodes="checked === 'DISABLED_BRANCH_NODES'"
|
|
137
|
+
:branch-nodes-first="checked === 'BRANCH_NODES_FIRST'"
|
|
138
|
+
:limit="checked === 'LIMIT TWO' ? 2 : Infinity"
|
|
139
|
+
:show-count="checked === 'SHOW_COUNT'"
|
|
140
|
+
:searchable="checked !== 'NO_SEARCHABLE'"
|
|
141
|
+
:backspace-removes="checked !== 'BACK_SPACE_REMOVES'"
|
|
142
|
+
:clearable="checked !== 'CLEARABLE'"
|
|
143
|
+
:clear-on-select="checked === 'CLEAR_ON_SELECT'"
|
|
144
|
+
:close-on-select="checked !== 'CLOSE_ON_SELECT'"
|
|
145
|
+
:flatten-search-results="checked === 'FLATTEN_SEARCH_RESULT'"
|
|
146
|
+
:disable-fuzzy-matching="checked === 'DISABLED_FUZZY_MATCHING'"
|
|
147
|
+
:search-nested="checked === 'SEARCH_NESTED'"
|
|
148
|
+
:default-expand-level="1"
|
|
149
|
+
:append-to-body="checked === 'appendToBody'"
|
|
150
|
+
/>
|
|
151
|
+
</div>
|
|
152
|
+
</template>
|
|
153
|
+
|
|
154
|
+
<script>
|
|
155
|
+
function dig(path = '0', level = 3) {
|
|
156
|
+
const list = [];
|
|
157
|
+
for (let i = 0; i < 10; i += 1) {
|
|
158
|
+
const key = `${path}-${i}`;
|
|
159
|
+
const treeNode = {
|
|
160
|
+
label: key,
|
|
161
|
+
key,
|
|
162
|
+
id: key
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
if (level > 0) {
|
|
166
|
+
treeNode.children = dig(key, level - 1);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
list.push(treeNode);
|
|
170
|
+
}
|
|
171
|
+
return list;
|
|
172
|
+
}
|
|
173
|
+
const OPTIONS = dig()
|
|
174
|
+
|
|
175
|
+
export default {
|
|
176
|
+
data() {
|
|
177
|
+
return {
|
|
178
|
+
value: '',
|
|
179
|
+
checked: null,
|
|
180
|
+
size: 'mini', // medium small mini
|
|
181
|
+
checkedOptions: {
|
|
182
|
+
'DISABLED': '禁用操作',
|
|
183
|
+
'DISABLED_BRANCH_NODES': '禁用分支选项',
|
|
184
|
+
'ALWAYS_OPEN': '保持打开菜单',
|
|
185
|
+
'BRANCH_NODES_FIRST': '在叶节点之前显示分支节点',
|
|
186
|
+
'FLAT': '平铺模式(同联合模式相对)',
|
|
187
|
+
'LIMIT TWO': '限制显示长度模式为2(仅多选模式)',
|
|
188
|
+
'NO_OPTIONS': '不存在Options值时',
|
|
189
|
+
'SHOW_COUNT': '分支节点显示数量统计',
|
|
190
|
+
'CLEAR_ON_SELECT': '选择选项后是否清除搜索输入(仅多选模式)',
|
|
191
|
+
'NO_SEARCHABLE': '禁用搜索(默认开启)',
|
|
192
|
+
'BACK_SPACE_REMOVES': '没有输入时,不允许删除最后一项(默认允许)',
|
|
193
|
+
'CLEARABLE': '是否显示重置值的“×”按钮(默认显示)',
|
|
194
|
+
'CLOSE_ON_SELECT': '单选模式,选择不关闭menu',
|
|
195
|
+
'FLATTEN_SEARCH_RESULT': '搜索时是否展平树(仅同步)',
|
|
196
|
+
'DISABLED_FUZZY_MATCHING': '设置为true禁用默认情况下启用的模糊匹配功。',
|
|
197
|
+
'SEARCH_NESTED': '巢状搜索',
|
|
198
|
+
'appendToBody': '添加到body'
|
|
199
|
+
},
|
|
200
|
+
options: OPTIONS
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
|
|
204
|
+
computed: {
|
|
205
|
+
showMultiple() {
|
|
206
|
+
return ['FLAT', 'LIMIT TWO', 'CLEAR_ON_SELECT'].includes(this.checked)
|
|
207
|
+
},
|
|
208
|
+
|
|
209
|
+
checkedOptionsKeys() {
|
|
210
|
+
return Object.keys(this.checkedOptions)
|
|
211
|
+
},
|
|
212
|
+
|
|
213
|
+
checkedOptionsValues() {
|
|
214
|
+
return Object.values(this.checkedOptions)
|
|
215
|
+
},
|
|
216
|
+
|
|
217
|
+
checkedOptionsLen() {
|
|
218
|
+
const len = Math.floor(this.checkedOptionsKeys.length / 3)
|
|
219
|
+
const isMode = this.checkedOptionsKeys.length % 3 === 0
|
|
220
|
+
return !isMode ? len + 1 : len
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
|
|
224
|
+
watch: {
|
|
225
|
+
checked: {
|
|
226
|
+
handler(val) {
|
|
227
|
+
if (val === 'NO_OPTIONS') this.options = []
|
|
228
|
+
else this.options = OPTIONS
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
},
|
|
232
|
+
}
|
|
233
|
+
</script>
|
|
234
|
+
```
|
|
235
|
+
:::
|
|
236
|
+
|
|
237
|
+
### 节点选择模式
|
|
238
|
+
|
|
239
|
+
对于非固定和多选模式,如果选中了分支节点及其所有后代,则vue-treeselect会将它们组合到值数组中的单个项目中,如以下示例所示。通过使用valueConsistsOf道具,您可以更改该行为。该道具有四个选项:
|
|
240
|
+
|
|
241
|
+
* "ALL" - 选中的所有节点都将包含在 value 数组中
|
|
242
|
+
* "BRANCH_PRIORITY"(默认)-如果选中了分支节点,则其所有后代将被排除在value 数组之外
|
|
243
|
+
* "LEAF_PRIORITY" - 如果选中了分支节点,则此节点本身及其分支后代将从value阵列中排除,但其叶后代将包括在内
|
|
244
|
+
* "ALL_WITH_INDETERMINATE" -选中的任何节点将包括在value 数组中,另外还有不确定的节点
|
|
245
|
+
|
|
246
|
+
:::demo 通过使用valueConsistsOf道具,来变更选择模式。
|
|
247
|
+
```html
|
|
248
|
+
|
|
249
|
+
<template>
|
|
250
|
+
<div>
|
|
251
|
+
<div style="
|
|
252
|
+
margin-bottom: 1rem;
|
|
253
|
+
background-color: #F5F7FA;
|
|
254
|
+
padding: 10px;
|
|
255
|
+
border-radius: 5px ">
|
|
256
|
+
value: {{ value }}
|
|
257
|
+
</div>
|
|
258
|
+
<el-select-tree :options="options" :multiple="true" v-model="value" :value-consists-of="checked" />
|
|
259
|
+
<el-radio-group v-model="checked" style="padding: 1rem 0">
|
|
260
|
+
<el-radio v-for="check in checkedOptions" :key="check" :label="check" >{{ check }}</el-radio>
|
|
261
|
+
</el-radio-group>
|
|
262
|
+
</div>
|
|
263
|
+
</template>
|
|
264
|
+
|
|
265
|
+
<script>
|
|
266
|
+
export default {
|
|
267
|
+
data() {
|
|
268
|
+
return {
|
|
269
|
+
value: null,
|
|
270
|
+
checked: 'BRANCH_PRIORITY',
|
|
271
|
+
checkedOptions: [
|
|
272
|
+
'ALL',
|
|
273
|
+
'BRANCH_PRIORITY',
|
|
274
|
+
'LEAF_PRIORITY',
|
|
275
|
+
'ALL_WITH_INDETERMINATE'
|
|
276
|
+
],
|
|
277
|
+
options: [{
|
|
278
|
+
id: 'fruits 1',
|
|
279
|
+
label: 'Fruits',
|
|
280
|
+
children: [{
|
|
281
|
+
id: 'apple',
|
|
282
|
+
label: 'Apple 🍎',
|
|
283
|
+
isNew: true,
|
|
284
|
+
}, {
|
|
285
|
+
id: 'grapes',
|
|
286
|
+
label: 'Grapes 🍇',
|
|
287
|
+
isDisabled: true,
|
|
288
|
+
}, {
|
|
289
|
+
id: 'pear',
|
|
290
|
+
label: 'Pear 🍐',
|
|
291
|
+
isDisabled: true,
|
|
292
|
+
}, {
|
|
293
|
+
id: 'strawberry',
|
|
294
|
+
label: 'Strawberry 🍓',
|
|
295
|
+
}, {
|
|
296
|
+
id: 'watermelon',
|
|
297
|
+
label: 'Watermelon 🍉',
|
|
298
|
+
}],
|
|
299
|
+
}, {
|
|
300
|
+
id: 'vegetables',
|
|
301
|
+
label: 'Vegetables',
|
|
302
|
+
children: [{
|
|
303
|
+
id: 'corn',
|
|
304
|
+
label: 'Corn 🌽',
|
|
305
|
+
}, {
|
|
306
|
+
id: 'carrot',
|
|
307
|
+
label: 'Carrot 🥕',
|
|
308
|
+
}, {
|
|
309
|
+
id: 'eggplant',
|
|
310
|
+
label: 'Eggplant 🍆',
|
|
311
|
+
}, {
|
|
312
|
+
id: 'tomato',
|
|
313
|
+
label: 'Tomato 🍅',
|
|
314
|
+
}],
|
|
315
|
+
}],
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
</script>
|
|
320
|
+
```
|
|
321
|
+
:::
|
|
322
|
+
|
|
323
|
+
### 平面模式和排序值
|
|
324
|
+
|
|
325
|
+
在前面的所有示例中,我们使用了默认的非平坦模式vue-treeselect,这意味着:
|
|
326
|
+
* 每当分支节点被检查时,其所有子节点也将被检查
|
|
327
|
+
* 每当分支节点检查所有子节点时,分支节点本身也将被检查
|
|
328
|
+
|
|
329
|
+
有时我们不需要那种机制,并且希望分支节点和叶子节点不会相互影响。在这种情况下,应使用平面模式,如下所示。
|
|
330
|
+
|
|
331
|
+
如果要控制所选选项的显示顺序,请使用sortValueBy道具。该道具有三个选择:
|
|
332
|
+
* "ORDER_SELECTED" (默认)-选择订单
|
|
333
|
+
* "LEVEL" - 选择级别: C 🡒 BB 🡒 AAA
|
|
334
|
+
* "INDEX" - 选项索引: AAA 🡒 BB 🡒 C
|
|
335
|
+
|
|
336
|
+
:::demo 首先通过flat开启平面模式,再请使用sortValueBy道具,来变更排序模式。
|
|
337
|
+
```html
|
|
338
|
+
|
|
339
|
+
<template>
|
|
340
|
+
<div>
|
|
341
|
+
<div style="
|
|
342
|
+
margin-bottom: 1rem;
|
|
343
|
+
background-color: #F5F7FA;
|
|
344
|
+
padding: 10px;
|
|
345
|
+
border-radius: 5px ">
|
|
346
|
+
value: {{ sortedValue }}
|
|
347
|
+
</div>
|
|
348
|
+
<el-select-tree
|
|
349
|
+
flat
|
|
350
|
+
:options="options"
|
|
351
|
+
:multiple="true"
|
|
352
|
+
v-model="sortedValue"
|
|
353
|
+
:sort-value-by="sorted"
|
|
354
|
+
/>
|
|
355
|
+
<el-radio-group v-model="sorted" style="padding: 1rem 0">
|
|
356
|
+
<el-radio v-for="check in sortedOptions" :key="check" :label="check">{{ check }}</el-radio>
|
|
357
|
+
</el-radio-group>
|
|
358
|
+
</div>
|
|
359
|
+
</template>
|
|
360
|
+
|
|
361
|
+
<script>
|
|
362
|
+
export default {
|
|
363
|
+
data() {
|
|
364
|
+
return {
|
|
365
|
+
sorted: 'ORDER_SELECTED',
|
|
366
|
+
sortedValue: ['C', 'AAA', 'BB'],
|
|
367
|
+
sortedOptions: ['ORDER_SELECTED', 'LEVEL', 'INDEX'],
|
|
368
|
+
options: [
|
|
369
|
+
{
|
|
370
|
+
id: 'A',
|
|
371
|
+
label: 'A',
|
|
372
|
+
children: [{
|
|
373
|
+
id: 'AA',
|
|
374
|
+
label: 'AA',
|
|
375
|
+
}, {
|
|
376
|
+
id: 'AB',
|
|
377
|
+
label: 'AB',
|
|
378
|
+
}, {
|
|
379
|
+
id: 'AC',
|
|
380
|
+
label: 'AC',
|
|
381
|
+
children: [
|
|
382
|
+
{ id: 'AAA', label: 'AAA' }
|
|
383
|
+
]
|
|
384
|
+
}, ],
|
|
385
|
+
}, {
|
|
386
|
+
id: 'B',
|
|
387
|
+
label: 'B',
|
|
388
|
+
children: [{
|
|
389
|
+
id: 'BA',
|
|
390
|
+
label: 'BA',
|
|
391
|
+
},{
|
|
392
|
+
id: 'BB',
|
|
393
|
+
label: 'BB',
|
|
394
|
+
}],
|
|
395
|
+
}, {
|
|
396
|
+
id: 'C',
|
|
397
|
+
label: 'C',
|
|
398
|
+
children: [{
|
|
399
|
+
id: 'CA',
|
|
400
|
+
label: 'CA',
|
|
401
|
+
}],
|
|
402
|
+
}],
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
</script>
|
|
407
|
+
```
|
|
408
|
+
:::
|
|
409
|
+
|
|
410
|
+
### 延迟加载
|
|
411
|
+
|
|
412
|
+
如果您有大量深度嵌套的选项,则可能只希望在初始加载时加载最顶层的选项,而仅在需要时加载其余选项。您可以通过执行以下步骤来实现:
|
|
413
|
+
|
|
414
|
+
* 通过设置声明一个卸载的分支节点children: null
|
|
415
|
+
* 添加 loadOptions 道具
|
|
416
|
+
* 每当卸载的分支节点被扩展时, loadOptions({ action, parentNode, callback, instanceId }) 都会被调用,然后您就可以执行从远程服务器请求数据的作业
|
|
417
|
+
|
|
418
|
+
:::demo
|
|
419
|
+
```html
|
|
420
|
+
|
|
421
|
+
<template>
|
|
422
|
+
<div>
|
|
423
|
+
<div style="
|
|
424
|
+
margin-bottom: 1rem;
|
|
425
|
+
background-color: #F5F7FA;
|
|
426
|
+
padding: 10px;
|
|
427
|
+
border-radius: 5px ">
|
|
428
|
+
value: {{ value }}
|
|
429
|
+
</div>
|
|
430
|
+
<el-select-tree
|
|
431
|
+
:multiple="true"
|
|
432
|
+
:options="options"
|
|
433
|
+
:load-options="loadOptions"
|
|
434
|
+
placeholder="尝试展开任意分支节点"
|
|
435
|
+
v-model="value"
|
|
436
|
+
/>
|
|
437
|
+
</div>
|
|
438
|
+
</template>
|
|
439
|
+
|
|
440
|
+
<script>
|
|
441
|
+
const simulateAsyncOperation = fn => {
|
|
442
|
+
setTimeout(fn, 200)
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
export default {
|
|
446
|
+
data() {
|
|
447
|
+
return {
|
|
448
|
+
value: [],
|
|
449
|
+
options: [{
|
|
450
|
+
id: 'success',
|
|
451
|
+
label: '存在子选项',
|
|
452
|
+
// Declare an unloaded branch node.
|
|
453
|
+
children: null,
|
|
454
|
+
}, {
|
|
455
|
+
id: 'no-children-show-message',
|
|
456
|
+
label: '没有子选项,显示提示信息',
|
|
457
|
+
children: null,
|
|
458
|
+
}, {
|
|
459
|
+
id: 'no-children',
|
|
460
|
+
label: '没有子选项,不显示提示信息(改为隐藏箭头标识)—— 不建议使用',
|
|
461
|
+
children: null,
|
|
462
|
+
isLeaf: false,
|
|
463
|
+
},{
|
|
464
|
+
id: 'failure',
|
|
465
|
+
label: '由于各种原因造成的失败',
|
|
466
|
+
children: null,
|
|
467
|
+
}, {
|
|
468
|
+
id: 'is Leaf',
|
|
469
|
+
label: '允许设置isLeaf为true将节点标记为叶子节点,优先级大children',
|
|
470
|
+
children: null,
|
|
471
|
+
isLeaf: true,
|
|
472
|
+
}],
|
|
473
|
+
}
|
|
474
|
+
},
|
|
475
|
+
|
|
476
|
+
methods: {
|
|
477
|
+
loadOptions({action, parentNode, callback}) {
|
|
478
|
+
// LOAD_CHILDREN_OPTIONS
|
|
479
|
+
if (action === 'LOAD_CHILDREN_OPTIONS') {
|
|
480
|
+
switch (parentNode.id) {
|
|
481
|
+
case 'success': {
|
|
482
|
+
simulateAsyncOperation(() => {
|
|
483
|
+
parentNode.children = [{
|
|
484
|
+
id: 'child',
|
|
485
|
+
label: 'Child option',
|
|
486
|
+
}]
|
|
487
|
+
callback()
|
|
488
|
+
})
|
|
489
|
+
break
|
|
490
|
+
}
|
|
491
|
+
case 'no-children': {
|
|
492
|
+
simulateAsyncOperation(() => {
|
|
493
|
+
// this.$set(parentNode, 'isLeaf', true)
|
|
494
|
+
parentNode.isLeaf = true
|
|
495
|
+
callback()
|
|
496
|
+
})
|
|
497
|
+
break
|
|
498
|
+
}
|
|
499
|
+
case 'no-children-show-message': {
|
|
500
|
+
simulateAsyncOperation(() => {
|
|
501
|
+
// parentNode.children = null
|
|
502
|
+
callback()
|
|
503
|
+
})
|
|
504
|
+
break
|
|
505
|
+
}
|
|
506
|
+
case 'failure': {
|
|
507
|
+
simulateAsyncOperation(() => {
|
|
508
|
+
callback(new Error('加载失败,网络错误。'))
|
|
509
|
+
})
|
|
510
|
+
break
|
|
511
|
+
}
|
|
512
|
+
default: /* empty */
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
</script>
|
|
519
|
+
```
|
|
520
|
+
:::
|
|
521
|
+
|
|
522
|
+
### 异步搜索
|
|
523
|
+
|
|
524
|
+
vue-treeselect支持根据用户类型动态加载和更改整个选项列表。默认情况下,vue-treeselect将缓存每个AJAX请求的结果,因此用户可以减少等待时间。
|
|
525
|
+
|
|
526
|
+
:::demo
|
|
527
|
+
```html
|
|
528
|
+
|
|
529
|
+
<template>
|
|
530
|
+
<div>
|
|
531
|
+
<div style="
|
|
532
|
+
margin-bottom: 1rem;
|
|
533
|
+
background-color: #F5F7FA;
|
|
534
|
+
padding: 10px;
|
|
535
|
+
border-radius: 5px ">
|
|
536
|
+
value: {{ value }}
|
|
537
|
+
</div>
|
|
538
|
+
<el-select-tree
|
|
539
|
+
:multiple="true"
|
|
540
|
+
:async="true"
|
|
541
|
+
:load-options="loadOptions"
|
|
542
|
+
v-model="value"
|
|
543
|
+
/>
|
|
544
|
+
</div>
|
|
545
|
+
</template>
|
|
546
|
+
|
|
547
|
+
<script>
|
|
548
|
+
const simulateAsyncOperation = fn => {
|
|
549
|
+
setTimeout(fn, 2000)
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
export default {
|
|
553
|
+
data() {
|
|
554
|
+
return {
|
|
555
|
+
value: [],
|
|
556
|
+
}
|
|
557
|
+
},
|
|
558
|
+
|
|
559
|
+
methods: {
|
|
560
|
+
loadOptions({action, searchQuery, callback}) {
|
|
561
|
+
// LOAD_CHILDREN_OPTIONS
|
|
562
|
+
if (action === 'ASYNC_SEARCH') {
|
|
563
|
+
simulateAsyncOperation(() => {
|
|
564
|
+
const options = [ 1, 2, 3, 4, 5 ].map(i => ({
|
|
565
|
+
id: `${searchQuery}-${i}`,
|
|
566
|
+
label: `${searchQuery}-${i}`,
|
|
567
|
+
}))
|
|
568
|
+
callback(null, options)
|
|
569
|
+
})
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
</script>
|
|
575
|
+
```
|
|
576
|
+
:::
|
|
577
|
+
|
|
578
|
+
### 自定义键名 & 自定义选项标签 & 自定义值标签
|
|
579
|
+
|
|
580
|
+
如果通过AJAX加载的选项数据与vue-treeselect要求的数据结构不同,
|
|
581
|
+
例如,您的数据具有name属性,但vue-treeselect需要label,则可能需要自定义键名。
|
|
582
|
+
在这种情况下,您可以提供一个称为函数的propnormalizer,在数据初始化期间它将传递给树中的每个节点。
|
|
583
|
+
使用此函数创建并返回转换后的对象。
|
|
584
|
+
|
|
585
|
+
:::demo 您可以通过option-label自定义每个选项的标签、value-label自定义选项后的输出值
|
|
586
|
+
```html
|
|
587
|
+
|
|
588
|
+
<template>
|
|
589
|
+
<div>
|
|
590
|
+
<div style="
|
|
591
|
+
margin-bottom: 1rem;
|
|
592
|
+
background-color: #F5F7FA;
|
|
593
|
+
padding: 10px;
|
|
594
|
+
border-radius: 5px ">
|
|
595
|
+
value: {{ value }}
|
|
596
|
+
</div>
|
|
597
|
+
<el-select-tree
|
|
598
|
+
:options="options"
|
|
599
|
+
:multiple="true"
|
|
600
|
+
:normalizer="normalizer"
|
|
601
|
+
value-consists-of="ALL"
|
|
602
|
+
v-model="value"
|
|
603
|
+
>
|
|
604
|
+
<label
|
|
605
|
+
slot="option-label"
|
|
606
|
+
slot-scope="{ node, shouldShowCount, count, labelClassName, countClassName }"
|
|
607
|
+
:class="labelClassName">
|
|
608
|
+
{{ node.isBranch ? 'Branch' : 'Leaf' }}: {{ node.label }}
|
|
609
|
+
<span v-if="shouldShowCount" :class="countClassName">({{ count }})</span>
|
|
610
|
+
</label>
|
|
611
|
+
|
|
612
|
+
<div slot="value-label" slot-scope="{ node }">{{ node.isBranch ? 'Branch' : 'Leaf' }}: {{ node.label }}</div>
|
|
613
|
+
</el-select-tree>
|
|
614
|
+
</div>
|
|
615
|
+
</template>
|
|
616
|
+
|
|
617
|
+
<script>
|
|
618
|
+
const simulateAsyncOperation = fn => {
|
|
619
|
+
setTimeout(fn, 2000)
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
export default {
|
|
623
|
+
data() {
|
|
624
|
+
return {
|
|
625
|
+
value: [],
|
|
626
|
+
options: [
|
|
627
|
+
{
|
|
628
|
+
value: 'A',
|
|
629
|
+
name: 'A',
|
|
630
|
+
child: [
|
|
631
|
+
{
|
|
632
|
+
value: 'AA',
|
|
633
|
+
name: 'AA',
|
|
634
|
+
child: []
|
|
635
|
+
},
|
|
636
|
+
{
|
|
637
|
+
value: 'AB',
|
|
638
|
+
name: 'AB',
|
|
639
|
+
child: [],
|
|
640
|
+
leaf: true
|
|
641
|
+
}
|
|
642
|
+
]
|
|
643
|
+
}
|
|
644
|
+
]
|
|
645
|
+
}
|
|
646
|
+
},
|
|
647
|
+
|
|
648
|
+
methods: {
|
|
649
|
+
normalizer(node) {
|
|
650
|
+
return {
|
|
651
|
+
id: node.value,
|
|
652
|
+
label: node.name,
|
|
653
|
+
children: node.child,
|
|
654
|
+
isLeaf: node.leaf
|
|
655
|
+
}
|
|
656
|
+
},
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
</script>
|
|
660
|
+
```
|
|
661
|
+
:::
|