ct-component-plus 2.2.13 → 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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ct-component-plus",
3
3
  "private": false,
4
- "version": "2.2.13",
4
+ "version": "2.2.14",
5
5
  "type": "module",
6
6
  "main": "packages/components/index.js",
7
7
  "files": [
@@ -1,12 +1,22 @@
1
1
  <template>
2
- <el-cascader ref="cascaderRef" :class="[
3
- ns.b(),
4
- ns.is('disabled', disabled),
5
- ns.is('filterable', filterable),
6
- componentId,
7
- ]" v-model="showValue" :props="propsShow" :options="optionsShow" :show-all-levels="showAllLevels"
8
- :filterable="filterable" :clearable="clearable" :disabled="disabled" :popper-class="popperClassShow"
9
- v-bind="{ ...$attrs, ...rawAttr }" />
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 (!values && values.includes(node[props.mapObj?.value || "value"])) {
176
- result.push(node[props.mapObj?.label || "label"]);
187
+ if (isArray(values) && values.includes(node?.[valueKey])) {
188
+ result.push(node?.[labelKey]);
177
189
  }
178
190
 
179
- if (node.children && node.children.length > 0) {
180
- node.children.forEach(traverse);
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 {