ct-component-plus 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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ct-component-plus",
3
3
  "private": false,
4
- "version": "2.1.4",
4
+ "version": "2.1.5",
5
5
  "type": "module",
6
6
  "main": "packages/components/index.js",
7
7
  "files": [
@@ -29,7 +29,7 @@
29
29
  </template>
30
30
  <div :class="[ns.e('top')]" v-if="multiple">
31
31
  <div :class="[ns.e('filter')]">
32
- <el-input v-model="keyword" ref="filterInput">
32
+ <el-input v-model="keyword" ref="filterInput" @input="changeKeyword">
33
33
  <template #prefix>
34
34
  <ct-icon name="search_line"></ct-icon>
35
35
  </template>
@@ -66,6 +66,21 @@
66
66
  </div>
67
67
  <Empty :text="emptyText" v-if="multiple && noFilterOptions" />
68
68
  <template #empty>
69
+ <div :class="[ns.e('top')]" v-if="multiple">
70
+ <div :class="[ns.e('filter')]">
71
+ <el-input v-model="keyword" ref="filterInput" @input="changeKeyword">
72
+ <template #prefix>
73
+ <ct-icon name="search_line"></ct-icon>
74
+ </template>
75
+ </el-input>
76
+ </div>
77
+ <div :class="[ns.e('select')]" v-if="!rawAttr.multipleLimit">
78
+ <span :class="[ns.e('select-title')]">
79
+ <span v-if="!keyword">已选{{ selectLength }}项</span>
80
+ <span v-else>检索结果</span>
81
+ </span>
82
+ </div>
83
+ </div>
69
84
  <slot name="empty">
70
85
  <Empty :text="emptyText" />
71
86
  </slot>
@@ -285,12 +300,28 @@ watch(
285
300
  immediate: true,
286
301
  }
287
302
  );
288
- watch(
289
- () => keyword.value,
290
- () => {
291
- watchServiceHandle(true);
292
- }
293
- );
303
+ // watch(
304
+ // () => keyword.value,
305
+ // () => {
306
+
307
+ // watchServiceHandle(true);
308
+ // }
309
+ // );
310
+
311
+ function debounce(fn, delay = 300) {
312
+ //防抖
313
+ var timer = null; //借助闭包
314
+ return function (...args) {
315
+ const context = this;
316
+ clearTimeout(timer);
317
+ timer = setTimeout(() => {
318
+ fn.apply(context, args);
319
+ }, delay);
320
+ };
321
+ }
322
+ const changeKeyword = debounce(() => {
323
+ watchServiceHandle(true);
324
+ });
294
325
 
295
326
  const handleScrollLoad = (e) => {
296
327
  const el = e.target;