ct-component-plus 2.2.10 → 2.2.12

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
@@ -1,4 +1,4 @@
1
- # v2.2.10版本更新内容:
1
+ # v2.2.12版本更新内容:
2
2
 
3
3
  1. 优化分页下拉组件搜索相关逻辑
4
4
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ct-component-plus",
3
3
  "private": false,
4
- "version": "2.2.10",
4
+ "version": "2.2.12",
5
5
  "type": "module",
6
6
  "main": "packages/components/index.js",
7
7
  "files": [
@@ -7,7 +7,7 @@
7
7
  collapse-tags
8
8
  v-bind="rawAttr"
9
9
  :multiple="multiple"
10
- :filterable="filterable"
10
+ :filterable="filterable && !multiple"
11
11
  :filter-method="filterMethod"
12
12
  :clear-icon="clearIcon"
13
13
  :suffix-icon="suffixIcon"
@@ -17,7 +17,7 @@
17
17
  @focus="showSearchPrefix"
18
18
  @blur="hideSearchPrefix"
19
19
  @click="focusSearchInput"
20
- @visible-change="handleListSort"
20
+ @visible-change="handleVisibleChange"
21
21
  >
22
22
  <template #prefix>
23
23
  <div
@@ -63,25 +63,19 @@
63
63
  }}</span>
64
64
  </slot>
65
65
  </el-option>
66
+ <el-option
67
+ v-if="multiple && noFilterOptions"
68
+ :key="'__ct_paging_select_empty__'"
69
+ :label="''"
70
+ :value="'__ct_paging_select_empty__'"
71
+ disabled
72
+ style="display: none"
73
+ >
74
+ </el-option>
66
75
  </slot>
67
76
  </div>
68
77
  <Empty :text="emptyText" v-if="multiple && noFilterOptions" />
69
78
  <template #empty>
70
- <div :class="[ns.e('top')]" v-if="multiple">
71
- <div :class="[ns.e('filter')]">
72
- <el-input v-model="keyword" ref="filterInput" @input="changeKeyword">
73
- <template #prefix>
74
- <ct-icon name="search_line"></ct-icon>
75
- </template>
76
- </el-input>
77
- </div>
78
- <div :class="[ns.e('select')]" v-if="!rawAttr.multipleLimit">
79
- <span :class="[ns.e('select-title')]">
80
- <span v-if="!keyword">已选{{ selectLength }}项</span>
81
- <span v-else>检索结果</span>
82
- </span>
83
- </div>
84
- </div>
85
79
  <slot name="empty">
86
80
  <Empty :text="emptyText" />
87
81
  </slot>
@@ -235,6 +229,11 @@ const handleListSort = (val) => {
235
229
  }
236
230
  }
237
231
  };
232
+ const dropdownVisible = ref(false);
233
+ const handleVisibleChange = (visible) => {
234
+ dropdownVisible.value = visible;
235
+ handleListSort(visible);
236
+ };
238
237
  const watchServiceHandle = async (reset = false) => {
239
238
  // 通过api获取数据,会监听api以及serviceParams的改变(收集到的依赖改变)都会触发重新查询
240
239
  const cbs = props.cbs || {};
@@ -259,7 +258,7 @@ const watchServiceHandle = async (reset = false) => {
259
258
  .then((res) => {
260
259
  const mapObj = props.mapObj || {};
261
260
  const {
262
- list = "list",
261
+ list,
263
262
  label = "label",
264
263
  value = "value",
265
264
  self,
@@ -386,10 +385,15 @@ useBuriedParams(props, emit, {
386
385
  });
387
386
 
388
387
  function filterMethod(val) {
389
- if (props.multiple) {
390
- return; //多选走原有搜索逻辑
391
- }
392
- keyword.value = val;
388
+ if (props.multiple) return; //多选走原有搜索逻辑
389
+ const next = typeof val === "string" ? val : "";
390
+ const nextTrim = next.trim();
391
+ if (!dropdownVisible.value && !nextTrim) return;
392
+ //单选开启 filterable 时, el-select 内部有一套“输入查询”的状态。
393
+ // 下拉收起(点击别处/blur)时,Element Plus 往往会把内部 query 清空,并触发一次 filter-method,
394
+ // 所以这里优化了下拉收起时的查询
395
+ if (nextTrim === keyword.value) return;
396
+ keyword.value = nextTrim;
393
397
  changeKeyword();
394
398
  }
395
399