From 8a03ddd5d5e846451be0605b35f70b8b60a55d58 Mon Sep 17 00:00:00 2001 From: mahao Date: Thu, 27 Apr 2023 15:01:27 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20feat(uni-data-select):=20=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E8=BF=87=E6=BB=A4=E7=AD=9B=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/vue/data-select/data-select.vue | 5 ++ .../uni-data-select/uni-data-select.vue | 55 +++++++++++++------ 2 files changed, 44 insertions(+), 16 deletions(-) diff --git a/pages/vue/data-select/data-select.vue b/pages/vue/data-select/data-select.vue index 2a39eca01..44b48c6dd 100644 --- a/pages/vue/data-select/data-select.vue +++ b/pages/vue/data-select/data-select.vue @@ -25,6 +25,11 @@ + + + + + diff --git a/uni_modules/uni-data-select/components/uni-data-select/uni-data-select.vue b/uni_modules/uni-data-select/components/uni-data-select/uni-data-select.vue index 19b2d9e94..3c4b9658b 100644 --- a/uni_modules/uni-data-select/components/uni-data-select/uni-data-select.vue +++ b/uni_modules/uni-data-select/components/uni-data-select/uni-data-select.vue @@ -3,24 +3,27 @@ {{label + ':'}} - - {{current}} - {{typePlaceholder}} - - - - - - + + + - + {{emptyTips}} - {{formatItemName(item)}} @@ -38,7 +41,8 @@ * @tutorial https://uniapp.dcloud.io/component/uniui/uni-data-select * @property {String} value 默认值 * @property {Array} localdata 本地数据 ,格式 [{text:'',value:''}] - * @property {Boolean} clear 是否可以清空已选项 + * @property {Boolean} clear 是否可以清空已选项 + * @property {Boolean} filterable 是否可以检索 * @property {Boolean} emptyText 没有数据时显示的文字 ,本地数据无效 * @property {String} label 左侧标题 * @property {String} placeholder 输入框的提示文字 @@ -79,6 +83,10 @@ clear: { type: Boolean, default: true + }, + filterable:{ + type:Boolean, + default:false }, defItem: { type: Number, @@ -98,10 +106,14 @@ return { showSelector: false, current: '', - mixinDatacomResData: [], + mixinDatacomResData: [], + mixinDatacomResDataFilter:[], apps: [], channels: [], - cacheKey: "uni-data-select-lastSelectedValue", + cacheKey: "uni-data-select-lastSelectedValue", + inputStyles:{ + backgroundColor: 'transparent', + }, }; }, created() { @@ -139,7 +151,8 @@ immediate: true, handler(val, old) { if (Array.isArray(val) && old !== val) { - this.mixinDatacomResData = val + this.mixinDatacomResData = val + this.mixinDatacomResDataFilter = val } } }, @@ -155,7 +168,17 @@ } } }, - methods: { + methods: { + // 筛选过滤 + handleInput(e){ + if(e){ + this.mixinDatacomResDataFilter = this.mixinDatacomResData.filter(item=>{ + return item.text.includes(e) + }) + }else{ + this.mixinDatacomResDataFilter = [...this.mixinDatacomResData] + } + }, debounce(fn, time = 100){ let timer = null return function(...args) {