ct-component-plus 2.2.12 → 2.2.14
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
CHANGED
package/package.json
CHANGED
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<el-cascader
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
<el-cascader
|
|
3
|
+
ref="cascaderRef"
|
|
4
|
+
:class="[
|
|
5
|
+
ns.b(),
|
|
6
|
+
ns.is('disabled', disabled),
|
|
7
|
+
ns.is('filterable', filterable),
|
|
8
|
+
componentId,
|
|
9
|
+
]"
|
|
10
|
+
v-model="showValue"
|
|
11
|
+
:props="propsShow"
|
|
12
|
+
:options="optionsShow"
|
|
13
|
+
:show-all-levels="showAllLevels"
|
|
14
|
+
:filterable="filterable"
|
|
15
|
+
:clearable="clearable"
|
|
16
|
+
:disabled="disabled"
|
|
17
|
+
:popper-class="popperClassShow"
|
|
18
|
+
v-bind="{ ...$attrs, ...rawAttr }"
|
|
19
|
+
/>
|
|
10
20
|
<!-- <Teleport :to="appendPanelDom">
|
|
11
21
|
<span>大写的六</span>
|
|
12
22
|
</Teleport> -->
|
|
@@ -91,7 +101,7 @@ watch(
|
|
|
91
101
|
() => props.modelValue,
|
|
92
102
|
(newValue) => {
|
|
93
103
|
getCheckedText();
|
|
94
|
-
}
|
|
104
|
+
},
|
|
95
105
|
);
|
|
96
106
|
const appendPanelDom = document.createElement("div");
|
|
97
107
|
|
|
@@ -153,34 +163,38 @@ watchEffect(async () => {
|
|
|
153
163
|
cbs.afterSearch(res, optionsByApi, showValue);
|
|
154
164
|
}
|
|
155
165
|
});
|
|
156
|
-
} catch (error) {
|
|
166
|
+
} catch (error) {}
|
|
157
167
|
}
|
|
158
168
|
if (isFunction(cbs.defineSearch)) {
|
|
159
169
|
try {
|
|
160
170
|
const defineSearchHandle = await cbs.defineSearch(
|
|
161
171
|
optionsByApi,
|
|
162
|
-
showValue
|
|
172
|
+
showValue,
|
|
163
173
|
);
|
|
164
174
|
if (defineSearchHandle === false) return;
|
|
165
175
|
if (defineSearchHandle) {
|
|
166
176
|
optionsByApi.value = defineSearchHandle;
|
|
167
177
|
}
|
|
168
|
-
} catch (error) {
|
|
178
|
+
} catch (error) {}
|
|
169
179
|
}
|
|
170
180
|
});
|
|
171
181
|
function findLabelsByValues(tree, values) {
|
|
172
|
-
// 通过value值的数组获取label并返回一个包含label的数组
|
|
173
182
|
const result = [];
|
|
183
|
+
const valueKey = props.mapObj?.value || "value";
|
|
184
|
+
const labelKey = props.mapObj?.label || "label";
|
|
185
|
+
const childrenKey = props.mapObj?.children || "children";
|
|
174
186
|
function traverse(node) {
|
|
175
|
-
if (
|
|
176
|
-
result.push(node[
|
|
187
|
+
if (isArray(values) && values.includes(node?.[valueKey])) {
|
|
188
|
+
result.push(node?.[labelKey]);
|
|
177
189
|
}
|
|
178
190
|
|
|
179
|
-
|
|
180
|
-
|
|
191
|
+
const children = node?.[childrenKey];
|
|
192
|
+
if (isArray(children) && children.length > 0) {
|
|
193
|
+
children.forEach(traverse);
|
|
181
194
|
}
|
|
182
195
|
}
|
|
183
196
|
|
|
197
|
+
if (!isArray(tree)) return result;
|
|
184
198
|
tree.forEach(traverse);
|
|
185
199
|
return result;
|
|
186
200
|
}
|
|
@@ -188,8 +202,9 @@ useBuriedParams(props, emit, {
|
|
|
188
202
|
getContent: () => {
|
|
189
203
|
let data = findLabelsByValues(
|
|
190
204
|
optionsShow.value,
|
|
191
|
-
props.multiple ? showValue.value : [showValue.value]
|
|
205
|
+
props.multiple ? showValue.value : [showValue.value],
|
|
192
206
|
);
|
|
207
|
+
console.log(data, "data", showValue.value);
|
|
193
208
|
if (props.multiple) {
|
|
194
209
|
return data;
|
|
195
210
|
} else {
|
|
@@ -7,6 +7,12 @@ export const selectProps = {
|
|
|
7
7
|
...searchComponentProps,
|
|
8
8
|
modelValue: [String, Number, Array, Boolean],
|
|
9
9
|
multiple: Boolean,
|
|
10
|
+
options: {
|
|
11
|
+
type: Array,
|
|
12
|
+
default() {
|
|
13
|
+
return [];
|
|
14
|
+
},
|
|
15
|
+
},
|
|
10
16
|
filterable: Boolean,
|
|
11
17
|
api: String,
|
|
12
18
|
serviceMethod: String,
|
|
@@ -107,8 +107,23 @@ const attrs = useAttrs();
|
|
|
107
107
|
|
|
108
108
|
const ns = useNamespace("paging-select");
|
|
109
109
|
const optionsByApi = ref([]);
|
|
110
|
+
const extraOptions = computed(() => {
|
|
111
|
+
return props.options && Array.isArray(props.options) ? props.options : [];
|
|
112
|
+
});
|
|
113
|
+
|
|
110
114
|
const showOptions = computed(() => {
|
|
111
|
-
|
|
115
|
+
const map = new Map();
|
|
116
|
+
(extraOptions.value || []).forEach((item) => {
|
|
117
|
+
if (!item || item.value === undefined || item.value === null) return;
|
|
118
|
+
map.set(item.value, item);
|
|
119
|
+
});
|
|
120
|
+
(optionsByApi.value || []).forEach((item) => {
|
|
121
|
+
if (!item || item.value === undefined || item.value === null) return;
|
|
122
|
+
if (!map.has(item.value)) {
|
|
123
|
+
map.set(item.value, item);
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
return Array.from(map.values());
|
|
112
127
|
});
|
|
113
128
|
const valueModel = computed({
|
|
114
129
|
get() {
|
|
@@ -197,8 +212,8 @@ watch(
|
|
|
197
212
|
selectRef.value.selectedLabel = newVal;
|
|
198
213
|
},
|
|
199
214
|
);
|
|
200
|
-
watch(
|
|
201
|
-
const arr =
|
|
215
|
+
watch(showOptions, () => {
|
|
216
|
+
const arr = showOptions.value || [];
|
|
202
217
|
if (arr.length) {
|
|
203
218
|
filterOptions.value = arr;
|
|
204
219
|
noFilterOptions.value = false;
|